public void OnOpenDailyTaskUI() { EventDispatcher.TriggerEvent <bool>(Events.MogoGlobleUIManagerEvent.ShowWaitingTip, true); LoggerHelper.Debug("OnMainUIDailyTaskIconPressed"); if (!m_bBeenInited && m_DailyTaskUIPanel == null) { LoggerHelper.Debug("OnMainUIDailyTaskIconPressed 1"); m_bBeenInited = true; AssetCacheMgr.GetResources(new string[] { "DailyTaskUI.prefab", "Task.prefab" }, (objs) => { LoggerHelper.Debug("inside the call back AssetCacheMgr.GetResources( DailyTaskUI.prefab Task.prefab"); InitDailyTaskView(objs); }); } else { LoggerHelper.Debug("OnMainUIDailyTaskIconPressed 2"); if (m_DailyTaskUIPanel != null) { AllPanelIsReady(); } } }
public override void Initialize(int num) { Transform driverTrans = GameObject.Find("Driver").transform; for (int i = 0; i < num; ++i) { int index = i; AssetCacheMgr.GetUIInstance("AloneBattleBillboard.prefab", (prefab, guid, gameObject) => { ((GameObject)gameObject).transform.parent = driverTrans; m_listPoolObj.Add((GameObject)(gameObject)); ((GameObject)gameObject).AddComponent <AloneBattleBillboardAnim>(); m_listPoolObjFree.Add(index); m_dictIDToObj.Add(index, ((GameObject)gameObject)); }); if (index == num - 1) { //Debug.Log("Pool Init Finished"); } } }
private void AddUIGridList(int num, Action act = null) { for (int i = 0; i < num; ++i) { int index = i; AssetCacheMgr.GetUIInstance("ChooseDragonUIGrid.prefab", (prefab, guid, go) => { GameObject obj = (GameObject)go; obj.transform.parent = m_tranChooseDragonUIGridList; obj.transform.localPosition = new Vector3(ITEMSPACEHORIZON * index, 0, 0); obj.transform.localScale = new Vector3(1f, 1f, 1f); ChooseDragonUIGrid gridUI = obj.AddComponent <ChooseDragonUIGrid>(); gridUI.LoadResourceInsteadOfAwake(); m_listGrid.Add(gridUI); if (index == num - 1 && act != null) { act(); } }); } }
public void AddRewardGrid(RankRewardGridData rd) { AssetCacheMgr.GetUIInstance("WeekRankDialogRewardItem.prefab", (prefab, id, go) => { GameObject obj = (GameObject)go; obj.transform.FindChild("WeekRankDialogRewardItemFG").GetComponentsInChildren <UISprite>(true)[0].spriteName = rd.imgName; obj.transform.FindChild("WeekRankDialogRewardItemText").GetComponentsInChildren <UILabel>(true)[0].text = rd.text; obj.transform.parent = m_transRewardGridList; obj.transform.localPosition = new Vector3(m_listRewardGrid.Count * 215, 0, 0); obj.transform.localScale = new Vector3(1, 1, 1); RewardGrid rg = obj.AddComponent <RewardGrid>(); rg.Id = m_listRewardGrid.Count; m_listRewardGrid.Add(obj); MyDragCamera mdc = obj.AddComponent <MyDragCamera>(); mdc.RelatedCamera = m_camRewardGrid; m_camRewardGrid.GetComponentsInChildren <MyDragableCamera>(true)[0].MAXX = 430 + 215 * (m_listRewardGrid.Count - 5); }); }
void PlayGetAwardFX() { Vector3 pos = transform.parent.parent.GetChild(0).GetComponent <Camera>().WorldToScreenPoint(m_GetAwardButton.transform.position); pos = transform.parent.parent.GetChild(1).GetComponent <Camera>().ScreenToWorldPoint(pos); AssetCacheMgr.GetUIInstance("fx_ui_icon_open.prefab", (prefab, id, go) => { m_GetAwardFX = (GameObject)go; m_GetAwardFX.name = m_strOrder; m_GetAwardFX.transform.parent = m_scDailyTaskFXRoot.transform; m_GetAwardFX.transform.position = pos; m_GetAwardFX.transform.localScale = new Vector3(1.5f, 1.5f, 0); m_GetAwardFX.transform.GetChild(0).gameObject.GetComponent <ParticleSystem>().startSize = 600.0f; m_GetAwardFX.transform.GetChild(1).gameObject.GetComponent <ParticleSystem>().startSize = 600.0f; AutoDie sc = m_GetAwardFX.AddComponent <AutoDie>(); sc.m_fDisapearIn = 1.0f; sc.m_fLifeTime = 1.0f; sc.m_WhenIDie = m_scDailyTaskFXRoot.OnFXDie; sc.m_Target = m_GetAwardButton; sc.m_RelativeCamera = transform.parent.parent.GetChild(1).GetComponent <Camera>(); }); }
//public void LoadResource(string path,MFUIManager.MFUIID id, GameObject outGO) //{ // if (m_dictResNameToObj.ContainsKey(path)) // { // outGO = (GameObject)(GameObject.Instantiate(m_dictResNameToObj[path])); // MFUIGameObjectPool.GetSingleton().ResourceLoaded(id); // } // else // { // Object obj = Resources.Load(path); // if (obj == null) // { // MFUIUtils.MFUIDebug(string.Concat(path, " Not Found ! ")); // return; // } // m_dictResNameToObj.Add(path, obj); // outGO = (GameObject)(GameObject.Instantiate(obj)); // MFUIGameObjectPool.GetSingleton().ResourceLoaded(id); // } //} public void PreLoadResource(string path, MFUIManager.MFUIID id) //预加载资源存放到UIID->Object Dict & resName->Object { if (!m_dictUIIDToObjList.ContainsKey(id)) { m_dictUIIDToObjList.Add(id, new List <Object>()); } if (!m_dictResNameToObj.ContainsKey(path)) { AssetCacheMgr.GetUIResource(path, (obj) => { m_dictResNameToObj.Add(path, obj); //if(!m_dictUIIDToObjList.ContainsKey(id)) //{ // m_dictUIIDToObjList[id].Add(obj); //} if (!m_dictUIIDToObjList[id].Contains(obj)) { m_dictUIIDToObjList[id].Add(obj); } }); } else { //if (!m_dictUIIDToObjList.ContainsKey(id)) //{ // //m_dictUIIDToObjList[id].Add(m_dictResNameToObj[path]); //} if (!m_dictUIIDToObjList[id].Contains(m_dictResNameToObj[path])) { m_dictUIIDToObjList[id].Add(m_dictResNameToObj[path]); } } }
public void ShowMainUI(bool isShow = true) { transform.gameObject.SetActive(isShow); if (!isShow) { return; } ClearOld(); InventoryManager.SetIcon(m_viewData.oldEquipId, m_oldEquipIconFg, 0, null, m_oldEquipIconBg); InventoryManager.SetIcon(m_viewData.newEquipId, m_newEquipIconFg, 0, null, m_newEquipIconBg); m_powerLbl.text = m_viewData.power; m_goldLbl.text = m_viewData.needGold; for (int i = 0; i < m_viewData.materialIdList.Count; i++) { int index = i; AssetCacheMgr.GetUIInstance(MATERIAL_ICON_PREFAB, (str, id, obj) => { GameObject go = obj as GameObject; Utils.MountToSomeObjWithoutPosChange(go.transform, m_materialListRoot); go.transform.localPosition = new Vector3(go.transform.localPosition.x + index * HORIZONTAL_GAP, go.transform.localPosition.y, go.transform.localPosition.z); UISprite bg = go.transform.Find("EquipUpgradeCostMaterialIconBG").GetComponent <UISprite>(); UISprite fg = go.transform.Find("EquipUpgradeCostMaterialIconFG").GetComponent <UISprite>(); UILabel lbl = go.transform.Find("EquipUpgradeCostMaterialIconNum").GetComponent <UILabel>(); InventoryManager.SetIcon(m_viewData.materialIdList[index], fg, 0, null, bg); lbl.text = m_viewData.materilNumStrList[index]; go.AddComponent <MogoUIListener>().MogoOnClick = () => { OnClickMaterial(index); }; m_goList.Add(go); }); } //int offset = (m_viewData.materialIdList.Count - 1) * HORIZONTAL_GAP / 2; //m_materialListRoot.localPosition = new Vector3(m_materialListRootPos.x - offset, m_materialListRootPos.y, m_materialListRootPos.z); }
public void AddInsetGridItem(int level, string type, int gridId, string imgName = "", int color = 0) { Mogo.Util.LoggerHelper.Debug(gridId); RemoveRuneInsetItem(gridId); LoggerHelper.Debug("AddInset " + gridId); AssetCacheMgr.GetUIInstance("RuneUIInsetGridInfotest.prefab", (prefab, id, go) => { GameObject obj = (GameObject)go; obj.SetActive(true); obj.name = gridId.ToString(); obj.transform.parent = m_myTransform.FindChild(m_widgetToFullName["RuneUIInset"]); obj.transform.localPosition = m_arrInsetGird[gridId].localPosition; obj.transform.localScale = new Vector3(1, 1, 1); obj.transform.FindChild("RuneUIInsetGridLevel").GetComponentsInChildren <UILabel>(true)[0].text = "Lv" + level; obj.transform.FindChild("RuneUIInsetGridName").GetComponentsInChildren <UILabel>(true)[0].text = type; UISprite s = obj.transform.FindChild("RuneUIInsetGridBG").GetComponentsInChildren <UISprite>(true)[0]; s.spriteName = imgName; MogoUtils.SetImageColor(s, color); m_listRuneInsetItem.Add(obj); }); }
public override void CallWhenHide() { //if (SystemSwitch.DestroyAllUI) //{ Release(); m_instance = null; MFUIManager.GetSingleton().ReleaseRuneUI(m_myGameObject); //} MFUIUtils.ShowGameObject(false, m_myGameObject); //Debug.LogError("RuneUIDisable"); MogoUIManager.Instance.ShowBillboardList(true); if (MogoMainCamera.instance) { MogoMainCamera.instance.SetActive(true); } MogoUIManager.Instance.GetMainUICamera().clearFlags = CameraClearFlags.Depth; DisablePlayerModel(); if (!SystemSwitch.DestroyResource) { return; } m_texInsetBodyBG.mainTexture = null; AssetCacheMgr.ReleaseResourceImmediate("lyfw_fuwenxiangqianbeijng.png"); //DragonUIViewManager.Instance.AtlasCanRelease.spriteMaterial.mainTexture = null; //AssetCacheMgr.ReleaseResourceImmediate("MogoDragonUI.png"); }
private void AddTongList() { m_tongListBtnList.SingleButtonList = new List <MogoSingleButton>(); for (int i = 0; i < m_tongDataList.Count; i++) { int index = i; AssetCacheMgr.GetUIInstance(TONG_LIST_GRID_PREFAB, (str, id, obj) => { GameObject go = obj as GameObject; Utils.MountToSomeObjWithoutPosChange(go.transform, m_tongListRoot); go.transform.localPosition = new Vector3(go.transform.localPosition.x, -index * TONG_LIST_GRID_GAP, go.transform.localPosition.z); m_tongListBtnList.SingleButtonList.Add(go.GetComponent <MogoSingleButton>()); go.GetComponent <MyDragCamera>().RelatedCamera = m_tongListCamera.GetComponent <Camera>(); go.AddComponent <TongButton>().id = index; go.transform.FindChild("TongListGridName").GetComponent <UILabel>().text = m_tongDataList[index].name; go.transform.FindChild("TongListGridLevel").GetComponent <UILabel>().text = m_tongDataList[index].level; go.transform.FindChild("TongListGridNum").GetComponent <UILabel>().text = m_tongDataList[index].num; m_tongListGridObj.Add(go); }); } }
void OnDestroy() { m_TaskName = null; m_ExpAmount = null; m_GoldAmount = null; m_CurrentStep = null; m_TaskIcon = null; m_GetAwardButton = null; m_AlreadyGetAwardButton = null; m_UnfinishedButton = null; m_ProgressBar = null; m_FinishedText = null; if (m_FinishedFX != null) { DestroyImmediate(m_FinishedFX); m_FinishedFX = null; } if (m_GetAwardFX != null) { DestroyImmediate(m_GetAwardFX); m_GetAwardFX = null; } AssetCacheMgr.SynReleaseInstance(gameObject); }
public void Release() { ButtonTypeToEventUp.Clear(); EventDispatcher.RemoveEventListener <int>(AttributeRewardLogicManager.AttributeRewardUIEvent.AttributeGridShareBtnUp, OnShareBtnUp); EmptyAttributeGridList(); AttributeRewardLogicManager.Instance.Release(); //for (int i = 0; i < m_listAttributeGrid.Count; ++i) //{ // AssetCacheMgr.ReleaseInstance(m_listAttributeGrid[i]); // m_listAttributeGrid[i] = null; //} m_listAttributeGrid.Clear(); for (int i = 0; i < m_listAttributeGridGameObject.Count; ++i) { AssetCacheMgr.ReleaseInstance(m_listAttributeGridGameObject[i]); m_listAttributeGridGameObject[i] = null; } m_listAttributeGridGameObject.Clear(); }
public EquipFXUILogicManager() { AssetCacheMgr.GetUIResource("FlowLightShaderWithTwirl.shader", (obj) => { m_shaderFlowLight = (Shader)obj; }); AssetCacheMgr.GetUIResource("PlayerShader.shader", (obj) => { m_playerShader = (Shader)obj; }); foreach (var item in EquipSpecialEffectData.dataMap) { if (item.Value.group == 1) { ++JewelFXNum; } else if (item.Value.group == 2) { ++EquipFXNum; } else if (item.Value.group == 3) { ++StrenthFXNum; } } Mogo.Util.EventDispatcher.AddEventListener <int, int>("EquipFXUIActiveBtnUp", OnActiveBtnUp); Mogo.Util.EventDispatcher.AddEventListener <byte, byte>("ActiveSepciaclEffectsResp", OnActiveFXResp); }
public void HideAll(int type) { m_tipQueueList[type].Clear(); if (!HasAnyTip()) { if (m_tempAtlas != null) { //AssetCacheMgr.ReleaseResource(m_tempAtlas.texture); AssetCacheMgr.ReleaseInstance(m_tempAtlas.gameObject, SystemSwitch.DestroyAllUI); m_tempAtlas = null; } if (NormalMainUIViewManager.Instance != null) { NormalMainUIViewManager.Instance.ShowHelpTip(false); } //gameObject.SetActive(false); } else { ShowTip(); } }
public void SetTipRewardList(List <string> listReward) { if (listReward == null) { return; } for (int i = 0; i < listReward.Count; ++i) { int index = i; AssetCacheMgr.GetUIInstance("ProtectGodressTipReward.prefab", (name, id, go) => { GameObject gameObj = (GameObject)go; gameObj.name = string.Concat("ProtectGodressTipReward", index); MFUIUtils.AttachWidget(gameObj.transform, GetTransform("ProtectGodressTipRewardList")); gameObj.transform.localPosition = new Vector3(-520, -GridHeight * index, 0); UILabel lblText = gameObj.transform.FindChild("ProtectGodressTipRewardText").GetComponentsInChildren <UILabel>(true)[0]; lblText.text = listReward[index]; //GameObject goDOT1 = gameObj.transform.FindChild("ProtectGodressTipRewardDOT1").gameObject; //GameObject goDOT2 = gameObj.transform.FindChild("ProtectGodressTipRewardDOT2").gameObject; if (listReward.Count > 5) { GetTransform("ProtectGodressTipRewardListCam").GetComponent <MyDragableCamera>().MINY = OffsetY - (listReward.Count - 5) * GridHeight; } else { GetTransform("ProtectGodressTipRewardListCam").GetComponent <MyDragableCamera>().MINY = OffsetY; } m_listReward.Add(gameObj); }); } }
/// <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 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; } ); }
public void AttachFXToTimeLimitActivityInfoUI(Transform tranFxPos, Action <GameObject> action) { if (m_infoGridListMogoListImproved.SourceCamera == null) { m_infoGridListMogoListImproved.SourceCamera = GameObject.Find("Camera").GetComponentsInChildren <Camera>(true)[0]; } if (m_infoGridListMogoListImproved.ObjCamera == null) { LoggerHelper.Error("m_infoGridListMogoListImproved.ObjCamera is null"); return; } INSTANCE_COUNT++; MogoGlobleUIManager.Instance.ShowWaitingTip(true); if (m_gridTimeLimitActivityListCamera == null) { m_gridTimeLimitActivityListCamera = m_infoGridListMogoListImproved.ObjCamera.GetComponentsInChildren <Camera>(true)[0]; } if (m_gridTimeLimitActivityListCameraFX == null) { GameObject goTimeLimitActivityInfoCameraFx = new GameObject(); goTimeLimitActivityInfoCameraFx.name = "TimeLimitActivityInfoCameraFx"; goTimeLimitActivityInfoCameraFx.transform.parent = m_infoGridListMogoListImproved.ObjCamera.transform; goTimeLimitActivityInfoCameraFx.transform.localPosition = new Vector3(0, 0, 0); goTimeLimitActivityInfoCameraFx.transform.localScale = new Vector3(1, 1, 1); // 设置特效摄像机 m_gridTimeLimitActivityListCameraFX = goTimeLimitActivityInfoCameraFx.AddComponent <Camera>(); m_gridTimeLimitActivityListCameraFX.clearFlags = CameraClearFlags.Depth; m_gridTimeLimitActivityListCameraFX.cullingMask = 1 << 0; m_gridTimeLimitActivityListCameraFX.orthographic = true; m_gridTimeLimitActivityListCameraFX.orthographicSize = m_gridTimeLimitActivityListCamera.orthographicSize; m_gridTimeLimitActivityListCameraFX.nearClipPlane = -50; m_gridTimeLimitActivityListCameraFX.farClipPlane = 50; m_gridTimeLimitActivityListCameraFX.depth = 30; m_gridTimeLimitActivityListCameraFX.rect = m_gridTimeLimitActivityListCamera.rect; } Vector3 pos = m_gridTimeLimitActivityListCamera.WorldToScreenPoint(tranFxPos.position); pos = m_gridTimeLimitActivityListCameraFX.ScreenToWorldPoint(pos); AssetCacheMgr.GetUIInstance("fx_ui_skill_yes.prefab", (prefab, id, go) => { GameObject goFx = null; goFx = (GameObject)go; goFx.name = "TimeLimitActivityInfoFinishedFx"; goFx.transform.parent = m_goTimeLimitActivityInfoGridListFx.transform; goFx.transform.position = pos; goFx.transform.localPosition += new Vector3(3, -120, 0); goFx.transform.localScale = new Vector3(1f, 1f, 1f); INSTANCE_COUNT--; if (INSTANCE_COUNT <= 0) { MogoGlobleUIManager.Instance.ShowWaitingTip(false); } if (action != null) { action(goFx); } }); }
void ReleasePreLoadResrouces() { AssetCacheMgr.ReleaseResourceImmediate("TimeLimitActivityGrid.prefab"); }
public void RefreshWingGridList(System.Collections.Generic.List <WingGridData> dataList) { for (int i = 0; i < gridList.Count; ++i) { AssetCacheMgr.ReleaseInstance(gridList[i].gameObject); } gridList.Clear(); GetTransform("WingUIListDialogGridList").GetComponent <MogoSingleButtonList>().SingleButtonList.Clear(); GetTransform("WingUIListDialogGridListCamera").localPosition = new Vector3(0, -166f, 0); for (int i = 0; i < dataList.Count; ++i) { int index = i; AssetCacheMgr.GetUIInstance("WingUIListDialogGrid.prefab", (name, id, go) => { GameObject gameObj = (GameObject)go; MFUIUtils.AttachWidget(gameObj.transform, GetTransform("WingUIListDialogGridList")); gameObj.transform.localPosition = new Vector3(0, -112 * index, 0); gameObj.GetComponent <MyDragCamera>().RelatedCamera = GetTransform("WingUIListDialogGridListCamera").GetComponent <Camera>(); GetTransform("WingUIListDialogGridList").GetComponent <MogoSingleButtonList>().SingleButtonList.Add( gameObj.GetComponent <MogoSingleButton>()); WingUIGrid uigrid = gameObj.AddComponent <WingUIGrid>(); uigrid.ID = index; WingGridData data = dataList[index]; if (data.IsHave == false) { uigrid.ShowBuyBtn(true); uigrid.ShowUsedSign(false); uigrid.SetWingCost(data.WingPrice); uigrid.SetWingName(data.WingName); uigrid.SetWingStatus(data.WingStatus); uigrid.SetWingDescripte(data.WingDescripe); uigrid.ShowWingLock(false); uigrid.ShowWingProgress(false); uigrid.ShowWingIconBlackWhite(true); uigrid.ShowCost(true); } else { if (data.IsActive == true) { if (data.IsUsing == false) { uigrid.ShowBuyBtn(false); uigrid.ShowUsedSign(false); uigrid.SetWingName(data.WingName); uigrid.SetWingStatus(data.WingStatus); uigrid.SetWingDescripte(data.WingDescripe); uigrid.ShowWingLock(false); //uigrid.ShowWingProgress(false); uigrid.ShowWingProgress(true); uigrid.SetWingProgressText(string.Concat(data.WingCurExp, "/", data.WingTotalExp)); uigrid.SetWingProgressSize((float)data.WingCurExp / (float)data.WingTotalExp); uigrid.ShowWingIconBlackWhite(false); uigrid.ShowCost(false); } else { uigrid.ShowBuyBtn(false); uigrid.ShowUsedSign(true); uigrid.SetWingName(data.WingName); uigrid.SetWingStatus(data.WingStatus); uigrid.SetWingDescripte(data.WingDescripe); uigrid.ShowWingLock(false); uigrid.ShowWingProgress(true); uigrid.SetWingProgressText(string.Concat(data.WingCurExp, "/", data.WingTotalExp)); uigrid.SetWingProgressSize((float)data.WingCurExp / (float)data.WingTotalExp); uigrid.ShowWingIconBlackWhite(false); uigrid.ShowCost(false); } } else { uigrid.ShowBuyBtn(false); uigrid.ShowUsedSign(false); uigrid.SetWingName(data.WingName); uigrid.SetWingStatus(data.WingStatus); uigrid.SetWingDescripte(data.WingDescripe); uigrid.ShowWingLock(true); uigrid.ShowWingProgress(false); uigrid.ShowWingIconBlackWhite(false); uigrid.ShowCost(false); } } if (dataList.Count <= 4) { GetTransform("WingUIListDialogGridListCamera").GetComponent <MyDragableCamera>().MINY = -166f; } else { GetTransform("WingUIListDialogGridListCamera").GetComponent <MyDragableCamera>().MINY = -166f - (dataList.Count - 4) * 112f; } gridList.Add(gameObj); }); } }
/// <summary> /// 创建Grid /// </summary> /// <param name="gridData"></param> /// <param name="theID"></param> public void AddActivityGrid(LimitActivityGridData gridData, int theID) { INSTANCE_COUNT++; MogoGlobleUIManager.Instance.ShowWaitingTip(true); AssetCacheMgr.GetUIInstance("TimeLimitActivityGrid.prefab", (prefab, id, go) => { for (int i = 0; i < m_listActivityGird.Count; ++i) { if (m_listActivityGird[i].Id == theID) { AssetCacheMgr.ReleaseInstance((GameObject)go); return; } } GameObject obj = (GameObject)go; TimeLimitActivityGrid gridUI = obj.AddComponent <TimeLimitActivityGrid>(); obj.name = "TimeLimitActivityGrid" + m_listActivityGird.Count; gridUI.LoadResourceInsteadOfAwake(); gridUI.Id = theID; gridUI.Index = m_listActivityGird.Count; gridUI.CDText = gridData.CDText; gridUI.TitleText = gridData.TitleText; gridUI.GridFGName = gridData.FGImgName; gridUI.SetActivityStatus(gridData.Status); obj.transform.parent = m_goActivityGridList.transform; obj.transform.localPosition = new Vector3(m_listActivityGirdObject.Count * ACTIVITYGRIDWIDTH, 0, -1); obj.transform.localScale = new Vector3(1, 1, 1); m_listActivityGirdObject.Add(obj); m_listActivityGird.Add(gridUI); obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_camActivityGridList.transform.GetComponentsInChildren <Camera>(true)[0]; INSTANCE_COUNT--; if (INSTANCE_COUNT <= 0) { MogoGlobleUIManager.Instance.ShowWaitingTip(false); } if (m_listActivityGirdObject.Count - ActivityGridCountOnePage >= 0) { m_dragableCameraActivityGridList.MAXX = 380 + ACTIVITYGRIDWIDTH * (m_listActivityGirdObject.Count - 3); } else { m_dragableCameraActivityGridList.MAXX = 380; } EventDispatcher.TriggerEvent <int>("LoadTimeLimitActivityGridDone", gridUI.Id); if (obj.name == MogoUIManager.Instance.WaitingWidgetName) { EventDispatcher.TriggerEvent("WaitingWidgetFinished"); } // 创建翻页位置 int index = m_listActivityGirdObject.Count - 1; if (index % ActivityGridCountOnePage == 0) { GameObject trans = new GameObject(); trans.transform.parent = m_camActivityGridList.transform; trans.transform.localPosition = new Vector3(index / ActivityGridCountOnePage * 1140 + 380, 0, 0); trans.transform.localEulerAngles = Vector3.zero; trans.transform.localScale = new Vector3(1, 1, 1); trans.name = "ActivityGridPagePosHorizon" + index / ActivityGridCountOnePage; m_dragableCameraActivityGridList.transformList.Add(trans.transform); m_dragableCameraActivityGridList.SetCurrentPage(0); // 创建页数点 ++m_iActivityGridPageNum; int num = m_iActivityGridPageNum; AssetCacheMgr.GetUIInstance("ChooseServerPage.prefab", (prefabPage, idPage, goPage) => { GameObject objPage = (GameObject)goPage; objPage.transform.parent = m_goGOTimeLimitActivityUIActivityListPage.transform; objPage.transform.localPosition = new Vector3((num - 1) * 40, 0, 0); objPage.transform.localScale = Vector3.one; objPage.name = "ActivityGridPage" + num; m_camActivityGridList.GetComponentsInChildren <MyDragableCamera>(true)[0].ListPageDown.Add(objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject); m_goGOTimeLimitActivityUIActivityListPage.transform.localPosition = new Vector3(-20 * (num - 1), m_goGOTimeLimitActivityUIActivityListPage.transform.localPosition.y, 0); // 选择当前页 if (num - 1 == m_dragableCameraActivityGridList.GetCurrentPage()) { objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(true); } else { objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(false); } m_dragableCameraActivityGridList.GODOTPageList = m_goGOTimeLimitActivityUIActivityListPage; m_dragableCameraActivityGridList.SetCurrentPage(m_dragableCameraActivityGridList.GetCurrentPage()); }); } }); }
public void AddChooseServerGrid(ChooseServerGridData cd) { AssetCacheMgr.GetUIInstance("ChooseServerUIServerBtn.prefab", (prefab, id, go) => { GameObject obj = (GameObject)go; obj.transform.parent = m_goChooseServerGridList.transform; int page = m_listChooseServerGrid.Count / 12; int row = (m_listChooseServerGrid.Count % 12) / 3; int col = (m_listChooseServerGrid.Count % 12) % 3; if (page + 1 > m_iCurrentServerGridPage) { GameObject trans = new GameObject(); trans.transform.parent = m_goChooseServerGridList.transform; trans.transform.localPosition = new Vector3(page * CHOOSESERVERGRIDPAGEWIDTH + CHOOSESERVERGRIDWIDTH, -125, 0); trans.transform.localEulerAngles = Vector3.zero; trans.transform.localScale = new Vector3(1, 1, 1); m_dragableCameraChooseServerGridList.transformList.Add(trans.transform); m_dragableCameraChooseServerGridList.SetArrow(); ++m_iCurrentServerGridPage; } obj.transform.localPosition = new Vector3(page * CHOOSESERVERGRIDPAGEWIDTH + col * CHOOSESERVERGRIDWIDTH, -row * CHOOSESERVERGRIDHEIGHT, 0); obj.transform.localScale = new Vector3(1, 1, 1); obj.AddComponent <MyDragCamera>().RelatedCamera = m_camChooseServerGridList; ChooseServerUIGrid sg = obj.AddComponent <ChooseServerUIGrid>(); sg.Id = m_listChooseServerGrid.Count; sg.ServerName = cd.serverName; sg.ServerStatus = cd.serverStatus; m_listChooseServerGrid.Add(obj); if (m_iChooseServerPageNum < page + 1) { ++m_iChooseServerPageNum; int num = m_iChooseServerPageNum; AssetCacheMgr.GetUIInstance("ChooseServerPage.prefab", (prefabPage, idPage, goPage) => { GameObject objPage = (GameObject)goPage; objPage.transform.parent = m_goChooseServerGridPageList.transform; objPage.transform.localPosition = new Vector3((num - 1) * 40, 0, 0); objPage.transform.localScale = Vector3.one; m_dragableCameraChooseServerGridList.ListPageDown.Add(objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject); m_goChooseServerGridPageList.transform.localPosition += new Vector3(-20 * (num - 1), 0, 0); if (num == 1) { objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(true); } m_listChooseServerGridPage.Add(objPage); }); } }); }
void Awake() { m_instance = this; m_myTransform = transform; FillFullNameData(m_myTransform); Camera cam = GameObject.Find("MogoMainUI").transform.FindChild("Camera").GetComponentsInChildren <Camera>(true)[0]; m_myTransform.FindChild(m_widgetToFullName["ChooseCharacterUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseCharacterUIBottomRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseCharacterUIRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseCharacterUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseCharacterUITopRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUITopLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIBottomRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUILeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterUIBottomRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseServerUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseServerUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["ChooseServerUITopLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_myTransform.FindChild(m_widgetToFullName["CreateCharacterUITopLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam; m_camChooseServerGridList = m_myTransform.FindChild(m_widgetToFullName["ChooseServerUIServerGridListCamera"]).GetComponentsInChildren <Camera>(true)[0]; m_camChooseServerGridList.GetComponentsInChildren <UIViewport>(true)[0].sourceCamera = cam; m_dragableCameraChooseServerGridList = m_camChooseServerGridList.GetComponentsInChildren <MyDragableCamera>(true)[0]; m_dragableCameraChooseServerGridList.LeftArrow = FindTransform("ChooseServerUIArrowL").gameObject; m_dragableCameraChooseServerGridList.RightArrow = FindTransform("ChooseServerUIArrowR").gameObject; m_lblCreateCharacterText = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterUITitleText"]).GetComponentsInChildren <UILabel>(true)[0]; m_lblJobName = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIJobInfoName"]).GetComponentsInChildren <UILabel>(true)[0]; m_lblJobInfo = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIJobInfoDetail"]).GetComponentsInChildren <UILabel>(true)[0]; m_lblCharacterNameInput = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIInput"]).GetComponentsInChildren <UIInput>(true)[0]; m_lblRecommendServerName = m_myTransform.FindChild(m_widgetToFullName["RecommendServerUIServerName"]).GetComponentsInChildren <UILabel>(true)[0]; m_goCreateCharacterDetailUIEnterBtn = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIEnterBtn"]).gameObject; m_lblEnter = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIEnterBtnText"]).GetComponentsInChildren <UILabel>(true)[0]; m_spCreateCharacterDetailUIEnterBtnBGUp = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIEnterBtnBGUp"]).GetComponentsInChildren <UISprite>(true)[0]; m_goCharacterNameInput = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIInput"]).gameObject; m_goRandomBtn = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIRandomBtn"]).gameObject; m_goChooseCharcterGridList = m_myTransform.FindChild(m_widgetToFullName["ChooseCharacterUIList"]).gameObject; m_goJobAttrList = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIJobAttrList"]).gameObject; m_goChooseServerGridList = m_myTransform.FindChild(m_widgetToFullName["ChooseServerUIServerGridList"]).gameObject; m_goCreateCharacterUIBackBtn = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterUIBackBtn"]).gameObject; m_goChooseCharacterUI = m_myTransform.FindChild("ChooseCharacterUI").gameObject; m_goChooseServerUI = m_myTransform.FindChild("ChooseServerUI").gameObject; m_goCreateCharacterDetailUI = m_myTransform.FindChild("CreateCharacterDetailUI").gameObject; m_goCreateCharacterUI = m_myTransform.FindChild("CreateCharacterUI").gameObject; m_goRecommendServerUI = m_myTransform.FindChild("RecommendServerUI").gameObject; m_goChooseServerGridPageList = m_myTransform.FindChild(m_widgetToFullName["ChooseServerPageList"]).gameObject; m_MTBChooseCharacterUIServer = m_myTransform.FindChild("ChooseCharacterUI/ChooseCharacterUIBottomLeft/ChooseCharcterUIServerBtn").GetComponentsInChildren <MogoTwoStatusButton>(true)[0]; m_MTBCreateCharacterUIServer = m_myTransform.FindChild("CreateCharacterUI/CreateCharacterUIBottomRight/CreateCharacterUIServerBtn").GetComponentsInChildren <MogoTwoStatusButton>(true)[0]; m_MTBLatelyLog0 = m_myTransform.FindChild("ChooseServerUI/ChooseServerUILatelyLogBtn0").GetComponentsInChildren <MogoTwoStatusButton>(true)[0]; m_MTBLatelyLog1 = m_myTransform.FindChild("ChooseServerUI/ChooseServerUILatelyLogBtn1").GetComponentsInChildren <MogoTwoStatusButton>(true)[0]; m_goCreateCharacterDetailUIJobIconList = m_myTransform.FindChild(m_widgetToFullName["CreateCharacterDetailUIJobIconList"]).gameObject; m_spResCtrl = m_myTransform.FindChild(m_widgetToFullName["NewLoginUIResCtrl"]).GetComponentsInChildren <UISprite>(true)[0]; m_atlasCanRelease = m_spResCtrl.atlas; m_goCurrentUI = m_goChooseCharacterUI; for (int i = 0; i < 4; ++i) { AssetCacheMgr.GetUIInstance("ChooseCharcterUIGrid.prefab", (prefab, id, go) => { GameObject obj = (GameObject)go; obj.transform.parent = m_goChooseCharcterGridList.transform; obj.transform.localPosition = new Vector3(0, -m_listChooseCharacterGrid.Count * CHOOSECHARACTERGRIDHEIGHT, 0); obj.transform.localScale = new Vector3(1, 1, 1); //obj.GetComponentsInChildren<ChooseCharacterUIGrid>(true)[0].Id = m_listChooseCharacterGrid.Count; obj.AddComponent <ChooseCharacterUIGrid>().Id = m_listChooseCharacterGrid.Count; m_goChooseCharcterGridList.GetComponentsInChildren <MogoSingleButtonList>(true)[0].SingleButtonList.Add(obj.GetComponentsInChildren <MogoSingleButton>(true)[0]); m_listChooseCharacterGrid.Add(obj); if (m_listChooseCharacterGrid.Count == 4) { TruelyFillChooseCharacterGridData(); TruelySetCharacterGridDown(); MogoGlobleUIManager.Instance.ShowWaitingTip(false); } }); } for (int i = 0; i < 3; ++i) { AssetCacheMgr.GetUIInstance("CreateCharacterDetailUIJobAttr.prefab", (prefab, id, go) => { GameObject obj = (GameObject)go; obj.transform.parent = m_goJobAttrList.transform; obj.transform.localPosition = new Vector3(0, -m_listJobAttr.Count * JOBATTRGRIDHEIGHT, 0); obj.transform.localScale = new Vector3(1, 1, 1); obj.AddComponent <CreateCharacterDetailUIJobAttr>(); m_listJobAttr.Add(obj); }); } Initialize(); inited = true; }
public void SetGridLayout <T>(int NewCount, Transform parentTrans, Action loaded) where T : Component { if (width == 0) { width = ColSize * UnitWidth + (ColSize - 1) * XMargin; } if (height == 0) { height = RowSize * UnitHeight + (RowSize - 1) * YMargin; } int PageSize = ColSize * RowSize; MaxPageIndex = (byte)(Math.Ceiling((double)NewCount / PageSize) - 1); int curGridCount = DataGUIDList.Count; if (curGridCount < NewCount) { for (int index = curGridCount; index < NewCount; index++) { var uniqueID = index; var curPage = index / PageSize; var curIndex = index % PageSize; var curRow = curIndex / ColSize; var curCol = curIndex % ColSize; var startPoint = new Vector2(); startPoint = getStartPoint(curPage); zeroPoint = Vector2.zero; var size = IsHorizontal ? ColSize : RowSize; var lastPageNum = NewCount % PageSize == 0 ? PageSize : NewCount % PageSize; var cmr = (NewCount / PageSize - 1) + (lastPageNum >= size ? 1 : lastPageNum % size / (float)size); if (IsHorizontal) { lastPoint = new Vector2(width * IsOpposite * cmr, 0); } else { lastPoint = new Vector2(0, -height * IsOpposite * cmr); } AssetCacheMgr.GetUIInstance(PrefabName + ".prefab", (prefab, id, go) => { GameObject obj = (GameObject)go; obj.transform.parent = parentTrans; obj.transform.localPosition = new Vector3(startPoint.x + (curCol * (XMargin + UnitWidth) + UnitWidth / 2) * IsOpposite , startPoint.y - (curRow * (YMargin + UnitHeight) + UnitHeight / 2) * IsOpposite , 0.0f); obj.transform.localScale = new Vector3(1, 1, 1); if (!IsOneButton) { var btnList = obj.transform.GetComponentsInChildren <MogoButton>(true); foreach (var single in btnList) { single.pressHandler += PressHandler; single.dragHandler += DragHandler; } } DataGUIDList.Push(go); UnityEngine.Component unit = obj.AddComponent <T>(); /****�ֻ�ϵͳ�����ø÷�ʽ��ӿؼ� * if (!unit) * { * var type = Type.GetType(PrefabName); * if (type != null) * unit = obj.AddComponent(type); * } * if (unit == null) * Debug.LogError("SetGridLayout unit is null: " + PrefabName); ****/ DataList.Add(uniqueID, unit); if (DataList.Count == NewCount) { if (loaded != null) { loaded(); } } }); } } else { for (int i = 0; i < curGridCount - NewCount; i++) { DataList.RemoveAt(curGridCount - 1 - i); AssetCacheMgr.ReleaseInstance(DataGUIDList.Pop()); } if (loaded != null) { loaded(); } } }
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 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; } ); }
readonly static int MercenaryPageCount = 3;// 每页显示助阵玩家个数 /// <summary> /// 更新助阵玩家信息(一页N行,上下拖动) /// </summary> /// <param name="mercenaryInfo"></param> /// <returns></returns> //public int UpdateMercenaryList(Dictionary<int, MercenaryInfo> mercenaryInfo) //{ // Debug.Log("friendList.Count" + mercenaryInfo.Count); // ClearMercenaryList(); // // 重置Camera位置 // m_goInstanceHelpChooseUIPlayerListCamera.transform.localPosition = new Vector3(0, 0, 0); // // 删除翻页位置 // if (m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren<MyDragableCamera>(true)[0].transformList != null) // { // for (int i = 0; i < m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren<MyDragableCamera>(true)[0].transformList.Count; ++i) // { // Destroy(m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren<MyDragableCamera>(true)[0].transformList[i].gameObject); // } // m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren<MyDragableCamera>(true)[0].transformList.Clear(); // } // int count = -1; // int ret = 0; // foreach (var item in mercenaryInfo) // { // int index = ++count; // int id = item.Key; // var info = item.Value; // AssetCacheMgr.GetUIInstance("InstanceLevelChooseUIPlayerGrid.prefab", (prefab, guid, go) => // { // if (index == 0) // ret = id; // GameObject temp = (GameObject)go; // temp.transform.parent = m_tranInstancePlayerListCamera.transform; // temp.transform.localPosition = new Vector3(0.25f, -index * 0.08f + 0.268f, 100); // temp.transform.localScale = new Vector3(0.00078f, 0.00078f, 1); // InstanceHelperGrid theGrid = temp.AddComponent<InstanceHelperGrid>(); // if (theGrid != null) // { // theGrid.id = id; // theGrid.SetHelper((Vocation)(info.vocation), info.name, info.level.ToString(), info.fight.ToString(), 0); // to do // } // temp.GetComponentsInChildren<MyDragCamera>(true)[0].RelatedCamera = m_dragCamera; // m_listInstanceMercenary.Add(temp); // InstanceUILogicManager.Instance.CountMercenaryGridCreate(); // // 创建翻页位置 // if (index % MercenaryPageCount == 0) // { // GameObject trans = new GameObject(); // trans.transform.parent = m_goInstanceHelpChooseUIPlayerListCamera.transform; // trans.transform.localPosition = new Vector3(0, index * (-0.08f), 0); // trans.transform.localEulerAngles = Vector3.zero; // trans.transform.localScale = new Vector3(1, 1, 1); // trans.name = "MercenaryPagePos" + index / MercenaryPageCount; // m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren<MyDragableCamera>(true)[0].transformList.Add(trans.transform); // } // }); // } // m_dragCamera.gameObject.GetComponent<MyDragableCamera>().MAXX = (mercenaryInfo.Count - 3) * 0.25f; // return ret; //} /// <summary> /// 更新助阵玩家信息(一页N行,左右拖动) /// </summary> /// <param name="mercenaryInfo"></param> /// <returns></returns> public int UpdateMercenaryList(Dictionary <int, MercenaryInfo> mercenaryInfo) { Debug.Log("friendList.Count" + mercenaryInfo.Count); ClearMercenaryList(); // 重置Camera位置 m_goInstanceHelpChooseUIPlayerListCamera.transform.localPosition = new Vector3(0, 0, 0); // 删除翻页位置 if (m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].transformList != null) { for (int i = 0; i < m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].transformList.Count; ++i) { Destroy(m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].transformList[i].gameObject); } m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].transformList.Clear(); m_listInstanceHelpPlayerGridSet.Clear(); } int count = -1; int ret = 0; int page = (mercenaryInfo.Count - 1) / MercenaryPageCount + 1; foreach (var item in mercenaryInfo) { int index = ++count; int id = item.Key; if (index == 0) { ret = id; } if (index % MercenaryPageCount == 0) { AssetCacheMgr.GetUIInstance("InstanceHelpPlayerGridSet.prefab", (prefab, guid, go) => { GameObject temp = (GameObject)go; temp.transform.parent = m_tranInstancePlayerListCamera.transform; temp.transform.localPosition = new Vector3(index / MercenaryPageCount * 0.362f + 0.255f, 0.22f, 100); temp.transform.localScale = new Vector3(0.00078f, 0.00078f, 1); temp.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_dragCamera; m_listInstanceHelpPlayerGridSet.Add(temp); // 创建翻页位置 if (index % MercenaryPageCount == 0) { GameObject trans = new GameObject(); trans.transform.parent = m_goInstanceHelpChooseUIPlayerListCamera.transform; trans.transform.localPosition = new Vector3(index / MercenaryPageCount * 0.362f, 0, 0); trans.transform.localEulerAngles = Vector3.zero; trans.transform.localScale = new Vector3(1, 1, 1); trans.name = "MercenaryPagePosHorizon" + index / MercenaryPageCount; m_goInstanceHelpChooseUIPlayerListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].transformList.Add(trans.transform); } if (m_listInstanceHelpPlayerGridSet.Count == page) { SetInstanceMercenary(mercenaryInfo); } }); } } m_dragCamera.gameObject.GetComponent <MyDragableCamera>().MAXX = page * 0.362f + 0.255f; return(ret); }
public void ReleaseCharacter() { try { foreach (var item in m_avatarList) { item.Value.ResetFade(); item.Value.RemoveOld(); AssetCacheMgr.ReleaseInstance(item.Value.gameObject); item.Value.Release(); //item.Value.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true)[0].sharedMaterial.shader = // PlayerShader; } m_avatarList.Clear(); AssetCacheMgr.ReleaseResourceImmediate("fx_jqqd.prefab"); #region ��Ч �� ��Чɾ��������ʱ�� foreach (var item in m_fxTimes) { TimerHeap.DelTimer(item.Value); } foreach (var item in m_sfxHandlers) { item.Value.RemoveAllFX(); } m_sfxHandlers.Clear(); m_fxTimes.Clear(); #endregion #region ���� foreach (var item in CharacterInfoData.dataMap) { //if (item.Value.runtimeAnimatorController != null) //{ if (!String.IsNullOrEmpty(item.Value.controller)) { AssetCacheMgr.ReleaseResourceImmediate(item.Value.controller); } //} } m_Animators.Clear(); #endregion //ж��ģ����Դ foreach (var item in AvatarModelData.dataMap) { if (!String.IsNullOrEmpty(item.Value.prefabName) && item.Value.prefabName.EndsWith(".prefab")) { AssetCacheMgr.ReleaseResourceImmediate(item.Value.prefabName); } } MogoFXManager.Instance.RemoveAllShadow(); } catch (Exception ex) { Debug.LogException(ex); } }
public override void CallWhenShow() { EventDispatcher.TriggerEvent(Events.RuneEvent.GetRuneBag); MFUIUtils.ShowGameObject(true, m_myGameObject); //Debug.LogError("DragonEnable"); MogoUIManager.Instance.ShowBillboardList(false); if (MogoMainCamera.instance) { MogoMainCamera.instance.SetActive(false); } MogoUIManager.Instance.GetMainUICamera().clearFlags = CameraClearFlags.SolidColor; //Debug.Log("DamnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnEnable"); if (isFirst) { //���ӳٵĻ���transform.positionȡֵ����ȷ TimerHeap.AddTimer(100, 0, () => { MogoFXManager.Instance.AttachUIFX(5, MogoUIManager.Instance.GetMainUICamera(), 0, 0, 0, null); MogoFXManager.Instance.AttachUIFX(6, MogoUIManager.Instance.GetMainUICamera(), 0, 0, 0, null); isFirst = false; }); } else { MogoFXManager.Instance.ShowUIFX(5, true); MogoFXManager.Instance.ShowUIFX(6, true); } uiCursor.atlas = AtlasCanRelease; if (!SystemSwitch.DestroyResource) { return; } if (m_myTransform.Find("DragonIcon").GetComponentsInChildren <UITexture>(true)[0].mainTexture == null) { AssetCacheMgr.GetResourceAutoRelease("lyfw_ditu.png", (obj) => { m_myTransform.Find("DragonIcon").GetComponentsInChildren <UITexture>(true)[0].mainTexture = (Texture)obj; }); } //if (AtlasCanRelease != null) //{ // if (AtlasCanRelease.spriteMaterial.mainTexture == null) // { // AssetCacheMgr.GetUIResource("MogoDragonUI.png", (obj) => // { // AtlasCanRelease.spriteMaterial.mainTexture = (Texture)obj; // AtlasCanRelease.MarkAsDirty(); // m_myTransform.GetComponent<UIPanel>().enabled = false; // m_myTransform.GetComponent<UIPanel>().enabled = true; // }); // } //} }
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(); } } }); } }); }); }); }