Ejemplo n.º 1
0
        void Start()
        {
            for (int i = 0; i < 8; i++)
            {
                if (i == 0)
                {
                    buttonList[0].Init();
                }
                else if (i > 0)
                {
                    buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "AbilityButton" + (i + 1)));
                }

                if (UIMainControl.InTouchMode())
                {
                    buttonList[i].SetCallback(null, null, this.OnAbilityButton, null);
                }
                else
                {
                    buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnAbilityButton, null);
                }
                //buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnAbilityButton, null);

                buttonList[i].rootObj.SetActive(false);
            }

            buttonCancel.Init();
            buttonCancel.SetCallback(null, null, this.OnCancelButton, null);
            buttonCancel.SetActive(false);
            buttonCancel.rectT.SetAsLastSibling();
        }
Ejemplo n.º 2
0
        private int currentButtonID = -1;       //last touched button, for touch mode only
        public void OnAbilityButton(GameObject butObj, int pointerID = -1)
        {
            int ID = GetButtonID(butObj);

            if (UIMainControl.InTouchMode())
            {
                if (currentButtonID >= 0)
                {
                    buttonList[currentButtonID].imgHighlight.enabled = false;
                }
                if (currentButtonID != ID)
                {
                    currentButtonID = ID;
                    buttonList[ID].imgHighlight.enabled = true;
                    OnHoverButton(butObj);
                    return;
                }
                ClearTouchModeButton();
            }

            string exception = AbilityManagerFaction.SelectAbility(ID);

            if (exception != "")
            {
                UIMessage.DisplayMessage(exception);
            }

            buttonList[ID].imgHighlight.enabled = true;
        }
Ejemplo n.º 3
0
        // Update is called once per frame
        void Update()
        {
            if (lastHoveredTile != null)
            {
                UpdateTooltipPos();
            }

            if (UIMainControl.InTouchMode())
            {
                return;
            }

            if (UI.IsCursorOnUI(-1))
            {
                if (tooltipObj.activeInHierarchy)
                {
                    _SetNewHoveredTile(null);
                }
                return;
            }

            Tile tile = GridManager.GetHoveredTile();

            if (tile != lastHoveredTile)
            {
                _SetNewHoveredTile(tile);
            }
        }
Ejemplo n.º 4
0
 public void OnHoldAbilityButton(GameObject butObj)
 {
     if (UIMainControl.InTouchMode() && !tooltipObj.activeSelf)
     {
         OnHoverButton(butObj);
     }
 }
Ejemplo n.º 5
0
        private int currentButtonID = -1;       //last touched button, for touch mode only
        public void OnAbilityButton(GameObject butObj, int pointerID = -1)
        {
            int ID = GetButtonID(butObj);

            if (UIMainControl.InTouchMode())
            {
                if (currentButtonID >= 0)
                {
                    buttonList[currentButtonID].imgHighlight.enabled = false;
                }
                currentButtonID = ID;
                buttonList[ID].imgHighlight.enabled = true;
            }
            else
            {
                string exception = GameControl.GetSelectedUnit().SelectAbility(ID);
                if (exception != "")
                {
                    UIMessage.DisplayMessage(exception);
                }
            }
        }
Ejemplo n.º 6
0
 public void OnReleaseAbilityButton(GameObject butObj, int pointId = -1)
 {
     if (UIMainControl.InTouchMode())
     {
         if (tooltipObj.activeSelf)
         {
             OnExitButton(null);
             if (currentButtonID >= 0)
             {
                 buttonList[currentButtonID].imgHighlight.enabled = false;
             }
             currentButtonID = -1;
         }
         else
         {
             int ID = GetButtonID(butObj);
             if (currentButtonID == ID)                   // this check is BS because the buttons seem to capture focus, but leave it in since it doesn't break anything HACK
             {
                 string exception = GameControl.GetSelectedUnit().SelectAbility(ID);
                 if (exception != "")
                 {
                     UIMessage.DisplayMessage(exception);
                     buttonList[currentButtonID].imgHighlight.enabled = false;
                 }
                 else
                 {
                     bool isInTargetMode = GameControl.GetSelectedUnit().abilityList[ID].requireTargetSelection;
                     if (!isInTargetMode)
                     {
                         buttonList[currentButtonID].imgHighlight.enabled = false;
                         currentButtonID = -1;
                     }
                 }
             }
         }
     }
 }