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;
        }
        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();
        }
예제 #3
0
        public void _Show()
        {
            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            UIMainControl.FadeIn(canvasGroup, 0.25f);
        }
예제 #4
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);
            }
        }
예제 #5
0
        public void _Hide()
        {
            OnCancelButton(null);

            UIMainControl.FadeOut(canvasGroup, 0.25f);
            StartCoroutine(DelayHide());
        }
예제 #6
0
 public void _Hide()
 {
     isOn = false;
     UIMainControl.FadeOut(canvasGroup, 0.25f, thisObj);
     butClose.SetActive(false);
     //StartCoroutine(DelayHide());
 }
예제 #7
0
        public void _Hide()
        {
            indicator.gameObject.SetActive(false);

            UIMainControl.FadeOut(canvasGroup, 0.2f, thisObj);
            //StartCoroutine(DelayHide());
        }
예제 #8
0
        public void _Show(Tile tile)
        {
            if (tile.unit == null || !tile.IsVisible())
            {
                if (thisObj.activeInHierarchy)
                {
                    _Hide();
                }
                else
                {
                    return;
                }
            }

            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            UpdateDisplay(tile);

            if (thisObj.activeInHierarchy)
            {
                return;
            }
            UIMainControl.FadeIn(canvasGroup, 0.2f, thisObj);
        }
예제 #9
0
        public Vector3 GetScreenPos(Vector3 worldPos)
        {
            Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos) * UIMainControl.GetScaleFactor();

            screenPos.z = 0;
            return(screenPos);
        }
예제 #10
0
 public void OnHoldAbilityButton(GameObject butObj)
 {
     if (UIMainControl.InTouchMode() && !tooltipObj.activeSelf)
     {
         OnHoverButton(butObj);
     }
 }
예제 #11
0
        void NewTextOverlay(TextOverlay overlayInstance)
        {
            if (!UIMainControl.EnableTextOverlay())
            {
                return;
            }

            Text txt = GetUnusedTextOverlay();

            txt.text = overlayInstance.msg;
            if (overlayInstance.useColor)
            {
                txt.color = overlayInstance.color;
            }
            else
            {
                txt.color = defaultColor;
            }

            txt.fontSize = (int)Mathf.Round(defaultFontSize * overlayInstance.scale);

            txt.transform.localPosition = GetScreenPos(overlayInstance.pos);
            txt.gameObject.SetActive(true);

            StartCoroutine(TextOverlayRoutine(overlayInstance.pos, txt));
        }
예제 #12
0
        public void _Show()
        {
            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            //rectT.localPosition=new Vector3(0, 0, 0);
            UIMainControl.FadeIn(canvasGroup, 0.25f);
        }
예제 #13
0
        public void _OnGameInAction(bool flag)
        {
            //if(!flag) Debug.Log("resume control   "+UIMainControl.IsPlayerTurn());
            //else Debug.Log("lock control   "+UIMainControl.IsPlayerTurn());
            endTurnButton.button.interactable = !flag& UIMainControl.IsPlayerTurn();

            perkButton.button.interactable = !flag& UIMainControl.IsPlayerTurn();
        }
예제 #14
0
        public void _Show()
        {
            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            UpdateDisplay();

            UIMainControl.FadeIn(canvasGroup, 0.35f, thisObj);
        }
예제 #15
0
        void Start()
        {
            if (!UIMainControl.EnablePerkButton())
            {
                thisObj.SetActive(false);
            }

            if (!manuallySetupItem)
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (i == 0)
                    {
                        perkItemList[0].Init();
                    }
                    else if (i > 0)
                    {
                        perkItemList.Add(UIPerkItem.Clone(perkItemList[0].rootObj, "PerkButton" + (i + 1)));
                    }

                    perkItemList[i].imgIcon.sprite = perkList[i].icon;
                    perkItemList[i].perkID         = perkList[i].prefabID;
                    perkItemList[i].selectHighlight.SetActive(i == 0);

                    perkItemList[i].SetCallback(null, null, this.OnPerkItem, null);
                }

                UpdateContentRectSize();
            }
            else
            {
                for (int i = 0; i < perkItemList.Count; i++)
                {
                    perkItemList[i].Init();
                    perkItemList[i].selectHighlight.SetActive(i == 0);
                    perkItemList[i].SetCallback(null, null, this.OnPerkItem, null);
                }
            }

            butPurchase.Init();
            if (butClose.rootObj != null)
            {
                butClose.Init();
            }

            UpdatePerkItemList();
            UpdateDisplay();

            if (demoMenu)
            {
                thisObj.SetActive(false);
            }
            //rectT.localPosition=new Vector3(0, 0, 0);
        }
예제 #16
0
 public void _OnGameInAction(bool flag)
 {
     if (!UIMainControl.IsPlayerTurn())
     {
         return;
     }
     for (int i = 0; i < abilityList.Count; i++)
     {
         buttonList[i].button.interactable = (abilityList[i].IsAvailable() == "" & !flag);
     }
 }
