Beispiel #1
0
 /// <summary>
 /// /// <summary>Add to the selection the given selectable.</summary>
 /// </summary>
 /// <param name="sel">Selectable added to selection.</param>
 public void AddSelection(SelectableCtrl sel)
 {
     if (sel != null)
     {
         sel.Selected = true;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Set an action for the current selection.
 /// </summary>
 /// <param name="target">Target selectable.</param>
 /// <param name="groundPos">Ground position.</param>
 public void SetAction(SelectableCtrl target, Vector3 groundPos)
 {
     if (!target || !target.att ||
         target.PlayerNum == PlayerCtrl.PlayerNum)
     {
         // It is a move action.
         if (LOG)
         {
             Debug.Log("SelectionMngr: Player action movement.");
         }
         this.SpawnDestFx(groundPos);
         foreach (SelectableCtrl sel in selectedList)
         {
             sel.Move(groundPos);
         }
     }
     else
     {
         // It is an attack action.
         if (LOG)
         {
             Debug.Log("SlectionMngr: Player action attack.");
         }
         target.view.Targeted();
         this.SpawnDestFx(target.trans.position);
         foreach (SelectableCtrl sel in selectedList)
         {
             sel.Attack(target);
         }
     }
 }
Beispiel #3
0
        //======================================================================

        /// <summary>
        /// /// <summary>Set the selection to the given selectable.</summary>
        /// </summary>
        /// <param name="sel">Selectable selected.</param>
        public void SetSelection(SelectableCtrl sel)
        {
            this.ClearSelection();
            if (sel != null)
            {
                if (LOG)
                {
                    Debug.Log("SelectionMngr: Selected " + sel.name);
                }
                sel.Selected = true;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Turn tapping input into game functions: selection or action
        /// </summary>
        /// <param name="screenPos">Screen position.</param>
        /// <param name="tapCount">Number of taps.</param>
        private void TapToSelectionAction(Vector3 screenPos, int tapCount)
        {
            SelectableCtrl target = this.ScreenPointToSelectable(screenPos);

            if (tapCount == 1)
            {
                _selMngr.SetSelection(target);
            }
            else
            {
                _selMngr.SetAction(target, this.ScreenPointToGround(screenPos));
            }
        }
Beispiel #5
0
        //======================================================================

        void Awake()
        {
            PlayerNum = 2;
            unitsList = new List <SelectableCtrl> ();
            foreach (Transform child in transform)
            {
                if (child.gameObject.activeInHierarchy)
                {
                    // Add to units list.
                    SelectableCtrl sel = child.GetComponent <SelectableCtrl> ();
                    unitsList.Add(sel);
                }
            }
        }
Beispiel #6
0
 void Start()
 {
     // Remove from units list if killed.
     foreach (SelectableCtrl sel in unitsList)
     {
         // Create local reference for the closure.
         SelectableCtrl sel2 = sel;
         if (sel.att)
         {
             sel.att.CurrentHp
             .TakeUntilDestroy(gameObject)
             .TakeWhile(hp => hp > 0)
             .Subscribe(_ => {}, () => {
                 unitsList.Remove(sel2);
             });
         }
     }
 }
Beispiel #7
0
 public void Attack(SelectableCtrl target)
 {
     if (LOG)
     {
         Debug.Log(name + " Player set attack to " + target.name);
     }
     if (this.aggPA && target.att &&
         this.PlayerNum !=
         target.GetComponent <SelectableCtrl> ().PlayerNum)
     {
         this.aggPA.PlayerAttack(target.att);
         view.Attack(target.att);
     }
     else
     {
         Debug.Log(
             string.Format("{0} can't attack {1}", name, target.name)
             );
     }
 }
Beispiel #8
0
 public void SetReferences()
 {
     sel     = GetComponent <SelectableCtrl> ();
     sel.mov = this;
 }
Beispiel #9
0
 public void SetReferences()
 {
     sel          = GetComponentInParent <SelectableCtrl> ();
     wolrdUiTrans = GameObject.Find("WorldUI").transform;
     hpBar        = GetComponentInChildren <HpBar> ();
 }
Beispiel #10
0
 public void SetReferences()
 {
     sel       = GetComponentInParent <SelectableCtrl> ();
     sel.aggAA = this;
 }
Beispiel #11
0
        public void SetReferences()
        {
            sel = GetComponentInParent <SelectableCtrl> ();
//			_mov = sel.mov;
        }