ladders somewhat work
This commit is contained in:
parent
52b404c9db
commit
e7c375d9e7
3 changed files with 36 additions and 4 deletions
|
@ -11,6 +11,7 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
private SpriteFont _spriteFont;
|
||||
private Dictionary<string, string> _text = new();
|
||||
private List<string> _log = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
@ -27,10 +28,11 @@ namespace DangerousD.GameCore.GUI
|
|||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()),
|
||||
keysString,
|
||||
new Vector2(10, 10),
|
||||
Color.Cyan,
|
||||
0,
|
||||
|
@ -39,6 +41,17 @@ namespace DangerousD.GameCore.GUI
|
|||
SpriteEffects.None,
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -46,5 +59,14 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
_text[key] = value;
|
||||
}
|
||||
|
||||
public void Log(string value)
|
||||
{
|
||||
_log.Add(value);
|
||||
if (_log.Count > 30)
|
||||
{
|
||||
_log.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
private bool isShooting = false;
|
||||
public GameObject objectAttack;
|
||||
private int bullets;
|
||||
public bool FallingThroughPlatform = false;
|
||||
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
|
@ -153,6 +154,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (isOnGround && FallingThroughPlatform)
|
||||
{
|
||||
FallingThroughPlatform = false;
|
||||
AppManager.Instance.DebugHUD.Log("not falling");
|
||||
}
|
||||
GraphicsComponent.SetCameraPosition(Pos);
|
||||
if (!isAttacked)
|
||||
{
|
||||
|
@ -214,8 +220,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public void MoveDown()
|
||||
{
|
||||
// ПОЧЕМУ
|
||||
velocity.Y = -11;
|
||||
FallingThroughPlatform = true;
|
||||
isOnGround = false;
|
||||
AppManager.Instance.DebugHUD.Log("FallingThroughPlatform");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace DangerousD.GameCore.Managers
|
|||
if (currentEntity is Player)
|
||||
{
|
||||
AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString());
|
||||
AppManager.Instance.DebugHUD.Set("falling", (currentEntity as Player).FallingThroughPlatform.ToString());
|
||||
AppManager.Instance.DebugHUD.Set("intersects y", "");
|
||||
}
|
||||
foreach (var mapObject in mapObjects)
|
||||
|
@ -107,7 +108,7 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
foreach (var player in players)
|
||||
{
|
||||
if (player.velocity.Y <= 0)
|
||||
if (player.velocity.Y <= 0 || player.FallingThroughPlatform)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -129,6 +130,8 @@ namespace DangerousD.GameCore.Managers
|
|||
}
|
||||
if (collidedY)
|
||||
{
|
||||
// костыль потому что в CheckCollisionsLE_MO он спускается
|
||||
newRect.Y -= (int)Math.Ceiling(player.velocity.Y);
|
||||
player.isOnGround = true;
|
||||
player.velocity.Y = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue