Beispiel #1
0
        public void InitializeMagicList(MagicId[] _availableMagic)
        {
            m_ListContainer.SetActive(true);
            m_SelectedMagic.gameObject.SetActive(false);

            m_SelectedMagic.onCancel.RemoveAllListeners();
            m_SelectedMagic.onCancel.AddListener(() => { ShowMagicList(); });

            int btnId = 0;

            foreach (MagicId id in _availableMagic)
            {
                if (btnId == m_BtnMagic.Length)
                {
                    break;
                }

                MagicDescription desc = MagicManager.GetInstance().GetDescription(id);
                if (desc == null)
                {
                    Debug.LogError(string.Format("Can't find magic description with id {0}", id));
                    continue;
                }

                CustomButton btn = m_BtnMagic[btnId];

                btn.GetComponentInChildren <Text>().text = desc.m_DisplayName;

                btn.onCancel.RemoveAllListeners();
                btn.onCancel.AddListener(() => { Close(); });

                MagicId capturedId = id; //necessary for the lambda to work
                btn.onClick.RemoveAllListeners();
                btn.onClick.AddListener(() => { Clicked(capturedId); });

                btn.gameObject.SetActive(true);

                PawnStatistics stats = GameTurnManager.GetInstance().GetCurrentPawnStatistics();
                if (desc.m_Power.CanBeUsed(stats))
                {
                    btn.IsUnselectable = false;
                }
                else
                {
                    btn.IsUnselectable = true;
                }

                btn.Send(WidgetEvent.Unselect);
                ++btnId;
            }

            for (int i = btnId; i < m_BtnMagic.Length; ++i)
            {
                m_BtnMagic[i].gameObject.SetActive(false);
            }

            m_BtnMagic[0].Send(WidgetEvent.Select);
        }
Beispiel #2
0
        //public IAction GetAction(ActionId _id)
        //{
        //    return m_ActionsMap[_id];
        //}

        public ActionRunner GetAction(MagicId _id)
        {
            if (!m_OverrideMagicMap.ContainsKey(_id))
            {
                return(m_DefaultMagic);
            }

            return(m_OverrideMagicMap[_id]);
        }
        public void VerifyIdentityHasThereLittleFragmentationUsingString()
        {
            // Act
            InsertRows(() => MagicId.NewComb().Value, ROWS, "IndexFragmentationString");

            // Assert
            var fragmentation = GetIndexFragmentation("IndexFragmentationString");

            fragmentation.Should().BeLessThan(10);
        }
        public MagicDescription GetDescription(MagicId _id)
        {
            if (m_lookUpTable.ContainsKey(_id))
            {
                return(m_lookUpTable[_id]);
            }

            Debug.LogError(string.Format("Can't find MagicDescription with a MagicId {0}", _id));
            return(null);
        }
Beispiel #5
0
        void Clicked(MagicId _clickedMagicId)
        {
            m_ListContainer.SetActive(false);
            m_SelectedMagic.gameObject.SetActive(true);
            m_SelectedMagic.GetComponentInChildren <Text>().text = MagicManager.GetInstance().GetDescription(_clickedMagicId).m_DisplayName;
            m_SelectedMagic.SetFocus();

            if (m_OnClicked != null)
            {
                m_OnClicked(_clickedMagicId);
            }
        }
Beispiel #6
0
        private void OnMagicMagicSelected(MagicId _id)
        {
            //get the action
            MagicDescription desc        = MagicManager.GetInstance().GetDescription(_id);
            ActionRunner     magicAction = GameTurnManager.GetInstance().GetCurrentPawn().GetComponent <PawnActions>().GetAction(_id);

            magicAction.ActionDescription = desc;

            //set the action in the game master
            GameMaster.GetInstance().SetSelectedAction(magicAction);

            //show enemy selection
            WidgetManager.GetInstance().Show(m_CanvasEnemyList.gameObject, false, false);
            m_CanvasEnemyList.OnEnemySelected = OnMagicEnemySelected;
            m_CanvasEnemyList.OnCanvasClosed  = OnMagicEnemyClosed;
            m_CanvasEnemyList.Show();
            m_CanvasEnemyList.SetColumn(1);
        }