Exemple #1
0
        public override bool Init(Obj_Init_Data initData)
        {
            if (null == m_ObjTransform)
            {
                m_ObjTransform = gameObject.transform;
            }

            m_ObjTransform.position = ActiveScene.GetTerrainPosition(new Vector3(initData.m_fX, 0, initData.m_fZ));

            //暂时 写死了 后面再用服务器
            m_ObjTransform.Rotate(Vector3.up * 135);

            //服务器发过来的信息
            this.ServerID       = initData.m_ServerID;
            BaseAttr.RoleBaseID = initData.m_RoleBaseID;
            BaseAttr.RoleName   = initData.m_StrName;
            m_OwnerObjId        = initData.m_OwnerObjId;
            StealthLev          = initData.m_StealthLev;
            m_Quality           = initData.m_FellowQuality;
            OptStealthLevChange();
            //防止伙伴追上人物导致动作不流畅 把客户端主角伙伴速度修改为和人物一样
            if (IsOwnedByMainPlayer() == true)
            {
                Singleton <ObjManager> .GetInstance().MainPlayer.CurFellowObjId = ServerID;

                Singleton <ObjManager> .GetInstance().MainPlayer.CurFellowObjGuid = initData.m_Guid;

                BaseAttr.MoveSpeed = Singleton <ObjManager> .GetInstance().MainPlayer.BaseAttr.MoveSpeed;
            }
            else
            {
                Obj_OtherPlayer otherPlayer = Singleton <ObjManager> .Instance.FindObjInScene(m_OwnerObjId) as Obj_OtherPlayer;

                if (null != otherPlayer)
                {
                    otherPlayer.FellowID = ServerID;
                    m_bVisible           = otherPlayer.IsVisibleChar();
                }

                BaseAttr.MoveSpeed = initData.m_MoveSpeed;
            }
            Tab_CabalFellowAttr fellowAttrTab = TableManager.GetCabalFellowAttrByID(BaseAttr.RoleBaseID, 0);

            if (fellowAttrTab != null)
            {
                //初始化CharModelID,并读取部分客户端信息
                ModelID = fellowAttrTab.ModelId;
                Tab_CharModel charModel = TableManager.GetCharModelByID(ModelID, 0);
                if (null != charModel)
                {
                    BaseAttr.HeadPic = charModel.HeadPic;
                    //设置动作路径
                    AnimationFilePath = charModel.AnimPath;
                    //设置名字版高度
                    DeltaHeight = charModel.HeadInfoHeight;

                    m_ObjTransform.localScale    = new Vector3(charModel.Scale, charModel.Scale, charModel.Scale);
                    m_ObjTransform.localRotation = Utils.DirServerToClient(initData.m_fDir);
                }
            }


            //初始化寻路代理
            InitNavAgent();

            //初始化AutoMove功能模块
            //if (gameObject.GetComponent<AutoMove>() == null)
            //{
            gameObject.AddComponent <AutoMove>();
            //}

            //初始化动画,需要在AnimationFilePath被赋值后进行
            if (AnimLogic == null)
            {
                AnimLogic = gameObject.AddComponent <AnimationLogic>();
            }
            //初始化特效
            if (ObjEffectController == null)
            {
                ObjEffectController = gameObject.AddComponent <CharacterEffectBehaviourController>();
            }

            //召出播放特效
            if (Singleton <ObjManager> .GetInstance().MainPlayer != null)
            {
                if (m_OwnerObjId == Singleton <ObjManager> .GetInstance().MainPlayer.ServerID)
                {
                    if (GameManager.gameManager.PlayerDataPool.FellowPlayerEffect == true)
                    {
                        //PlayEffect(52);
                        GameManager.gameManager.PlayerDataPool.FellowPlayerEffect = false;
                    }
                }
            }

            if (IsDie())
            {
                OnCorpse();
            }
            else
            {
                if (Objanimation != null)
                {
                    Objanimation.Stop();
                }
                CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR;
            }

            InitNameBoard();

            return(base.Init(initData));
        }
