Exemplo n.º 1
0
 public void SetButtonActions(MageAssignableBuilding.Action action)
 {
     foreach (var actionWithEvent in action.actions)
     {
         UIManager.SetButtonEvent(_thisButton, actionWithEvent);
     }
 }
        public void AddPlayerButton()
        {
            var mageButton = Instantiate(PlayerButtonPrefab);

            MageButtonsList.Add(mageButton);
            mageButton.transform.SetParent(transform, false);
            mageButton.GetComponent <UIAccordionElement>().SetAccordion();
            mageButton.GetComponentInChildren <Text>().text = Player.Data.GetPlayerName();
            SetButtonElement(mageButton, Player.Data.GetElement());
            var profilePage = mageButton.gameObject.transform.GetChild(1);
            var buttons     = profilePage.GetComponentsInChildren <Button>();

            //buttons[0].onClick.AddListener(delegate
            //{
            //    Player.Data.UpgradePlayer();
            //});
            Player.AssignActions();
            foreach (var t in Player.upgrade1Actions)
            {
                UIManager.SetButtonEvent(buttons[0], t);
            }
            //buttons[1].onClick.AddListener(delegate
            //{
            //    Player.Data.UpgradeIdleGenerated();
            //});
            foreach (var t in Player.upgrade2Actions)
            {
                UIManager.SetButtonEvent(buttons[1], t);
            }


            mageButton.GetComponent <UIAccordionElement>().onValueChanged.AddListener(delegate
            {
                Player._audioManager.PlayButtonClickSound();
                SetPerson(profilePage.gameObject, null);
                SetScroll(1);
            });
        }
        public void OnMagePrefabUpdated(Mage mage)
        {
            var mageButton = MageButtonsList[mage.Data.ProfileButtonIndex - 1];

            mageButton.GetComponentInChildren <Text>().text = mage.Data.GetName();
            SetButtonElement(mageButton, mage.Data.GetElement());
            var profilePage = mageButton.gameObject.transform.GetChild(1);
            var buttons     = profilePage.GetComponentsInChildren <Button>();

            mage.AssignActions();

            foreach (var t in mage.upgradeActions)
            {
                UIManager.SetButtonEvent(buttons[0], t);
            }

            var uiAccordionElement = mageButton.GetComponent <UIAccordionElement>();

            if (uiAccordionElement.isOn)
            {
                Player.TelevoleManager.SetMage(mage.Data);
            }

            uiAccordionElement.onValueChanged.AddListener(delegate
            {
                Player._audioManager.PlayButtonClickSound();
                SetPerson(profilePage.gameObject, mage.Data);
                if (mage.GetBuilding())
                {
                    if (uiAccordionElement.isOn)
                    {
                        // mage.GetBuilding().StartHighlighting(ElementController.Instance.GetColor(mage.Data.GetElement()));
                        mage.GetBuilding().StartHighlighting();
                        mage.GetBuilding().DisplayRangeObject();
                    }
                    else
                    {
                        mage.GetBuilding().StopHighlighting();
                        mage.GetBuilding().HideRangeObject();
                    }

                    if (mage.GetBuilding().MenuOpen)
                    {
                        mage.GetBuilding().MenuOpen = uiAccordionElement.isOn;
                        if (MageMenuOpen)
                        {
                            Player.UIManager.DestroyTowerMenuCloser();
                        }
                    }
                    else if (uiAccordionElement.isOn)
                    {
                        Player.BuildingMenuSpawner.SpawnMenu(mage.GetBuilding());
                    }
                }
                else
                {
                    mage.SetHightlighActive(uiAccordionElement.isOn);
                }
                SetScroll(mage.Data.ProfileButtonIndex);
            });
        }