public void Init() { if (init) { return; } init = true; //if(!enablePerk) return; //loading the perks from DB List <Perk> dbList = Perk_DB.Load(); for (int i = 0; i < dbList.Count; i++) { if (!unavailableIDList.Contains(dbList[i].ID)) { Perk perk = dbList[i].Clone(); perkList.Add(perk); } } for (int i = 0; i < perkList.Count; i++) { perkList[i].SetPlayer(player); } StartCoroutine(UnlockPurchasedPerk()); }
public static Perk_DB Init() { if (instance != null) { return(instance); } instance = LoadDB(); return(instance); }
public static void LoadPerk() { perkDB = Perk_DB.LoadDB(); for (int i = 0; i < perkDB.perkList.Count; i++) { if (perkDB.perkList[i] != null) { //perkDB.perkList[i].ID=i; perkIDList.Add(perkDB.perkList[i].ID); } else { perkDB.perkList.RemoveAt(i); i -= 1; } } UpdateLabel_Perk(); TDSEditorWindow.SetPerkDB(perkDB, perkIDList, perkLabel); TDSEditorInspector.SetPerkDB(perkDB, perkIDList, perkLabel); }
public static void SetPerkDB(Perk_DB db, List <int> IDList, string[] label) { perkDB = db; perkIDList = IDList; perkLabel = label; }
public override bool OnGUI() { if (!base.OnGUI()) { return(true); } if (window == null) { Init(); } List <Perk> perkList = perkDB.perkList; Undo.RecordObject(this, "window"); Undo.RecordObject(perkDB, "PerkDB"); if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save")) { SetDirtyTDS(); } if (!Perk_DB.UpdatedToPost_2018_3()) { GUI.color = new Color(0, 1f, 1f, 1f); if (GUI.Button(new Rect(Math.Max(260, window.position.width - 230), 5, 100, 25), "Copy Old DB")) { Perk_DB.CopyFromOldDB(); Select(0); } GUI.color = Color.white; } if (GUI.Button(new Rect(5, 5, 120, 25), "Create New")) { Select(NewItem()); } if (perkList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected")) { Select(NewItem(selectID)); } float startX = 5; float startY = 55; if (minimiseList) { if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>")) { minimiseList = false; } } else { if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<")) { minimiseList = true; } } Vector2 v2 = DrawPerkList(startX, startY, perkList); startX = v2.x + 25; if (perkList.Count == 0) { return(true); } Rect visibleRect = new Rect(startX, startY, window.position.width - startX - 10, window.position.height - startY - 5); Rect contentRect = new Rect(startX, startY, contentWidth - startY, contentHeight); scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); startY = DrawPerkConfigurator(startX, startY, perkList[selectID]); contentWidth = 360; contentHeight = startY - 55; GUI.EndScrollView(); if (GUI.changed) { SetDirtyTDS(); } return(true); }