Skip to content

Commit

Permalink
Skills in-game drawing and selector
Browse files Browse the repository at this point in the history
Added in-game selectable cells for skills
Added skill IsoTexture
Skills editor
Connector options editor
  • Loading branch information
WyrnCael committed May 19, 2018
1 parent fe663c3 commit 68cf54a
Show file tree
Hide file tree
Showing 27 changed files with 433 additions and 57 deletions.
1 change: 1 addition & 0 deletions Assets/Scenes/test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -31475,6 +31475,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
moveCell: {fileID: 11400000, guid: 1285aa62ffa004945b03dfbda9cf0afd, type: 2}
attackCell: {fileID: 11400000, guid: e7bd64f3e7f95d54289deccf42920283, type: 2}
skillCell: {fileID: 11400000, guid: 121fd29bd24ece6439bdf3010f2e1b41, type: 2}
arrowDecoration: {fileID: 11400000, guid: 0db37da799e54d5458c420331560f165, type: 2}
--- !u!43 &771847860
Mesh:
Expand Down
19 changes: 19 additions & 0 deletions Assets/SkillCell.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c453d041690ab642b6e517807c4ef31, type: 3}
m_Name: SkillCell
m_EditorClassIdentifier:
realTexture: {fileID: 2800000, guid: ee93a90737cf8724cbd5c661141efdaf, type: 3}
xCorner: 0
yCorner: 0
isXSimetric: 0
isYSimetric: 0
rotation: 0
10 changes: 10 additions & 0 deletions Assets/SkillCell.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Assets/TRPGMaker/Database/Characters/NewCharacter.asset
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ MonoBehaviour:
value: 0
attributesWithFormulas:
- _attribute: {fileID: 11400000, guid: 570466ba20bcf074aa9cb2a7bc75d9aa, type: 2}
maxValue: 0
maxValue: 20
minValue: 0
value: 0
value: 20
- _attribute: {fileID: 11400000, guid: 2bacf50ce194d1b46b929529f5723ad4, type: 2}
maxValue: 0
maxValue: 23
minValue: 0
value: 21
- _attribute: {fileID: 11400000, guid: 7a51ab61027fe2842b7277a93add2237, type: 2}
Expand Down
5 changes: 4 additions & 1 deletion Assets/TRPGMaker/Database/Database.asset
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ MonoBehaviour:
- {fileID: 11400000, guid: e7f127d3314f50841893ffe7a2ef77e7, type: 2}
teams:
- {fileID: 11400000, guid: ff36771f8c32cc64b9f083fbe542428e, type: 2}
skills: []
skills:
- {fileID: 11400000, guid: 6140f844d2699c34183175b8e0937e5e, type: 2}
- {fileID: 11400000, guid: 58c4a5f649a699b4282451a006428fc1, type: 2}
- {fileID: 11400000, guid: 347122fdaa7394b4baf27c18b79176bb, type: 2}
_TRPGOptions:
_gameType: 0
_turnType: 0
Expand Down
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Database/Skills.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/TRPGMaker/Database/Skills/NewSkill(1).asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2fcfda68e797b224485786ca9e52d4b9, type: 3}
m_Name: NewSkill(1)
m_EditorClassIdentifier:
name: Area
description:
skillType: 1
areaRange: 4
formulas: []
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/TRPGMaker/Database/Skills/NewSkill(2).asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2fcfda68e797b224485786ca9e52d4b9, type: 3}
m_Name: NewSkill(2)
m_EditorClassIdentifier:
name: Target
description:
skillType: 0
areaRange: 0
formulas: []
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/TRPGMaker/Database/Skills/NewSkill.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2fcfda68e797b224485786ca9e52d4b9, type: 3}
m_Name: NewSkill
m_EditorClassIdentifier:
name: Area Objetive
description: new skill
skillType: 2
areaRange: 3
formulas: []
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ MonoBehaviour:
minValue: 0
value: 0
formula: {fileID: 0}
skills: []
skills:
- {fileID: 11400000, guid: 347122fdaa7394b4baf27c18b79176bb, type: 2}
- {fileID: 11400000, guid: 58c4a5f649a699b4282451a006428fc1, type: 2}
- {fileID: 11400000, guid: 6140f844d2699c34183175b8e0937e5e, type: 2}
21 changes: 21 additions & 0 deletions Assets/TRPGMaker/Editor/ConnectorEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(IsoUnityOptions))]
public class ConnectorEditor : Editor
{

private static readonly string[] _dontIncludeMe = new string[] { "m_Script" };

public override void OnInspectorGUI()
{
serializedObject.Update();

DrawPropertiesExcluding(serializedObject, _dontIncludeMe);

serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
}
13 changes: 13 additions & 0 deletions Assets/TRPGMaker/Editor/ConnectorEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 86 additions & 2 deletions Assets/TRPGMaker/Editor/SkillsEditor.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,84 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;

[CustomEditor(typeof(Skills))]
public class SkillsEditor : Editor {

private static readonly string[] _dontIncludeMe = new string[] { "m_Script" };
//private static readonly string[] _dontIncludeMe = new string[] { "m_Script" };
private ReorderableList listFormulas;
private Texture2D removeTexture;
int indexFormula;
private GUIStyle removeStyle;

private void OnEnable()
{
Skills skill = (Skills)target;

// Remove button
removeTexture = (Texture2D)Resources.Load("Buttons/remove", typeof(Texture2D));

// Get Formulas
listFormulas = new ReorderableList(serializedObject,
serializedObject.FindProperty("formulas"),
true, true, true, true);

// Draw formulas
listFormulas.drawElementCallback =
(Rect rect, int index, bool isActive, bool isFocused) => {
//var element = listFormulas.serializedProperty.GetArrayElementAtIndex(index);
var formula = skill.formulas[index];
rect.y += 2;

indexFormula = Database.Instance.attributes.IndexOf(Database.Instance.attributes.Find(x => x.id == formula.attributeID));

EditorGUI.BeginChangeCheck();
indexFormula = EditorGUI.Popup(new Rect(rect.x, rect.y, 50, EditorGUIUtility.singleLineHeight), indexFormula, Database.Instance.attributes.Select(x => x.id).ToArray());

EditorGUI.LabelField(new Rect(rect.x + 55, rect.y, 10, EditorGUIUtility.singleLineHeight), "=", EditorStyles.boldLabel);

formula.formula = EditorGUI.TextField(new Rect(rect.x + 70, rect.y, rect.width - 98, EditorGUIUtility.singleLineHeight), formula.formula);

bool removed = false;
if (GUI.Button(new Rect(rect.width, rect.y, 16, 16), new GUIContent("", removeTexture), removeStyle))
{
skill.formulas.Remove(skill.formulas[index]);
removed = true;
}

var f = FormulaScript.Create(formula.formula);
if (!removed && !f.FormulaParser.IsValidExpression)
{
EditorGUI.LabelField(new Rect(rect.x + 70, rect.y + EditorGUIUtility.singleLineHeight + 2.0f, rect.width, EditorGUIUtility.singleLineHeight), f.FormulaParser.Error);
}

if (!removed && EditorGUI.EndChangeCheck())
formula.attributeID = Database.Instance.attributes[indexFormula].id;
};

listFormulas.elementHeight = (EditorGUIUtility.singleLineHeight * 2) + 4.0f;

// listFormulas header
listFormulas.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "Formulas");
};

// Add formula
listFormulas.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
skill.formulas.Add(new Formula());
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
};

