Skip to content

Commit

Permalink
ITRPGMapConnector, GamePlayManager and IsoUnityConnector
Browse files Browse the repository at this point in the history
- ITRPGMapConnector interface "implemented"
- GetCharacterAtCell method in IsoUnityConnector  implemented
- GamePlayManager totally independent of IsoUnity
- Starting GamePlayManager methods (Create canvas menu, moveEvent and
attackEvent completed; Turn prepared)
- LifeBar improved
  • Loading branch information
WyrnCael committed Mar 27, 2018
1 parent 0b48b3e commit f6daca4
Show file tree
Hide file tree
Showing 46 changed files with 243 additions and 157 deletions.
2 changes: 1 addition & 1 deletion Assets/Scenes/test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -6059,7 +6059,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 53999f937d6643b42949d28bcda1a943, type: 3}
m_Name:
m_EditorClassIdentifier:
character: {fileID: 11400000, guid: 36a63a88f336fee4fbee3ca4e3812861, type: 2}
character: {fileID: 11400000, guid: 47430d8af55fb254dbd2af8d116d196d, type: 2}
--- !u!114 &175549501
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
7 changes: 4 additions & 3 deletions Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ MonoBehaviour:
- name: Health
id: HP
description:
maxValue: 100
maxValue: 200
minValue: 0
value: 100
value: 50
isCore: 1
- name: asd
id:
Expand All @@ -44,5 +44,6 @@ MonoBehaviour:
value: 0
isCore: 1
specializedClass: []
height: 0
height: 1
distance: 5
attackRange: 4
3 changes: 2 additions & 1 deletion Assets/TRPGMaker/Database/Characters/NewCharacter.asset
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MonoBehaviour:
- name: Health
id: HP
description:
maxValue: 100
maxValue: 200
minValue: 0
value: 50
isCore: 1
Expand All @@ -46,3 +46,4 @@ MonoBehaviour:
specializedClass: []
height: 2
distance: 8
attackRange: 3
6 changes: 3 additions & 3 deletions Assets/TRPGMaker/Database/Database.asset
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ MonoBehaviour:
- name: Health
id: HP
description:
maxValue: 100
maxValue: 200
minValue: 0
value: 100
value: 200
isCore: 1
- name: asd
id:
Expand Down Expand Up @@ -72,5 +72,5 @@ MonoBehaviour:
- {fileID: 11400000, guid: 36a63a88f336fee4fbee3ca4e3812861, type: 2}
- {fileID: 11400000, guid: 47430d8af55fb254dbd2af8d116d196d, type: 2}
- {fileID: 11400000, guid: caa5b8cc4b5205b4297289922d3b7e33, type: 2}
- {fileID: 11400000, guid: 3eca2b4789a5bc44abd112d60d4af688, type: 2}
- {fileID: 11400000, guid: 2ce6ded48f42c8e46b99a9a665a8efda, type: 2}
- {fileID: 11400000, guid: 3eca2b4789a5bc44abd112d60d4af688, type: 2}
3 changes: 2 additions & 1 deletion Assets/TRPGMaker/Editor/CharacterEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(serializedObject.FindProperty("name"), new GUIContent("Name: "), GUILayout.MinWidth(100));
EditorGUILayout.PropertyField(serializedObject.FindProperty("distance"), new GUIContent("Distance: "), GUILayout.MinWidth(100));
EditorGUILayout.PropertyField(serializedObject.FindProperty("height"), new GUIContent("Height: "), GUILayout.MinWidth(100));

EditorGUILayout.PropertyField(serializedObject.FindProperty("attackRange"), new GUIContent("Attack Range: "), GUILayout.MinWidth(100));

if (EditorGUI.EndChangeCheck())
{
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath((Character)target), character.name + ".asset");
Expand Down
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Scripts/Connectors.meta

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

22 changes: 22 additions & 0 deletions Assets/TRPGMaker/Scripts/Connectors/ITRPGMapConnector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using IsoUnity;
using IsoUnity.Entities;

public delegate void SetCharacterPositionCallBack(bool result);
public delegate void MoveCharacterToCallBack(bool result);
public delegate void ShowAreaCallBack(Cell selectedCell, bool result);
public delegate void MoveCameraToCallback(bool result);

public interface ITRPGMapConnector {
List<Cell> calculateAttackPath(Character character, Cell cell);
void cleanCells();
void MoveCameraToCharacter(CharacterScript character, MoveCameraToCallback callback);
void MoveCharacterTo(CharacterScript character, Cell cell, MoveCharacterToCallBack callback);
IEnumerator SelectedCell();
void SetCharacterPosition(CharacterScript character, Cell cell, SetCharacterPositionCallBack callback);
void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback);
void triggerAnimation(Character character, Cell cell);
CharacterScript GetCharacterAtCell(Cell cell);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
using IsoUnity.Entities;
using System.Linq;

