public override void CreateDeafaultModel() { AvatarModelData data = AvatarModelData.dataMap[999]; GameObject gameObject = AssetCacheMgr.GetLocalInstance(data.prefabName) as GameObject; ActorPlayer actor = gameObject.AddComponent <ActorPlayer>(); motor = gameObject.AddComponent <MogoMotorServer>(); animator = gameObject.GetComponent <Animator>(); sfxHandler = gameObject.AddComponent <SfxHandler>(); // GearEffectListener作用已经交由ActorMyself处理,不需要增加这个脚本了 // gameObject.AddComponent<GearEffectListener>(); //actor.mogoMotor = motor; actor.theEntity = this; GameObject = gameObject; Transform = gameObject.transform; Debug.LogError(GameObject.name + " " + ID + " Player CreateDeafaultModel: " + Transform.position); this.Actor = actor; Transform.localScale = scale; Transform.tag = "OtherPlayer"; UpdatePosition(); base.CreateModel(); }
public void Preload(List <int> cgIDs, Action callback = null) { m_preloadStatus.Clear(); foreach (var cgID in cgIDs) { if (m_mapOfStoryMap.ContainsKey(cgID)) { foreach (var command in m_mapOfStoryMap[cgID]) { String[] commands = Regex.Split(command.Value.Trim(), @"[ ]+"); if (commands[0].Equals("CreateModel")) { AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(Int32.Parse(commands[2]), null); if (data == null) { LoggerHelper.Error("Model not found: " + Int32.Parse(commands[2])); return; } m_preloadStatus.Add(data.prefabName); } } } } if (m_preloadStatus.Count > 0) { var ms = m_preloadStatus.ToArray(); AssetCacheMgr.GetResourcesAutoRelease(ms, (obj) => { //AssetCacheMgr.UnloadAssetbundles(ms); if (callback != null) { callback(); } }); } else { if (callback != null) { callback(); } } }
public override void CreateDeafaultModel() { AvatarModelData data = AvatarModelData.dataMap[999]; LoggerHelper.Debug("monster create:" + ID + ",name:" + data.prefabName); GameObject go = AssetCacheMgr.GetLocalInstance(data.prefabName) as GameObject; Transform = go.transform; Transform.localScale = scale; Transform.tag = "Monster"; motor = go.AddComponent <MogoMotorServer>(); animator = go.GetComponent <Animator>(); ActorMercenary ap = go.AddComponent <ActorMercenary>(); ap.theEntity = this; this.Actor = ap; UpdatePosition(); base.CreateModel(); }
protected override void OnCreateModel() { data = AvatarModelData.GetByID(1); if (data == null) { Debuger.LogError("数据Error null" + serverInfo.dataId); return; } gameObject = Res.ResourceManager.Instance.Instantiate <GameObject>(GameCommonUtils.GetResourceData(data.prefabName).resourcePath); transform = gameObject.transform; transform.tag = "Player"; transform.gameObject.layer = 11; ActorMyself ap = gameObject.AddComponent <ActorMyself>(); this.Motor = gameObject.AddComponent <MotorMyself>(); this.Motor.theEntity = this; ap.theEntity = this; animator = gameObject.GetComponent <Animator>(); this.Actor = ap; UpdatePosition(); animator.applyRootMotion = false; gameObject.AddComponent <DontDestroyMe>(); //ap.InitEquipment(); ap.Equip(104001); ap.Equip(104002); if (data.scale > 0) { ap.transform.localScale = Vector3.one * data.scale; } GameObject light = Res.ResourceManager.Instance.Instantiate <GameObject>("Gear/RoundLight"); light.transform.parent = gameObject.transform; light.transform.localPosition = new Vector3(0, 1, 0); character = ap.GetComponent <CharacterController>(); }
protected override void OnCreateModel() { data = MonsterData.GetByID(serverInfo.dataId); if (data == null) { Debuger.LogError("怪物数据Error null" + serverInfo.dataId); return; } AvatarModelData modelData = AvatarModelData.GetByID(data.modelId); gameObject = Res.ResourceManager.Instance.Instantiate <GameObject>(GameCommonUtils.GetResourceData(modelData.prefabName).resourcePath); transform = gameObject.transform; transform.tag = "Monster"; transform.gameObject.layer = 11; ActorMonster ap = gameObject.AddComponent <ActorMonster>(); ap.theEntity = this; animator = gameObject.GetComponent <Animator>(); this.Actor = ap; this.Motor = gameObject.AddComponent <MotorParent>(); this.Motor.theEntity = this; UpdatePosition(); if (modelData != null && modelData.scale > 0) { gameObject.transform.localScale = new Vector3(modelData.scale, modelData.scale, modelData.scale); if (modelData.scaleRadius > 0 && ap.GetComponent <CharacterController>() != null) { ap.GetComponent <CharacterController>().radius = modelData.scaleRadius; } } animator.applyRootMotion = false; }
public override void CreateActualModel() { AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(m_monsterData.model, null); if (data == null) { LoggerHelper.Error("Model not found: " + m_monsterData.model); return; } LoggerHelper.Debug("monster create:" + ID + ",name:" + data.prefabName); SubAssetCacheMgr.GetCharacterInstance(data.prefabName, (prefab, guid, gameObject) => { if (this.Actor) { this.Actor.Release(); } if (Transform) { AssetCacheMgr.ReleaseLocalInstance(Transform.gameObject); } GameObject = (gameObject as GameObject); Transform = GameObject.transform; Transform.localScale = scale; if (data.scale > 0) { Transform.localScale = new Vector3(data.scale, data.scale, data.scale); } Transform.tag = "Monster"; Transform.gameObject.layer = 11; sfxHandler = GameObject.AddComponent <SfxHandler>(); motor = GameObject.AddComponent <MogoMotorServer>(); audioSource = GameObject.AddComponent <AudioSource>(); audioSource.rolloffMode = AudioRolloffMode.Custom; CharacterController controller = GameObject.GetComponent <CharacterController>(); controller.radius = m_monsterData.scaleRadius / 100f; controller.height = EntityColiderHeight; float centerY = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius); controller.center = new Vector3(0, centerY, 0); animator = GameObject.GetComponent <Animator>(); ActorMercenary ap = GameObject.AddComponent <ActorMercenary>(); ap.theEntity = this; this.Actor = ap; UpdatePosition(); if (data.originalRotation != null && data.originalRotation.Count == 3) { Transform.eulerAngles = new Vector3(data.originalRotation[0], data.originalRotation[1], data.originalRotation[2]); } else { Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position; Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z)); } motor.canTurn = !NotTurn(); base.CreateModel(); motor.SetAngularSpeed(400f); motor.acceleration = 2f; if (!NotTurn()) { Vector3 bornTargetToLookAt = MogoWorld.thePlayer.position; Transform.LookAt(new Vector3(bornTargetToLookAt.x, Transform.position.y, bornTargetToLookAt.z)); } #region Shader if (ShaderData.dataMap.ContainsKey(m_monsterData.shader) && GameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true) != null && ID != MogoWorld.theLittleGuyID) { MogoFXManager.Instance.SetObjShader(GameObject, ShaderData.dataMap[m_monsterData.shader].name, ShaderData.dataMap[m_monsterData.shader].color); MogoFXManager.Instance.AlphaFadeIn(GameObject, fadeInTime); } #endregion try { if (m_monsterData != null && m_monsterData.bornFx != null) { foreach (var item in m_monsterData.bornFx) { sfxHandler.HandleFx(item); } } } catch (Exception ex) { LoggerHelper.Except(ex); } //开始执行出生流程 m_bModelBuilded = true; m_aiRoot = AIContainer.container.Get((uint)m_monsterData.aiId); uint waitTime = (uint)m_monsterData.bornTime; if (waitTime <= 1) //容错 { waitTime = 3000; } if (blackBoard.timeoutId > 0) { TimerHeap.DelTimer(blackBoard.timeoutId); } m_currentSee = m_monsterData.see; blackBoard.ChangeState(Mogo.AI.AIState.THINK_STATE); TimerHeap.AddTimer(waitTime, 0, RebornAnimationDelay); TimerHeap.AddTimer(waitTime, 0, BornedHandler); Actor.ActChangeHandle = ActionChange; } ); }
/* * private void AttachBuildingModel() * { * GearParent[] gears = (GearParent[])GameObject.FindObjectsOfType(typeof(GearParent)); * foreach (GearParent gear in gears) * { * if (gear.ID == (uint)clientTrapId) * { * Transform = gear.transform; * GameObject = gear.gameObject; * Transform.tag = "Monster"; * // motor = GameObject.AddComponent<MogoMotorServer>(); * animator = GameObject.GetComponent<Animator>(); * * ActorDummy ap = GameObject.GetComponent<ActorDummy>(); * if (ap == null) * ap = GameObject.AddComponent<ActorDummy>(); * * ap.theEntity = this; * this.Actor = ap; * } * } * } */ public void CreatePlayerActualModel() { isCreatingModel = true; AssetCacheMgr.ReleaseLocalInstance(GameObject); AvatarModelData data = AvatarModelData.dataMap.Get((int)vocation); SubAssetCacheMgr.GetPlayerInstance(data.prefabName, (prefab, guid, go) => { var gameObject = go as GameObject; var actor = gameObject.AddComponent <ActorMercenary>(); actor.InitEquipment((int)vocation); motor = gameObject.AddComponent <MogoMotorServer>(); CharacterController controller = gameObject.GetComponent <CharacterController>(); controller.radius = m_monsterData.scaleRadius / 100f; controller.height = EntityColiderHeight; float centerY = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius); controller.center = new Vector3(0, centerY, 0); animator = gameObject.GetComponent <Animator>(); sfxHandler = gameObject.AddComponent <SfxHandler>(); actor.theEntity = this; GameObject = gameObject; Transform = gameObject.transform; this.Actor = actor; //Transform.localScale = scale; Transform.tag = "OtherPlayer"; Transform.gameObject.layer = 18; Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position; Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z)); UpdatePosition(); base.CreateModel(); LoadEquip(); //gameObject.SetActive(false); gameObject.SetActive(true); isCreatingModel = false; if (m_factionFlag == 0) { BillboardLogicManager.Instance.AddInfoBillboard(ID, Transform, this, true); } else { BillboardLogicManager.Instance.AddInfoBillboard(ID, Transform, this, false); } MogoFXManager.Instance.AddShadow(Transform.gameObject, ID); #region 血条 if (isLittleGuy) { MainUILogicManager.Instance.SetMercenaryMessageInit(this); } else if (IsPVP()) { //logic } else { hp = (uint)m_monsterData.hpBase; //curHp = (uint)m_monsterData.hpBase; if (m_monsterData != null && m_monsterData.hpShow != null && m_monsterData.hpShow.Count >= 3) { MainUILogicManager.Instance.SetBossMessageInit(this, m_monsterData.hpShow[2]); } } #endregion //开始执行出生流程 m_bModelBuilded = true; m_aiRoot = AIContainer.container.Get((uint)m_monsterData.aiId); uint waitTime = (uint)m_monsterData.bornTime; if (waitTime <= 1) //容错 { waitTime = 3000; } if (blackBoard.timeoutId > 0) { TimerHeap.DelTimer(blackBoard.timeoutId); } //LoggerHelper.Error("RebornAnimationDelay begin:" + waitTime); m_currentSee = m_monsterData.see; blackBoard.ChangeState(Mogo.AI.AIState.THINK_STATE); TimerHeap.AddTimer(waitTime, 0, RebornAnimationDelay); Actor.ActChangeHandle = ActionChange; } ); }
private void CreateCharacterModel(AvatarModelData ai, int vocation, CharacterInfoData ci, Action loaded) { if (m_avatarList.ContainsKey(vocation) && loaded != null) { if (m_avatarList[vocation].actorParent != null) { loaded(); return; } if (m_avatarList[vocation].gameObject != null) { AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject); } } AssetCacheMgr.GetInstanceAutoRelease(ai.prefabName, (prefab, id, go) => { var ety = new EtyAvatar(); ety.vocation = vocation; ety.equipList = ci.EquipList; ety.weapon = ci.Weapon; ety.CreatePosition = ci.Location; var avatar = (go as GameObject); ety.gameObject = avatar; avatar.name = vocation.ToString(); var cc = avatar.GetComponent <Collider>() as CharacterController; cc.radius = 0.5f; ety.animator = avatar.GetComponent <Animator>(); ety.animator.applyRootMotion = false; ety.PlayerShader = PlayerShader; ety.FakeLightShader = FakeLightShader; //MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1); if (vocation == 1) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, -0.4f, 0.01f, -0.5f); } else if (vocation == 2) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f); } else if (vocation == 3) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f); } else if (vocation == 4) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f); } else if (vocation == 3 || vocation == 4) { // �����ڴ� AssetCacheMgr.GetInstanceAutoRelease("fx_jqqd.prefab", (prefabb, idd, goo) => { GameObject goFX = (GameObject)goo; goFX.transform.parent = avatar.transform; goFX.transform.localScale = Vector3.one; if (vocation == 3) { goFX.transform.localPosition = new Vector3(0, 2.2f, 0); } else { goFX.transform.localPosition = new Vector3(0, 2f, 0); } }); } #region ���� if (m_Animators.ContainsKey(vocation)) { m_Animators[vocation] = avatar.GetComponent <Animator>(); } else { m_Animators.Add(vocation, avatar.GetComponent <Animator>()); } #endregion avatar.transform.position = ci.Location; avatar.transform.localScale = Vector3.one; ety.sfxHandler = avatar.AddComponent <SfxHandler>(); #region ��Ч �� ��Чɾ��������ʱ�� if (!m_sfxHandlers.ContainsKey(vocation)) { SfxHandler handler = avatar.GetComponent <SfxHandler>(); if (handler == null) { handler = avatar.AddComponent <SfxHandler>(); } m_sfxHandlers.Add(vocation, handler); uint timer = uint.MaxValue; m_fxTimes.Add(vocation, timer); } #endregion ety.actorParent = avatar.AddComponent <ActorParent>(); ety.actorParent.SetNakedEquid(ai.nakedEquipList); ety.InitEquip(); if (m_avatarList.ContainsKey(vocation)) { m_avatarList[vocation].sfxHandler.RemoveAllFX(); AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject); } ety.Hide(); m_avatarList[vocation] = ety; AssetCacheMgr.GetResource(ci.controller, (obj) => { var controller = obj as RuntimeAnimatorController; if (ety.animator) { ety.animator.runtimeAnimatorController = controller; } if (loaded != null) { loaded(); } }); }); }
public override void CreateModel() { //AvatarModelData data = AvatarModelData.dataMap[(int)vocation]; //Debug.Log("EntityNPC.CreateModel(id=" + ID + ")"); int modelID = NPCData.dataMap[(int)ID].mode; if (!AvatarModelData.dataMap.ContainsKey(modelID) && modelID != 150000) { return; } if (modelID != 150000) { AvatarModelData data = AvatarModelData.dataMap[modelID]; AssetCacheMgr.GetInstanceAutoRelease(data.prefabName, (prefab, guid, gameObject) => { GameObject = gameObject as GameObject; Transform = (gameObject as GameObject).transform; Transform.position = position; Transform.eulerAngles = rotation; // Transform.localScale = scale; animator = GameObject.GetComponent <Animator>(); SetIdleAction(); motor = null; npcMotor = GameObject.AddComponent <MogoMotorNPC>(); Transform.tag = "NPC"; GameObject.layer = 17; //Trap? UpdatePosition(); ap = Transform.GetComponent <ActorNPC>(); if (ap == null) { Transform.gameObject.AddComponent <ActorNPC>(); ap = Transform.GetComponent <ActorNPC>(); (ap as ActorNPC).theEntity = this; } SphereCollider collider = Transform.gameObject.AddComponent <SphereCollider>(); collider.isTrigger = true; collider.center = Vector3.zero; collider.radius = NPCData.dataMap[(int)ID].colliderRange / ((Transform.localScale.x < Transform.localScale.y ? Transform.localScale.x : Transform.localScale.y) < Transform.localScale.z ? (Transform.localScale.x < Transform.localScale.y ? Transform.localScale.x : Transform.localScale.y) : Transform.localScale.z); BillboardLogicManager.Instance.AddInfoBillboard(ID, Transform, this, false); BillboardLogicManager.Instance.SetHead(this); EventDispatcher.TriggerEvent <Vector3, uint>(BillboardLogicManager.BillboardLogicEvent.UPDATEBILLBOARDPOS, Transform.position, ID); MogoFXManager.Instance.AddShadow(GameObject, ID, 1 / Transform.localScale.x, 1 / Transform.localScale.y, 1 / Transform.localScale.z); if (MogoWorld.thePlayer.CurrentTask != null) { if (MogoWorld.thePlayer.CurrentTask.conditionType == 1 && MogoWorld.thePlayer.CurrentTask.condition != null && MogoWorld.thePlayer.CurrentTask.condition.Count >= 3 && TaskData.dataMap.Get(MogoWorld.thePlayer.CurrentTask.condition[2]).npc == (int)ID) { SetNPCSign(NPCSignState.Doing); } if (MogoWorld.thePlayer.CurrentTask.isShowNPCTip == 1) { SetNPCSign(NPCSignState.Done); } } ((GameObject)gameObject).AddComponent <MogoObjOpt>().ObjType = MogoObjType.NPC; if (((GameObject)gameObject).GetComponent <Animator>() != null) { ((GameObject)gameObject).GetComponent <Animator>().enabled = false; } if (((GameObject)gameObject).GetComponent <Animation>() != null) { ((GameObject)gameObject).GetComponent <Animation>().enabled = false; } if (!NPCManager.npcEntitiePosition.ContainsKey((uint)ID)) { NPCManager.npcEntitiePosition.Add((uint)ID, Transform.position); } EventDispatcher.TriggerEvent(Events.TaskEvent.CheckNpcInRange); NPCCheckThink(); } ); } else { GameObject = new GameObject(); GameObject.name = "Sky_NPC"; Transform = GameObject.transform; Transform.position = position; Transform.eulerAngles = rotation; // Transform.localScale = scale; Transform.tag = "NPC"; UpdatePosition(); ActorNPC ap = Transform.GetComponent <ActorNPC>(); if (ap == null) { Transform.gameObject.AddComponent <ActorNPC>(); ap = Transform.GetComponent <ActorNPC>(); (ap as ActorNPC).theEntity = this; } SphereCollider collider = Transform.gameObject.AddComponent <SphereCollider>(); collider.isTrigger = true; collider.center = Vector3.zero; collider.radius = 5; } }
private void CreateCharacterModel(AvatarModelData ai, int vocation, CharacterInfoData ci, Action loaded) { if (m_avatarList.ContainsKey(vocation) && loaded != null) { if (m_avatarList[vocation].actorParent != null) { loaded(); return; } if (m_avatarList[vocation].gameObject != null) { AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject); } } AssetCacheMgr.GetInstanceAutoRelease(ai.prefabName, (prefab, id, go) => { var ety = new EtyAvatar(); ety.vocation = vocation; ety.equipList = ci.EquipList; ety.weapon = ci.Weapon; ety.CreatePosition = ci.Location; var avatar = (go as GameObject); ety.gameObject = avatar; avatar.name = vocation.ToString(); var cc = avatar.collider as CharacterController; cc.radius = 0.5f; ety.animator = avatar.GetComponent<Animator>(); ety.animator.applyRootMotion = false; ety.PlayerShader = PlayerShader; ety.FakeLightShader = FakeLightShader; //MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1); if (vocation == 1) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, -0.4f, 0.01f, -0.5f); } else if (vocation == 2) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f); } else if(vocation == 3) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f); } else if (vocation == 4) { MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f); } else if (vocation == 3 || vocation == 4) { // 敬请期待 AssetCacheMgr.GetInstanceAutoRelease("fx_jqqd.prefab", (prefabb, idd, goo) => { GameObject goFX = (GameObject)goo; goFX.transform.parent = avatar.transform; goFX.transform.localScale = Vector3.one; if (vocation == 3) { goFX.transform.localPosition = new Vector3(0, 2.2f, 0); } else { goFX.transform.localPosition = new Vector3(0, 2f, 0); } }); } #region 动作 if (m_Animators.ContainsKey(vocation)) m_Animators[vocation] = avatar.GetComponent<Animator>(); else m_Animators.Add(vocation, avatar.GetComponent<Animator>()); #endregion avatar.transform.position = ci.Location; avatar.transform.localScale = Vector3.one; ety.sfxHandler = avatar.AddComponent<SfxHandler>(); #region 特效 和 特效删除函数定时器 if (!m_sfxHandlers.ContainsKey(vocation)) { SfxHandler handler = avatar.GetComponent<SfxHandler>(); if (handler == null) handler = avatar.AddComponent<SfxHandler>(); m_sfxHandlers.Add(vocation, handler); uint timer = uint.MaxValue; m_fxTimes.Add(vocation, timer); } #endregion ety.actorParent = avatar.AddComponent<ActorParent>(); ety.actorParent.SetNakedEquid(ai.nakedEquipList); ety.InitEquip(); if (m_avatarList.ContainsKey(vocation)) { m_avatarList[vocation].sfxHandler.RemoveAllFX(); AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject); } ety.Hide(); m_avatarList[vocation] = ety; AssetCacheMgr.GetResource(ci.controller, (obj) => { var controller = obj as RuntimeAnimatorController; if (ety.animator) ety.animator.runtimeAnimatorController = controller; if (loaded != null) loaded(); }); }); }
public override void CreateActualModel() { isCreatingModel = true; AssetCacheMgr.ReleaseLocalInstance(GameObject); AvatarModelData data = AvatarModelData.dataMap.Get((int)vocation); SubAssetCacheMgr.GetPlayerInstance(data.prefabName, (prefab, guid, go) => { var gameObject = go as GameObject; var actor = gameObject.AddComponent <ActorPlayer>(); actor.theEntity = this; motor = gameObject.AddComponent <MogoMotorServer>(); animator = gameObject.GetComponent <Animator>(); sfxHandler = gameObject.AddComponent <SfxHandler>(); //actor.mogoMotor = motor; audioSource = gameObject.AddComponent <AudioSource>(); audioSource.rolloffMode = AudioRolloffMode.Custom; GameObject = gameObject; Transform = gameObject.transform; GameObject.layer = 20; //otherplayer //Debug.LogError("entityPlayer.CreateActualModel:" + gameObject.layer); // Debug.LogError(GameObject.name + " " + ID + " Player CreateActualModel: " + Transform.position); this.Actor = actor; //Transform.localScale = scale; Transform.tag = "OtherPlayer"; UpdatePosition(); foreach (var item in gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true)) { item.enabled = false; } if (data.scale > 0) { Transform.localScale = new Vector3(data.scale, data.scale, data.scale); } base.CreateModel(); LoadEquip(); foreach (var item in gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true)) { item.enabled = true; } //Debug.Log("AddComponent<CombineSkinnedMeshes>"); //gameObject.AddComponent<CombineSkinnedMeshes>(); //Debug.Log("AddComponent<CombineSkinnedMeshes>"); gameObject.SetActive(false); idleTimer = TimerHeap.AddTimer(1000, 0, DelayCheckIdle); TimerHeap.AddTimer(3000, 0, () => { if (gameObject == null) { return; } gameObject.SetActive(true); isCreatingModel = false; SetBillBoard(); MogoFXManager.Instance.AddShadow(gameObject, ID); //gameObject.AddComponent<MogoObjOpt>().ObjType = MogoObjType.Player; //if (gameObject.GetComponent<Animator>() != null) //{ // gameObject.GetComponent<Animator>().enabled = false; //} //if (gameObject.GetComponent<Animation>() != null) //{ // gameObject.GetComponent<Animation>().enabled = false; //} }); Actor.ActChangeHandle = ActionChange; UpdateDressWing(); AddEquipFX(loadedEquipId); AddJewelFX(loadedJewelId); AddStrenthFX(loadedStrengthenId); } ); }
public override void CreateActualModel() { AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(model, null); if (data == null) { Debug.LogError("Model not found: " + model); return; } SubAssetCacheMgr.GetCharacterInstance(data.prefabName, (prefab, guid, gameObject) => { if (this.Actor) { this.Actor.Release(); } if (Transform) { AssetCacheMgr.ReleaseLocalInstance(Transform.gameObject); } GameObject = (gameObject as GameObject); Transform = GameObject.transform; Transform.localScale = scale; Transform.tag = "Monster"; Transform.gameObject.layer = 11; //monster sfxHandler = GameObject.AddComponent <SfxHandler>(); motor = GameObject.AddComponent <MogoMotorServer>(); audioSource = GameObject.AddComponent <AudioSource>(); audioSource.rolloffMode = AudioRolloffMode.Custom; if (m_monsterData.notTurn == 0) { motor.SetAngularSpeed(360f); } else { motor.canMove = false; motor.canTurn = false; } Debug.Log(" m_monsterData.scaleRadius:" + m_monsterData.scaleRadius); CharacterController controller = GameObject.GetComponent <CharacterController>(); controller.radius = m_monsterData.scaleRadius / 100f; controller.height = EntityColiderHeight; float centerY = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius); controller.center = new Vector3(0, centerY, 0); animator = GameObject.GetComponent <Animator>(); //animator.speed = 0.3f; ActorMonster ap = GameObject.AddComponent <ActorMonster>(); ap.theEntity = this; this.Actor = ap; UpdatePosition(); if (data.originalRotation != null && data.originalRotation.Count == 3) { Transform.eulerAngles = new Vector3(data.originalRotation[0], data.originalRotation[1], data.originalRotation[2]); } else { Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position; Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z)); } base.CreateModel(); animator.applyRootMotion = false; #region Shader if (ShaderData.dataMap.ContainsKey(m_monsterData.shader) && (GameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true) != null || GameObject.GetComponentsInChildren <MeshRenderer>(true) != null)) { MogoFXManager.Instance.SetObjShader(GameObject, ShaderData.dataMap[m_monsterData.shader].name, ShaderData.dataMap[m_monsterData.shader].color); MogoFXManager.Instance.AlphaFadeIn(GameObject, 0.3f); } #endregion if (data.scale > 0) { Transform.localScale = new Vector3(data.scale, data.scale, data.scale); } try { if (m_monsterData != null && m_monsterData.bornFx != null && PlayBornFX) { foreach (var item in m_monsterData.bornFx) { sfxHandler.HandleFx(item); } } } catch (Exception ex) { Debug.LogException(ex); } uint waitTime = (uint)m_monsterData.bornTime; if (waitTime <= 1) //容错 { waitTime = 3000; } BornedHandler(); Actor.ActChangeHandle = ActionChange; } ); }