private bool IsPlayerSeen(Rectangle rect, ArrowDir dir) { if (dir == ArrowDir.Up || dir == ArrowDir.Down) { for (int i = 0; i < rect.Width; i++) { Rectangle lineRect = new Rectangle(rect.X + i, rect.Y, 1, rect.Height); if (!Scene.CollideCheck <Solid>(lineRect)) { return(true); } } return(false); } else { for (int i = 0; i < rect.Height; i++) { Rectangle lineRect = new Rectangle(rect.X, rect.Y + i, rect.Width, 1); if (!Scene.CollideCheck <Solid>(lineRect)) { return(true); } } return(false); } }
private DashCollisionResults OnDashed(Player player, Vector2 direction) { bool playerAttacked = false; if (direction == Vector2.UnitX && weakLeft) { // left side playerAttacked = true; dir = ArrowDir.Right; } else if (direction == -Vector2.UnitX && weakRight) { // right side playerAttacked = true; dir = ArrowDir.Left; } else if (direction == Vector2.UnitY && weakTop) { // top side playerAttacked = true; dir = ArrowDir.Down; } else if (direction == -Vector2.UnitY && weakBottom) { // bottom side playerAttacked = true; dir = ArrowDir.Up; } if (playerAttacked) { squishScale = new Vector2(1f + Math.Abs(direction.Y) * 0.4f - Math.Abs(direction.X) * 0.4f, 1f + Math.Abs(direction.X) * 0.4f - Math.Abs(direction.Y) * 0.4f); crushDir = direction; Attack(true); return(DashCollisionResults.Rebound); } return(DashCollisionResults.NormalCollision); }
private void ActivateTiles(ArrowDir dir) { switch (dir) { case ArrowDir.Up: topTilesAlpha = 1f; break; case ArrowDir.Down: bottomTilesAlpha = 1f; break; case ArrowDir.Left: leftTilesAlpha = 1f; break; case ArrowDir.Right: rightTilesAlpha = 1f; break; default: break; } }
public override void Update() { SetSeekerBarriersCollidable(true); base.Update(); eye.Scale = squishScale; squishScale = Calc.Approach(squishScale, Vector2.One, Engine.DeltaTime * 4f); if (!triggered && Util.TryGetPlayer(out Player player)) { bool detectedPlayer = false; Rectangle toPlayerRect = new Rectangle(); if (player.Center.Y > Y && player.Center.Y < Y + Height) { int y1 = (int)Math.Max(player.Top, Top); int y2 = (int)Math.Min(player.Bottom, Bottom); if (player.Center.X > X + Width) { // right detectedPlayer = true; crushDir = Vector2.UnitX; dir = ArrowDir.Right; toPlayerRect = new Rectangle((int)(X + Width), y1, (int)(player.Left - X - Width), y2 - y1); } if (player.Center.X < X) { // left detectedPlayer = true; crushDir = -Vector2.UnitX; dir = ArrowDir.Left; toPlayerRect = new Rectangle((int)(player.Right), y1, (int)(X - player.Right), y2 - y1); } } if (player.Center.X > X && player.Center.X < X + Width) { int x1 = (int)Math.Max(player.Left, Left); int x2 = (int)Math.Min(player.Right, Right); if (player.Center.Y < Y) { // top detectedPlayer = true; crushDir = -Vector2.UnitY; dir = ArrowDir.Up; toPlayerRect = new Rectangle(x1, (int)(player.Bottom), x2 - x1, (int)(Y - player.Bottom)); } if (player.Center.Y > Y + Height) { // bottom detectedPlayer = true; crushDir = Vector2.UnitY; dir = ArrowDir.Down; toPlayerRect = new Rectangle(x1, (int)(Y + Height), x2 - x1, (int)(player.Top - Y - Height)); } } if (detectedPlayer && IsPlayerSeen(toPlayerRect, dir)) { Attack(false); } } SetSeekerBarriersCollidable(false); UpdateActiveTiles(); if (currentMoveLoopSfx != null) { currentMoveLoopSfx.Param("submerged", Submerged ? 1 : 0); } if (returnLoopSfx != null) { returnLoopSfx.Param("submerged", Submerged ? 1 : 0); } }