Пример #1
0
    void ClickTileOrUI(bool left)
    {
        var accepter = FindInputAccepter();

        if (accepter == null)
        {
            if (unitCursor.HasFoundTile())
            {
                AbstractAttack attack = null;
                if (left)
                {
                    attack = new RoundAttack(unitCursor.GetSpawnPoint(false));
                }
                else
                {
                    attack = new StraightAttack(unitCursor.GetSpawnPoint(false));
                }

                if (attack.GetComsumption() <= GameDataManager.Instance.UnitPower)
                {
                    mainCharacter.AnimateAttack();
                    attack.Animate(unitCursor.GetSpawnPoint(false));
                    ObjectManager.Instance.WaveManager.enemies
                    .Where(e => attack.IsInRange(e.transform.position))
                    .ToList()
                    .ForEach(e => e.Damaged(attack.GetDamage()));
                    GameDataManager.Instance.UnitPower -= attack.GetComsumption();
                }
            }
        }
        else
        {
            accepter.Execute();
        }
    }