Skip to content

Commit

Permalink
IsoUnity updated and little fix
Browse files Browse the repository at this point in the history
- IsoUnity updated for animations
- Click doesn't go throw buttons
  • Loading branch information
WyrnCael committed May 30, 2018
1 parent 1385e10 commit 4c48083
Show file tree
Hide file tree
Showing 23 changed files with 585 additions and 118 deletions.
2 changes: 1 addition & 1 deletion Assets/IsoUnity/Editor/Inspector/ItemForkEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public override void OnInspectorGUI()
{
var isf = target as ItemFork;
isf.contains = EditorGUILayout.Toggle("Contains", isf.contains);
isf.item = EditorGUILayout.ObjectField("Item", (Object)isf.item, typeof(IsoUnity.Entities.Item), true) as IsoUnity.Entities.Item;
isf.item = EditorGUILayout.ObjectField("Item", (Object)isf.item, typeof(Item), true) as IsoUnity.Entities.Item;
isf.inventory = EditorGUILayout.ObjectField("Inventory", (Object)isf.inventory, typeof(IsoUnity.Entities.Inventory), true) as IsoUnity.Entities.Inventory;
}
}
Expand Down
38 changes: 37 additions & 1 deletion Assets/IsoUnity/Resources/IsoSwitches.asset
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,40 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4f903b5c05730594280dcba273e69bc4, type: 3}
m_Name: IsoSwitches
m_EditorClassIdentifier:
switches: []
switches:
- {fileID: 114917095835242190}
--- !u!114 &114119281123777720
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: 8daaa0a8c5652f247939f4ab49339994, type: 3}
m_Name:
m_EditorClassIdentifier:
i: 0
f: 0
d: 0
s:
v2: {x: 0, y: 0}
v3: {x: 0, y: 0, z: 0}
v4: {x: 0, y: 0, z: 0, w: 0}
q: {x: 0, y: 0, z: 0, w: 0}
b: 0
c: 0
whatIs: System.Boolean
--- !u!114 &114917095835242190
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: 0887338ee6657394ebdae4d5c768a9de, type: 3}
m_Name:
m_EditorClassIdentifier:
id: hablado
state: {fileID: 114119281123777720}
10 changes: 10 additions & 0 deletions Assets/IsoUnity/Source/Animations.meta

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

27 changes: 27 additions & 0 deletions Assets/IsoUnity/Source/Animations/IsoAnimation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace IsoUnity
{
[System.Serializable]
[CreateAssetMenu(fileName = "new IsoAnimation", menuName = "IsoUnity/IsoAnimation")]
public class IsoAnimation : ScriptableObject {

[System.Serializable]
public struct Frame {
public int column;
public float duration;
}

[SerializeField]
public bool loop = false;
[SerializeField]
public List<Frame> frames = new List<Frame>();
[SerializeField]
public string sheet;
[SerializeField]
public IsoDecoration overrideSheet;
}
}

11 changes: 11 additions & 0 deletions Assets/IsoUnity/Source/Animations/IsoAnimation.cs.meta

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

13 changes: 11 additions & 2 deletions Assets/IsoUnity/Source/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace IsoUnity.Entities
{
[ExecuteInEditMode]
[DisallowMultipleComponent]
[RequireComponent(typeof(DecorationAnimator))]
[RequireComponent(typeof(Mover))]
public class Entity : MonoBehaviour
{
Expand Down Expand Up @@ -59,9 +60,10 @@ public Option[] getOptions()
}

// Use this for initialization
void Start()
private void OnEnable()
{

foreach(var es in GetComponents<EntityScript>())
es.OnEntityReady();
}


Expand All @@ -81,6 +83,13 @@ public Mover mover
return this.GetComponent<Mover>();
}
}
public DecorationAnimator decorationAnimator
{
get
{
return this.GetComponent<DecorationAnimator>();
}
}

