protected override void ShiftItemDown() { if (selectID < CreepDB.GetList().Count - 1) { ShiftItem(1); } }
public void UpdateUnitList() { List <GenItem> newItemList = new List <GenItem>(); List <UnitCreep> unitList = CreepDB.GetList(); for (int i = 0; i < unitList.Count; i++) { int idx = -1; for (int n = 0; n < genItemList.Count; n++) { if (genItemList[n].unitPrefabID == unitList[i].prefabID) { idx = n; break; } } if (idx < 0) { newItemList.Add(new GenItem(unitList[i])); newItemList[i].SetAllOverride(true); } else { newItemList.Add(genItemList[idx]); } } genItemList = newItemList; }
private void ShiftItem(int dir) { UnitCreep creep = CreepDB.GetList()[selectID]; CreepDB.GetList()[selectID] = CreepDB.GetList()[selectID + dir]; CreepDB.GetList()[selectID + dir] = creep; selectID += dir; }
private void SelectItem(int newID) { selectID = newID; if (CreepDB.GetList().Count <= 0) { return; } selectID = Mathf.Clamp(selectID, 0, CreepDB.GetList().Count - 1); UpdateObjHierarchyList(CreepDB.GetList()[selectID].transform); }
private int _NewItem(UnitCreep creep) { if (CreepDB.GetList().Contains(creep)) { return(selectID); } creep.prefabID = TDE.GenerateNewID(CreepDB.GetPrefabIDList()); CreepDB.GetList().Add(creep); CreepDB.UpdateLabel(); return(CreepDB.GetList().Count - 1); }
public void OnGUI() { TDE.InitGUIStyle(); if (!CheckIsPlaying()) { return; } if (window == null) { Init(); } List <UnitCreep> creepList = CreepDB.GetList(); Undo.RecordObject(this, "window"); Undo.RecordObject(CreepDB.GetDB(), "creepDB"); if (creepList.Count > 0) { Undo.RecordObject(creepList[selectID], "creep"); } if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save")) { TDE.SetDirty(); } UnitCreep newCreep = null; TDE.Label(5, 7, 150, 17, "Add New Creep:", "Drag creep prefab to this slot to add it to the list"); newCreep = (UnitCreep)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newCreep, typeof(UnitCreep), false); if (newCreep != null) { Select(NewItem(newCreep)); } 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 = DrawCreepList(startX, startY, creepList); startX = v2.x + 25; if (creepList.Count == 0) { return; } Rect visibleRect = new Rect(startX, startY, window.position.width - startX, window.position.height - startY); Rect contentRect = new Rect(startX, startY, contentWidth, contentHeight); scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); v2 = DrawUnitConfigurator(startX, startY, creepList[selectID]); contentWidth = v2.x - startX; contentHeight = v2.y - 55; GUI.EndScrollView(); if (GUI.changed) { TDE.SetDirty(); } }
protected override void DeleteItem() { CreepDB.GetList().RemoveAt(deleteID); CreepDB.UpdateLabel(); }