protected override void Execute(LevelStateChanged msg) { if (map.NumOfJumpables == 1 && !_spawned) { var heroTile = new TilePoint(map.Hero.gameObject); if (map.IsJumpable(new TilePoint(heroTile.X - 1, heroTile.Y)) && map.IsWalkable(new TilePoint(heroTile.X - 2, heroTile.Y))) { SpawnDataCube(new TilePoint(heroTile.X - 2, heroTile.Y)); } if (map.IsJumpable(new TilePoint(heroTile.X + 1, heroTile.Y)) && map.IsWalkable(new TilePoint(heroTile.X + 2, heroTile.Y))) { SpawnDataCube(new TilePoint(heroTile.X + 2, heroTile.Y)); } if (map.IsJumpable(new TilePoint(heroTile.X, heroTile.Y - 1)) && map.IsWalkable(new TilePoint(heroTile.X, heroTile.Y - 2))) { SpawnDataCube(new TilePoint(heroTile.X, heroTile.Y - 2)); } if (map.IsJumpable(new TilePoint(heroTile.X, heroTile.Y + 1)) && map.IsWalkable(new TilePoint(heroTile.X, heroTile.Y + 2))) { SpawnDataCube(new TilePoint(heroTile.X, heroTile.Y + 2)); } } }
public override bool IsValid(MovementProposed m) => m.Type == MovementType.Attack || map.IsWalkable(m.To);