public void Collide(Enemy e,List<WorldElement> elements) { foreach (WorldElement elem in elements) if (elem.State) { if (elem.BlocksLeft.Intersects(e.BlocksRight)) { e.worldPosition -= new Vector2(5f, 0f); e.current_num_move = e.NumberMoves; } if (elem.BlocksRight.Intersects(e.BlocksLeft)) { e.worldPosition += new Vector2(5f, 0f); e.current_num_move = e.NumberMoves; } if (elem.BlocksTop.Intersects(e.BlocksBottom)) { e.worldPosition -= new Vector2(0f, 5f); e.current_num_move = e.NumberMoves; } if (elem.BlocksBottom.Intersects(e.BlocksTop)) { e.worldPosition += new Vector2(0f, 5f); e.current_num_move = e.NumberMoves; } } }
public void collide(Enemy e, Player player) { { if (e.BlocksTop.Intersects(player.footBounds)) { e.IsAlive = false; } if (e.BlocksRight.Intersects(player.leftRec)) { if (player.footBounds.Y >= e.BlocksRight.Y) { if (!astralMode) { player.Life = false; player.Lives -= 1; } else OffAstralMode(player); e.worldPosition.X += 15f; player.worldPosition.X -= 5f; player.cameraPosition.X -= 5f; } } if (e.BlocksLeft.Intersects(player.rightRec)) { if (player.footBounds.Y >= e.BlocksLeft.Y) { if (!astralMode) { player.Life = false; player.Lives -= 1; } else OffAstralMode(player); e.worldPosition.X -= 15f; player.worldPosition.X += 5f; player.cameraPosition.X += 5f; } } } }