void Refresh()
        {
            if (Dbg.Assert(_target != null))
            {
                return;
            }


            if (_target.IsHilighted || _target.IsSelected)
            {
                Material mat = null;
                if (_target.IsHilighted && _target.IsSelected)
                {
                    mat = _selectedAndHilightedMat;
                }
                else if (_target.IsHilighted)
                {
                    mat = _highlightedMat;
                }
                else if (_target.IsSelected)
                {
                    mat = _selectedMat;
                }

                if (_projector.material != mat)
                {
                    _projector.material = mat;
                }
            }

            UN.SetActive(gameObject, _target.IsHilighted || _target.IsSelected);
        }
 public void HidePopup(bool hideAll)
 {
     if (hideAll)
     {
         UN.SetActive(_root, false);
     }
 }
        void RebuildActionList(MT_Combatant who)
        {
            if (Dbg.Assert(who != null))
            {
                return;
            }
            if (Dbg.Assert(who.Base != null))
            {
                return;
            }
            if (Dbg.Assert(who.Base.Actions != null))
            {
                return;
            }

            for (int i = 0; i < who.Base.Actions.Count; i++)
            {
                GameObject obj = AddElement();
                if (Dbg.Assert(obj != null))
                {
                    return;
                }

                UI_ActionListPanelEntry entry = obj.GetComponent <UI_ActionListPanelEntry>();
                if (Dbg.Assert(entry != null))
                {
                    return;
                }

                entry.Set(who, who.Base.Actions[i], i);
                UN.SetActive(obj, true);
            }
        }
Exemple #4
0
        public int ShowDestinationPoint(Vector3 position, int widgetId = -1)
        {
            Widget widget = GetWidget(widgetId, _pathDestinationPool);

            widget.Visual.transform.position = position;
            UN.SetActive(widget.Visual, true);
            return(widget.Id);
        }
 public override void SetSelected(bool b)
 {
     if (b != IsSelected)
     {
         IsSelected = b;
         Refresh();
         UN.SetActive(this, b);
     }
 }
 void OnClick(bool response)
 {
     if (_info.CloseOnFinish)
     {
         UN.SetActive(_root, false);
     }
     if (_info.Callback != null)
     {
         _info.Callback(response);
     }
 }
Exemple #7
0
        private void Start()
        {
            _music = PT_Game.Sound.InstantiateSource("IntroMusic", transform);

            for (int i = 0; i < _spashImages.Length; i++)
            {
                UN.SetActive(_spashImages[i], false);
            }

            _introOp = StartCoroutine(ShowIntro());
        }
        protected override void Awake()
        {
            base.Awake();
            UN.SetActive(_root, false);
            _defaultOkText     = _okBtnText.text;
            _defaultCancelText = _cancelBtnText.text;

            _ok.onClick.RemoveAllListeners();
            _ok.onClick.AddListener(() => OnClick(true));
            _cancel.onClick.RemoveAllListeners();
            _cancel.onClick.AddListener(() => OnClick(false));
        }
 void SetTarget(SM_ISelectable sel)
 {
     _target = sel;
     if (_target != null)
     {
         _selectionProjector.transform.SetParent(_target.gameObject.transform);
         _selectionProjector.transform.localPosition = Vector3.zero;
         _selectionProjector.transform.localRotation = Quaternion.identity;
         Refresh();
     }
     else
     {
         UN.SetActive(_selectionProjector, false);
     }
 }
Exemple #10
0
        public void Update()
        {
            MT_Combatant me     = PT_Game.UI.Match.SelectedPCCombatant;
            bool         active = me != null;

            UN.SetActive(_actionList, active);
            UN.SetActive(_apAvail, active);
            UN.SetActive(_apCost, active);

            if (active)
            {
                UN.SetText(_apAvail, ((int)Math.Round(me.Base.ActionPoints)).ToString());

                UN.SetActive(_apCost, active);  //### TODO: Add logic to compute cost of current action
            }
        }
Exemple #11
0
        public int ShowPath(List <Vector3> pathPositions, int widgetId = -1)
        {
            Widget widget = GetWidget(widgetId, _pathLinePool);

            Dbg.Assert(widget != null);
            UN_VisualLine line = widget.Visual.GetComponent <UN_VisualLine>();

            if (Dbg.Assert(line != null))
            {
                return(-1);
            }

            line.SetLine(pathPositions);
            UN.SetActive(line.gameObject, true);
            return(widget.Id);
        }
