public static void SavePerk() { GameObject obj = Resources.Load("PrefabList/PerkTBListPrefab", typeof(GameObject)) as GameObject; if (obj == null) { Debug.Log("load perk fail, make sure the resource file exists"); return; } PerkTBListPrefab prefab = obj.GetComponent <PerkTBListPrefab>(); prefab.perkTBList = perkList; }
public static List<PerkTB> Load() { GameObject obj=Resources.Load("PrefabList/PerkTBListPrefab", typeof(GameObject)) as GameObject; if(obj==null) obj=CreatePrefab(); prefab=obj.GetComponent<PerkTBListPrefab>(); if(prefab==null) prefab=obj.AddComponent<PerkTBListPrefab>(); perkList=prefab.perkTBList; foreach(PerkTB perk in perkList){ perkIDList.Add(perk.ID); } return perkList; }
public static List <PerkTB> Load() { GameObject obj = Resources.Load("PrefabList/PerkTBListPrefab", typeof(GameObject)) as GameObject; if (obj == null) { obj = CreatePrefab(); } prefab = obj.GetComponent <PerkTBListPrefab>(); if (prefab == null) { prefab = obj.AddComponent <PerkTBListPrefab>(); } perkList = prefab.perkTBList; foreach (PerkTB perk in perkList) { perkIDList.Add(perk.ID); } return(perkList); }
/* * void OnGUI(){ * * int startX=10; * int startY=10; * * GUI.Label(new Rect(startX, startY, 150, 25), "perk point: "+perkPoint); * startY+=30; * * for(int i=0; i<perkList.Count; i++){ * PerkTB perk=perkList[i]; * if(perk.unlocked){ * GUI.Label(new Rect(startX, startY, 100, 25), perk.name); * } * else{ * if(perk.IsAvailable()){ * if(GUI.Button(new Rect(startX, startY, 100, 25), perk.name)){ * UnlockPerk(perk); * } * } * else{ * GUI.Box(new Rect(startX, startY, 100, 25), perk.name); * } * } * startY+=30; * } * * if(GUI.Button(new Rect(startX, startY+30, 100, 25), "reset all")){ * ResetPerk(); * } * } */ public static void LoadPerk() { GameObject obj = Resources.Load("PrefabList/PerkTBListPrefab", typeof(GameObject)) as GameObject; if (obj == null) { Debug.Log("load perk fail, make sure the resource file exists"); return; } PerkTBListPrefab prefab = obj.GetComponent <PerkTBListPrefab>(); perkList = prefab.perkTBList; if (!instance.usePersistentData) { for (int i = 0; i < perkList.Count; i++) { perkList[i] = perkList[i].Clone(); } } //check local perk, synchronice the list, set the lock/unlock list for (int i = 0; i < perkList.Count; i++) { PerkTB perk = perkList[i]; for (int j = 0; j < instance.localPerkList.Count; j++) { PerkTB localPerk = instance.localPerkList[j]; if (perk.ID == localPerk.ID) { if (!localPerk.availableInScene) { perkList.RemoveAt(i); i -= 1; } else { if (localPerk.startingState == _StartingState.Locked) { perk.unlocked = false; } else if (localPerk.startingState == _StartingState.Unlocked) { perk.unlocked = true; } else if (localPerk.startingState == _StartingState.Default) { } } break; } } } //re-'unlocked' unlocked perk, to register the perk point and etc. for (int i = 0; i < perkList.Count; i++) { if (perkList[i].unlocked) { UnlockPerk(perkList[i], false); } } }