Beispiel #1
0
        void OnFPSMode(bool flag)
        {
            //FPSModeCrosshairObj.SetActive(flag);

                        #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY
            UIGameMessage.DisplayMessage("FPS mode is not supported in mobile");
                        #endif

            if (flag)
            {
                UIBuildButton.Hide();
                UIAbilityButton.Hide();
                UIPerkMenu.Hide();
                UIFPSHUD.Show();
            }
            else
            {
                if (UseDragNDrop())
                {
                    UIBuildButton.Show();
                }
                if (AbilityManager.IsOn())
                {
                    UIAbilityButton.Show();
                }
                if (PerkManager.IsOn())
                {
                    UIPerkMenu.Show();
                }
                UIFPSHUD.Hide();
            }
        }
        void Start()
        {
            if (!AbilityManager.IsOn() || AbilityManager.GetAbilityCount() == 0)
            {
                thisObj.SetActive(false);
                return;
            }

            List <Ability> abList = AbilityManager.GetAbilityList();

            for (int i = 0; i < abList.Count; i++)
            {
                if (i == 0)
                {
                    buttonList[0].Init();
                }
                else if (i > 0)
                {
                    buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "AbilityButton" + (i + 1)));
                }

                buttonList[i].imgIcon.sprite       = abList[i].icon;
                buttonList[i].imgHighlight.enabled = false;
                buttonList[i].label.text           = "";

                if (abList[i].usedRemained > 0)
                {
                    buttonList[i].label.text = abList[i].usedRemained.ToString();
                }
                //else buttonList[i].label.text="∞";

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


            tooltipRscItem.Init();


            butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>();
            OnAbilitySelectingTarget(false);

            UIItemCallback cancelCallback = butCancelObj.AddComponent <UIItemCallback>();

            cancelCallback.SetDownCallback(this.OnCancelAbilityButton);
            //cancelCallback.SetUpCallback(up);

            tooltipObj.SetActive(false);
        }
Beispiel #3
0
        // Use this for initialization
        void Start()
        {
            tooltipObj.SetActive(false);

            if (!AbilityManager.IsOn())
            {
                Hide();
                return;
            }

            List <Ability> abList = AbilityManager.GetAbilityList();

            if (abList.Count == 0)
            {
                Hide();
                return;
            }

            EventTrigger.Entry entryRequireTargetSelect     = SetupTriggerEntry(true);
            EventTrigger.Entry entryDontRequireTargetSelect = SetupTriggerEntry(false);

            for (int i = 0; i < abList.Count; i++)
            {
                if (i == 0)
                {
                    buttonList[0].Init();
                }
                else if (i > 0)
                {
                    buttonList.Add(buttonList[0].Clone("button" + (i + 1), new Vector3(i * 55, 0, 0)));
                }
                buttonList[i].imageIcon.sprite = abList[i].icon;
                buttonList[i].label.text       = "";

                EventTrigger trigger = buttonList[i].rootObj.GetComponent <EventTrigger>();
                if (abList[i].requireTargetSelection)
                {
                    trigger.triggers.Add(entryRequireTargetSelect);
                }
                else
                {
                    trigger.triggers.Add(entryDontRequireTargetSelect);
                }
            }

            float offset = 0.5f * (buttonList.Count - 1) * 55;

            for (int i = 0; i < buttonList.Count; i++)
            {
                buttonList[i].rootT.localPosition -= new Vector3(offset, 0, 0);
            }
        }
        // Use this for initialization
        void Start()
        {
            tooltipObj.SetActive(false);
            if (!AbilityManager.IsOn())
            {
                Hide();
                return;
            }

            abList = AbilityManager.GetAbilityList();
            if (abList.Count == 0)
            {
                Hide();
                return;
            }
            EventTrigger.Entry entryRequireTargetSelect     = SetupTriggerEntry(true);
            EventTrigger.Entry entryDontRequireTargetSelect = SetupTriggerEntry(false);

            for (int i = 0; i < abList.Count; i++)
            {
                if (i == 0)
                {
                    buttonList[0].Init();
                }
                else if (i > 0)
                {
                    buttonList.Add(buttonList[0].Clone("button" + (i + 1), new Vector3(i * 155, 0, 0)));
                }
                buttonList[i].InitAbility(abList[i]);

                EventTrigger trigger = buttonList[i].gameObject.GetComponent <EventTrigger>();
                if (abList[i].requireTargetSelection)
                {
                    trigger.triggers.Add(entryRequireTargetSelect);
                }
                else
                {
                    trigger.triggers.Add(entryDontRequireTargetSelect);
                }
            }
        }