Ejemplo n.º 1
0
Archivo: Game.cs Proyecto: Eibis/Slimes
    void HandleAttacks()
    {
        Dictionary <GameTile, int> pending_damage = new Dictionary <GameTile, int>();

        for (int i = 0; i < Grid.Width; i++)
        {
            for (int j = 0; j < Grid.Height; j++)
            {
                GameTile tile = Grid.GetTile(i, j, 0);

                if (tile == null)
                {
                    return;
                }

                GameTile opposite_tile = tile.GetOppositeTile();

                bool success = Damage(tile, opposite_tile);

                if (success)
                {
                    if (!pending_damage.ContainsKey(opposite_tile))
                    {
                        pending_damage.Add(opposite_tile, 0);
                    }

                    pending_damage[opposite_tile] += tile.Slime.Power;
                }

                success = Damage(opposite_tile, tile);

                if (success)
                {
                    if (!pending_damage.ContainsKey(tile))
                    {
                        pending_damage.Add(tile, 0);
                    }

                    pending_damage[tile] += opposite_tile.Slime.Power;
                }
            }
        }

        foreach (var damage in pending_damage)
        {
            damage.Key.Damage(damage.Value);
        }
    }