コード例 #1
0
        public void AddDamageText(GameEntity entity, string text, long remainTime)
        {
            UnityView view = entity.view.Value as UnityView;

            if (null != view)
            {
                var hudObject = ResourceSystem.NewObject("HudText") as GameObject;
                hudObject.transform.SetParent(UIRoot, false);
                hudObject.transform.localPosition = Vector3.zero;

                DamageInfo hudInfo = new DamageInfo();
                hudInfo.Obj = hudObject;
                UnityEngine.UI.Text uiText = hudObject.GetComponentInChildren <UnityEngine.UI.Text>();
                if (null != uiText)
                {
                    uiText.text = text;
                }

                hudInfo.SelfTransform = hudObject.GetComponentInChildren <RectTransform>();
                hudInfo.Position      = view.gameObject.transform.position + Vector3.up * 2;
                hudInfo.DeleteTime    = Time.time + remainTime / 1000.0f;

                hudInfo.FloatSpeed = m_FloatSpeed;
                hudInfo.Delay      = m_DelayStay + Time.time;
                hudInfo.Movement   = Guidance.LeftUp;

                m_Damages.Add(hudInfo);
            }
        }
コード例 #2
0
 public void RecylceAsset(GameEntity entity)
 {
     if (entity.hasView)
     {
         UnityView view = entity.view.Value as UnityView;
         view.gameObject.Unlink();
         ResourceSystem.RecycleObject(view.gameObject);
     }
 }
コード例 #3
0
        private void OnTriggerEnter(Collider collider)
        {
            UnityView view = collider.gameObject.GetComponent <UnityView>();

            if (null != view)
            {
                if (null != OnChunkTriggerEnter)
                {
                    OnChunkTriggerEnter(m_Chunk, view);
                }
            }
        }
コード例 #4
0
        public void RemoveHudHead(GameEntity entity)
        {
            UnityView view = entity.view.Value as UnityView;

            if (null != view)
            {
                HudInfo hudInfo;
                if (m_HudHeadInfos.TryGetValue(view.gameObject.GetInstanceID(), out hudInfo))
                {
                    ResourceSystem.RecycleObject(hudInfo.Obj);
                    m_HudHeadInfos.Remove(view.gameObject.GetInstanceID());
                }
            }
        }
コード例 #5
0
        public void UpdateHudHead(GameEntity entity, float hpCur, float hpMax)
        {
            UnityView view = entity.view.Value as UnityView;

            if (null != view)
            {
                HudInfo hudInfo;
                if (m_HudHeadInfos.TryGetValue(view.gameObject.GetInstanceID(), out hudInfo))
                {
                    UnityEngine.UI.Slider slider = hudInfo.Obj.GetComponentInChildren <UnityEngine.UI.Slider>();
                    if (null != slider)
                    {
                        slider.value = hpCur / hpMax;
                    }
                }
            }
        }
コード例 #6
0
        public void AddHudHead(GameEntity entity)
        {
            UnityView view = entity.view.Value as UnityView;

            if (null != view)
            {
                var hudHeadObject = ResourceSystem.NewObject("HudHead") as GameObject;
                hudHeadObject.transform.SetParent(UIRoot, false);

                HudInfo hudInfo = new HudInfo();
                hudInfo.Obj = hudHeadObject;

                hudInfo.SelfTransform = hudHeadObject.GetComponentInChildren <RectTransform>();
                hudInfo.Owner         = view.gameObject.transform;
                hudInfo.DeleteTime    = -1;

                m_HudHeadInfos.Add(view.gameObject.GetInstanceID(), hudInfo);
            }
        }
コード例 #7
0
        private void OnTriggerEnter(Collider collider)
        {
            UnityView view = collider.gameObject.GetComponent <UnityView>();

            if (null != view)
            {
                Util.LogUtil.Info("Name {0} Layer {1} , Name {2} Layer {3}.", collider.gameObject.name, collider.gameObject.layer, this.gameObject.name, this.gameObject.layer);
                if (view.Entity is GameEntity gameEntity)
                {
                    if (gameEntity.hasId)
                    {
                        if (null != OnColliderTriggerEnter)
                        {
                            OnColliderTriggerEnter(gameEntity.id.value);
                        }
                    }
                }
            }
        }
コード例 #8
0
        private void OnChunkTriggerEnter(IChunk chunk, IView view)
        {
            UnityChunk unityChunk = chunk as UnityChunk;

            if (unityChunk.Triggered)
            {
                return;
            }

            UnityView unityView = view as UnityView;

            if (unityView.Entity is GameEntity gameEntity)
            {
                if (gameEntity.isMainPlayer)
                {
                    unityChunk.Entity.isActiveChunk = true;
                    CloseDoor(chunk);
                    SummonNpc(chunk);
                    unityChunk.Triggered = true;
                }
            }
        }