Exemplo n.º 1
0
        public void Update()
        {
            if (mIsEnabled == false)
            {
                return;
            }

            Camera cam = Game.Instance.MainCamera;

            if (cam != null)
            {
                mNeatRect       = cam.pixelRect;
                mNeatRect.xMin -= 65f;
                mNeatRect.xMax += 65f;
                mNeatRect.yMin -= 65f;
                mNeatRect.yMax += 65f;

                //目前只处理NPC
                if (mIsEnableNpcModelCull == true)
                {
                    using (var enumerator = NpcManager.Instance.AllNpc.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            var       actorMono = enumerator.Current.Value;
                            NpcPlayer npcPlayer = actorMono.BindActor as NpcPlayer;
                            if (npcPlayer != null)
                            {
                                Vector3 pos = cam.WorldToScreenPoint(actorMono.transform.position);
                                // 在屏幕范围内
                                if (mNeatRect.Contains(pos))
                                {
                                    // 离主角一定距离外需要隐藏,主角骑上坐骑的一瞬间位置是0,所以要排除主角位置是0的情况
                                    Actor localPlayer = Game.Instance.GetLocalPlayer();
                                    if (localPlayer != null && localPlayer.ActorTrans.position.Equals(Vector3.zero) == false && (npcPlayer.ActorTrans.position - localPlayer.ActorTrans.position).sqrMagnitude >= mNpcMaxVisibleDistanceSquare)
                                    {
                                        npcPlayer.mAvatarCtrl.UnloadModel();
                                        npcPlayer.GetBehavior <ShadowBehavior>().HideFakeShadow = true;
                                        npcPlayer.ShowTextName(false);
                                    }
                                    else
                                    {
                                        npcPlayer.mAvatarCtrl.ReloadModel();
                                        npcPlayer.GetBehavior <ShadowBehavior>().HideFakeShadow = false;
                                        npcPlayer.ShowTextName(true);
                                    }
                                }
                                else
                                {
                                    npcPlayer.mAvatarCtrl.UnloadModel();
                                    npcPlayer.ShowTextName(false);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void BuildIcons()
        {
            NpcPlayer mNpc = (NpcPlayer)mOwner;

            if (mNpc == null || mNpc.Define == null)
            {
                return;
            }

            if (!mDirty)
            {
                return;
            }

            if (!mOwner.IsResLoaded)
            {
                return;
            }

            float nextHeightOffset = mOwner.Height;

            // 名称
            TextNameBehavior textName = mNpc.GetBehavior <TextNameBehavior>();

            if (textName != null)
            {
                textName.HeadOffset = new Vector3(0.0f, nextHeightOffset, 0.0f);
                nextHeightOffset   += 0.2f;
            }

            BuildTaskStateIcon(null);

            // Npc任务
            List <Task> tasks = TaskManager.Instance.GetNpcRelateCurrentStepTasks((uint)mNpc.NpcData.Id);

            if (tasks.Count > 0)
            {
                Task task = null;

                // 显示顺序:可提交>可接>进行中
                foreach (var item in tasks)
                {
                    if (item.State == GameConst.QUEST_STATE_DONE)
                    {
                        task = item;
                    }
                }
                if (task == null)
                {
                    foreach (var item in tasks)
                    {
                        if (item.State == GameConst.QUEST_STATE_ACCEPT || item.State == GameConst.QUEST_STATE_FAIL)
                        {
                            task = item;
                        }
                    }
                }
                if (task == null)
                {
                    foreach (var item in tasks)
                    {
                        if (item.State == GameConst.QUEST_STATE_DOING)
                        {
                            task = item;
                        }
                    }
                }
                if (task == null)
                {
                    task = tasks[0];
                }

                BuildTaskStateIcon(task);

                nextHeightOffset += 2.3f;
            }

            mDirty = false;
        }