public virtual void SetPetLevel(ActorObj actor) { PetObj pet = (actor as PetObj); if (actor.mActorType == ActorType.AT_PET && pet != null) { LuaTable cfg = pet.PetConfig; //if (pet.m_MasterActor != null) { GetHeroDesc fun = LuaMgr.Instance.GetLuaEnv().Global.GetInPath <GetHeroDesc>("ModelManager.HeroModel.GetHeroDesc"); //Debug.LogError("pet.Starlevel: " + pet.Starlevel); if (fun != null) { NameText.text = fun(cfg.Get <int>("id"), pet.Starlevel, pet.OwnName, pet.Qua, LordText); } else { LordText.text = ""; NameText.text = string.Format("{0}\n{1}的魔神", cfg.Get <string>("name"), pet.OwnName); } } //else //{ // NameText.text = string.Format("{0}", cfg.Get<string>("name")); //} } }
/// <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 void HideModel() { mVisiable = false; HideSelf(); HideBlobShadow(); HideEffect(); HideHorse(); HideWing(); HideMagic(); HideZhenFa(); List <ActorObj> pets = CoreEntry.gActorMgr.GetAllPetActors(); for (int i = 0; i < pets.Count; i++) { PetObj pet = pets[i] as PetObj; if (null != pet && pet.m_MasterServerID == serverID) { pet.HideSelf(); break; } } }
public void ShowModel() { mVisiable = true; ShowSelf(); ShowBlobShadow(); ShowEffect(); ShowHorse(); ShowWing(); ShowMagic(); ShowZhenFa(); List <ActorObj> pets = CoreEntry.gActorMgr.GetAllPetActors(); for (int i = 0; i < pets.Count; i++) { PetObj pet = pets[i] as PetObj; if (null != pet && pet.m_MasterServerID == serverID) { pet.ShowSelf(); break; } } }
public override void OnEnter(ActorObj actor) { if (actor == null) { return; } m_state = ACTOR_STATE.AS_ATTACK; m_actor = actor; m_curSkillID = m_actor.castSkillID; //if (m_actor != null) //{ // m_actor.m_bIsInAttack = true; //} LuaTable skillDesc = ConfigManager.Instance.Skill.GetSkillConfig(m_curSkillID); if (skillDesc == null) { return; } SkillClassDisplayDesc skillClass = null; if (skillDesc != null) { //if (skillDesc.e_type_1 == 1) { skillClass = m_gameDBMgr.GetSkillClassDisplayDesc(skillDesc.Get <int>("skillDisplayID")); } } m_curSkillDesc = skillDesc; GameObject obj = null; if (skillClass != null) { obj = CoreEntry.gGameObjPoolMgr.InstantiateSkillBase("Skill/SkillBase");; //(GameObject)Instantiate(CoreEntry.gResLoader.LoadResource("Skill/SkillBase")); } else { // LogMgr.Log("Can not found skillClass skillDesc.skillDisplayID: " + skillDesc.Get<int>("skillDisplayID") + " ActorObj: " + m_actor); return; } if (obj == null) { return; } //设置脚本组件 SkillBase skillBase = obj.GetComponent <SkillBase>(); ActorObj hitObj = null; if (CurParam != null) { hitObj = CurParam.HitActor; } skillBase.Init(actor, hitObj, m_curSkillID); m_curSkillBase = skillBase; //霸体时间。不可以转换为其他状态,除了死亡 if (skillDesc.Get <int>("stiff_time") > 0) { StartEndure(); } //m_isSkillCastEnd = false; if (m_curSkillDesc.Get <int>("stiff_time") > 0) { CancelInvoke("SkillCastEnd"); Invoke("SkillCastEnd", m_curSkillDesc.Get <int>("stiff_time") / 1000f); } //一个人的时候触发关门 if (m_actor.mActorType == ActorType.AT_BOSS) { CoreEntry.gSceneMgr.CloseDoor(); } if (null != skillDesc && skillDesc.Get <int>("showtype") == (int)SkillShowType.ST_HUANLING && skillDesc.Get <int>("subtype") != (int)SkillType.SKILL_NORMAL) { bool isHuanlingSkill = false; if (actor.mActorType == ActorType.AT_LOCAL_PLAYER) { isHuanlingSkill = true; } else if (actor.mActorType == ActorType.AT_PET) { PetObj pet = actor as PetObj; if (pet != null && null != pet.m_MasterActor && pet.m_MasterActor.mActorType == ActorType.AT_LOCAL_PLAYER) { isHuanlingSkill = true; } } if (isHuanlingSkill) { EventParameter param = EventParameter.Get(); param.intParameter = skillDesc.Get <int>("showtype"); param.stringParameter = skillDesc.Get <string>("name"); CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_FLY_SKILL, param); } } }
//播放动画,特效,声音 IEnumerator PlayActionEfxSound(SkillPlayParam param, float delayTime) { if (m_actor == null) { yield break; } m_strActionName = param.action; if (m_strActionName != null && m_strActionName.Length > 0) { //动作带位移 的 不能延迟播放, 延迟播放将影响 位移曲线计算 m_actor.PlayAction(m_strActionName, false); m_actor.SetActionTime(m_strActionName, param.startTime); m_actor.SetSkillActionSpeed(m_strActionName, param.speed, m_skillDesc); } //其它玩家不播放了 if (m_actor.mActorType == ActorType.AT_REMOTE_PLAYER) { yield break; } if (m_actor.mActorType == ActorType.AT_PET) { PetObj pet = m_actor as PetObj; if (null != pet && pet.m_MasterActor != CoreEntry.gActorMgr.MainPlayer) { yield break; } } //播放声音 string sound1 = param.sound; string sound2 = param.voice; if (sound1 != null && sound1.Length > 0) { m_actor.StopSound(); m_actor.PlaySound(sound1); } if (sound2 != null && sound2.Length > 0) { m_actor.StopSound2(); m_actor.PlaySound2(sound2); } LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillID); if (skill_action == null) { Debug.LogError("==skill_action == is null m_skillID = " + m_skillID); yield break; } Vector3 efxPos = m_actor.transform.position; bool isBind = skill_action.Get <bool>("isBind"); int bindType = skill_action.Get <int>("skillEfxPos"); if (!isBind) { if (bindType == 1) { ActorObj target = m_actor.GetSelTarget(); if (null != target) { efxPos = target.transform.position; } } } if (delayTime > 0.0001f) { yield return(new WaitForSeconds(delayTime)); } //if (ByteToString.toString(m_skillDesc.szAttackEfxPrefab).Length > 0) if (param.actionEfx != null && param.actionEfx.Length > 0) { if (/*m_skillDesc.skilltype == 0 && */ m_actor.mActorType == ActorType.AT_BOSS) { yield return(new WaitForSeconds(m_actor.NoramalAttackEffectDelayTime)); } if (skill_action != null) { param.actionEfx = skill_action.Get <string>("skilleffect"); //efxObj = Instantiate(CoreEntry.gResLoader.LoadResource(param.actionEfx)) as GameObject;//CoreEntry.gGameObjPoolMgr.InstantiateEffect(param.actionEfx); efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(param.actionEfx); if (efxObj == null) { LogMgr.LogError("找不到attackEfxPrefab:" + skill_action.Get <string>("skilleffect") + " " + m_skillDesc.Get <string>("name")); } } float maxEfxTime = 0; if (skill_action.Get <float>("skillEfxLength") > 0) { maxEfxTime = skill_action.Get <float>("skillEfxLength"); } //LogMgr.UnityLog("maxEfxTime=" + maxEfxTime + ", " + m_strActionName); //特效存在时间 if (maxEfxTime <= 0.001) { maxEfxTime = m_actor.GetActionLength(m_strActionName); if (maxEfxTime <= 0.001) { LogMgr.UnityError("技能 动作时间 没有配置 skillID:" + m_skillDesc.Get <int>("id")); } } bool isFollowMove = false; EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = efxObj.AddComponent <EfxAttachActionPool>(); } if (efx != null) { efx.Init(m_actor.transform, maxEfxTime, isFollowMove); m_actionEfx = efx; if (isBind) { ActorObj bindActor = null; if (bindType == 0) { bindActor = m_actor; } else { bindActor = m_actor.GetSelTarget(); } Transform bindTran = null; if (null != bindActor) { string hangPoint = skill_action.Get <string>("hangPoint"); if (!string.IsNullOrEmpty(hangPoint)) { bindTran = bindActor.transform.FindChild(hangPoint); } if (null == bindTran) { bindTran = bindActor.transform; } } else { bindTran = m_actor.transform; } m_actionEfx.transform.parent = bindTran; m_actionEfx.transform.localPosition = Vector3.zero; m_actionEfx.transform.localScale = Vector3.one; m_actionEfx.transform.rotation = m_actor.transform.rotation; } else { if (bindType == 1) { m_actionEfx.transform.position = efxPos; } else { m_actionEfx.transform.position = m_actor.transform.position; } m_actionEfx.transform.localScale = Vector3.one; m_actionEfx.transform.rotation = m_actor.transform.rotation; } //设置有挂点的特效 Transform[] childTransform = efxObj.GetComponentsInChildren <Transform>(); //foreach (Transform childTrans in childTransform) for (int i = 0; i < childTransform.Length; ++i) { Transform childTrans = childTransform[i]; EfxSetAttachPoint setAttach = childTrans.gameObject.GetComponent <EfxSetAttachPoint>(); if (setAttach == null || setAttach.m_attachPointEnum == AttachPoint.E_None) { continue; } setAttach.Init(false); Transform parent = m_actor.GetChildTransform(setAttach.m_attachPointEnum.ToString()); if (parent != null) { childTrans.parent = parent; childTrans.localPosition = Vector3.zero; childTrans.localRotation = Quaternion.identity; childTrans.localScale = Vector3.one; m_attachEfxObjectlist.Add(childTrans.gameObject); } } //影子 ghostMesh[] ghostMesh = efx.GetComponentsInChildren <ghostMesh>(); if (ghostMesh.Length > 0) { SkinnedMeshRenderer MianSkinMesh = m_actor.m_skinnedMeshRenderer[0]; for (int i = 0; i < m_actor.m_skinnedMeshRenderer.Length; ++i) { if (m_actor.m_skinnedMeshRenderer[i].name.Contains("weapon")) { continue; } MianSkinMesh = m_actor.m_skinnedMeshRenderer[i]; } for (int i = 0; i < ghostMesh.Length; ++i) { ghostMesh[i].characterMesh[0] = MianSkinMesh; } } } } yield return(1); }
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); }