コード例 #1
0
ファイル: TDUIControl.cs プロジェクト: asd540578/TD_Project
        private void OnCursorDownAbilityTargetMode(int idx = -1)
        {
            TargetingInfo tInfo = AbilityManager.OnCursorDown(Input.mousePosition, idx);

            //if -1 is passed, AbilityManager will use the idx given when AbilityManager.SelectAbility() is called
            if (tInfo.valid)
            {
                AbilityManager.ActivateAbility(idx, tInfo.pos);
            }
            else
            {
                Debug.Log("target not valid");
            }
        }
コード例 #2
0
        public void OnAbilityButton(GameObject butObj, int pointerID = -1)
        {
            int idx = UI.GetItemIndex(butObj, abilityButtons);

            if (UIControl.InTargetSelectionMode())
            {
                if (AbilityManager.GetPendingTargetAbilityIndex() == idx || UIControl.GetPendingAbilityIdx() == idx)
                {
                    abilityButtons[idx].imgHighlight.gameObject.SetActive(false);
                    UIControl.ClearSelectedAbility();
                    buttonClearSelect.SetActive(false);
                    return;
                }
            }

            Ability._Status status = AbilityManager.IsReady(idx);

            if (status != Ability._Status.Ready)
            {
                if (status == Ability._Status.OnCooldown)
                {
                    GameControl.InvalidAction("Ability is on cooldown");
                }
                if (status == Ability._Status.InsufficientRsc)
                {
                    GameControl.InvalidAction("Insufficient resource");
                }
                if (status == Ability._Status.UseLimitReached)
                {
                    GameControl.InvalidAction("Use limit exceeded");
                }
                return;
            }

            if (UIControl.InTouchMode())
            {
                if (!AbilityManager.RequireTargetSelection(idx) && touchModeButtonIdx != idx)
                {
                    if (touchModeButtonIdx >= 0)
                    {
                        ClearTouchModeSelect();
                    }

                    touchModeButtonIdx = idx;
                    abilityButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(true);
                    OnHoverAbilityButton(butObj);
                    buttonClearSelect.SetActive(true);
                    return;
                }

                ClearTouchModeSelect();
            }


            if (AbilityManager.RequireTargetSelection(idx))
            {
                UIControl.SelectAbility(idx);
                abilityButtons[idx].imgHighlight.gameObject.SetActive(true);
                buttonClearSelect.SetActive(true);
            }
            else
            {
                AbilityManager.ActivateAbility(idx);
                abilityButtons[idx].lbMain.text = AbilityManager.GetAbility(idx).GetUseLimitText();
            }
        }