/// <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); }
public GameObject LoadPet(MsgData_sSceneObjectEnterPet petStruct) { LuaTable petCfg = ConfigManager.Instance.HeroConfig.GetHeroConfig(petStruct.ConfigID); if (null == petCfg) { return(null); } float s = petCfg.Get <float>("scale"); Vector3 position = CommonTools.ServerPosToClient(petStruct.PosX, petStruct.PosY); Vector3 eulerAngle = CommonTools.ServerDirToClient(petStruct.Dir); Vector3 scale = new Vector3(s, s, s); if (petStruct.Job <= 0) { return(null); } int modelid = petCfg.Get <int>("model" + petStruct.Job); if (petStruct.Level > 0) { LuaTable petShengjieCfg = ConfigManager.Instance.HeroConfig.GetHeroShengjieConfig(petStruct.ConfigID * 100 + petStruct.Level); if (petShengjieCfg != null) { modelid = petShengjieCfg.Get <int>("model" + petStruct.Job); } } GameObject obj = CreateGameObject(modelid, position, eulerAngle, scale); if (obj == null) { return(null); } //obj.transform.localScale = Vector3.one; ActorObj actorObject = null; actorObject = obj.GetComponent <ActorObj>(); if (null != actorObject) { Object.DestroyImmediate(actorObject); } PlayerAgent agent = obj.GetComponent <PlayerAgent>(); if (null != agent) { agent.enabled = false; } PetObj pet = obj.AddComponent <PetObj>(); pet.Starlevel = petStruct.Level; pet.Qua = petStruct.Qua; pet.OwnName = UiUtil.GetNetString(petStruct.RoleName); pet.SetMaster(petStruct.Owner); //Debug.LogError("pet :" + petStruct.Owner + " id:" + petStruct.ConfigID); pet.Init(modelid, petStruct.ConfigID, petStruct.Guid); pet.ServerID = petStruct.Guid; pet.InitSpeed(CommonTools.ServerValueToClient(petStruct.Speed)); CoreEntry.gActorMgr.AddActorObj(pet); //宠物创建时,需要检查主人的显示隐藏属性 if (pet.m_MasterActor && !pet.m_MasterActor.Visiable) { pet.HideSelf(); } //ActorObj owner = CoreEntry.gActorMgr.GetPlayerActorByServerID(petStruct.Owner); //if (null != owner) //{ // if (owner.mActorType == ActorType.AT_LOCAL_PLAYER) // { // pet.ChangeWeapon(PlayerData.Instance.GetWeaponModelID()); // } // else // { // MsgData_sSceneObjectEnterHuman ownerData = CoreEntry.gSceneObjMgr.GetEntityData(petStruct.Owner) as MsgData_sSceneObjectEnterHuman; // if (null != ownerData) // { // pet.ChangeWeapon(GetWeaponModelID(ownerData.FashionState == 0 ? ownerData.FashionWeapon : 0, ownerData.ShenBin, ownerData.Weapon, ownerData.Prof)); // } // } //} return(obj); }