Esempio n. 1
0
        private GameObject CreateHeroItem(BaseNpc Npc)
        {
            var Obj = AssetManager.CreatePrefabSync(new AssetUri("prefabs/heroitem.prefab"));

            Obj.transform.SetParent(ListContent_, false);

            if (Current_ != null && Current_.ID == Npc.ID)
            {
                UIHelper.SetActive(Obj.transform, "Selected", true);
            }
            else
            {
                UIHelper.SetActive(Obj.transform, "Selected", false);
            }

            UIHelper.GetComponent <Text>(Obj.transform, "Name").text = Npc.Name;

            // temp head icon
            if (Npc.ID == PlayerManager.Master.ID)
            {
                UIHelper.GetComponent <Image>(Obj.transform, "Icon").sprite =
                    AssetManager.CreateAssetSync <Sprite>(new AssetUri("textures/build.png"));
            }

            UIHelper.AddEvent(Obj.transform, () => { SetCurrent(Npc); });

            /*Obj.GetComponent<Button>().onClick.AddListener(() =>
             * {
             *  SetCurrent(Npc);
             * });*/

            return(Obj);
        }
Esempio n. 2
0
        public static void AddTips(Transform Obj, Func <string> GetFunc)
        {
            TimerEntity Timer    = null;
            var         BeginPos = Vector2.zero;

            UIHelper.AddEvent(Obj, (Data) =>
            {
                var Msg = GetFunc?.Invoke() ?? string.Empty;
                if (string.IsNullOrWhiteSpace(Msg))
                {
                    return;
                }

                BeginPos = Data.Location;
                Timer    = TimerManager.AddTimer(Configure.TipsHoldTime, () => { UIManager.OpenUI <TipsUI>(Msg, Data.Location); }, 1);
            }, EventSystemType.Down);

            UIHelper.AddEvent(Obj, (Data) =>
            {
                if (Timer == null)
                {
                    return;
                }

                if (Vector2.Distance(Data.Location, BeginPos) > 10)
                {
                    TimerManager.StopTimer(Timer);
                    Timer = null;
                }
            }, EventSystemType.Drag);

            UIHelper.AddEvent(Obj, () =>
            {
                TimerManager.StopTimer(Timer);
                Timer = null;
                UIManager.CloseUI <TipsUI>();
            }, EventSystemType.Up);

            UIHelper.AddEvent(Obj, () =>
            {
                TimerManager.StopTimer(Timer);
                Timer = null;
            }, EventSystemType.Cancel);
        }
Esempio n. 3
0
            internal WaveInfoPart(Transform Trans)
            {
                Trans_ = Trans.GetComponent <RectTransform>();

                WaveText_         = UIHelper.GetComponent <Text>(Trans, "List/Wave");
                RemainingNumText_ = UIHelper.GetComponent <Text>(Trans, "List/RemainingNum");
                IntervalText_     = UIHelper.GetComponent <Text>(Trans, "List/Interval");
                SpeedText_        = UIHelper.GetComponent <Text>(Trans, "List/Speed");
                HpText_           = UIHelper.GetComponent <Text>(Trans, "List/Hp");
                DamageText_       = UIHelper.GetComponent <Text>(Trans, "List/Damage");
                GemText_          = UIHelper.GetComponent <Text>(Trans, "List/Gem");
                NewWaveText_      = UIHelper.GetComponent <Text>(Trans, "NewWave");
                NewWaveText_.gameObject.SetActive(false);
                BtnNextWaveObj_ = UIHelper.FindChild(Trans, "BtnNextWave").gameObject;

                UIHelper.AddEvent(BtnNextWaveObj_.transform, OnBtnNextWaveClick);

                EventManager.Register <WaveChangeEvent>(OnWaveChangeEvent);
                EventManager.Register <NewWaveEvent>(OnNewWaveEvent);
            }
Esempio n. 4
0
 public void AddEvent(UnityAction Callback, EventSystemType Type = EventSystemType.Click)
 {
     UIHelper.AddEvent(UITransform, Callback, Type);
 }
Esempio n. 5
0
 public void AddEvent(LiteAction <EventSystemData> Callback, EventSystemType Type = EventSystemType.Click)
 {
     UIHelper.AddEvent(UITransform, Callback, Type);
 }