Skip to content

Commit

Permalink
AttackEvent, EventTypes, LifeBar and Attributes cloneable
Browse files Browse the repository at this point in the history
- Implemented attack event in IsoUnityConnector.
- EventTypes for move or attack.
- LifeBar upside characters.
- Attributes cloneable. Cloned when assigned.
  • Loading branch information
WyrnCael committed Mar 26, 2018
1 parent 49932d2 commit 0b48b3e
Show file tree
Hide file tree
Showing 21 changed files with 390 additions and 59 deletions.
19 changes: 19 additions & 0 deletions Assets/AttackCell.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: AttackCell
m_EditorClassIdentifier:
realTexture: {fileID: 2800000, guid: 529a0dba784aea3468ca0b653c7849e4, type: 3}
xCorner: 0
yCorner: 0
isXSimetric: 0
isYSimetric: 0
rotation: 0
10 changes: 10 additions & 0 deletions Assets/AttackCell.asset.meta

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

2 changes: 1 addition & 1 deletion Assets/Floor.asset
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c453d041690ab642b6e517807c4ef31, type: 3}
m_Name: IsoTexture
m_Name: Floor
m_EditorClassIdentifier:
realTexture: {fileID: 2800000, guid: a2f241151e0e7c848aba3d6c6d0b7abd, type: 3}
xCorner: 16
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scenes/test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -31202,6 +31202,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
moveCell: {fileID: 11400000, guid: 1285aa62ffa004945b03dfbda9cf0afd, type: 2}
attackCell: {fileID: 11400000, guid: e7bd64f3e7f95d54289deccf42920283, type: 2}
arrowDecoration: {fileID: 11400000, guid: 0db37da799e54d5458c420331560f165, type: 2}
--- !u!43 &771847860
Mesh:
Expand Down Expand Up @@ -45882,7 +45883,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 11400000, guid: 8a1da15bc40e9ac4897e6f088f39ae14, type: 2}
propertyPath: walkable
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 8a1da15bc40e9ac4897e6f088f39ae14, type: 2}
Expand Down
32 changes: 30 additions & 2 deletions Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,35 @@ MonoBehaviour:
name: NewCharacter(1)
inventory: {fileID: 0}
Slots: []
attributes: []
attributes:
- name: Experience
id: Exp
description: Health points
maxValue: 0
minValue: 0
value: 0
isCore: 1
- name: Health
id: HP
description:
maxValue: 100
minValue: 0
value: 100
isCore: 1
- name: asd
id:
description:
maxValue: 0
minValue: 0
value: 0
isCore: 1
- name: ddddd
id:
description:
maxValue: 0
minValue: 0
value: 0
isCore: 1
specializedClass: []
height: 0
distance: 0
distance: 5
23 changes: 22 additions & 1 deletion Assets/TRPGMaker/Database/Characters/NewCharacter.asset
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ MonoBehaviour:
minValue: 0
value: 0
isCore: 1
- name: Health
id: HP
description:
maxValue: 100
minValue: 0
value: 50
isCore: 1
- name: asd
id:
description:
maxValue: 0
minValue: 0
value: 0
isCore: 1
- name: ddddd
id:
description:
maxValue: 0
minValue: 0
value: 0
isCore: 1
specializedClass: []
height: 2
distance: 4
distance: 8
21 changes: 21 additions & 0 deletions Assets/TRPGMaker/Database/Database.asset
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ MonoBehaviour:
minValue: 0
value: 0
isCore: 0
- name: Health
id: HP
description:
maxValue: 100
minValue: 0
value: 100
isCore: 1
- name: asd
id:
description:
maxValue: 0
minValue: 0
value: 0
isCore: 1
- name: ddddd
id:
description:
maxValue: 0
minValue: 0
value: 0
isCore: 1
tags:
- Espada
- Mandoble
Expand Down
Binary file added Assets/TRPGMaker/Resources/AttackCell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions Assets/TRPGMaker/Resources/AttackCell.png.meta

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

15 changes: 14 additions & 1 deletion Assets/TRPGMaker/Scripts/Attribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
using UnityEngine;

[Serializable]
public class Attribute{
public class Attribute : ICloneable
{

// Defined in editor
[SerializeField]
public string name; // Long identifier
[SerializeField]
public string id; // Three letters identifier
[SerializeField]
public string description;
[SerializeField]
public int maxValue;
[SerializeField]
public int minValue;
// Defined in game (now just default values)
[SerializeField]
public int value;
[SerializeField]
public bool isCore; // 'true' if is a basic or core attribute

public Attribute(string name, string id, string description, int maxValue, int minValue, int value, bool isCore)
Expand All @@ -29,6 +37,11 @@ public Attribute(string name, string id, string description, int maxValue, int m
this.value = value;
}

public object Clone()
{
return this.MemberwiseClone();
}

protected bool Equals(Attribute other)
{
return id == other.id;
Expand Down
13 changes: 10 additions & 3 deletions Assets/TRPGMaker/Scripts/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
public class Character: ScriptableObject{

//public ... image/texture
[SerializeField]
public string name;
[SerializeField]
public Inventory inventory;
[SerializeField]
public List<Slot> Slots;
[SerializeField]
public List<Attribute> attributes = null;
[SerializeField]
public List<SpecializedClass> specializedClass;
[SerializeField]
public int height;
[SerializeField]
public int distance;

public void init()
Expand All @@ -28,13 +35,13 @@ public void init()
public void refreshAttributes()
{
if (attributes == null)
attributes = Database.Instance.attributes.Where(x => x.isCore).ToList();
attributes = Extensions.Clone<Attribute>(Database.Instance.attributes.Where(x => x.isCore).ToList()).ToList();
else
{
List<Attribute> aux = new List<Attribute>();
aux = attributes.Where(x => !x.isCore && Database.Instance.attributes.Contains(x)).ToList();
aux = Extensions.Clone<Attribute>(attributes.Where(x => !x.isCore && Database.Instance.attributes.Contains(x)).ToList()).ToList();
attributes = new List<Attribute>();
attributes.AddRange(Database.Instance.attributes.Where(x => x.isCore).ToList());
attributes.AddRange(Extensions.Clone<Attribute>(Database.Instance.attributes.Where(x => x.isCore).ToList()));
attributes.AddRange(aux);
}
}
Expand Down
26 changes: 26 additions & 0 deletions Assets/TRPGMaker/Scripts/CharacterScript.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

public class CharacterScript : MonoBehaviour {

private Vector2 pos;
[SerializeField]
public Character character;

private void Start()
{

}

private void OnGUI()
{
if (character != null && character.attributes.Any(x => x.id == "HP"))
{
Attribute attribute = character.attributes.Find(x => x.id == "HP");
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()
{

}
}
7 changes: 7 additions & 0 deletions Assets/TRPGMaker/Scripts/EventTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using UnityEngine;
using System.Collections;

public enum EventTypes{
ATTACK,
MOVE
};
Loading

0 comments on commit 0b48b3e

Please sign in to comment.