protected bool showVar; //temp bool value for variable depending on (enable/disable flag such as anchor-down, destroy effect) protected Vector2 DrawUnitBaseStats(float startX, float startY, Unit unit, bool isPlayer) { TDSEditorUtility.DrawSprite(new Rect(startX, startY, 60, 60), unit.icon); startX += 65; float offsetY = TDSEditor.IsPrefab(unit.gameObject) ? 5 : 0; cont = new GUIContent("Name:", "The unit name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += offsetY, width, height), cont); unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), unit.unitName); 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.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), unit.icon, typeof(Sprite), false); if (TDSEditor.IsPrefab(unit.gameObject)) { 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 - 5, height), unit.gameObject, typeof(GameObject), false); } else { EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX - 65, height + 5), "The unit being edited is not a prefab", MessageType.Warning); startY += 5; } startX -= 65; startY += spaceY; EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Basic Stats", headerStyle); startY += 5; cont = new GUIContent("Hit Point:", "The hit-point capacity of the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.hitPointFull = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hitPointFull); unit.startHitPointAtFull = EditorGUI.Toggle(new Rect(startX + spaceX + 50, startY, 40, height), unit.startHitPointAtFull); EditorGUI.LabelField(new Rect(startX + spaceX + 65, startY, width, height), " - start at full"); cont = new GUIContent("Hit Point Regen:", "The amount of hit-point regenerated per second"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.hpRegenRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hpRegenRate); cont = new GUIContent("Hit Point Stagger:", "The duration in second in which the hit-point regen would stop after the unit being hit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.hpRegenRate > 0) { unit.hpRegenStagger = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hpRegenStagger); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-"); } if (isPlayer) { startY += 10; cont = new GUIContent("Energy:", "The energy capacity of the unit"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.energyFull = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.energyFull); unit.startEnergyAtFull = EditorGUI.Toggle(new Rect(startX + spaceX + 50, startY, 40, height), unit.startEnergyAtFull); EditorGUI.LabelField(new Rect(startX + spaceX + 65, startY, width, height), " - start at full"); cont = new GUIContent("Energy Rate:", "The rate (per second) in which the energy will recharge"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.energyRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.energyRate); } startY += 10; cont = new GUIContent("Armor Type:", "The armor type of the unit\nArmor type can be configured in Damage Armor Table Editor"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (armorTypeLabel.Length > 0) { unit.armorType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.armorType, armorTypeLabel); } else { if (GUI.Button(new Rect(startX + spaceX, startY, 83, height - 2), "Add Type")) { DamageTableEditorWindow.Init(); } } return(new Vector2(startX, startY)); }
//not in used, wip /* * protected Vector2 DrawAttackStats(string propertyName, float startX, float startY, SerializedObject aStats, bool showAOE=true, bool showPhysics=true, string label="Attack Stats"){ * * EditorGUI.LabelField(new Rect(startX, startY, width+50, height), label, headerStyle); startY+=spaceY; * * string pf="attackStats."; * //SerializedProperty spas= aStats.FindProperty("attackStats"); * SerializedProperty spas= aStats.FindProperty(propertyName); * string lbSp=" - "; * * cont=new GUIContent(lbSp+"Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor"); * EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); * if(damageTypeLabel.Length>0){ * srlPpt=spas.FindPropertyRelative("damageType"); * EditorGUI.showMixedValue=srlPpt.hasMultipleDifferentValues; * //Debug.Log(srlPpt.intValue+" "+srlPpt.hasMultipleDifferentValues); * EditorGUI.BeginChangeCheck(); * int value=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), srlPpt.intValue, damageTypeLabel); * if(EditorGUI.EndChangeCheck()) srlPpt.intValue=value; * EditorGUI.showMixedValue=false; * * //aStats.damageType=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), aStats.damageType, damageTypeLabel); * } * else{ * if(GUI.Button(new Rect(startX+spaceX, startY, 83, height-2), "Add Type")) DamageTableEditorWindow.Init(); * } * * cont=new GUIContent(lbSp+"Damage (Min/Max):", "Damage value done to the target's hit-point."); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"damageMin"), contN); * EditorGUI.PropertyField(new Rect(startX+spaceX+42, startY, 40, height), aStats.FindProperty(pf+"damageMax"), contN); * * startY+=10; * * if(showAOE){ * cont=new GUIContent(lbSp+"AOE Radius:", "Area of effect radius of the attack. Any hostile unit within the area is affected by the attack"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"aoeRadius"), contN); * * cont=new GUIContent(lbSp+"Diminishing AOE22:", "Check if damage value diminished the further away the target is from the center of the aoe"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * if(aStats.FindProperty(pf+"aoeRadius").floatValue>0) * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"diminishingAOE")); * else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-"); * * startY+=10; * } * * cont=new GUIContent(lbSp+"Critical Chance:", "The chance of the attack to score a critical. Takes value from 0-1 with 0.3 being 30% to score a critical"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"critChance"), contN); * * cont=new GUIContent(lbSp+"Critical Multiplier:", "The multiplier to be applied to damage if the attack scores a critical.\n - 1.5 for 150% of normal damage, 2 for 200% and so on"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"critChance"), contN); * if(aStats.FindProperty(pf+"critChance").floatValue>0) * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"critMultiplier"), contN); * else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-"); * * startY+=10; * * if(showPhysics){ * cont=new GUIContent(lbSp+"Impact Force:", "If the attack will applies a knock back force to the target\nOnly applies if the attack is a direct hit from a shoot object"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"impactForce"), contN); * * cont=new GUIContent(lbSp+"Explosion Radius:", "The radius in which all unit is affected by explosion force"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"explosionRadius"), contN); * * cont=new GUIContent(lbSp+"Explosion Force:", "The force of the explosion which pushes all affect unit away from the impact point"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); * if(aStats.FindProperty(pf+"explosionRadius").floatValue>0) * EditorGUI.PropertyField(new Rect(startX+spaceX, startY, 40, height), aStats.FindProperty(pf+"explosionRadius"), contN); * else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-"); * } * * startY+=30; * * srlPpt=aStats.FindProperty(pf+"effectID"); * EditorGUI.showMixedValue=srlPpt.hasMultipleDifferentValues; * int effectIdx=srlPpt.intValue>=0 ? TDSEditor.GetEffectIndex(srlPpt.intValue) : 0 ; * * if(!srlPpt.hasMultipleDifferentValues) * TDSEditorUtility.DrawSprite(new Rect(startX+spaceX+width-40, startY+spaceY-45, 40, 40), effectIdx>0 ? effectDB.effectList[effectIdx-1].icon : null); * if(GUI.Button(new Rect(startX+spaceX, startY-2, 40, height-2), "Edit")) EffectEditorWindow.Init(); * * cont=new GUIContent(lbSp+"Attack Effect:", "Special effect that applies with each hit (optional)"); * EditorGUI.LabelField(new Rect(startX, startY+=spaceY-5, width, height), cont); * * EditorGUI.BeginChangeCheck(); * effectIdx=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), effectIdx, effectLabel); * if(EditorGUI.EndChangeCheck()){ * if(effectIdx>0) srlPpt.intValue=effectDB.effectList[effectIdx-1].ID; * else srlPpt.intValue=-1; * } * EditorGUI.showMixedValue=false; * * return new Vector2(startX, startY); * } */ protected Vector2 DrawAttackStats1(float startX, float startY, AttackStats aStats, bool showAOE = true, bool showPhysics = true, string label = "Attack Stats") { EditorGUI.LabelField(new Rect(startX, startY, width + 50, height), label, headerStyle); startY += spaceY; string lbSp = " - "; cont = new GUIContent(lbSp + "Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); if (damageTypeLabel.Length > 0) { aStats.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), aStats.damageType, damageTypeLabel); } else { if (GUI.Button(new Rect(startX + spaceX, startY, 83, height - 2), "Add Type")) { DamageTableEditorWindow.Init(); } } cont = new GUIContent(lbSp + "Damage (Min/Max):", "Damage value done to the target's hit-point."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); aStats.damageMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.damageMin); aStats.damageMax = EditorGUI.FloatField(new Rect(startX + spaceX + 42, startY, 40, height), aStats.damageMax); startY += 10; if (showAOE) { cont = new GUIContent(lbSp + "AOE Radius:", "Area of effect radius of the attack. Any hostile unit within the area is affected by the attack"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); aStats.aoeRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.aoeRadius); //used in pre-version1.2, dimishingAOE is wrongly spelt //cont=new GUIContent(lbSp+"Diminishing AOE:", "Check if damage value diminished the further away the target is from the center of the aoe"); //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); //if(aStats.aoeRadius>0) aStats.dimishingAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), aStats.dimishingAOE); //else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-"); cont = new GUIContent(lbSp + "Diminishing AOE:", "Check if damage value diminished the further away the target is from the center of the aoe"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (aStats.aoeRadius > 0) { aStats.diminishingAOE = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), aStats.diminishingAOE); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-"); } startY += 10; } cont = new GUIContent(lbSp + "Critical Chance:", "The chance of the attack to score a critical. Takes value from 0-1 with 0.3 being 30% to score a critical"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); aStats.critChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.critChance); cont = new GUIContent(lbSp + "Critical Multiplier:", "The multiplier to be applied to damage if the attack scores a critical.\n - 1.5 for 150% of normal damage, 2 for 200% and so on"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (aStats.critChance > 0) { aStats.critMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.critMultiplier); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-"); } startY += 10; if (showPhysics) { cont = new GUIContent(lbSp + "Impact Force:", "If the attack will applies a knock back force to the target\nOnly applies if the attack is a direct hit from a shoot object"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); aStats.impactForce = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.impactForce); cont = new GUIContent(lbSp + "Explosion Radius:", "The radius in which all unit is affected by explosion force"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); aStats.explosionRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.explosionRadius); cont = new GUIContent(lbSp + "Explosion Force:", "The force of the explosion which pushes all affect unit away from the impact point"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (aStats.explosionRadius > 0) { aStats.explosionForce = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), aStats.explosionForce); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-"); } } startY += 30; int effectIdx = aStats.effectID >= 0 ? TDSEditor.GetEffectIndex(aStats.effectID) : 0; TDSEditorUtility.DrawSprite(new Rect(startX + spaceX + width - 40, startY + spaceY - 45, 40, 40), effectIdx > 0 ? effectDB.effectList[effectIdx - 1].icon : null); if (GUI.Button(new Rect(startX + spaceX, startY - 2, 40, height - 2), "Edit")) { EffectEditorWindow.Init(); } cont = new GUIContent(lbSp + "Attack Effect:", "Special effect that applies with each hit (optional)"); EditorGUI.LabelField(new Rect(startX, startY += spaceY - 5, width, height), cont); effectIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effectIdx, effectLabel); if (effectIdx > 0) { aStats.effectID = effectDB.effectList[effectIdx - 1].ID; } else { aStats.effectID = -1; } return(new Vector2(startX, startY)); }
public static void OpenDamageTableEditor() { DamageTableEditorWindow.Init(); }