Skip to content

Commit

Permalink
IA Move and Attack: decissions and actions
Browse files Browse the repository at this point in the history
- IA move decissions (nearest character)
- IA atomatically shows move and attack area and select the destination
cell.
- IA atomatically moves and attack.
- Team editor fixed.
  • Loading branch information
WyrnCael committed Apr 11, 2018
1 parent 88ae815 commit 1a2fa5f
Show file tree
Hide file tree
Showing 14 changed files with 388 additions and 266 deletions.
2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MonoBehaviour:
description:
maxValue: 250
minValue: 0
value: 250
value: 500
isCore: 1
- name: Move Height
id: MVH
Expand Down
2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MonoBehaviour:
description:
maxValue: 250
minValue: 0
value: 250
value: 500
isCore: 1
- name: Move Range
id: MVR
Expand Down
2 changes: 1 addition & 1 deletion Assets/TRPGMaker/Database/Characters/NewCharacter.asset
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MonoBehaviour:
description:
maxValue: 250
minValue: 0
value: 250
value: 500
isCore: 1
- name: Move Range
id: MVR
Expand Down
4 changes: 2 additions & 2 deletions Assets/TRPGMaker/Database/Database.asset
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 496024b31fb8d604ba8b12317f0d4762, type: 2}
- {fileID: 11400000, guid: bac31a58c9f786c4a9d5b67034ba5482, type: 2}
teams:
- {fileID: 11400000, guid: 6997cfd5caffcfe4c874c9f0ac22d59b, type: 2}
- {fileID: 11400000, guid: 6c8f21e3fb66c0346a2b2cc371eb3219, type: 2}
- {fileID: 11400000, guid: 15bb40f2e1f0dd04a8ec14b3c2bb0cc4, type: 2}
- {fileID: 11400000, guid: edbd6fc84edad7749b2192b14449f153, type: 2}
_TRPGOptions:
_gameType: 0
_turnType: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4a7b1fcdece9778478b2575993f98a72, type: 3}
m_Name: EnemyTea
m_Name: NewTeam(1)
m_EditorClassIdentifier:
name: EnemyTeam
name: NewTeam(1)
id: 0
characters:
- {fileID: 11400000, guid: 3eca2b4789a5bc44abd112d60d4af688, type: 2}
Expand Down

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 @@ -9,9 +9,9 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4a7b1fcdece9778478b2575993f98a72, type: 3}
m_Name: PlayerTeam
m_Name: NewTeam
m_EditorClassIdentifier:
name: PlayerTeam
name: NewTeam
id: 0
characters:
- {fileID: 11400000, guid: 36a63a88f336fee4fbee3ca4e3812861, type: 2}
Expand Down

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

14 changes: 11 additions & 3 deletions Assets/TRPGMaker/Editor/TeamEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ private void OnEnable()
listCharacters = new ReorderableList(serializedObject,
serializedObject.FindProperty("characters"),
true, true, true, true);

// Draw characters
listCharacters.drawElementCallback =
(Rect rect, int index, bool isActive, bool isFocused) => {
var element = listCharacters.serializedProperty.GetArrayElementAtIndex(index);
Character character = element.objectReferenceValue as Character;

rect.y += 2;

EditorGUI.LabelField(
new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight),
character.name);
Expand Down Expand Up @@ -51,6 +51,14 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

// Clean array if there are null objects
for (int i = 0; i < listCharacters.serializedProperty.arraySize; i++)
{
var elementProperty = listCharacters.serializedProperty.GetArrayElementAtIndex(i);
if (elementProperty.objectReferenceValue == null)
listCharacters.serializedProperty.DeleteArrayElementAtIndex(i);
}

var customStyle = new GUIStyle();
customStyle.alignment = TextAnchor.UpperCenter;
customStyle.fontSize = 17;
Expand Down Expand Up @@ -78,6 +86,6 @@ private void clickHandlerCharacters(object target)
{
var data = (Character)target;
((Team)this.target).characters.Add(data);
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(this.target);
}
}
3 changes: 3 additions & 0 deletions Assets/TRPGMaker/Scripts/Connectors/ITRPGMapConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ public interface ITRPGMapConnector {
void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback);
void triggerAnimation(Character character, Cell cell);
CharacterScript GetCharacterAtCell(Cell cell);
Cell GetCellAtCharacter(CharacterScript character);

// IA Methods
List<CharacterScript> GetAttackRangeTargets(CharacterScript character);
List<Cell> GetPathFromCharToChar(CharacterScript character, CharacterScript target);
void IAAttack(CharacterScript character, CharacterScript target, ShowAreaCallBack callback);
void IAMove(CharacterScript character, Cell destiny, MoveCharacterToCallBack callback);
}
Loading

0 comments on commit 1a2fa5f

Please sign in to comment.