예제 #17
0
        public void _Hide()
        {
            if (!showing)
            {
                return;
            }
            showing = false;

            UIMainControl.FadeOut(canvasGroup, 0.25f);
            StartCoroutine(DelayHide());
        }
예제 #18
0
        public void _Show()
        {
            UpdatePerkItemList();
            UpdateDisplay();

            isOn = true;
            butClose.SetActive(true);

            rectT.localPosition = Vector3.zero;
            UIMainControl.FadeIn(canvasGroup, 0.25f, thisObj);
        }
예제 #19
0
        public void _Show(Unit unit)
        {
            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            UpdateDisplay(unit);
            buttonClose.SetActive(true);

            rectT.localPosition = new Vector3(0, 0, 0);
            UIMainControl.FadeIn(canvasGroup, 0.25f, thisObj);
        }
예제 #20
0
        public void OnEndTurnButton()
        {
            if (!TurnControl.ClearToProceed())
            {
                return;
            }
            OnGameInAction(true);

            endTurnButton.imgHighlight.gameObject.SetActive(false);

            //GameControl.EndTurn();
            UIMainControl.EndTurn();
        }
예제 #21
0
        public void _Show()
        {
            if (showing)
            {
                return;
            }
            showing = true;

            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            UIMainControl.FadeIn(canvasGroup, 0.25f);
        }
예제 #22
0
        public void _Show()
        {
            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            //UpdateDisplay(tile);
            // buttonInfo.SetActive(true);

            if (thisObj.activeInHierarchy)
            {
                return;
            }
            UIMainControl.FadeIn(canvasGroup, 0.2f, thisObj);
        }
예제 #23
0
        IEnumerator DisplayItemRoutine(UIMsgItem item)
        {
            item.rectT.SetAsFirstSibling();

            UIMainControl.FadeIn(item.canvasG, 0.1f, item.rootObj);

            StartCoroutine(ScaleRectTRoutine(item.rectT, .1f, scale, scaleZoomed));
            yield return(StartCoroutine(UIMainControl.WaitForRealSeconds(.1f)));

            //yield return new WaitForSeconds(0.1f);
            StartCoroutine(ScaleRectTRoutine(item.rectT, .25f, scaleZoomed, scale));

            yield return(StartCoroutine(UIMainControl.WaitForRealSeconds(.8f)));

            //yield return new WaitForSeconds(0.8f);

            UIMainControl.FadeOut(item.canvasG, 1.0f, item.rootObj);
        }
예제 #24
0
        public void _Show(int winningFactionID)
        {
            canvasGroup.interactable   = true;
            canvasGroup.blocksRaycasts = true;

            if (FactionManager.IsPlayerFaction(winningFactionID))
            {
                lbStatus.text = "Victory!!";
            }
            else
            {
                if (!UIMainControl.ShowContinueButtonWhenLost() && continueButton != null)
                {
                    continueButton.SetActive(false);
                }
            }

            UIMainControl.FadeIn(canvasGroup, 0.25f);
        }
예제 #25
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);
                }
            }
        }
예제 #26
0
        // Update is called once per frame
        void LateUpdate()
        {
            if (unit == null)
            {
                if (gameObject.activeInHierarchy)
                {
                    gameObject.SetActive(false);
                }
                return;
            }

            Vector3 screenPos = Camera.main.WorldToScreenPoint(unit.thisT.position);

            screenPos.z         = 0;
            rectT.localPosition = (screenPos + new Vector3(0, posOffset)) * UIMainControl.GetScaleFactor();

            sliderHP.value = unit.GetHPRatio();
            sliderAP.value = unit.GetAPRatio();
            textHP.text    = unit.HP + " / " + unit.GetFullHP();
            textAP.text    = unit.AP + " / " + unit.GetFullAP();

            canvasGroup.alpha = (unit.thisObj.layer == TBTK.GetLayerUnitInvisible() ? 0 :  1);

            //_CoverType{None, Half, Full}
            if ((int)unit.coverStatus != currentCoverStatus)
            {
                currentCoverStatus = (int)unit.coverStatus;
                if (currentCoverStatus == 1)
                {
                    imgCoverIcon.sprite = spriteHalfCover;
                }
                if (currentCoverStatus == 2)
                {
                    imgCoverIcon.sprite = spriteFullCover;
                }
                imgCoverIcon.enabled = !(currentCoverStatus == 0);
            }
        }
예제 #27
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;
                     }
                 }
             }
         }
     }
 }
예제 #28
0
        void UpdateTooltipPos()
        {
            Vector3 screenPos = Camera.main.WorldToScreenPoint(lastHoveredTile.GetPos());

            tooltipRectT.localPosition = (screenPos + new Vector3(offset.x, offset.y + verticalOffset, 0)) * UIMainControl.GetScaleFactor();
        }
예제 #29
0
 public void _Hide()
 {
     UIMainControl.FadeOut(canvasGroup, 0.2f, thisObj);
     //StartCoroutine(DelayHide());
 }
예제 #30
0
 void Awake()
 {
     instance = this;
 }