Exemple #12
0
        protected override void Start()
        {
            base.Start();
            // if we're debugging arena, we might not have some things
            if (PT_Game.Match == null)
            {
                return;
            }

            _team = PT_Game.Match.GetTeam(_teamNdx);
            if (_team == null)
            {
                Dbg.LogWarning("Not team for this display");
                UN.SetActive(this, false);
                return;
            }

            _backGround.color = _team.BaseColor;

            UN.SetText(_teamName, _team.DisplayName);
            UN.SetText(_scoreText, PT_Game.Match.GetTeamScore(_teamNdx).ToString());


            List <MT_Combatant> cbts = PT_Game.Match.GetTeamCombatants(_teamNdx);
            int numPlayers           = cbts.Count;
            UI_CombatantMiniDisplay thingToSet;

            for (int i = 0; i < numPlayers; i++)
            {
                if (i == 0)
                {
                    thingToSet = _template;
                }
                else
                {
                    object     o        = Instantiate(_template.gameObject, _playerListRoot.gameObject.transform);
                    GameObject newThing = o as GameObject;
                    thingToSet = newThing.GetComponent <UI_CombatantMiniDisplay>();
                    _combatants.Add(thingToSet);
                }

                UN.SetActive(thingToSet, true);
                thingToSet.SetCombatant(PT_Game.Match.GetTeamCombatants(_teamNdx)[i]);
            }
        }
        public void SetCombatant(MT_Combatant c)
        {
            _who = c;
            if (c == null)
            {
                UN.SetActive(_visualBase, false);
            }
            else
            {
                UN.SetActive(_visualBase, true);
                UN.SetText(_nameText, c.Base.FullName);
                UN.SetFill(_healthBar, c.Base.GetPropertyRatio(BS_PropertyId.Health));
                UN.SetFill(_apBar, c.Base.GetPropertyRatio(BS_PropertyId.ActionPoints));
                UN.SetEnabled(_selectBtn, !c.Base.Team.IsAI);


                _icon.sprite = PT_Game.Data.Icons.GetIcon(c.Base.IconImageName);
            }
        }
Exemple #14
0
        public void ShowPopup(PopupInfo info)
        {
            UN.SetText(_header, info.PopUpLabel);
            UN.SetText(_body, info.PopUpText);

            bool okBtn     = false;
            bool cancelBtn = false;

            switch (info.Mode)
            {
            case PopupType.Notification:
                okBtn = true;
                break;

            case PopupType.Question:
                okBtn     = true;
                cancelBtn = true;
                break;
            }

            UN.SetActive(_ok, okBtn);
            UN.SetActive(_cancel, cancelBtn);
            UN.SetActive(_root, true);

            if (info.StringArgs.Length > 0)
            {
                UN.SetText(_okBtnText, info.StringArgs[0]);
            }
            else
            {
                UN.SetText(_okBtnText, _defaultOkText);
            }

            if (info.StringArgs.Length > 1)
            {
                UN.SetText(_okBtnText, info.StringArgs[1]);
            }
            else
            {
                UN.SetText(_okBtnText, _defaultCancelText);
            }
        }
Exemple #15
0
        IEnumerator SetActivePhase(GM_Phase newPhase)
        {
            Debug.Log("set active phase 1 : " + newPhase.GetType().ToString());


            UN_CameraFade.ClearAll();
            bool readyToSwitch1 = false;

            UN_CameraFade.FadeToBlack(() => { readyToSwitch1 = true; }, 2.0f);      //### PJS TO DO : remove time

            IEnumerator it;

            _previousPhase = _curPhase;
            if (_previousPhase != null)
            {
                it = _previousPhase.Exit(newPhase);
                while (it.MoveNext())
                {
                    yield return(null);
                }

                UN.SetActive(_previousPhase, false);
            }

            // wait for fade to black to be done
            while (readyToSwitch1 == false)
            {
                yield return(null);
            }

            _curPhase = newPhase;
            UN.SetActive(newPhase, true);
            it = newPhase.Enter(_previousPhase);
            while (it.MoveNext())
            {
                yield return(null);
            }

            string newSceneName = newPhase.SceneName;

            if (!string.IsNullOrEmpty(newSceneName) && newSceneName != SceneManager.GetActiveScene().name)
            {
                AsyncOperation loadingOp = SceneManager.LoadSceneAsync(newSceneName);
                if (loadingOp != null)
                {
                    while (loadingOp.isDone == false)
                    {
                        yield return(null);
                    }

                    Events.SendGlobal(new SceneChangedEvent()
                    {
                        Name = _curPhase.SceneName
                    });
                }
            }

            Events.SendGlobal(new GM_GamePhaseChangedEvent()
            {
                NewPhase = _curPhase == null ? null : _curPhase.GetType(),
                OldPhase = _previousPhase == null ? null : _previousPhase.GetType()
            });

            {
                bool readyToSwitch2 = false;
                UN_CameraFade.FadeToTransparent(() => { readyToSwitch2 = true; }, 2.0f);    //### pjs todo fix time
                while (readyToSwitch2 == false)
                {
                    yield return(null);
                }
            }
            _changingState = false;

            Debug.Log("set active phase 2 : " + newPhase.GetType().ToString());
        }
Exemple #16
0
 protected override void Awake()
 {
     base.Awake();
     UN.SetActive(_template, false);
 }
 private void Awake()
 {
     _target = GetComponentInParent <SM_ISelectable>();
     Refresh();
     UN.SetActive(this, false);
 }