Exemplo n.º 1
0
    internal override void OptionExtensions_OnLEFTCLICK(bool hold)
    {
        if (!hold)
        {
            if (attackState == OPTIONS.Attack)
            {
                UnitScript otherUnit = MouseEvents.State.Position.AsUnitUnderCursor;
                if (otherUnit)
                {
                    if (UNIT.IsEnemy(otherUnit))
                    {
                        UNIT.Options.Target      = otherUnit.gameObject;
                        UNIT.Options.MoveToPoint = UNIT.Options.Target.transform.position;
                        if (!UNIT.IsABuilding)
                        {
                            GetComponent <Movability>().IsMoving = true;
                        }
                        IsAttacking = true;
                    }
                    else if (UNIT.IsAllied(otherUnit))
                    {
                        this.UNIT.Options.Target = otherUnit.SetInteracting(this.gameObject);
                        if (otherUnit.Options.IsAttacking)
                        {
                            this.UNIT.Options.Target = otherUnit.Options.Target;
                            IsAttacking = true;
                            UNIT.Options.MoveAsGroup(otherUnit.gameObject);
                        }
                    }

                    UNIT.Options.UnlockFocus();
                }
            }
            else if (attackState == OPTIONS.Conquer)
            {
                UNIT.Options.MoveToPoint = MouseEvents.State.Position;

                if (!GetComponent <Gunner>())
                {
                    this.gameObject.AddComponent <Gunner>();
                }

                if (!UNIT.IsABuilding)
                {
                    GetComponent <Movability>().IsMoving = true;
                }

                IsDefending  = false;
                IsAttacking  = true;
                IsConquering = true;
                GetComponent <Gunner>().FireAtWill = true;

                UNIT.Options.UnlockFocus();
            }
        }
    }