Example #1
0
        /// <summary>
        /// 加载其它玩家
        /// </summary>
        /// <param name="humanStruct"></param>
        /// <returns></returns>
        public GameObject LoadOtherPlayer(MsgData_sSceneObjectEnterHuman humanStruct)
        {
            int modelID = GetClothesModelID(humanStruct.FashionState == 0 ? humanStruct.FashionDress : 0, humanStruct.Dress, humanStruct.Prof, humanStruct.EquipStarMin);

            if (humanStruct.ChangeID != 0)
            {
                CoreEntry.gMorphMgr.SetInMorph(humanStruct.Guid);
                //Configs.changeConfig changeCfg = CSVConfigLoader.GetchangeConfig((int)humanStruct.ChangeID);
                LuaTable changeCfg = ConfigManager.Instance.Actor.GetChangeConfig((int)humanStruct.ChangeID);
                if (changeCfg != null)
                {
                    modelID = changeCfg.Get <int>("model_id");
                }
            }

            GameObject obj = LoadOtherPlayer(modelID);

            Vector3 position = CommonTools.ServerPosToClient(humanStruct.PosX, humanStruct.PosY);

            position.y = CommonTools.GetTerrainHeight(new Vector2(position.x, position.z));
            Vector3 eulerAngle = CommonTools.ServerDirToClient(humanStruct.Dir);

            obj.transform.position    = position;
            obj.transform.eulerAngles = eulerAngle;
            obj.transform.localScale  = Vector3.one;

            OtherPlayer otherPlayer = obj.AddComponent <OtherPlayer>();

            otherPlayer.Faction = humanStruct.Faction;

            otherPlayer.Init(modelID, modelID, humanStruct.Guid);
            otherPlayer.ServerID = humanStruct.Guid;
            otherPlayer.InitAttr(humanStruct);
            CoreEntry.gActorMgr.AddActorObj(otherPlayer);
            otherPlayer.Health.OnCreateHPBar();    //名字有更新,重新创建血条
            PetObj petObj = CoreEntry.gActorMgr.GetPetActorByServerID(humanStruct.MoShenID) as PetObj;

            if (petObj != null)
            {
                petObj.SetMaster(otherPlayer);
                //Debug.LogError("找到 moshenid: " + humanStruct.MoShenID + " otherplayer:" + humanStruct.Guid);
            }
            else
            {
                //Debug.LogError("未找到 moshenid: " + humanStruct.MoShenID + " otherplayer:" + humanStruct.Guid);
            }

            //LoadMagicKey(otherPlayer, 620000001, position, eulerAngle);

            StartCoroutine(ChangeOtherPlayerShow(otherPlayer as OtherPlayer, humanStruct));

            EventParameter parameter = new EventParameter();

            parameter.objParameter = otherPlayer;
            CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_OTHERPLAYER_LOAD_OVER, parameter);

            return(obj);
        }
Example #2
0
        /// <summary>
        /// 加载镖车, 由于镖车有血量和阵营,并且可以被攻击,类似同阵营玩家,先用于玩家代替!!
        /// </summary>
        public GameObject LoadBiaoChe(MsgData_sSceneObjectEnterBiaoChe cheStruct)
        {
            ActorObj ao = CoreEntry.gActorMgr.GetPlayerActorByServerID(cheStruct.Guid);

            if (null != ao)
            {
                return(ao.gameObject);
            }

            LuaTable row = RawLuaConfig.Instance.GetRowData("t_kuafubiaoche", cheStruct.DartID);

            if (null == row)
            {
                return(null);
            }

            int modelid = row.Get <int>("model");

            Vector3 position   = CommonTools.ServerPosToClient(cheStruct.PosX, cheStruct.PosY);
            Vector3 eulerAngle = CommonTools.ServerDirToClient(cheStruct.Dir);
            Vector3 scale      = new Vector3(1, 1, 1);

            GameObject obj = LoadOtherPlayer(modelid);

            obj.transform.position    = position;
            obj.transform.eulerAngles = eulerAngle;
            obj.transform.localScale  = scale;

            OtherPlayer BiaoChe = obj.AddComponent <OtherPlayer>();

            BiaoChe.Faction = cheStruct.Camp;
            if (BiaoChe.mBaseAttr == null)
            {
                BiaoChe.mBaseAttr = new BaseAttr();
            }
            BiaoChe.mBaseAttr.MaxHP = cheStruct.HP;
            BiaoChe.mBaseAttr.CurHP = cheStruct.HP;
            BiaoChe.mBaseAttr.Level = cheStruct.Level;
            BiaoChe.mBaseAttr.Name  = CommonTools.BytesToString(cheStruct.LeaderName) + "的镖车";
            BiaoChe.Init(modelid, modelid, cheStruct.Guid);
            BiaoChe.mActorType      = ActorType.AT_MECHANICS;
            BiaoChe.mBaseAttr.Speed = CommonTools.ServerValueToClient(cheStruct.Speed);
            BiaoChe.SetSpeed(BiaoChe.mBaseAttr.Speed);
            BiaoChe.ServerID = cheStruct.Guid;
            CoreEntry.gActorMgr.AddActorObj(BiaoChe);

            return(obj);
        }
