예제 #1
0
    private void TrySelectUnit()
    {
        startPos = Input.mousePosition;
        DoMouseHit(characterLayer);

        if (mouseHit.collider == null)
        {
            DoMouseHit(-1);
            Collider[] units = Physics.OverlapSphere(mouseHit.point, findRadius, characterLayer);
            if (units.Length > 0)
            {
                selected = UnityExtension.GetClosest(mouseHit.point, PController.instance.playerUnits) as CharacterManager;
            }
            else
            {
                return;
            }
        }
        else
        {
            selected = mouseHit.collider.GetComponent <CharacterManager>();
        }
        if (selected == null || selected.GetTeam() != Team.Player1)
        {
            return;
        }
        mousePath.Clear();
        drag = true;
    }
예제 #2
0
 public override void StartCommand()
 {
     if (target == null)
     {
         target = UnityExtension.GetClosest(owner, PController.instance.playerUnits) as CharacterManager;
     }
     owner.Command = new FindEnemyCommand(owner);
 }
예제 #3
0
 public override void StartCommand()
 {
     if (target == null)
     {
         target = UnityExtension.GetClosest(owner, UnitsManager.instance.localities) as Unit;
     }
     owner.Command = new FindEnemyCommand(owner);
 }
예제 #4
0
 public void SetStartingTarget(List <Unit> units)
 {
     for (int i = 0; i < units.Count; i++)
     {
         Unit enemy = UnityExtension.GetClosest(units[i].transform, UnitsManager.instance.localities)
                      as Unit;
         units[i].Command = new GuardCommand(units[i]);
     }
 }