Skip to content

Commit

Permalink
Approach to turn
Browse files Browse the repository at this point in the history
- Random and attribute turn defines
- Shuffle the character list to Random Mode
- Move the camera to the character in the differents turns (if attack or move the character)

Known pending tasks:
- Check if the character is in a playable team
- Check if the character has health
- End the battle
  • Loading branch information
mperez01 committed Apr 10, 2018
1 parent dddf04e commit 897a93c
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 29 deletions.
6 changes: 4 additions & 2 deletions Assets/Scenes/test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.5748171, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -6060,6 +6060,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
character: {fileID: 11400000, guid: 47430d8af55fb254dbd2af8d116d196d, type: 2}
team: {fileID: 11400000, guid: c7870a66a01c2a54e90fa9d468b19807, type: 2}
--- !u!114 &175549501
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -35172,6 +35173,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
character: {fileID: 11400000, guid: 36a63a88f336fee4fbee3ca4e3812861, type: 2}
team: {fileID: 0}
--- !u!114 &930472394
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -56300,7 +56302,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 8a1da15bc40e9ac4897e6f088f39ae14, type: 2}
propertyPath: m_RootOrder
value: 226
value: 225
objectReference: {fileID: 0}
- target: {fileID: 6400000, guid: 8a1da15bc40e9ac4897e6f088f39ae14, type: 2}
propertyPath: m_Mesh
Expand Down
14 changes: 14 additions & 0 deletions Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,18 @@ MonoBehaviour:
minValue: 2
value: 2
isCore: 1
- name: Move Range
id: MVR
description:
maxValue: 4
minValue: 4
value: 4
isCore: 1
- name: Agility
id:
description:
maxValue: 100
minValue: 0
value: 20
isCore: 1
specializedClass: []
40 changes: 36 additions & 4 deletions Assets/TRPGMaker/Database/Characters/NewCharacter(3).asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,40 @@ MonoBehaviour:
name: NewCharacter(3)
inventory: {fileID: 0}
Slots: []
attributes: []
attributes:
- name: Health
id: HP
description:
maxValue: 3
minValue: 3
value: 3
isCore: 1
- name: Move Range
id: MVR
description:
maxValue: 4
minValue: 4
value: 4
isCore: 1
- name: Move Height
id: MVH
description:
maxValue: 2
minValue: 2
value: 2
isCore: 1
- name: Attack Range
id: ATR
description:
maxValue: 3
minValue: 3
value: 3
isCore: 1
- name: AttackHeight
id: ATH
description:
maxValue: 2
minValue: 2
value: 2
isCore: 1
specializedClass: []
height: 0
distance: 0
attackRange: 0
7 changes: 7 additions & 0 deletions Assets/TRPGMaker/Database/Characters/NewCharacter.asset
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@ MonoBehaviour:
minValue: 2
value: 2
isCore: 1
- name: Agility
id:
description:
maxValue: 100
minValue: 0
value: 10
isCore: 1
specializedClass: []
17 changes: 12 additions & 5 deletions Assets/TRPGMaker/Database/Database.asset
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ MonoBehaviour:
minValue: 2
value: 2
isCore: 1
- name: Agility
id:
description:
maxValue: 100
minValue: 0
value: 0
isCore: 1
tags:
- Espada
- Mandoble
Expand Down Expand Up @@ -119,10 +126,10 @@ MonoBehaviour:
value: 3
isCore: 1
_attackHeight:
name: Attack Range
id: ATR
name: AttackHeight
id: ATH
description:
maxValue: 3
minValue: 3
value: 3
maxValue: 2
minValue: 2
value: 2
isCore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,40 @@ MonoBehaviour:
name: New Specialized Class (1)
tags: []
slots: []
attributes: []
attributes:
- name: Health
id: HP
description:
maxValue: 3
minValue: 3
value: 3
isCore: 1
- name: Move Range
id: MVR
description:
maxValue: 4
minValue: 4
value: 4
isCore: 1
- name: Move Height
id: MVH
description:
maxValue: 2
minValue: 2
value: 2
isCore: 1
- name: Attack Range
id: ATR
description:
maxValue: 3
minValue: 3
value: 3
isCore: 1
- name: AttackHeight
id: ATH
description:
maxValue: 2
minValue: 2
value: 2
isCore: 1
formulas: []
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4a7b1fcdece9778478b2575993f98a72, type: 3}
m_Name: NewTeam
m_Name: Prueba
m_EditorClassIdentifier:
name: NewTeam
name: Prueba
id: 0
characters:
- {fileID: 11400000, guid: 36a63a88f336fee4fbee3ca4e3812861, type: 2}
- {fileID: 11400000, guid: caa5b8cc4b5205b4297289922d3b7e33, type: 2}
- {fileID: 11400000, guid: 47430d8af55fb254dbd2af8d116d196d, type: 2}
playable: 1

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 @@ -59,7 +59,7 @@ void OnGUI()
EditorGUILayout.LabelField("Turn type:");
selectedTurnStyle = EditorGUILayout.Popup(selectedTurnStyle, System.Enum.GetNames(typeof(TurnTypes)));
EditorGUILayout.EndHorizontal();

EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Health attribute name:");
selectedHealthAttribte = EditorGUILayout.Popup(selectedHealthAttribte, Database.Instance.attributes.Select(o => o.name).ToArray());
Expand Down
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Resources/Editor.meta

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

10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Resources/PolygonKnights.meta

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

10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Resources/PolygonKnights/Prefabs.meta

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

46 changes: 43 additions & 3 deletions Assets/TRPGMaker/Scripts/Game/CharacterScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using UnityEditor;

public class CharacterScript : MonoBehaviour {

private Vector2 pos;
[SerializeField]
public Character character;
public Team team;

private void Start()
{
Expand All @@ -16,19 +18,57 @@ private void Start()

private void OnGUI()
{
if (character != null && character.attributes.Any(x => x.id == "HP"))
if (character != null)
{
Attribute attribute = character.attributes.Find(x => x.id == "HP");
Attribute attribute = character.attributes.Find(x => x.id == Database.Instance.battleOptions.healthAttribute.id);
var renderer = gameObject.GetComponent<Renderer>();
float height = renderer.bounds.size.y * 15;
pos = Camera.main.WorldToScreenPoint(transform.position);
pos.y = Screen.height - pos.y - height;
GUI.Box(new Rect(pos.x - 50, pos.y - 40, 100, 20), attribute.value + "/" + attribute.maxValue);
}
}
}


void Update()
{

}
}

[CustomEditor(typeof(CharacterScript))]
public class CharacterScriptEditor : Editor
{
private int index = -1;
private CharacterScript characterScript;

private void OnEnable()
{
characterScript = (CharacterScript)target;
if (characterScript.team != null) {
index = Database.Instance.teams.IndexOf(characterScript.team);
}
}

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

SerializedProperty character = serializedObject.FindProperty("character");
EditorGUILayout.PropertyField(character);
characterScript = (CharacterScript)target;

EditorGUI.BeginChangeCheck();

EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Team");
index = EditorGUILayout.Popup(index, Database.Instance.teams.Where(x => x.characters.Exists(y => y.name == characterScript.character.name)).Select(item => item.name).ToArray());
EditorGUILayout.EndHorizontal();

if (EditorGUI.EndChangeCheck()) {
characterScript.team = Database.Instance.teams.Where(x => x.characters.Exists(y => y.name == characterScript.character.name)).ToArray()[index];
}
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
}
Loading

0 comments on commit 897a93c

Please sign in to comment.