Merge branch 'main' into particles

This commit is contained in:
Kaktus200020 2023-08-18 11:08:39 +03:00
commit 3a6f4b786e
6 changed files with 83 additions and 27 deletions

View file

@ -29,7 +29,8 @@ namespace DangerousD.GameCore.GameObjects.Entities
Player player = (Player)gameObject;
if (player.isUping)
{
AppManager.Instance.GameManager.Remove(this);
//тут спавн лута
}
}
}

View file

@ -59,7 +59,13 @@ namespace DangerousD.GameCore
{
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
//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);
}
}
}

View file

@ -28,7 +28,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
private bool isAttacked = false;
private bool isShooting = false;
public GameObject objectAttack;
public bool isInvincible;
private int bullets;
public bool FallingThroughPlatform = false;
public bool isUping = false;
@ -94,7 +93,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
public void Death(string monsterName)
{
return; //godmode
if (AppManager.Instance.InputManager.InvincibilityCheat)
{
return;
}
isAttacked = true;
if(monsterName == "Zombie")
{
@ -184,10 +186,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
if (isOnGround && FallingThroughPlatform)
{
FallingThroughPlatform = false;
AppManager.Instance.DebugHUD.Log("not falling");
}
GraphicsComponent.SetCameraPosition(Pos);
if (!isAttacked || isInvincible)
if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat)
{
Move(gameTime);
}
@ -249,7 +250,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{
FallingThroughPlatform = true;
isOnGround = false;
AppManager.Instance.DebugHUD.Log("FallingThroughPlatform");
}
}

View file

@ -237,23 +237,25 @@ namespace DangerousD.GameCore.Graphics
public static void SetCameraPosition(Vector2 playerPosition)
{
CameraPosition = (playerPosition).ToPoint();
CameraPosition.X -= 300;
CameraPosition.Y -= 200;
if (CameraPosition.X < AppManager.Instance.GameManager.CameraBorder.X)
{
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.X;
}
CameraPosition.X -= 200;
CameraPosition.Y -= 120;
if (CameraPosition.X > AppManager.Instance.GameManager.CameraBorder.Y - 460)
{
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.Y - 460;
}
if (CameraPosition.Y < 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}");
}

View file

@ -6,11 +6,12 @@ using System.Diagnostics;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
namespace DangerousD.GameCore
{
public enum ScopeState { Up, Middle, Down }
public enum ControlsState { Gamepad, Keyboard, Mouse }
public enum ControlsState { Gamepad, Keyboard }
public class InputManager
{
public delegate void Delegat();
@ -21,31 +22,77 @@ namespace DangerousD.GameCore
Vector2 vectorMovementDirection;
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
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 isShoot;
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
public ScopeState ScopeState { get => scopeState; }
public string currentControlsState = "";
public InputManager()
{
this.isJumpDown = false;
this.isShoot = false;
scopeState = ScopeState.Middle;
controlsState= ControlsState.Mouse;
controlsState= ControlsState.Keyboard;
vectorMovementDirection = new Vector2(0, 0);
}
public void SetState(ControlsState controlsStates)
{
currentControlsState = controlsStates.ToString();
}
public void Update()
{
// Работа с GamePad
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 являющийся вектором отклонения левого стика.
GamePadState gamePadState = GamePad.GetState(0);
vectorMovementDirection = gamePadState.ThumbSticks.Left;
@ -93,12 +140,12 @@ namespace DangerousD.GameCore
{
isShoot = false;
}
SetState(ControlsState.Gamepad);
}
// Работа с KeyBoard
else
{
controlsState = ControlsState.Keyboard;
KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры
// Обработка движения вправо-влево. Меняет у вектора vectorMovementDirection значение X на -1/0/1.

View file

@ -177,11 +177,11 @@ namespace DangerousD.GameCore
}
if (item.Pos.Y < CameraBorder.Z)
{
CameraBorder.Z = item.Pos.X;
CameraBorder.Z = item.Pos.Y;
}
if (item.Pos.Y > CameraBorder.W)
{
CameraBorder.W = item.Pos.X;
CameraBorder.W = item.Pos.Y;
}
}
}