Skip to content

Commit

Permalink
fix: migrated pre-existing code to Unity latest
Browse files Browse the repository at this point in the history
  • Loading branch information
ashblue committed Apr 11, 2021
1 parent 42c35c1 commit 11c8d86
Show file tree
Hide file tree
Showing 224 changed files with 13,055 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ trim_trailing_whitespace = true
max_line_length = off
trim_trailing_whitespace = false

[manifest.json]
[*.json]
indent_size = 2
9 changes: 9 additions & 0 deletions Assets/Examples.meta

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

9 changes: 9 additions & 0 deletions Assets/Examples/HealthExample.meta

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

37 changes: 37 additions & 0 deletions Assets/Examples/HealthExample/CharacterA.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b812d3dc4a4444adae812adfa041ca88, type: 3}
m_Name: CharacterA
m_EditorClassIdentifier:
collection: {fileID: 11400000, guid: 0cda059b3069840fe94a9480fa84c45c, type: 2}
overrides:
overrides:
- definition: {fileID: 11400000, guid: 3cf3e661c93fb496ca382be87b943584, type: 2}
value:
_valueInt:
value: 5
_valueIntCurve:
value:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
_valueFloat:
value: 0
_valueFloatCurve:
value:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
type: 0
8 changes: 8 additions & 0 deletions Assets/Examples/HealthExample/CharacterA.asset.meta

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

58 changes: 58 additions & 0 deletions Assets/Examples/HealthExample/CharacterB.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b812d3dc4a4444adae812adfa041ca88, type: 3}
m_Name: CharacterB
m_EditorClassIdentifier:
collection: {fileID: 11400000, guid: 0cda059b3069840fe94a9480fa84c45c, type: 2}
overrides:
overrides:
- definition: {fileID: 11400000, guid: 3cf3e661c93fb496ca382be87b943584, type: 2}
value:
_valueInt:
value: 5
_valueIntCurve:
value:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
_valueFloat:
value: 0
_valueFloatCurve:
value:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
type: 0
- definition: {fileID: 11400000, guid: 27355736af3274d11a63b95b6a5a14cf, type: 2}
value:
_valueInt:
value: 20
_valueIntCurve:
value:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
_valueFloat:
value: 0
_valueFloatCurve:
value:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
type: 0
8 changes: 8 additions & 0 deletions Assets/Examples/HealthExample/CharacterB.asset.meta

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

66 changes: 66 additions & 0 deletions Assets/Examples/HealthExample/CharacterExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Adnc.StatsSystem.Editors;
using AdncStats.Scripts.StatsContainer;
using UnityEngine;
using UnityEngine.UI;

namespace Adnc.StatsSystem {
[RequireComponent(typeof(StatsContainerExample))]
public class CharacterExample : MonoBehaviour {
[SerializeField] Slider healthBar;
StatsContainer stats;

void Start () {
stats = GetComponent<StatsContainerExample>().copy;

var health = stats.GetStat("health");
healthBar.maxValue = health;
healthBar.value = health;
}

void Update () {
healthBar.maxValue = stats.GetStat("health");
}

public void ReceiveDamage (int damage) {
healthBar.value -= Mathf.Max(0, damage - stats.GetStat("armor"));

if (healthBar.value < 1) {
Destroy(gameObject);
}
}

public void AttackTarget (CharacterExample target) {
if (target == null) return;

target.ReceiveDamage((int)stats.GetStat("attack"));
}

public void AddHealth (float amount) {
var health = stats.GetModifier(OperatorType.Add, "health", "example");
stats.SetModifier(OperatorType.Add, "health", "example", health + amount);
}

public void RemoveHealth (float amount) {
var health = stats.GetModifier(OperatorType.Subtract, "health", "example");
stats.SetModifier(OperatorType.Subtract, "health", "example", health + amount);
}

public void MultiplyHealth (float amount) {
var health = stats.GetModifier(OperatorType.Multiply, "health", "example");
stats.SetModifier(OperatorType.Multiply, "health", "example", health + amount);
}

public void DivideHealth (float amount) {
var health = stats.GetModifier(OperatorType.Divide, "health", "example");
stats.SetModifier(OperatorType.Divide, "health", "example", health + amount);
}

public void RefillHealth () {
healthBar.value = healthBar.maxValue;
}

public void ClearAll () {
stats.ClearAllModifiers(stats.GetRecord("health"), "example");
}
}
}
12 changes: 12 additions & 0 deletions Assets/Examples/HealthExample/CharacterExample.cs.meta

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

Loading

0 comments on commit 11c8d86

Please sign in to comment.