public class IsoUnityConnector : EventedEventManager, ITRPGMapConnector {
public class IsoUnityConnector : EventedEventManager, ITRPGMapConnector {

private GameEvent selectedCellEvent;

// Teleport Character to Cell position
public delegate void SetCharacterPositionCallBack(bool result);

// Teleport Character to Cell position
public void SetCharacterPosition(CharacterScript character, Cell cell, SetCharacterPositionCallBack callback)
{
StartCoroutine(SetCharacterPositionAsync(character, cell, callback));
Expand All @@ -38,8 +36,6 @@ private IEnumerator SetCharacterPositionAsync(CharacterScript character, Cell ce
}

// Move Character to Cell position
public delegate void MoveCharacterToCallBack(bool result);

public void MoveCharacterTo(CharacterScript character, Cell cell, MoveCharacterToCallBack callback /*, caracteristicas*/)
{
StartCoroutine(MoveCharacterToAsync(character, cell, callback));
Expand Down Expand Up @@ -69,8 +65,6 @@ private IEnumerator MoveCharacterToAsync(CharacterScript character, Cell cell, M
}

// Show calculated area with the character distance requirement
public delegate void ShowAreaCallBack(Cell selectedCell, bool result);

public void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback)
{
StartCoroutine(ShowAreaAsync(character, eventType, callback));
Expand All @@ -92,7 +86,10 @@ private IEnumerator ShowAreaAsync(CharacterScript character, EventTypes eventTyp

Game.main.enqueueEvent(selectedCellEvent);

CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.distance, character.character.height);
if(eventType == EventTypes.MOVE)
CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.distance, character.character.height);
else if (eventType == EventTypes.ATTACK)
CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attackRange, int.MaxValue);

Dictionary<string, object> outParams;
yield return new WaitForEventFinished(selectedCellEvent, out outParams);
Expand Down Expand Up @@ -230,15 +227,15 @@ private void OnMouseDown()
// Show an arrow in selectables cells
private void showSelector(IsoUnity.Cell cell, EventTypes eventType, IsoDecoration arrow)
{
cell.transform.gameObject.AddComponent<SelectableCell>().arrow = arrow;
SelectableCell selectableCell = cell.transform.gameObject.GetComponent<SelectableCell>();
SelectableCell selectableCell = cell.transform.gameObject.AddComponent<SelectableCell>();
selectableCell.arrow = arrow;
selectableCell.selectedCellEvent = selectedCellEvent;
selectableCell.previousTexture = cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping;
selectableCell.cell = cell;
selectableCell.eventType = eventType;
}

private void cleanCells()
public void cleanCells()
{
SelectableCell[] selectableCells = FindObjectsOfType<SelectableCell>();

Expand All @@ -258,7 +255,7 @@ private void cleanCells()
cell.forceRefresh();
if (selectableCell.arrowObject != null)
Destroy(selectableCell.arrowObject);
Destroy(selectableCell);
Destroy(selectableCell);
}

}
Expand All @@ -272,16 +269,7 @@ public IEnumerator SelectedCell()
Dictionary<string, object> outParams;

yield return new WaitForEventFinished(starter, out outParams);
}

// Seleccionamos la casilla donde realizaremos la acción
//ACTION TYPE, da errores
/*public void selectCell(ActionType actionType)
{
}*/


}

// Calculamos las celdas a las que afectará un ataque
// en función de su trayectoria
Expand All @@ -298,15 +286,17 @@ public void triggerAnimation(Character character, Cell cell)

}

// Obtener el character que se encuentra en una posicion
private CharacterScript getCharacterAtCell(IsoUnity.Cell cell)
// Get character at selected cell
public CharacterScript GetCharacterAtCell(Cell cell)
{
return null; // Si no hay nadie en esa casilla
IsoUnity.Cell selectedCell = SearchCellInMap(cell);

CharacterScript character = selectedCell.transform.GetComponentInChildren<CharacterScript>();

return character;
}

// Camera look to Character
public delegate void MoveCameraToCallback(bool result);

public void MoveCameraToCharacter(CharacterScript character, MoveCameraToCallback callback)
{
StartCoroutine(MoveCameraToCharacterAsync(character, callback));
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Scripts/Database.meta

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

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Character: ScriptableObject{
public int height;
[SerializeField]
public int distance;
public int attackRange;

public void init()
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions Assets/TRPGMaker/Scripts/Game.meta

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

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f6daca4

Please sign in to comment.