ladders somewhat work

This commit is contained in:
Ivan Filipenkov 2023-08-18 02:27:44 +03:00
parent 52b404c9db
commit e7c375d9e7
3 changed files with 36 additions and 4 deletions

View file

@ -11,6 +11,7 @@ namespace DangerousD.GameCore.GUI
{ {
private SpriteFont _spriteFont; private SpriteFont _spriteFont;
private Dictionary<string, string> _text = new(); private Dictionary<string, string> _text = new();
private List<string> _log = new();
public void Initialize() public void Initialize()
{ {
@ -27,10 +28,11 @@ namespace DangerousD.GameCore.GUI
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
{ {
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
spriteBatch.Begin(); spriteBatch.Begin();
spriteBatch.DrawString( spriteBatch.DrawString(
_spriteFont, _spriteFont,
Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()), keysString,
new Vector2(10, 10), new Vector2(10, 10),
Color.Cyan, Color.Cyan,
0, 0,
@ -39,6 +41,17 @@ namespace DangerousD.GameCore.GUI
SpriteEffects.None, SpriteEffects.None,
0 0
); );
spriteBatch.DrawString(
_spriteFont,
Join("\n", _log),
new Vector2(10, 10 + _spriteFont.MeasureString(keysString).Y),
Color.Green,
0,
Vector2.Zero,
1,
SpriteEffects.None,
0
);
spriteBatch.End(); spriteBatch.End();
} }
@ -46,5 +59,14 @@ namespace DangerousD.GameCore.GUI
{ {
_text[key] = value; _text[key] = value;
} }
public void Log(string value)
{
_log.Add(value);
if (_log.Count > 30)
{
_log.RemoveAt(0);
}
}
} }
} }

View file

@ -29,6 +29,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
private bool isShooting = false; private bool isShooting = false;
public GameObject objectAttack; public GameObject objectAttack;
private int bullets; private int bullets;
public bool FallingThroughPlatform = false;
public Player(Vector2 position) : base(position) public Player(Vector2 position) : base(position)
{ {
@ -153,6 +154,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (isOnGround && FallingThroughPlatform)
{
FallingThroughPlatform = false;
AppManager.Instance.DebugHUD.Log("not falling");
}
GraphicsComponent.SetCameraPosition(Pos); GraphicsComponent.SetCameraPosition(Pos);
if (!isAttacked) if (!isAttacked)
{ {
@ -214,8 +220,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
public void MoveDown() public void MoveDown()
{ {
// ПОЧЕМУ FallingThroughPlatform = true;
velocity.Y = -11; isOnGround = false;
AppManager.Instance.DebugHUD.Log("FallingThroughPlatform");
} }
} }

View file

@ -77,6 +77,7 @@ namespace DangerousD.GameCore.Managers
if (currentEntity is Player) if (currentEntity is Player)
{ {
AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString()); AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString());
AppManager.Instance.DebugHUD.Set("falling", (currentEntity as Player).FallingThroughPlatform.ToString());
AppManager.Instance.DebugHUD.Set("intersects y", ""); AppManager.Instance.DebugHUD.Set("intersects y", "");
} }
foreach (var mapObject in mapObjects) foreach (var mapObject in mapObjects)
@ -107,7 +108,7 @@ namespace DangerousD.GameCore.Managers
{ {
foreach (var player in players) foreach (var player in players)
{ {
if (player.velocity.Y <= 0) if (player.velocity.Y <= 0 || player.FallingThroughPlatform)
{ {
continue; continue;
} }
@ -129,6 +130,8 @@ namespace DangerousD.GameCore.Managers
} }
if (collidedY) if (collidedY)
{ {
// костыль потому что в CheckCollisionsLE_MO он спускается
newRect.Y -= (int)Math.Ceiling(player.velocity.Y);
player.isOnGround = true; player.isOnGround = true;
player.velocity.Y = 0; player.velocity.Y = 0;
} }