Merge branch 'main' into particles
This commit is contained in:
commit
3a6f4b786e
6 changed files with 83 additions and 27 deletions
|
@ -29,7 +29,8 @@ namespace DangerousD.GameCore.GameObjects.Entities
|
||||||
Player player = (Player)gameObject;
|
Player player = (Player)gameObject;
|
||||||
if (player.isUping)
|
if (player.isUping)
|
||||||
{
|
{
|
||||||
|
AppManager.Instance.GameManager.Remove(this);
|
||||||
|
//тут спавн лута
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,13 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
|
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
|
||||||
//debug
|
//debug
|
||||||
//wdaspriteBatch.Draw(debugTexture,new Rectangle(Rectangle.X-GraphicsComponent.CameraPosition.X,Rectangle.Y-GraphicsComponent.CameraPosition.Y,Rectangle.Width,Rectangle.Height), Color.White);
|
if (AppManager.Instance.InputManager.CollisionsCheat)
|
||||||
|
{
|
||||||
|
spriteBatch.Draw(debugTexture,
|
||||||
|
new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X,
|
||||||
|
Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height),
|
||||||
|
Color.White);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
private bool isAttacked = false;
|
private bool isAttacked = false;
|
||||||
private bool isShooting = false;
|
private bool isShooting = false;
|
||||||
public GameObject objectAttack;
|
public GameObject objectAttack;
|
||||||
public bool isInvincible;
|
|
||||||
private int bullets;
|
private int bullets;
|
||||||
public bool FallingThroughPlatform = false;
|
public bool FallingThroughPlatform = false;
|
||||||
public bool isUping = false;
|
public bool isUping = false;
|
||||||
|
@ -94,7 +93,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
}
|
}
|
||||||
public void Death(string monsterName)
|
public void Death(string monsterName)
|
||||||
{
|
{
|
||||||
return; //godmode
|
if (AppManager.Instance.InputManager.InvincibilityCheat)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
isAttacked = true;
|
isAttacked = true;
|
||||||
if(monsterName == "Zombie")
|
if(monsterName == "Zombie")
|
||||||
{
|
{
|
||||||
|
@ -184,10 +186,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
if (isOnGround && FallingThroughPlatform)
|
if (isOnGround && FallingThroughPlatform)
|
||||||
{
|
{
|
||||||
FallingThroughPlatform = false;
|
FallingThroughPlatform = false;
|
||||||
AppManager.Instance.DebugHUD.Log("not falling");
|
|
||||||
}
|
}
|
||||||
GraphicsComponent.SetCameraPosition(Pos);
|
GraphicsComponent.SetCameraPosition(Pos);
|
||||||
if (!isAttacked || isInvincible)
|
if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat)
|
||||||
{
|
{
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +250,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
{
|
{
|
||||||
FallingThroughPlatform = true;
|
FallingThroughPlatform = true;
|
||||||
isOnGround = false;
|
isOnGround = false;
|
||||||
AppManager.Instance.DebugHUD.Log("FallingThroughPlatform");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,23 +237,25 @@ namespace DangerousD.GameCore.Graphics
|
||||||
public static void SetCameraPosition(Vector2 playerPosition)
|
public static void SetCameraPosition(Vector2 playerPosition)
|
||||||
{
|
{
|
||||||
CameraPosition = (playerPosition).ToPoint();
|
CameraPosition = (playerPosition).ToPoint();
|
||||||
CameraPosition.X -= 300;
|
CameraPosition.X -= 200;
|
||||||
CameraPosition.Y -= 200;
|
CameraPosition.Y -= 120;
|
||||||
if (CameraPosition.X < AppManager.Instance.GameManager.CameraBorder.X)
|
|
||||||
{
|
|
||||||
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.X;
|
|
||||||
}
|
|
||||||
if (CameraPosition.X > AppManager.Instance.GameManager.CameraBorder.Y - 460)
|
if (CameraPosition.X > AppManager.Instance.GameManager.CameraBorder.Y - 460)
|
||||||
{
|
{
|
||||||
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.Y - 460;
|
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.Y - 460;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CameraPosition.Y < AppManager.Instance.GameManager.CameraBorder.Z)
|
if (CameraPosition.Y < AppManager.Instance.GameManager.CameraBorder.Z)
|
||||||
{
|
{
|
||||||
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.Z;
|
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.Z;
|
||||||
}
|
}
|
||||||
if (CameraPosition.Y > AppManager.Instance.GameManager.CameraBorder.W - 470)
|
if (CameraPosition.X < AppManager.Instance.GameManager.CameraBorder.X)
|
||||||
{
|
{
|
||||||
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.W - 470;
|
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.X;
|
||||||
|
}
|
||||||
|
if (CameraPosition.Y > AppManager.Instance.GameManager.CameraBorder.W - 240)
|
||||||
|
{
|
||||||
|
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.W - 240;
|
||||||
}
|
}
|
||||||
AppManager.Instance.DebugHUD.Set("CameraPosition", $"{CameraPosition.X}, {CameraPosition.Y}");
|
AppManager.Instance.DebugHUD.Set("CameraPosition", $"{CameraPosition.X}, {CameraPosition.Y}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@ using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum ScopeState { Up, Middle, Down }
|
public enum ScopeState { Up, Middle, Down }
|
||||||
public enum ControlsState { Gamepad, Keyboard, Mouse }
|
public enum ControlsState { Gamepad, Keyboard }
|
||||||
public class InputManager
|
public class InputManager
|
||||||
{
|
{
|
||||||
public delegate void Delegat();
|
public delegate void Delegat();
|
||||||
|
@ -21,31 +22,77 @@ namespace DangerousD.GameCore
|
||||||
Vector2 vectorMovementDirection;
|
Vector2 vectorMovementDirection;
|
||||||
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
||||||
ControlsState controlsState;
|
ControlsState controlsState;
|
||||||
|
private bool _overrideControls = false;
|
||||||
|
private bool _cheatsEnabled = false;
|
||||||
|
public bool InvincibilityCheat { get; private set; } = false;
|
||||||
|
public bool CollisionsCheat { get; private set; } = false;
|
||||||
|
|
||||||
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
||||||
private bool isShoot;
|
private bool isShoot;
|
||||||
|
|
||||||
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
||||||
public ScopeState ScopeState { get => scopeState; }
|
public ScopeState ScopeState { get => scopeState; }
|
||||||
public string currentControlsState = "";
|
|
||||||
|
|
||||||
public InputManager()
|
public InputManager()
|
||||||
{
|
{
|
||||||
this.isJumpDown = false;
|
this.isJumpDown = false;
|
||||||
this.isShoot = false;
|
this.isShoot = false;
|
||||||
scopeState = ScopeState.Middle;
|
scopeState = ScopeState.Middle;
|
||||||
controlsState= ControlsState.Mouse;
|
controlsState= ControlsState.Keyboard;
|
||||||
vectorMovementDirection = new Vector2(0, 0);
|
vectorMovementDirection = new Vector2(0, 0);
|
||||||
}
|
}
|
||||||
public void SetState(ControlsState controlsStates)
|
|
||||||
{
|
|
||||||
currentControlsState = controlsStates.ToString();
|
|
||||||
}
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
// Работа с GamePad
|
|
||||||
if (GamePad.GetState(0).IsConnected)
|
if (GamePad.GetState(0).IsConnected)
|
||||||
{
|
{
|
||||||
|
GamePadState gamepadState = GamePad.GetState(0);
|
||||||
|
if (gamepadState.Triggers.Left >= 0.9 && gamepadState.Triggers.Right >= 0.9)
|
||||||
|
{
|
||||||
|
_cheatsEnabled = true;
|
||||||
|
}
|
||||||
|
if (_cheatsEnabled)
|
||||||
|
{
|
||||||
|
if (gamepadState.Buttons.Y == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
InvincibilityCheat = true;
|
||||||
|
}
|
||||||
|
if (gamepadState.Buttons.B == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
CollisionsCheat = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var keyboardState = Keyboard.GetState();
|
||||||
|
if (keyboardState.IsKeyDown(Keys.LeftShift) && keyboardState.IsKeyDown(Keys.RightShift))
|
||||||
|
{
|
||||||
|
_cheatsEnabled = true;
|
||||||
|
}
|
||||||
|
if (_cheatsEnabled)
|
||||||
|
{
|
||||||
|
if (keyboardState.IsKeyDown(Keys.I))
|
||||||
|
{
|
||||||
|
InvincibilityCheat = true;
|
||||||
|
}
|
||||||
|
if (keyboardState.IsKeyDown(Keys.C))
|
||||||
|
{
|
||||||
|
CollisionsCheat = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_cheatsEnabled)
|
||||||
|
{
|
||||||
|
AppManager.Instance.DebugHUD.Set("cheats", _cheatsEnabled.ToString());
|
||||||
|
AppManager.Instance.DebugHUD.Set("invincible", InvincibilityCheat.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Работа с GamePad
|
||||||
|
if (_overrideControls ? controlsState == ControlsState.Gamepad : GamePad.GetState(0).IsConnected)
|
||||||
|
{
|
||||||
|
controlsState = ControlsState.Gamepad;
|
||||||
|
|
||||||
// Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
|
// Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
|
||||||
GamePadState gamePadState = GamePad.GetState(0);
|
GamePadState gamePadState = GamePad.GetState(0);
|
||||||
vectorMovementDirection = gamePadState.ThumbSticks.Left;
|
vectorMovementDirection = gamePadState.ThumbSticks.Left;
|
||||||
|
@ -93,12 +140,12 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
isShoot = false;
|
isShoot = false;
|
||||||
}
|
}
|
||||||
SetState(ControlsState.Gamepad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Работа с KeyBoard
|
// Работа с KeyBoard
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
controlsState = ControlsState.Keyboard;
|
||||||
KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры
|
KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры
|
||||||
|
|
||||||
// Обработка движения вправо-влево. Меняет у вектора vectorMovementDirection значение X на -1/0/1.
|
// Обработка движения вправо-влево. Меняет у вектора vectorMovementDirection значение X на -1/0/1.
|
||||||
|
|
|
@ -177,11 +177,11 @@ namespace DangerousD.GameCore
|
||||||
}
|
}
|
||||||
if (item.Pos.Y < CameraBorder.Z)
|
if (item.Pos.Y < CameraBorder.Z)
|
||||||
{
|
{
|
||||||
CameraBorder.Z = item.Pos.X;
|
CameraBorder.Z = item.Pos.Y;
|
||||||
}
|
}
|
||||||
if (item.Pos.Y > CameraBorder.W)
|
if (item.Pos.Y > CameraBorder.W)
|
||||||
{
|
{
|
||||||
CameraBorder.W = item.Pos.X;
|
CameraBorder.W = item.Pos.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue