public void PlaySaiZi(int banker, int[] dices) { ResourcesMgr rm = ResourcesMgr.GetInstance(); GameObject hand = rm.InstantiateGameObjectWithType("AnShaiZiHand", ResourceType.Hand); hand.GetComponent <PlayDicAnimationClick>().SetSaiZiNumber(dices); Transform tm = hand.transform; switch (banker) { case 0: tm.position = new Vector3(-0.101f, -0.015f, 0.607f); tm.rotation = Quaternion.Euler(Vector3.zero); break; case 1: tm.position = new Vector3(-0.611f, -0.015f, -0.103f); tm.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); break; case 2: tm.position = new Vector3(0.106f, -0.015f, -0.613f); tm.rotation = Quaternion.Euler(new Vector3(0, -180, 0)); break; case 3: tm.position = new Vector3(0.614f, -0.015f, 0.101f); tm.rotation = Quaternion.Euler(new Vector3(0, 90, 0)); break; } hand.GetComponent <Animation>().Play("ananniu"); }
/// <summary> /// 粒子特效加载公共方法 /// </summary> /// <param name="internalTime"></param> /// <param name="strParticalEffectPath">粒子特效路径</param> /// <param name="IsUseCache">是否使用缓存</param> /// <param name="particalEffectPosition">粒子特效方位</param> /// <param name="tranParent"></param> /// <param name="strAudioEffect"></param> /// <param name="destroyTime"></param> /// <returns></returns> protected IEnumerator LoadParticalEffectPublicMethod(float internalTime, string strParticalEffectPath, bool IsUseCache, Vector3 particalEffectPosition, Transform tranParent, string strAudioEffect = null, float destroyTime = 0) { //间隔时间 yield return(new WaitForSeconds(internalTime)); //提取的粒子预设 GameObject goParticalPrefab = ResourcesMgr.GetInstance().LoadAsset(strParticalEffectPath, IsUseCache); //粒子预设的位置 goParticalPrefab.transform.position = particalEffectPosition; //父子对象 if (tranParent != null) { goParticalPrefab.transform.parent = tranParent; } //特效音频 if (!string.IsNullOrEmpty(strAudioEffect)) { AudioManager.PlayAudioEffectA(strAudioEffect); } //销毁时间 if (destroyTime > 0) { Destroy(goParticalPrefab, destroyTime); } }
private void Awake() { dicFormsPath = new Dictionary <string, string>(); dicAllUIForms = new Dictionary <string, BaseUIForm>(); dicCurrentShowUIForms = new Dictionary <string, BaseUIForm>(); staCurrentUIForms = new Stack <BaseUIForm>(); canvasTransform = ResourcesMgr.GetInstance().LoadAsset("Prefabs/Canvas", false).transform; normalTransform = canvasTransform.Find("Normal"); fixedTransform = canvasTransform.Find("Fixed"); popUpTransform = canvasTransform.Find("PopUp"); scriptMgr = canvasTransform.Find("ScriptMgr"); if (canvasTransform == null || normalTransform == null || fixedTransform == null || popUpTransform == null || scriptMgr == null) { throw new System.Exception("初始化失败"); } canvasTransform.SetParent(transform); dicFormsPath.Add("LogonUIForm", "Prefabs/LogonUIForm"); dicFormsPath.Add("SelectHeroUIForm", "Prefabs/SelectHeroUIForm"); dicFormsPath.Add("MainCityUIForm", "Prefabs/MainCityUIForm"); dicFormsPath.Add("HeroInfoUIForm", "Prefabs/HeroInfoUIForm"); dicFormsPath.Add("MarketUIForm", "Prefabs/MarketUIForm"); dicFormsPath.Add("ClotheUIForm", "Prefabs/ClotheUIForm"); }
public void SetMoHandCard(int id, GameObject go = null) { if (id == -1) { id = INVALID_ID; } if (go == null) { go = ResourcesMgr.GetInstance().LoadMJ(id); } if (_MoHand != null) { Debug.LogError("[" + seatindex + "]SetMoHandCard error!!!!!!!!!"); } _MoHand = new HandCardItem(id, go); GameObject obj = _MoHand.getObj(); obj.layer = m_handCard_layer; obj.tag = tagValue; obj.transform.SetParent(_MoHandPos); obj.transform.rotation = _MoHandPos.rotation; obj.transform.position = _MoHandPos.TransformPoint(0.0731f * offSetX, 0, 0); }
public ModelUnit CreateModel(string modelName, Vector3 pos = default(Vector3), float scaleFactor = 1, bool setPos = false) { string modelPath = null; GameObject modelObj = null; ModelUnit unit = null; if (modelName.EndsWith("Ui")) { modelName = modelName.Substring(0, modelName.Length - 2); } modelPathDic.TryGetValue(modelName, out modelPath); if (!string.IsNullOrEmpty(modelPath)) { modelObj = ResourcesMgr.GetInstance().LoadAsset(modelPath, false); modelObj.transform.SetParent(modelRoot); } if (modelObj != null) { modelObjDic.TryGetValue(modelObj.GetInstanceID(), out unit); if (unit == null) { unit = new ModelUnit(); unit.isUiModel = false; unit.SetModelObj(modelObj, modelName); unit.SetSelfPosSize(pos, scaleFactor, setPos); modelObjDic.Add(modelObj.GetInstanceID(), unit); } } return(unit); }
public override void StartLoad(string UIName, UIOpenScreenParameterBase param = null) { mStrUIName = UIName; mOpenParam = param; ResourcesMgr.GetInstance().LoadAsset <GameObject>("InputListener", InputListenerLoadComplete); ResourcesMgr.GetInstance().LoadAsset <GameObject>(UIName, PanelLoadComplete); }
void showFlowers() { RoomMgr rm = RoomMgr.GetInstance(); List <int> flowers = rm.seats[seatindex].flowers; int cnt = flowers.Count; int childs = _flowerPlace.childCount; for (int i = 0; i < childs; i++) { Transform tm = _flowerPlace.GetChild(i); tm.localPosition = new Vector3(offSetX * (cnt - i), 0, 0); } for (int i = childs; i < cnt; i++) { int id = flowers[i]; GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id); obj.layer = LayerMask.NameToLayer("ZhuoPai"); obj.gameObject.tag = tagValue; Transform tm = obj.transform; tm.SetParent(_flowerPlace); tm.localRotation = Quaternion.Euler(-90, 0, 0); tm.localPosition = new Vector3(offSetX * (cnt - i), 0, 0); tm.localScale = new Vector3(0.1f, 0.1f, 0.1f); } }
public void sync() { List <int> folds = RoomMgr.GetInstance().seats [seatindex].folds; ResetInfo(); for (int i = 0; i < folds.Count; i++) { int id = folds [i] % 100; bool ting = folds [i] > 100; GameObject ob = ResourcesMgr.GetInstance().LoadMJ(id); HandCardItem item = new HandCardItem(id, ob); int row = getRow(i); int col = getCol(i); ob.layer = LayerMask.NameToLayer("ZhuoPai"); ob.transform.SetParent(this.transform); ob.transform.localRotation = Quaternion.Euler(new Vector3(-90, 0, 0)); ob.transform.localPosition = new Vector3(offSetX * col, 0, offSetZ * row + 0.0098f); //ob.transform.Translate(offSetX * col, 0, offSetZ * row); if (ting) { item.setTing(true); } _RecyleHandCardList.Add(item); } }
IEnumerator _exit(float delay) { while (syncQueue.Count > 0) { yield return(new WaitForEndOfFrame()); } ReplayMgr rm = ReplayMgr.GetInstance(); GameMgr gm = GameMgr.GetInstance(); RoomMgr room = RoomMgr.GetInstance(); ResourcesMgr.GetInstance().release(); rm.clear(); gm.Reset(); room.reset(); if (delay > 0) { PUtils.setTimeout(() => { LoadingScene.LoadNewScene("02.lobby"); }, delay); } else { LoadingScene.LoadNewScene("02.lobby"); } }
/// <summary> /// 加载指定名字的“UI窗口” /// 1.根据“UI窗口”的名称,加载预制克隆 /// 2.根据不同预制克隆体带的脚本中不同的“位置信息”,加载到“根窗体”下的不同节点 /// 3.隐藏创建的UI克隆体 /// 4.把克隆加入到“所有UI窗体”(缓存)集合中 /// </summary> /// <param name="uriFormName"></param> /// <returns></returns> private BaseUIForm LoadUIForm(string uriFormName) { Debug.Log("LoadUIForm:" + uriFormName); string strUIFormPath = null; //UI窗体的路径 GameObject goCloneUIPrefabs = null; //创建的UI窗体克隆 BaseUIForm baseUIForm = null; //窗体基类 //根据UI窗体名称,得到对应的加载路径 _dicFormsPaths.TryGetValue(uriFormName, out strUIFormPath); //根据“UI窗体”名称,加载预制克隆体 if (!string.IsNullOrEmpty(strUIFormPath)) { goCloneUIPrefabs = ResourcesMgr.GetInstance().LoadAsset(strUIFormPath, false); } else { Debug.LogError("JSON中未定义的窗口"); } //根据克隆体中带的脚本中的不同信息,设计Ui克隆的父节点 if (_traCanvasTransform != null && goCloneUIPrefabs != null) { baseUIForm = goCloneUIPrefabs.GetComponent <BaseUIForm>(); if (baseUIForm == null) { Debug.LogError("JSON定义的路径找不到窗口预制"); return(null); } switch (baseUIForm.CurrentUIType.UIForm_Type) { case UIFormType.Normal: //普通窗体 goCloneUIPrefabs.transform.SetParent(_traNormal, false); break; case UIFormType.Fixed: //固定窗体 goCloneUIPrefabs.transform.SetParent(_traFixed, false); break; case UIFormType.Popup: //弹出窗体 goCloneUIPrefabs.transform.SetParent(_traPopUp, false); break; default: break; } //隐藏克隆 goCloneUIPrefabs.SetActive(false); //加入克隆到“所有UI窗体(缓存)”集合中 _dicAllUIForms.Add(uriFormName, baseUIForm); return(baseUIForm); } else { Debug.Log("_traCanvasTransform == null OR goCloneUIPrefab == null, uriFormName = " + uriFormName); } Debug.Log("Unkown, uriFormName = " + uriFormName); return(null); }
public void SetSelet(string path) { if (isSelect) { GameObject item = ResourcesMgr.GetInstance().LoadAsset(path, true); SetSelet(item); } }
void OnCheckABResourceCallback(bool isfinish) { Debug.Log("OnCheckABResourceCallback isfinish=" + isfinish); if (isfinish) { ResourcesMgr.GetInstance(); } }
//主角升级 private void HeroLevelUp() { //提取升级粒子预设 GameObject HeroLevelUp = ResourcesMgr.GetInstance().LoadAsset("ParticleProps/Hero_LvUp", true); //音效 AudioManager.PlayAudioEffectA("LevelUp"); }
/// <summary> /// 根据类型和路径返回相应的资源(异步方法) /// </summary> /// <param name="path"></param> /// <param name="t"></param> public static void LoadAsync(string path, Type type, Action <Object, string> callback) { #if UNITY_EDITOR && !SIMULATE_MODE Debug.LogError("This Function is not implement in UnityEditor!"); #else ResourcesMgr.GetInstance().LoadAsync(path, type, callback); #endif }
/// <summary> /// 加载指定名称的“UI窗体” /// 功能: /// 1:根据“UI窗体名称”,加载预设克隆体。 /// 2:根据不同预设克隆体中带的脚本中不同的“位置信息”,加载到“根窗体”下不同的节点。 /// 3:隐藏刚创建的UI克隆体。 /// 4:把克隆体,加入到“所有UI窗体”(缓存)集合中。 /// /// </summary> /// <param name="uiFormName">UI窗体名称</param> private BaseUIForm LoadUIForm(string uiFormName) { string strUIFormPaths = null; //UI窗体路径 GameObject goCloneUIPrefabs = null; //创建的UI克隆体预设 BaseUIForm baseUiForm = null; //窗体基类 //根据UI窗体名称,得到对应的加载路径 _DicFormsPaths.TryGetValue(uiFormName, out strUIFormPaths); //根据“UI窗体名称”,加载“预设克隆体” if (!string.IsNullOrEmpty(strUIFormPaths)) { goCloneUIPrefabs = ResourcesMgr.GetInstance().LoadAsset(strUIFormPaths, false); } //设置“UI克隆体”的父节点(根据克隆体中带的脚本中不同的“位置信息”) if (_TraCanvasTransfrom != null && goCloneUIPrefabs != null) { baseUiForm = goCloneUIPrefabs.GetComponent <BaseUIForm>(); if (baseUiForm == null) { Debug.Log("baseUiForm==null! ,请先确认窗体预设对象上是否加载了baseUIForm的子类脚本! 参数 uiFormName=" + uiFormName); return(null); } switch (baseUiForm.CurrentUIType.UIForms_Type) { case UIFormType.Normal: //普通窗体节点 goCloneUIPrefabs.transform.SetParent(_TraNormal, false); break; case UIFormType.Fixed: //固定窗体节点 goCloneUIPrefabs.transform.SetParent(_TraFixed, false); break; case UIFormType.PopUp: //弹出窗体节点 goCloneUIPrefabs.transform.SetParent(_TraPopUp, false); break; default: break; } //设置隐藏 goCloneUIPrefabs.SetActive(false); if (!_DicALLUIForms.ContainsKey(uiFormName)) { //把克隆体,加入到“所有UI窗体”(缓存)集合中。 _DicALLUIForms.Add(uiFormName, baseUiForm); } return(baseUiForm); } else { Debug.Log("_TraCanvasTransfrom==null Or goCloneUIPrefabs==null!! ,Plese Check!, 参数uiFormName=" + uiFormName); } Debug.Log("出现不可以预估的错误,请检查,参数 uiFormName=" + uiFormName); return(null); } //Mehtod_end
/// <summary> /// 加载指定名称UI窗体 /// 功能: /// 1.根据“UI窗体枚举”,加载预设克隆体 /// 2.根据不同预设克隆体中带的脚本中不同的“位置信息”,加载到根窗体下不同的节点 /// 3.隐藏刚创建的UI克隆体 /// 4.把克隆体加入到所有UI窗体的缓存集合中 /// </summary> /// <param name="winType">UI窗体枚举</param> /// <returns></returns> private BaseUIForms LoadUIForm(EM_WinType winType) { string strUIFormPath = null; //UI窗体的查询路径 GameObject goCloneUIPrefab = null; //创建的UI克隆体 BaseUIForms baseUiForms = null; //窗体基类 //根据UI窗体名称,得到对应的加载路径 _DictionaryPaths.TryGetValue(winType, out strUIFormPath); //根据UI窗体名称,加载预设克隆体 if (!string.IsNullOrEmpty(strUIFormPath)) { goCloneUIPrefab = ResourcesMgr.GetInstance().LoadAsset(strUIFormPath, false); } else { LogMgr.GetInstance().Log(LogEnum.Error, "加载UI窗体出错,没有找到" + winType.ToString() + "窗口的路径"); return(null); } //设置UI克隆体的父节点 根据克隆体中带的脚本中不同的“位置信息” if (_TraCanvasTranform != null && goCloneUIPrefab != null) { baseUiForms = goCloneUIPrefab.GetComponent <BaseUIForms>(); //得到这个克隆体里面的BaseUIForms脚本 if (baseUiForms == null) { LogMgr.GetInstance().Log(LogEnum.Error, "baseUIForms为空,请先确认窗体预设对象是否已经加载了子类脚本,UIFormName=" + winType.ToString()); return(null); } if (baseUiForms.GetUIType() == UIFormType.Full) { goCloneUIPrefab.transform.SetParent(_TraNormal, false); } else if (baseUiForms.GetUIType() == UIFormType.PopUp) { goCloneUIPrefab.transform.SetParent(_TraPopUp, false); } //设置隐藏 初始时应该是隐藏的,因为不知道需不需要一开始就显示 goCloneUIPrefab.SetActive(false); //把克隆体加入到所有UI窗体缓存集合中 if (!_DicAllUiFormses.ContainsKey(winType)) { _DicAllUiFormses.Add(winType, baseUiForms); } return(baseUiForms); } return(null); }
/// <summary> /// 初始化皮肤 /// </summary> protected virtual void OnInitSkin() { if (!string.IsNullOrEmpty(mainSkinPath)) { _skin = ResourcesMgr.GetInstance().CreateGameObject(mainSkinPath, false); } _skin.transform.parent = this.transform; _skin.transform.localEulerAngles = Vector3.zero; _skin.transform.localScale = Vector3.one; _skin.transform.localPosition = Vector3.zero; }
/// <summary> /// 初始化游戏核心 /// </summary> public void InitGameCore(GameObject gameObject) { //初始化各种管理器 resourceMgr = ResourcesMgr.GetInstance(); gameLauncherObj = gameObject; sceneMgr = gameObject.AddComponent <SceneMgr>(); audioManager = AudioManager.Instance; inputMgr = gameLauncherObj.AddComponent <InputMgr>(); GameStart(); }
void logout() { ReplayMgr rm = ReplayMgr.GetInstance(); GameMgr gm = GameMgr.GetInstance(); RoomMgr room = RoomMgr.GetInstance(); ResourcesMgr.GetInstance().release(); rm.clear(); gm.Reset(); room.reset(); LoadingScene.LoadNewScene("01.login"); }
public void Test() { gameObject.SetActive(true); //ResourcesMgr.GetInstance().LoadSprite("Texture/SelfIcon", (obj) => //{ // m_img.sprite = obj as Sprite; //}); ResourcesMgr.GetInstance().LoadAsset("Localization_Sprite/cn/Main/icon_shangdian", (obj) => { m_img.sprite = (obj as GameObject).GetComponent <SpriteRenderer>().sprite; }); }
private void ShowAssetUpdateUI() { ResourcesMgr.GetInstance().LoadResourcesAsset("Prefabs/UI/TestAssetUpdatePanel", (go) => { if (go == null) { Debug.LogError("ShowAssetUpdateUI Fail,Not Exit"); return; } GameObject uiPrefab = GameObject.Instantiate(go) as GameObject; m_UITestAssetUpdateView = uiPrefab.GetAddComponent <UITestAssetUpdateView>(); }); }
/// <summary> /// 打开遮罩面板 /// </summary> /// <param name="screen">遮罩所需的参数,会根据param来设置关联的页面</param> public void Show(ScreenBase screen) { if (goAutoMask == null) { ResourcesMgr.GetInstance().LoadAsset <GameObject>("UIAutoMask", (ao) => { goAutoMask = ao; AttachEvent(screen); }); } else { AttachEvent(screen); } }
void onGameSync() { ResourcesMgr.GetInstance().StopAllHands(); DHM_CardManager[] cms = PlayerManager.GetInstance().getCardManagers(); foreach (DHM_CardManager cm in cms) { cm.sync(); } RoomMgr rm = RoomMgr.GetInstance(); InteractMgr.GetInstance().checkChuPai(rm.isMyTurn()); }
public GameObject CreatePengGangCard(int id, Vector3 pos, Quaternion q) { //GameObject obj = Instantiate(go, new Vector3(0, 0, 0), Quaternion.identity, pengGangArea) as GameObject; GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id); obj.transform.SetParent(pengGangArea); obj.transform.localPosition = pos; obj.transform.localRotation = q; //obj.GetComponent<HandCard> ().setID (id); //RuleManager.m_instance.UVoffSet(id,obj); AddToList(id, obj); obj.layer = LayerMask.NameToLayer("PengPai"); return(obj); }
void Start() { _MainCamera = Camera.main.gameObject.GetComponent <Camera>(); _UICamera = GameObject.FindGameObjectWithTag("UICamera").GetComponent <Camera>(); _EnemyProperty = gameObject.GetComponent <EnemyProperty>(); //加载敌人血条 _EnemyHPBar = ResourcesMgr.GetInstance().LoadAsset("Prefabs/UI/EnemyHPBar", true); _EnemyHPBar.transform.parent = GameObject.FindGameObjectWithTag("BattleSceneUI").transform; //血条尺寸 _EnemyHPBar.transform.localScale = new Vector3(_EnemyHPBarLength, _EnemyHPBarHeight, 0); if (_EnemyHPBar != null) { _EnemyHPSlider = _EnemyHPBar.GetComponent <Slider>(); } }
/// <summary> /// 根据类型和路径返回相应的资源(同步方法) /// </summary> /// <param name="path"></param> /// <param name="type"></param> /// <returns></returns> public static Object Load(string path, Type type) { #if UNITY_EDITOR && !SIMULATE_MODE path = GloablDefine.GameAssetBasePath + path; if (Path.HasExtension(path)) { return(AssetDatabase.LoadAssetAtPath(path, type)); } else { Debug.LogWarning("资源加载的路径不合法!"); return(null); } #else return(ResourcesMgr.GetInstance().Load(path, type)); #endif }
void Start() { playGrid = GetComponent <FlexGrid2D> (); if (!string.IsNullOrEmpty(corePath)) { GameObject core = ResourcesMgr.GetInstance().LoadAsset(corePath, false); SetGridItem(core, Vector2Int.zero); } screenSpaceZ = Camera.main.WorldToScreenPoint(transform.position).z; //选择效果 selectEffect = ResourcesMgr.GetInstance().LoadAsset(ShipConst.selectPath, false); MyTools.SetObjActive(selectEffect, false); srShowGrid = traShowGrid.GetComponent <SpriteRenderer> (); SetSize(1, 2, 4, 3); bulletPool = BulletPool.GetObjectPool(preBullet, bulletCount); path = Application.streamingAssetsPath + @"/Config/PlayerShip.json"; }
HandCardItem GetRandomHandCardItem(int id) { int cnt = _handCardList.Count; System.Random rd = new System.Random(); int start = _MoHand != null ? -1 : 0; int off = rd.Next(start, cnt); HandCardItem item = null; if (-1 == off) { item = _MoHand; } else { item = _handCardList[off]; } GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id); obj.layer = m_handCard_layer; obj.gameObject.tag = tagValue; obj.transform.SetParent(_HandCardPlace); HandCardItem card = new HandCardItem(id, obj); obj.transform.localPosition = item.getObj().transform.localPosition; obj.transform.localRotation = item.getObj().transform.localRotation; if (-1 == off) { _MoHand = card; } else { _handCardList[off] = card; } item.destroy(); return(card); }
public GameObject GetChuPaiWay() { ResourcesMgr rm = ResourcesMgr.GetInstance(); int way = Random.Range(1, 3); GameObject hand = null; way = 2; // TODO if (way == 1) { hand = rm.InstantiateGameObjectWithType("ChuPaiHand1", ResourceType.Hand); hand.transform.position = this.transform.TransformPoint(-0.0809f, -0.0141f, 0.4405f); return(hand); } else { hand = rm.InstantiateGameObjectWithType("ChuPaiHand2", ResourceType.Hand); hand.transform.position = this.transform.TransformPoint(-0.1367f, -0.0131f, 0.505f); return(hand); } }
/// <summary> /// 加载游戏一开始便需要加载的数据(同步) /// </summary> /// <param name="callback"></param> public void LoadStartConfig(Action callback) { //this.callback = callback; //this.isAsync = false; if (null != startLoadDic) { using (var enumerator = startLoadDic.GetEnumerator()) { while (enumerator.MoveNext()) { ResourcesMgr.GetInstance().LoadText(GetFilePath(enumerator.Current.Key), enumerator.Current.Key, TextLoadCallBack); } } if (null != callback) { callback(); } } }