// Remove formula
listFormulas.onRemoveCallback = (ReorderableList l) => {
skill.formulas.Remove(skill.formulas[l.index]);
serializedObject.ApplyModifiedProperties();
};
}

public override void OnInspectorGUI()
{
Expand All @@ -17,7 +89,19 @@ public override void OnInspectorGUI()
customStyle.fontSize = 17;
GUI.Label(new Rect(EditorGUILayout.GetControlRect().x, EditorGUILayout.GetControlRect().y, EditorGUILayout.GetControlRect().width, 30), "Editing \"" + ((Skills)target).name + "\" skill:", customStyle);

DrawPropertiesExcluding(serializedObject, _dontIncludeMe);
EditorGUILayout.PropertyField(serializedObject.FindProperty("name"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("description"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("skillType"));
//DrawPropertiesExcluding(serializedObject, _dontIncludeMe);

Skills skill = (Skills) target;

if (skill.skillType.ToString().Contains("AREA"))
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("areaRange"));
}

listFormulas.DoLayoutList();

serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void OnGUI()
}
else {
Editor editor = Editor.CreateEditor(objects[0]);
editor.DrawDefaultInspector();
editor.OnInspectorGUI();
}
}

Expand Down
Binary file added Assets/TRPGMaker/Resources/SkillCell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Assets/TRPGMaker/Resources/superheroe.png
Binary file not shown.
Loading

0 comments on commit 68cf54a

Please sign in to comment.