// Update is called once per frame
void Update()
Expand Down
5 changes: 1 addition & 4 deletions Assets/IsoUnity/Source/Entity/EntityScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ public Entity Entity
get { return this.GetComponent<Entity>(); }
}
// Use this for initialization
/*public virtual void Start()
{
}*/
public virtual void OnEntityReady() {}

//Abstract Methods
public abstract void eventHappened(IGameEvent ge);
Expand Down
33 changes: 21 additions & 12 deletions Assets/IsoUnity/Source/Entity/EventedEntityScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,35 @@ namespace IsoUnity.Entities
{
public abstract class EventedEntityScript : EntityScript
{
private bool inited = false;
public delegate IEnumerator CoroutineControllerDelegate(IGameEvent ge, IEnumerator toRun, MonoBehaviour holder);

private Dictionary<GameEventConfig, MethodInfo> calls;
private Dictionary<MethodInfo, GameEventAttribute> attrInfo;

public override void eventHappened(IGameEvent ge)
{
Current = ge;

EventHappened(this, calls, attrInfo, ge);
EventHappened(this, calls, attrInfo, ge, CoroutineController);

Current = null;
}

private static IEnumerator CoroutineController(IGameEvent ge, IEnumerator toRun)
private static IEnumerator CoroutineController(IGameEvent ge, IEnumerator toRun, MonoBehaviour holder)
{
var eventedES = holder as EventedEntityScript;

// We wrap the coroutine
while (toRun.MoveNext())
{
// Free the current value
eventedES.Current = null;
yield return toRun.Current;
// Set the current event value
eventedES.Current = ge;
}
// Free the current value
eventedES.Current = null;

// And when it finishes, we finish the event
Game.main.eventFinished(ge);
Expand All @@ -39,15 +50,13 @@ public override Option[] getOptions()

protected IGameEvent Current { get; private set; }

public override void tick()
protected virtual void Start()
{
if (!inited)
{
Init(this.GetType(), ref calls, ref attrInfo);
inited = true;
}
Init(this.GetType(), ref calls, ref attrInfo);
}

public override void tick() { }

internal static void Init(Type type, ref Dictionary<GameEventConfig, MethodInfo> calls, ref Dictionary<MethodInfo, GameEventAttribute> attrInfo)
{
calls = new Dictionary<GameEventConfig, MethodInfo>();
Expand All @@ -63,7 +72,7 @@ internal static void Init(Type type, ref Dictionary<GameEventConfig, MethodInfo>
}
}

internal static void EventHappened(MonoBehaviour reference, Dictionary<GameEventConfig, MethodInfo> calls, Dictionary<MethodInfo, GameEventAttribute> attrInfo, IGameEvent ge)
internal static void EventHappened(MonoBehaviour reference, Dictionary<GameEventConfig, MethodInfo> calls, Dictionary<MethodInfo, GameEventAttribute> attrInfo, IGameEvent ge, CoroutineControllerDelegate coroutineController)
{
if (calls != null && calls.Count > 0)
{
Expand All @@ -84,7 +93,7 @@ internal static void EventHappened(MonoBehaviour reference, Dictionary<GameEvent

if (output is IEnumerator)
// If we want to autofinish it we use the controller, else just launch it
reference.StartCoroutine(attrInfo[call].AutoFinish ? CoroutineController(ge, output as IEnumerator) : output as IEnumerator);
reference.StartCoroutine(attrInfo[call].AutoFinish ? coroutineController(ge, output as IEnumerator, reference) : output as IEnumerator);
else if (attrInfo[call].AutoFinish)
// If is not a coroutine and we have to auto finish it, we just do it
Game.main.eventFinished(ge);
Expand Down Expand Up @@ -204,4 +213,4 @@ public static string SplitCamelCase(string input)
return System.Text.RegularExpressions.Regex.Replace(input, "([A-Z])", " $1", System.Text.RegularExpressions.RegexOptions.Multiline).Trim();
}
}
}
}
Loading

0 comments on commit 4c48083

Please sign in to comment.