示例#1
0
        public CharacterView GetCharacterViewById(int objId)
        {
            CharacterView view = GetUserViewById(objId);

            if (null == view)
            {
                view = GetNpcViewById(objId);
            }
            return(view);
        }
示例#2
0
        private void OnNpcMeetEnemy(NpcInfo npc, Animation_Type animType)
        {
            CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId());

            if (null != view)
            {
                GfxSystem.SendMessage(view.Actor, "OnMeetEnemy", null);
            }
            view.PlayAnimation(animType);
            view.PlayQueuedAnimation(Animation_Type.AT_Stand);
        }
示例#3
0
        public bool IsVisible(int objId)
        {
            bool          ret  = false;
            CharacterView view = GetCharacterViewById(objId);

            if (null != view)
            {
                ret = view.Visible;
            }
            return(ret);
        }
示例#4
0
 private void NpcSkill(NpcInfo npc, int skillId, CharacterInfo target)
 {
     if (null != npc)
     {
         CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId());
         if (null != view)
         {
             SkillParam param = new SkillParam();
             param.SkillId  = skillId;
             param.TargetId = target.GetId();
             GfxSystem.SendMessage(view.Actor, "MonsterStartSkill", param);
         }
     }
 }
示例#5
0
        private void FindPath(UserInfo playerself, Vector3 targetpos, float towards)
        {
            CharacterView view = EntityManager.Instance.GetUserViewById(playerself.GetId());

            if (view != null && view.ObjectInfo.IsGfxMoveControl && Vector3.Zero != targetpos)
            {
                return;
            }
            playerself.GetMovementStateInfo().SetFaceDir(towards);
            PlayerMovement.Motion m = Vector3.Zero == targetpos ? PlayerMovement.Motion.Stop : PlayerMovement.Motion.Moving;
            pm_.MotionChanged = pm_.MotionStatus != m || m_lastDir != towards;
            m_lastDir         = towards;
            pm_.MotionStatus  = m;
            pm_.MoveDir       = towards;
            if (Vector3.Zero == targetpos)
            {
                pm_.MotionStatus = PlayerMovement.Motion.Stop;
            }

            /*
             * UserAiStateInfo aiInfo = playerself.GetAiStateInfo();
             * if(null == aiInfo)
             * return;
             * if (Vector3.Zero == targetpos) {
             * StopFindPath(playerself, aiInfo);
             * return;
             * }
             * bool ret = (m_lastDir > towards) ? ((m_lastDir - towards) > Math.PI / 4.0f) : ((towards - m_lastDir) > Math.PI / 4.0f);
             * if (ret) {
             * StopFindPath(playerself, aiInfo);
             * m_lastDir = towards;
             * }
             * aiInfo.TargetPos = targetpos;
             * aiInfo.ChangeToState((int)AiStateId.Move);
             */
        }
示例#6
0
        private void TickNpcs()
        {
            List <NpcInfo> deletes = new List <NpcInfo>();

            for (LinkedListNode <NpcInfo> linkNode = m_NpcMgr.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                NpcInfo info = linkNode.Value;
                if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged)
                {
                    NpcAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetShootStateInfo().WeaponChanged        = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                }

                // 约定npc的高度低于140时,直接判定npc死亡。
                if (140.0f > info.GetMovementStateInfo().GetPosition3D().Y)
                {
                    info.SetHp(Operate_Type.OT_Absolute, 0);
                }
                if (info.NeedDelete)
                {
                    deletes.Add(info);
                }
                else if (info.Hp <= 0)
                {
                    if (!info.LogicDead)
                    {
                        GfxSystem.PublishGfxEvent("ge_on_npc_dead", "story", info.GetUnitId());
                        info.LogicDead = true;
                    }
                    if (info.DeadTime <= 0)
                    {
                    }
                    else if (TimeUtility.GetServerMilliseconds() - info.DeadTime > info.ReleaseTime)
                    {
                        deletes.Add(info);
                    }
                }
                if (info.IsBorning && IsNpcBornOver(info))
                {
                    info.IsBorning = false;
                    info.SetAIEnable(true);
                    info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
                }
            }
            if (deletes.Count > 0)
            {
                foreach (NpcInfo ni in deletes)
                {
                    CharacterView view = EntityManager.Instance.GetCharacterViewById(ni.GetId());
                    if (null != view)
                    {
                        GfxSystem.SendMessage(view.Actor, "OnDead", null);
                    }
                    EntityManager.Instance.DestroyNpcView(ni.GetId());
                    WorldSystem.Instance.DestroyCharacterById(ni.GetId());
                    return;
                }
            }
        }