private void HandleDissonFx(FXData fx) { orgShader = GetMatShader(); AssetCacheMgr.GetResource(fx.dissonShader, (shader) => { SetMatShader(shader as Shader); currentShaderFx = fx.id; AssetCacheMgr.GetResource(fx.nosieTexture, (nosieTexture) => { SetMatTexture("_NosieTex", nosieTexture as Texture); float nosieOffset = fx.nosieOffetFrom; SetMatFloat("_NosieOffset", nosieOffset); TimerHeap.AddTimer((uint)fx.dissonDelay, 0, () => { //Debug.Log("begin HandleDissonFx"); var duration = fx.dissonDuration; var loopTimer = TimerHeap.AddTimer(0, 100, () => { SetMatFloat("_NosieOffset", nosieOffset); nosieOffset = nosieOffset + (fx.nosieOffetTo - fx.nosieOffetFrom) * 100 / duration; //Debug.Log("nosieOffset: " + nosieOffset); }); TimerHeap.AddTimer((uint)duration, 0, () => { //Debug.Log("DelTimer HandleDissonFx"); TimerHeap.DelTimer(loopTimer); }); }); }); }); //Debug.Log("HandleDissonFx: " + fx.actionID); }
public void LoadChooseCharacter() { AssetCacheMgr.GetResource("PlayerShader.shader", (obj) => { AssetCacheMgr.GetResource("MogoFakeLight.shader", (obj1) => { FakeLightShader = (Shader)obj1; PlayerShader = (Shader)obj; ClearChooseCharacterModel(); OnChooseCharacterGridUp(m_selectedCharacterId, true); }); }); }
private void HandleShaderFX(FXData fx) { //Debug.LogError("HandleShaderFX"); orgShader = GetMatShader(); AssetCacheMgr.GetResource(fx.shader, (shader) => { //Debug.LogError("SetMatShader: " + shader.name); SetMatShader(shader as Shader); currentShaderFx = fx.id; updatingShader = true; StartCoroutine(UpdateShader(fx)); }); //SetMatShader(Shader.Find("Mogo/FakeLight")); //Debug.Log("HandleShaderFX: " + fx.actionID); }
private void AddEquipFX(uint fxId) { Debug.LogError("@@@@@@@@AddEquipFX " + fxId); if (vocation != Vocation.Warrior) { return; } if (fxId == m_oldEquipFXID) { return; } int fxResId = EquipSpecialEffectData.dataMap[(int)fxId].fxid; m_oldEquipFXID = loadedEquipId; if (fxId != 0) { AssetCacheMgr.GetResource("equip_warrior_01_fx_5_mat.mat", (obj) => { Debug.LogError(fxId + " @@@@@@@@@@@@@@@"); Material fxMat = (Material)obj; GameObject.transform.FindChild("101_00").GetComponentsInChildren <SkinnedMeshRenderer>(true)[0].material = null; GameObject.transform.FindChild("101_00").GetComponentsInChildren <SkinnedMeshRenderer>(true)[0].material = fxMat; UVAnim anim = GameObject.transform.FindChild("101_00").gameObject.AddComponent <UVAnim>(); anim.Direction.x = 0.5f; anim.Direction.y = 0.13f; anim.speed = 1.5f; }); } else { //AssetCacheMgr.GetResource(Actor.EquipOnDic, (obj) => //{ // Debug.LogError(fxId + " @@@@@@@@@@@@@@@"); // Material fxMat = (Material)obj; // GameObject.transform.FindChild("101_00").GetComponentsInChildren<SkinnedMeshRenderer>(true)[0].material = null; // GameObject.transform.FindChild("101_00").GetComponentsInChildren<SkinnedMeshRenderer>(true)[0].material = fxMat; // UVAnim anim = GameObject.transform.FindChild("101_00").gameObject.AddComponent<UVAnim>(); // anim.Direction.x = 0.5f; // anim.Direction.y = 0.13f; // anim.speed = 1.5f; //}); } }
private void AddJewelFX(uint fxId) { //Debug.Log("@@@@@@@@AddJewelFX(" + fxId+")"); if (vocation != Vocation.Warrior) { return; } if (fxId == m_oldJewelFXID) { return; } int fxResId = EquipSpecialEffectData.dataMap[(int)fxId].fxid; m_oldJewelFXID = loadedJewelId; if (fxId != 0) { AssetCacheMgr.GetResource("blade_01_fx_6_mat.mat", (obj) => { Material fxMat = (Material)obj; System.Collections.Generic.List <GameObject> listGo = GameObject.GetComponent <ActorParent>().WeaponObj; for (int i = 0; i < listGo.Count; ++i) { int index = i; listGo[index].GetComponentsInChildren <MeshRenderer>(true)[0].material = null; listGo[index].GetComponentsInChildren <MeshRenderer>(true)[0].material = fxMat; UVAnim anim = listGo[index].AddComponent <UVAnim>(); anim.Direction.x = 0.5f; anim.Direction.y = 0.13f; anim.speed = 1.5f; } }); } else { } }
/// <summary> /// 加载场景。 /// </summary> /// <param name="lightmap">场景名称</param> /// <param name="loaded">加载结束,参数为是否加载场景</param> private void LoadScene(MapData data, Action <Boolean> loaded, string sceneName, Action <int> process = null) { try { //场景文件读取完毕后处理 Action sceneWasLoaded = () => { //if (MogoUIManager.Instance != null) // MogoUIManager.Instance.ReleaseMogoUI(); //场景文件加载完毕后处理 Action LevelWasLoaded = () => { Debug.Log("LevelWasLoaded: " + sceneName); //Debug.Log("LevelWasLoaded: " + sceneName); //if (!String.IsNullOrEmpty(m_lastSceneResourceName)) // AssetCacheMgr.ReleaseResource(m_lastSceneResourceName); if (data.modelName.Count == 0) { if (loaded != null) { loaded(true); } } Debug.Log("modelName Count: " + data.modelName.Count); if (process != null) { process(20); } var models = data.modelName.Keys.ToList(); for (int i = 0; i < models.Count; i++) { var currentOrder = i; Debug.Log(i + ":" + models[currentOrder]); //加载场景模型 AssetCacheMgr.GetSceneInstance(models[currentOrder], (pref, id, go) => { go.name = Utils.GetFileNameWithoutExtention(models[currentOrder]); if (data.modelName[models[currentOrder]])// && SystemSwitch.ReleaseMode { StaticBatchingUtility.Combine(go as GameObject); } Debug.Log("sceneLoaded: " + go.name); LoggerHelper.Debug("sceneLoaded: " + go.name); Debug.Log("id=" + id); //(go as GameObject).SetActive(false); //m_sceneObjects.Add(go); if (currentOrder == data.modelName.Count - 1) { AssetCacheMgr.UnloadAssetbundles(models.ToArray()); SwitchLightMapFog(data, loaded); } }, (progress) => { float cur = 60 * ((progress + currentOrder) / models.Count) + 20; if (process != null) { process((int)(cur)); } }); } //if (process != null) // process(100); //if (loaded != null) // loaded(true); Driver.Instance.LevelWasLoaded = null; }; if (sceneName != "10002_Login") { Driver.Instance.LevelWasLoaded = () => { Driver.Instance.StartCoroutine(UnloadUnusedAssets(() => { //Debug.LogError("UnloadUnusedAssets finish"); GC.Collect(); LevelWasLoaded(); })); }; //Driver.Instance.LevelWasLoaded = LevelWasLoaded; Application.LoadLevel(sceneName); } else { LevelWasLoaded(); } Debug.Log("LoadLevel: " + sceneName); }; if (SystemSwitch.ReleaseMode) { if (process != null) { process(5); } Debug.Log("xx sceneName: " + m_lastSceneResourceName); m_lastSceneResourceName = string.Concat(sceneName, ".unity"); AssetCacheMgr.GetResource(m_lastSceneResourceName,//加载场景 (scene) => { sceneWasLoaded(); }, (progress) => { float cur = 15 * progress + 5; if (process != null) { process((int)(cur)); } } ); //if (process != null) // process(40); } else { sceneWasLoaded(); } } catch (Exception ex) { Debug.LogException(ex); } }
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 void LoadCreateCharacter(Action callback) { AssetCacheMgr.GetResource("PlayerShader.shader", (obj) => { AssetCacheMgr.GetResource("MogoFakeLight.shader", (obj1) => { FakeLightShader = (Shader)obj1; PlayerShader = (Shader)obj; LoadCamera(); MogoWorld.inCity = false; m_lastSelectedCharacter = null; LoadCharacters(() => { foreach (var item in m_avatarList) { item.Value.Init(); item.Value.SetCreateMode(); } var avatarList = m_avatarList.Values.ToList(); var counter = 0; for (int i = 0; i < avatarList.Count; i++) { var item = avatarList[i]; item.gameObject.transform.position = item.CreatePosition; item.Equip(item.equipList, () => { counter++; if (counter == m_avatarList.Count * 2) { if (callback != null) { callback(); } } }); int vocation = item.vocation; item.Equip(item.weapon, () => { if (vocation == (int)Vocation.Mage && m_sfxHandlers.ContainsKey(vocation)) { m_sfxHandlers[vocation].HandleFx(10239, null, (go, fxid) => { go.transform.parent = m_avatarList[vocation].gameObject.transform.Find("Bip_master/bip_weapon_separate/equip_mage_staff_02_p(Clone)"); go.transform.localPosition = Vector3.zero; go.transform.localEulerAngles = new Vector3(270, 0, 0); go.transform.localScale = new Vector3(1, 1, 1); }); } counter++; if (counter == m_avatarList.Count * 2) { if (callback != null) { callback(); } } }); } }); }); }); }
public void Equip(EtyAvatar avatar, int _equipId, Action callback) { //Debug.Log("_equipId:" + _equipId); if (avatar.gameObject == null) { Debug.Log("Transform == null"); //Debug.LogError("Transform == null"); return; } System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); if (!ItemEquipmentData.dataMap.ContainsKey(_equipId)) { Debug.LogError("can not find equip:" + _equipId); return; } ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId]; if (equip.mode > 0) { if (avatar.actorParent == null) { Debug.Log("the actor is null!!!!"); //Debug.LogError("the actor is null!!!!"); return; } avatar.actorParent.m_isChangingWeapon = true; avatar.actorParent.Equip(equip.mode, () => { if (equip.type == (int)EquipType.Weapon) { //Debug.Log("ControllerOfWeaponData:" + equip.id); //Debug.Log("ControllerOfWeaponData:" + equip.subtype); //Debug.Log("ControllerOfWeaponData:" + (int)vocation); ControllerOfWeaponData controllerData = ControllerOfWeaponData.dataMap[equip.subtype]; RuntimeAnimatorController controller; AssetCacheMgr.GetResource(controllerData.controller, (obj) => { controller = obj as RuntimeAnimatorController; if (avatar.animator == null) { return; } avatar.animator.runtimeAnimatorController = controller; if (MogoWorld.inCity) { avatar.animator.SetInteger("Action", -1); } else { avatar.animator.SetInteger("Action", 0); } callback(); }); } else { callback(); } }); stopWatch.Stop(); } else { callback(); } }
void OnGUI() { if (GUI.Button(new Rect(120, 20, 50, 30), "switch")) { isShowDebug = !isShowDebug; //LoggerHelper.UploadLogFile(); } //if (GUI.Button(new Rect(20, 70, 50, 30), "kkkk")) //{ // EventDispatcher.TriggerEvent(Events.OtherEvent.ClientGM, "@OpenGM"); //} if (!isShowDebug) { return; } prefabName = GUI.TextField(new Rect(0, 60, 200, 40), prefabName); if (GUI.Button(new Rect(0, 100, 100, 100), "create")) { temps.Clear(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var prefs = prefabName.Split('-'); for (int i = 0; i < prefs.Length; i++) { var index = i; var item = prefs[index]; AssetCacheMgr.GetInstance(item, (a, b, c) => { if (index == prefs.Length - 1) { sw.Stop(); LoggerHelper.Debug("Load Fin: " + sw.ElapsedMilliseconds); } LoggerHelper.Debug(a); temps.Add(c); }); } } if (GUI.Button(new Rect(100, 100, 100, 100), "destroy")) { foreach (var item in temps) { AssetCacheMgr.ReleaseInstance(item); } } if (GUI.Button(new Rect(0, 200, 100, 100), "Res")) { AssetCacheMgr.GetResource(prefabName, (a) => { LoggerHelper.Debug(a); }); } resourceName = GUI.TextField(new Rect(200, 200, 200, 100), resourceName); result = GUI.TextField(new Rect(0, 300, 400, 400), result); if (GUI.Button(new Rect(100, 200, 50, 50), "Find Root")) { result = ResourceManager.GetResourceRoots(resourceName).PackList('\n'); } if (GUI.Button(new Rect(150, 200, 50, 50), "PR")) { LoggerHelper.Info(ResourceManager.resources.Values.ToList().PackList('\n')); } if (GUI.Button(new Rect(100, 250, 50, 50), "PRD")) { LoggerHelper.Info(AssetCacheMgr.ResourceDic.PackMap(mapSpriter: '\n')); } if (GUI.Button(new Rect(150, 250, 50, 50), "PGONM")) { LoggerHelper.Info(AssetCacheMgr.GameObjectNameMapping.PackMap(mapSpriter: '\n')); } if (GUI.Button(new Rect(200, 100, 100, 100), "show dep")) { LoggerHelper.Info(ResourceManager.resources.Values.ToList().PackList('\n')); } }
public void Equip(int _equipId) { if (Transform == null) { return; } System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); if (!ItemEquipmentData.dataMap.ContainsKey(_equipId)) { LoggerHelper.Error("can not find equip:" + _equipId); return; } ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId]; if (equip.mode > 0) { if (Actor == null) { return; } Actor.m_isChangingWeapon = true; Actor.Equip(equip.mode); if (equip.type == (int)EquipType.Weapon) { ControllerOfWeaponData controllerData = ControllerOfWeaponData.dataMap[equip.subtype]; RuntimeAnimatorController controller; if (animator == null) { return; } string controllerName = (MogoWorld.inCity ? controllerData.controllerInCity : controllerData.controller); if (animator.runtimeAnimatorController != null) { if (animator.runtimeAnimatorController.name == controllerName) { return; } AssetCacheMgr.ReleaseResource(animator.runtimeAnimatorController); } AssetCacheMgr.GetResource(controllerName, (obj) => { controller = obj as RuntimeAnimatorController; if (animator == null) { return; } animator.runtimeAnimatorController = controller; if (this is EntityMyself) { (this as EntityMyself).UpdateSkillToManager(); EventDispatcher.TriggerEvent <int, int>(InventoryEvent.OnChangeEquip, equip.type, equip.subtype); } if (this is EntityPlayer) { if (MogoWorld.inCity) { animator.SetInteger("Action", -1); } else { animator.SetInteger("Action", 0); } if (MogoWorld.isReConnect) { ulong s = stateFlag; stateFlag = 0; stateFlag = s; } } }); } stopWatch.Stop(); //if (!isCreatingModel) //{ // SetPosition(); // stopWatch.Start(); // //AssetCacheMgr.ReleaseInstance(GameObject); // CreateActualModel(); // stopWatch.Stop(); // Mogo.Util.LoggerHelper.Debug("CreateModel:" + stopWatch.Elapsed.Milliseconds); //} } }