public FrogMob(GameModel model, int x, int y) : base(model, ImagePath, x, y) { Action IceToWater = () => { if (Model.BackMap[X, Y] is IceBackground) { Model.BackMap[X, Y] = new WaterBackground(Model, X, Y); } }; OnMoveStart += () => { if (Model.BackMap[X, Y] is WaterBackground || Model.BackMap[MX, MY] is WaterBackground) { Destroy(); return; } IceToWater(); }; OnCantMove += (key) => { IceToWater(); var newDirection = Useful.ReverseDirection(key); GoTo(newDirection); }; OnStop += base.ForStop; }
public PenguinMob(GameModel model, int x, int y) : base(model, ImagePath, x, y) { Action WaterToIce = () => { if (Model.BackMap[X, Y] is WaterBackground) { Model.BackMap[X, Y] = new IceBackground(Model, X, Y); } }; OnMoveStart += () => { if (Model.BackMap[X, Y] is LavaBackground || Model.BackMap[MX, MY] is LavaBackground) { Destroy(); return; } WaterToIce(); }; OnCantMove += (key) => { WaterToIce(); var newDirection = Useful.ReverseDirection(key); GoTo(newDirection); }; }
public bool CanStep(MovableBase mob) => !(mob is IHero && Useful.ReverseDirection(mob.GazeDirection) == Direction);
public SkimletSpell(IHero hero, int X, int Y, string ImageFile) : base(hero, X, Y, ImageFile) { var dict = new Dictionary <IMob, Action>(); var willDie = new List <IMob>(); foreach (var mob in Model.Mobs .Where(mob => mob.DestroyBySkimletSpell)) { if (Useful.CheckTouch(mob, X, Y)) { willDie.Add(mob); continue; } dict.Add(mob, () => { if (mob.MX == X && mob.MY == Y) { mob.Destroy(); } }); mob.OnMoveStart += dict[mob]; } foreach (var mob in willDie) { mob.Destroy(); } foreach (var mob in Model.Mobs.Where(mob => Math.Abs(mob.X - X) <= 1 && Math.Abs(mob.Y - Y) <= 1)) { if (mob is FrogMob && !mob.CurrentAnimation.IsMoving) { var direction = GetOppositeDirection(this, mob); if (direction != Keys.None) { mob.GoTo(direction); } break; } if (mob is CactusMob && !mob.CurrentAnimation.IsMoving) { var direction = GetOppositeDirection(this, mob); if (direction != Keys.None) { mob.GoTo(Useful.ReverseDirection(direction)); } break; } } OnDestroy += () => { var ItemStack = Model.ItemsMap[X, Y]; if (ItemStack.Count > 0 && ItemStack.Peek() is FireItem) { Model.ItemsMap[X, Y].Peek().Destroy(); } foreach (var act in dict) { act.Key.OnMoveStart -= act.Value; } }; }