public static void SignFunc(WorldMap worldMap, Creature creature) { Vector2 v; v = creature.Location; if (worldMap.Portals.Count > 0) { var portal = worldMap.Portals.OrderBy((p) => (worldMap.GetDistance(v.X, v.Y, p.Location.X, p.Location.Y))).First(); portal.isOpen = false; portal.Destroyed = true; } }
internal static void ChargePlayerIfInRange(Creature creature, WorldMap worldMap, double random = 1) { if (creature.Is("changingDirections")) { Random rnd = new Random(); creature.MoveScript(rnd, worldMap); creature.Set("changingDirections", 0); } if (creature.Is("charging")) { creature.Speed = creature.Get("charging", 0); } else { //creature.Set("charging", creature.Speed); } if (random < 0.95) { return; } ; creature.Set("charging", creature.Speed); var distance = worldMap.GetDistance(creature.Location, worldMap.Player.Location); if (distance < (5 * creature.Range)) { creature.Speed = 12 - (int)creature.Type; creature.Direction = worldMap.GetAngle(creature.Location, worldMap.Player.Location); if (distance < creature.Range) { worldMap.Forces.Add( new Attack(worldMap.Player) { Creator = creature, Location = worldMap.Player.Location, Duration = 20, Damage = creature.Attack, Range = creature.Range + 16, WorldMap = worldMap, Visual = Force.Visuals.Bloody, Direction = (float)creature.Direction, Speed = 1, } ); } } }
internal static void CreateAttackIfInRange(Creature creature, WorldMap worldMap, double random = 1) { var creatures = worldMap.Creatures.Where((c) => ((worldMap.GetDistance(creature.Location, c.Location) <= creature.Range) && c.ID != creature.ID)).Take(5).ToList(); for (int i = 0; i < creatures.Count; i++) { var enemy = creatures[i]; worldMap.Forces.Add(new Attack(enemy) { Creator = creature, Damage = creature.Attack, Range = creature.Range + 16, Location = creature.GetMoveLocation(creature.Location.X, creature.Location.Y, creature.Direction, 32f), WorldMap = worldMap, Duration = 20, Visual = Force.Visuals.Bloody }); } }
public new void Apply() { var self = (this as Attack); if (null == _creature) { _creature = WorldMap.Creatures.OrderBy((c) => (WorldMap.GetDistance(self.Location, c.Location))) .FirstOrDefault((c) => ((WorldMap.GetDistance(self.Location, c.Location) <= self.Range) && c.ID != Creator.ID && !c.Is("dead"))); } Duration -= 1; //decay in 20 frames at 40fps. if (Duration <= 0) { //self._isApplied = true; self.Remove = true; } if (null == _creature) { this.Location = WorldMap.GetMoveLocation(this.Location, this.Direction, this.Speed); return; } if (WorldMap.GetDistance(self.Location, _creature.Location) <= self.Range) { self._creature.Set("hurt"); self._creature.Health -= Damage; self._creature.Set("hurt"); if (self._creature.Health <= 0 && !(self._creature.Is("dead"))) { self._creature.Set("dead", 4); Creator.Kills += 1; } //self.Remove = true; } if (!Piercing) { self._isApplied = true; } }
public void ExplosionFunc() { var self = this as Explosion; self.Duration -= 1; if (this.IsApplied) { return; } WorldMap.Creatures.ForEach((c) => { if ((c.ID != this.Creator.ID) && (WorldMap.GetDistance(c.Location, this.Location) <= this.Range)) { c.Health -= this.Damage; if (c.Health <= 0 && !(c.Is("dead"))) { c.Set("dead", 4); Creator.Kills++; } } }); self._isApplied = true; }