Example #3
0
        private void LoadFigters()
        {
            for (int i = 0; i < 2; i++)
            {
                if (i == mLocalIndex)
                {
                    continue;
                }

                MsgData_sResArenaMemVo player = ArenaFighters[i];
                int modelID = SceneLoader.GetClothesModelID(player.FashionDress, player.Dress, player.Job, 0);

                GameObject obj = CoreEntry.gSceneLoader.CreateGameObject(modelID);
                if (obj == null)
                {
                    return;
                }
                ActorObj actorObject = null;
                actorObject = obj.GetComponent <ActorObj>();
                if (null != actorObject)
                {
                    UnityEngine.Object.DestroyImmediate(actorObject);
                }

                PlayerAgent agent = obj.GetComponent <PlayerAgent>();
                if (null != agent)
                {
                    agent.enabled = false;
                }

                Vector3 position = Vector3.zero;
                position.x = initPos[1 - mLocalIndex].x;
                position.z = initPos[1 - mLocalIndex].y;
                position.y = CommonTools.GetTerrainHeight(new Vector2(position.x, position.y));

                obj.transform.position   = position;
                obj.transform.rotation   = Quaternion.identity;
                obj.transform.localScale = Vector3.one;

                OtherPlayer otherPlayer = obj.AddComponent <OtherPlayer>();
                otherPlayer.Init(modelID, modelID, player.RoleID, "", true);
                otherPlayer.ServerID = player.RoleID;
                CoreEntry.gActorMgr.AddActorObj(otherPlayer);

                int weaponID = SceneLoader.GetWeaponModelID(player.FashionWeapon, player.ShenBing, player.Weapon, player.Job);
                LoadWeapon(obj.transform, weaponID, player.Job == 4);
            }
        }
Example #4
0
        public GameObject LoadVirtualPlayer(MsgData_sSceneObjectEnterVirtualPlayer player)
        {
            int modelID = SceneLoader.GetClothesModelID(player.FashionDress, player.Dress, player.Job, 0);

            Vector3    position   = CommonTools.ServerPosToClient(player.PosX, player.PosY);
            Vector3    eulerAngle = CommonTools.ServerDirToClient(player.Dir);
            GameObject obj        = CreateGameObject(modelID, position, eulerAngle);

            ActorObj actorObject = null;

            actorObject = obj.GetComponent <ActorObj>();
            if (null != actorObject)
            {
                UnityEngine.Object.DestroyImmediate(actorObject);
            }

            PlayerAgent agent = obj.GetComponent <PlayerAgent>();

            if (null != agent)
            {
                agent.enabled = false;
            }

            /*Vector3 position = Vector3.zero;
             * position.x = player.PosX;
             * position.z = player.PosY;
             * position.y = CommonTools.GetTerrainHeight(new Vector2(position.x, position.y));
             *
             * obj.transform.position = position;
             * obj.transform.rotation = Quaternion.identity;
             * obj.transform.localScale = Vector3.one;*/

            OtherPlayer otherPlayer = obj.AddComponent <OtherPlayer>();

            otherPlayer.Init(modelID, modelID, player.Guid, "", true);
            otherPlayer.InitEnterHumanAttr(player);
            CoreEntry.gActorMgr.AddActorObj(otherPlayer);
            otherPlayer.Health.OnCreateHPBar();

            StartCoroutine(ChangeVirtualPlayerShow(otherPlayer as OtherPlayer, player));

            int weaponID = SceneLoader.GetWeaponModelID(player.FashionWeapon, player.ShenBing, player.Weapon, player.Job);

            LoadWeapon(obj.transform, weaponID, player.Job == 4);

            return(obj);
        }