public override Order Clone()
    {
        AttackUnitOrder AUO = new AttackUnitOrder();

        AUO.idPlayer       = this.idPlayer;
        AUO.isActive       = this.isActive;
        AUO.units          = this.units;
        AUO.targets        = this.targets;
        AUO.isConcentrated = this.isConcentrated;
        AUO.targetIndex    = this.targetIndex;
        AUO.movementOrder  = this.movementOrder;
        AUO.timeCounter    = this.timeCounter;

        return(AUO);
    }
Beispiel #2
0
    public override void Execute()
    {
        /**/
        if (building.isAttacked)
        {
            /**/

            if (this.AUO == null)
            {
                List <Unit> targets = GameController.players[building.idPlayer].action.GetUnitsEnemyIsAttacking(this.building);

                if (targets.Count > 0)
                {
                    this.AUO = new AttackUnitOrder(this.units, targets, this.isConcentrated, true);
                }
                else
                {
                    this.isActive = false;
                    return;
                }
            }

            if (!this.AUO.Cooldown())
            {
                this.AUO.Execute();
            }

            if (!this.AUO.isActive)
            {
                this.isActive = false;
            }
            /**/
        }
        else
        {
            this.AUO = null;

            if (CheckDistance())
            {
                this.MO = null;

                foreach (Unit unit in this.units)
                {
                    unit.isBusy    = false;
                    unit.isWalking = false;
                }
            }
            else
            {
                if (this.MO == null)
                {
                    this.MO = new MovementOrder(this.idPlayer, this.units, this.building.position, false, false, true, true);
                }

                if (!this.MO.Cooldown())
                {
                    this.MO.Execute();
                }
            }
        }
        /**/
    }