protected float DrawItemBasicInfo(float startX, float startY, Collectible item) { TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), item.icon); startX += 65; cont = new GUIContent("Name:", "The collectible name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont); item.itemName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), item.itemName); if (GUI.changed) { UpdateLabel_Collectible(); } cont = new GUIContent("Icon:", "The collectible icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); item.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), item.icon, typeof(Sprite), false); cont = new GUIContent("Prefab:", "The prefab object of the collectible\nClick this to highlight it in the ProjectTab"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), item.gameObject, typeof(GameObject), false); startX -= 65; startY += spaceY * 2; cont = new GUIContent("Trigger Effect:", "The effect object to be spawned when the item is triggered\nThis is entirely optional"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); item.triggerEffectObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.triggerEffectObj, typeof(GameObject), false); cont = new GUIContent(" - AutoDestroy:", "Check if the effect object needs to be removed from the game"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (item.triggerEffectObj != null) { item.destroyTriggerEffect = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.destroyTriggerEffect); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", "")); } cont = new GUIContent(" - EffectDuration:", "The delay in seconds before the effect object is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (item.triggerEffectObj != null && item.destroyTriggerEffect) { item.triggerEffectDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.triggerEffectDuration); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", "")); } return(startY + spaceY); }
private Vector2 DrawAbilityConfigurator(float startX, float startY, FactionAbility ability) { TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), ability.icon); startX += 65; cont = new GUIContent("Name:", "The ability name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += spaceY / 4, width, height), cont); ability.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.name); if (GUI.changed) { UpdateLabel_FactionAbility(); } cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ability.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.icon, typeof(Sprite), false); cont = new GUIContent("AbilityID:", "The ID used to associate a perk item in perk menu to a perk when configuring perk menu manually"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); EditorGUI.LabelField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.prefabID.ToString()); startX -= 65; startY += 10 + spaceY - spaceY / 2; //cachedY=startY; cont = new GUIContent("Only Available Via Perk:", "Check if the ability can only be added by perk "); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ability.onlyAvailableViaPerk = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, widthS, height), ability.onlyAvailableViaPerk); startY += 10; startY = DrawGeneralSetting(startX, startY + spaceY, ability); startY = DrawTargetingSetting(startX, startY + spaceY, ability); startY = DrawAbilityVisualEffect(startX, startY + spaceY, ability); startY = DrawAbilityEffect(startX, startY + spaceY, ability); startY += 10; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Description (for runtime and editor): ", ""); EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont); ability.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 100), ability.desp, style); return(new Vector2(startX, startY + spaceY + 100)); }
private Vector2 DrawPerkConfigurator(float startX, float startY, Perk perk) { TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), perk.icon); startX += 65; cont = new GUIContent("Name:", "The perk name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += spaceY / 4, width, height), cont); perk.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.name); if (GUI.changed) { UpdateLabel_Perk(); } cont = new GUIContent("Icon:", "The perk icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); perk.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.icon, typeof(Sprite), false); cont = new GUIContent("PerkID:", "The ID used to associate a perk item in perk menu to a perk when configuring perk menu manually"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); EditorGUI.LabelField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.prefabID.ToString()); startX -= 65; startY += 10 + spaceY - spaceY / 2; //cachedY=startY; startY = DrawGeneralSetting(startX, startY + spaceY, perk); startY = DrawPerkProperty(startX, startY + spaceY, perk); startY += 10; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Description (for runtime and editor): ", ""); EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont); perk.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 100), perk.desp, style); return(new Vector2(startX, startY + spaceY + 100)); }
protected float DrawUnitReserveAbilities(float startX, float startY, Unit unit) { string text = "Unit Deck Abilities " + (!foldAbilities ? "(show)" : "(hide)"); foldAbilities = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldAbilities, text, foldoutStyle); if (foldAbilities) { startX += 15; if (unit.reserveAbilityIDList.Count > 0) { startY += spaceY; for (int i = 0; i < unit.reserveAbilityIDList.Count; i++) { int index = TBEditor.GetUnitAbilityIndex(unit.reserveAbilityIDList[i]); if (index < 0) { unit.reserveAbilityIDList.RemoveAt(i); i -= 1; continue; } TBEditor.DrawSprite(new Rect(startX + (i * 45), startY, 40, 40), uAbilityDB.abilityList[index - 1].icon); } startY += 45 - spaceY; } cont = new GUIContent("Abilities:", "Abilities in the common deck"); EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont); int count = Mathf.Min(unit.reserveAbilityIDList.Count + 1, 6); for (int i = 0; i < count; i++) { EditorGUI.LabelField(new Rect(startX + 55, startY + spaceY, width, height), "-"); int index = (i < unit.reserveAbilityIDList.Count) ? TBEditor.GetUnitAbilityIndex(unit.reserveAbilityIDList[i]) : 0; index = EditorGUI.Popup(new Rect(startX + 65, startY += spaceY, width, height), index, uAbilityLabel); if (index > 0) { int abID = uAbilityDB.abilityList[index - 1].prefabID; //if(!unit.reserveAbilityIDList.Contains(abID)){ if (i < unit.reserveAbilityIDList.Count) { unit.reserveAbilityIDList[i] = abID; } else { unit.reserveAbilityIDList.Add(abID); } //} } else if (i < unit.reserveAbilityIDList.Count) { unit.reserveAbilityIDList.RemoveAt(i); i -= 1; } if (i < unit.reserveAbilityIDList.Count && GUI.Button(new Rect(startX + 67 + width, startY, 20, height - 1), "-")) { unit.reserveAbilityIDList.RemoveAt(i); i -= 1; } } } return(startY + spaceY); }
protected float DrawUnitBasicStats(float startX, float startY, Unit unit) { TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), unit.iconSprite); startX += 65; //bool enter=Event.current.Equals (Event.KeyboardEvent ("return")); cont = new GUIContent("Name:", "The unit name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont); unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), unit.unitName); //if(enter) UpdateLabel_Unit(); if (GUI.changed) { UpdateLabel_Unit(); } cont = new GUIContent("Icon:", "The unit icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.iconSprite = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.iconSprite, typeof(Sprite), false); cont = new GUIContent("Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.gameObject, typeof(GameObject), false); startX -= 65; startY += spaceY * 2; string text = "Basic Unit Info " + (!foldHitPoint ? "(show)" : "(hide)"); foldHitPoint = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldHitPoint, text, foldoutStyle); if (foldHitPoint) { startX += 15; cont = new GUIContent("HitPoint (HP):", "The unit's base Hit-Point.\nDetermine how much the damage the unit can take before it's destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.defaultHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.defaultHP); cont = new GUIContent(" - Regen (PerTurn):", "HP regeneration rate. The amount of HP to be regenerated each turn"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.HPPerTurn = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.HPPerTurn); //startX+=140; startY=cachedY; startY += 5; cont = new GUIContent("ActionPoint (AP):", "The unit's base Action-Point. Used by the unit to performed various action"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.defaultAP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.defaultAP); cont = new GUIContent(" - Regen (PerTurn):", "AP regeneration rate. The amount of AP to be regenerated each turn"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.APPerTurn = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.APPerTurn); //startX-=140; startY += 5; cont = new GUIContent("Unit Value:", "The value of the unit. Used in unit generation on grid if the limit mode is set to be based on value."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.value = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.value); } return(startY + spaceY); }
void DrawPerkList() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List"); EditorGUILayout.EndHorizontal(); if (showPerkList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { instance.purchasedIDList = new List <int>(); instance.unavailableIDList = new List <int>(); for (int i = 0; i < perkDB.perkList.Count; i++) { instance.unavailableIDList.Add(perkDB.perkList[i].prefabID); } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < perkDB.perkList.Count; i++) { Perk perk = perkDB.perkList[i]; GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TBEditor.DrawSprite(rect, perk.icon, perk.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(perk.name, GUILayout.ExpandWidth(false)); GUILayout.BeginHorizontal(); bool flag = !instance.unavailableIDList.Contains(perk.prefabID) ? true : false; //if(Application.isPlaying) flag=!flag; //switch it around in runtime EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70)); flag = EditorGUILayout.Toggle(flag); if (!Application.isPlaying) { if (flag) { instance.unavailableIDList.Remove(perk.prefabID); } else { if (!instance.unavailableIDList.Contains(perk.prefabID)) { instance.unavailableIDList.Add(perk.prefabID); instance.purchasedIDList.Remove(perk.prefabID); } } } if (!instance.unavailableIDList.Contains(perk.prefabID)) { flag = instance.purchasedIDList.Contains(perk.prefabID); EditorGUILayout.LabelField(new GUIContent("- purchased:", "Check to set the perk as purchased right from the start"), GUILayout.Width(75)); flag = EditorGUILayout.Toggle(flag); if (!flag) { instance.purchasedIDList.Remove(perk.prefabID); } else if (!instance.purchasedIDList.Contains(perk.prefabID)) { instance.purchasedIDList.Add(perk.prefabID); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } }
//private bool showItemList=true; void DrawItemList() { //~ EditorGUILayout.BeginHorizontal(); //~ EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); //~ showPerkList=EditorGUILayout.Foldout(showItemList, "Show Collectible List"); //~ EditorGUILayout.EndHorizontal(); //~ if(showItemList){ EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { //instance.purchasedIDList=new List<int>(); instance.unavailableIDList = new List <int>(); for (int i = 0; i < collectibleDB.collectibleList.Count; i++) { instance.unavailableIDList.Add(collectibleDB.collectibleList[i].prefabID); } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < collectibleDB.collectibleList.Count; i++) { Collectible item = collectibleDB.collectibleList[i]; GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TBEditor.DrawSprite(rect, item.icon, item.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(item.name, GUILayout.ExpandWidth(false)); GUILayout.BeginHorizontal(); bool flag = !instance.unavailableIDList.Contains(item.prefabID) ? true : false; //if(Application.isPlaying) flag=!flag; //switch it around in runtime EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the item in this level"), GUILayout.Width(70)); flag = EditorGUILayout.Toggle(flag); if (!Application.isPlaying) { if (flag) { instance.unavailableIDList.Remove(item.prefabID); } else { if (!instance.unavailableIDList.Contains(item.prefabID)) { instance.unavailableIDList.Add(item.prefabID); } } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } //} }
protected float DrawGeneralSetting(float startX, float startY, Perk perk) { string text = "General Setting " + (!foldGeneral ? "(show)" : "(hide)"); foldGeneral = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldGeneral, text, foldoutStyle); if (foldGeneral) { startX += 15; cont = new GUIContent("Cost:", "How many perk currency is required to purchase the perk"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); perk.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.cost); cont = new GUIContent("Min PerkPoint req:", "Minimum perk point to have before the perk becoming available"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); perk.minPerkPoint = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.minPerkPoint); startY += 5; cont = new GUIContent("Prerequisite Perk:", "Perks that needs to be purchased before this perk is unlocked and become available"); EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont); for (int i = 0; i < perk.prereq.Count + 1; i++) { EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-"); int index = (i < perk.prereq.Count) ? TBEditor.GetPerkIndex(perk.prereq[i]) : 0; index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 20, height), index, perkLabel); if (index > 0) { int perkID = perkDB.perkList[index - 1].prefabID; if (perkID != perk.prefabID && !perk.prereq.Contains(perkID)) { if (i < perk.prereq.Count) { perk.prereq[i] = perkID; } else { perk.prereq.Add(perkID); } } } else if (i < perk.prereq.Count) { perk.prereq.RemoveAt(i); i -= 1; } if (i < perk.prereq.Count && GUI.Button(new Rect(startX + spaceX + width - 15, startY, 20, height - 1), "-")) { perk.prereq.RemoveAt(i); i -= 1; } } if (perk.prereq.Count > 0) { startY += spaceY + 5; for (int i = 0; i < perk.prereq.Count; i++) { int index = TBEditor.GetPerkIndex(perk.prereq[i]) - 1; TBEditor.DrawSprite(new Rect(startX + (i * 45), startY, 40, 40), perkDB.perkList[index].icon); } startY += 45 - spaceY; } } return(startY + spaceY); }
protected Vector2 DrawList(float startX, float startY, float winWidth, float winHeight, List <Item> list, bool drawRemove = true, bool shiftItem = true, bool clampSelectID = true) { float width = minimiseList ? 60 : 260; if (!minimiseList && shiftItem) { if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up")) { if (shiftItemUpCallback != null) { shiftItemUpCallback(); } else { Debug.Log("call back is null"); } if (selectID * 35 < scrollPosList.y) { scrollPosList.y = selectID * 35; } } if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down")) { if (shiftItemDownCallback != null) { shiftItemDownCallback(); } else { Debug.Log("call back is null"); } if (visibleRectList.height - 35 < selectID * 35) { scrollPosList.y = (selectID + 1) * 35 - visibleRectList.height + 5; } } } visibleRectList = new Rect(startX, startY, width + 15, winHeight - startY - 5); contentRectList = new Rect(startX, startY, width, list.Count * 35 + 5); GUI.color = new Color(.8f, .8f, .8f, 1f); GUI.Box(visibleRectList, ""); GUI.color = Color.white; scrollPosList = GUI.BeginScrollView(visibleRectList, scrollPosList, contentRectList); startY += 5; startX += 5; for (int i = 0; i < list.Count; i++) { TBEditor.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), list[i].icon); if (minimiseList) { if (selectID == i) { GUI.color = new Color(0, 1f, 1f, 1f); } if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), "")) { Select(i); } GUI.color = Color.white; continue; } if (selectID == i) { GUI.color = new Color(0, 1f, 1f, 1f); } if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150 + (!drawRemove ? 60 : 0), 30), list[i].name)) { Select(i); } GUI.color = Color.white; if (!drawRemove) { continue; } if (deleteID == i) { if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel")) { deleteID = -1; } GUI.color = Color.red; if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm")) { if (selectID >= deleteID) { Select(Mathf.Max(0, selectID - 1)); } if (deleteItemCallback != null) { deleteItemCallback(); } else { Debug.Log("callback is null"); } deleteID = -1; } GUI.color = Color.white; } else { if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove")) { deleteID = i; } } } GUI.EndScrollView(); if (clampSelectID) { selectID = Mathf.Clamp(selectID, 0, list.Count - 1); } return(new Vector2(startX + width + 10, startY)); }