Exemplo n.º 1
0
 public override void MouseClickRight(GameObject hitObject, Vector3 hitPoint)
 {
     if (hitObject)
     {
         Collider attackCol = WorkManager.FindEnemyTargetCollider(hitObject, unit.worldObject);
         if (attackCol)
         {
             AudioManager.Instance.Play("AttackCommand", unit.audioSource);
             WorldObject wo = attackCol.gameObject.GetComponentInParent <WorldObject>();
             if (wo)
             {
                 wo.TargetedByPlayer();
             }
             manuallyInitatedState = true;
             if (unit.attacker.CheckForRepeatCommand(attackCol))
             {
                 return;
             }
             else
             {
                 unit.animationManager.ChangeAnimation(RTS.EAnimation.Attack, false);
                 unit.attacker.ResetAttacker();
                 ReactToColliderFocus(attackCol);
                 return;
             }
         }
     }
     base.MouseClickRight(hitObject, hitPoint);
 }
Exemplo n.º 2
0
    public virtual void MouseClickRight(GameObject hitObject, Vector3 hitPoint)
    {
        unit.mover.EnableMoveInput();
        WorldObject hitWorldObject = hitObject.GetComponentInParent <WorldObject> ();

        if (unit.hatcheryInteracter)
        {
            if (unit.hatcheryInteracter.IssueInteractCommand(hitWorldObject))
            {
                AudioManager.Instance.Play("AllyInteractCommand");
                unit.SetUnitState(new HatcheryInteractState(unit, true));
                if (hitWorldObject)
                {
                    hitWorldObject.TargetedByPlayer();
                }
                return;
            }
        }

        if (unit.builder)
        {
            if (unit.builder.CheckToCancelBuildingPlacement())
            {
                return;
            }
            if (unit.builder.CheckToGiveResumeBuildOrder(hitObject))
            {
                unit.SetUnitState(new BuildState(unit, true));
                if (hitWorldObject)
                {
                    hitWorldObject.TargetedByPlayer();
                }
                return;
            }
        }

        if (unit.attacker)
        {
            Collider attackCol = WorkManager.FindEnemyTargetCollider(hitObject, unit.worldObject);
            if (attackCol)
            {
                AudioManager.Instance.Play("AttackCommand", unit.audioSource);
                if (hitWorldObject)
                {
                    hitWorldObject.TargetedByPlayer();
                }
                unit.SetUnitState(new AttackState(unit, true));
                unit.SetColliderFocus(attackCol);
                return;
            }
        }

        if (unit.reviver)
        {
            if (unit.reviver.IssueReviveCommand(hitObject))
            {
                AudioManager.Instance.Play("AllyInteractCommand");
                if (hitWorldObject)
                {
                    hitWorldObject.TargetedByPlayer();
                }
                unit.SetUnitState(new ReviveState(unit, true));
                return;
            }
        }

        if (unit.mover)
        {
            if (hitWorldObject && WorkManager.AreWorldObjectsOnSameTeam(hitWorldObject, unit.worldObject) == true)
            {
                AudioManager.Instance.Play("AllyInteractCommand");
                unit.mover.ClearMovement();
                //unit.mover.SecondaryInteractGameObjectAtDistance (hitObject, 1.2f);
                unit.mover.PrimaryInteractGameObjectAtDistance(hitObject, 1.2f);
                unit.SetUnitState(new MoveState(unit, true));
                return;
            }
            if (hitWorldObject == null)
            {
                //AudioManager.Instance.Play("MoveCommand");
                unit.mover.ClearMovement();
                unit.player.groupFormationManager.DetermineFormationGroup(null, hitPoint);
                unit.SetUnitState(new MoveState(unit, true));
                return;
            }
        }
    }