public WorldEffect(GameScreen game, Texture2D effect, Entity entity, Vector2 delta, int lifeSpan, int frameX, int frameY) { this.effect = effect; LifeSpan = lifeSpan; InitEffect(effect, frameX, frameY); BindTo(entity, delta); Game = game; Game.WorldEffects.Add(this); }
public void Damage(Entity source, int life) { Life -= life; if (Life <= 0) { if (source is Player) { ((Player) source).GainXp(xp); ((Player) source).Stats.AmountKilled++; } Delete(); // Appelle la fonction Delete() qui supprime le Monster et envoie ce dernier dans la liste deletedEntities if (Targeter != null && ReferenceEquals(Targeter.Target, this)) // Si Game.Player.Target == Ce Monster (celui qui vient d'etre detruit) alors le joueur n'a plus de cible Targeter.Target = null; } }
public Pathfinding(GameTime gameTime, Vector2 player, Entity monster, MapData map) { this.monster = monster; openedList = new List<Node>(); closedList = new List<Node>(); mapData = map; if (player.X < 0 || player.X > mapData.MapWidth * 32 || player.Y < 0 || player.Y > mapData.MapHeight * 32 || mapData.Accessibility[ConversionManager.VectToId(map, player)] == 1) return; start = new Node(monster.Position, monster.Position, player, mapData) { Parent = null }; arrival = new Node(player, monster.Position, player, mapData); openedList.Add(start); PathFind(gameTime, map); }
public void BindTo(Entity entity, Vector2 delta) { entityBind = entity; entityDelta = delta; }
public void Movement(GameTime gameTime, Entity entitie, MapData map) { int id = (int)(entitie.Position.X / 32) + (int)(entitie.Position.Y / 32) * mapData.MapWidth; float time = (float)gameTime.ElapsedGameTime.TotalMilliseconds / 10.0f; move = Vector2.Zero; if (list != null) list.Remove(id); if (list != null && list.Count > 0) { if (list[list.Count - 1] == id - mapData.MapWidth) { if (gameTime.TotalGameTime.TotalMilliseconds % 500 < 10 || !(entitie is Monster)) entitie.Direction = Direction.Up; move.Y--; move.Normalize(); if (ConversionManager.VectToId(map, new Vector2(entitie.Position.X, entitie.Position.Y + entitie.TextureSize.Y + (move.Y * entitie.Speed * time))) == id - mapData.MapWidth) list.Remove(id - mapData.MapWidth); } else if (list[list.Count - 1] == id + mapData.MapWidth) { if (gameTime.TotalGameTime.TotalMilliseconds % 1000 < 10 || !(entitie is Monster)) entitie.Direction = Direction.Down; move.Y++; move.Normalize(); if (ConversionManager.VectToId(map, new Vector2(entitie.Position.X, entitie.Position.Y + (move.Y * entitie.Speed * time))) == id + mapData.MapWidth) list.Remove(id + mapData.MapWidth); } else if (list[list.Count - 1] == id - 1) { if (gameTime.TotalGameTime.TotalMilliseconds % 1000 < 10 || !(entitie is Monster)) entitie.Direction = Direction.Left; move.X--; move.Normalize(); if (ConversionManager.VectToId(map, new Vector2(entitie.Position.X + entitie.TextureSize.X + (move.X * entitie.Speed * time), entitie.Position.Y)) == id - 1) list.Remove(id - 1); } else if (list[list.Count - 1] == id + 1) { if (gameTime.TotalGameTime.TotalMilliseconds % 1000 < 10 || !(entitie is Monster)) entitie.Direction = Direction.Right; move.X++; move.Normalize(); if (ConversionManager.VectToId(map, new Vector2(entitie.Position.X + (move.X * entitie.Speed * time), entitie.Position.Y)) == id + 1) list.Remove(id + 1); } if (move == Vector2.Zero) return; entitie.Position = entitie.Position + move * entitie.Speed * time; } }
public MegaBlast(Entity owner) : base(owner, TexturesManager.MegaBlast, SpellType.Cast, 1) { }
public SpeedUp(Entity owner) : base(owner, TexturesManager.SpeedUp, SpellType.Buff , 1) { }
public AstralMove(Entity owner) : base(owner, TexturesManager.AstralMove,SpellType.Buff, 1) { position = owner.Position; }