Exemple #2
0
        public override bool Init(Obj_Init_Data initData)
        {
            if (null == m_ObjTransform)
            {
                m_ObjTransform = transform;
            }

            m_ObjTransform.position = ActiveScene.GetTerrainPosition(new Vector3(initData.m_fX, 0, initData.m_fZ));

            BaseAttr.RoleBaseID = initData.m_RoleBaseID;
            BaseAttr.MoveSpeed  = initData.m_MoveSpeed;
            Tab_RoleBaseAttr roleBaseTab = TableManager.GetRoleBaseAttrByID(BaseAttr.RoleBaseID, 0);

            if (roleBaseTab != null)
            {
                m_NpcType = (Games.GlobeDefine.GameDefine_Globe.NPC_TYPE)roleBaseTab.NpcType;
                //初始化CharModelID,并读取部分客户端信息
                ModelID = roleBaseTab.CharModelID;
                Tab_CharModel charModel = TableManager.GetCharModelByID(ModelID, 0);
                if (null != charModel)
                {
                    BaseAttr.HeadPic = charModel.HeadPic;
                    //设置动作路径
                    AnimationFilePath = charModel.AnimPath;
                    //设置名字版高度
                    DeltaHeight = charModel.HeadInfoHeight;

                    transform.localScale = Vector3.one;
                }
            }

            //服务器发过来的信息
            this.ServerID = initData.m_ServerID;
            this.BornPosX = initData.m_fX;
            this.BornPosY = gameObject.transform.position.y;
            this.BornPosZ = initData.m_fZ;

            BaseAttr.RoleName       = initData.m_StrName;
            BaseAttr.Force          = initData.m_Force;
            BaseAttr.Die            = initData.m_IsDie;
            m_ObjTransform.rotation = Utils.DirServerToClient(initData.m_fDir);
            StealthLev      = initData.m_StealthLev;
            m_bIsBornCreate = initData.m_bNpcBornCreate;
            OptStealthLevChange();
            // NPC挂任务
            AddDialogMission();

            //组件在初始化数据后进行

            //初始化寻路代理
            InitNavAgent();

            //初始化动画,需要在AnimationFilePath被赋值后进行
            AnimLogic = gameObject.GetComponent <AnimationLogic>();
            if (AnimLogic == null)
            {
                AnimLogic = gameObject.AddComponent <AnimationLogic>();
            }

            //初始化特效
            ObjEffectController = gameObject.GetComponent <CharacterEffectBehaviourController>();
            if (ObjEffectController == null)
            {
                ObjEffectController = gameObject.AddComponent <CharacterEffectBehaviourController>();
            }

            //初始化AutoMove功能模块
            if (gameObject.GetComponent <AutoMove>() == null)
            {
                gameObject.AddComponent <AutoMove>();
            }

            if (IsDie())
            {
                OnCorpse();
            }
            else
            {
                if (Objanimation != null)
                {
                    Objanimation.Stop();
                }
                CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR;
            }

            //创新跟玩家一样的模型
            m_ModelVisualID   = initData.m_ModelVisualID;
            m_nProfession     = initData.m_nProfession;
            m_WeaponDataID    = initData.m_WeaponDataID;
            m_WeaponEffectGem = initData.m_WeaponDataID;
            if (initData.m_ModelVisualID != GlobeVar.INVALID_ID && initData.m_nProfession != -1)
            {
                ReloadPlayerModelVisual(initData.m_ModelVisualID, initData.m_nProfession);
            }

            //初始化名字版
            //InitNameBoard();
            if (!m_IsNameBoard)
            {
                InitNameBoard();
            }
            else
            {
                if (m_MissionBoard != null)
                {
                    //m_MissionBoard.SetActive(true);
                    ShowNameBoard();
                }
            }

            m_mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

            // 帮会活动NPC判断
            m_bIsGuildActivityBoss = IsGuildBoss();

            m_SceneNpcId = initData.m_SceneNpcId;
            return(base.Init(initData));
        }