using UnityEngine;
using System.Collections.Generic;
public class addmagic : MonoBehaviour
{
public GameObject frstLabel;
public GameObject scdLabel;
public string ele1;
public string ele2;
public UILabel label1;
public UILabel label2;
public Element fire{
get{return Element.Fire;}
}
public Element water{
get{return Element.Fire;}
}
public Element earth{
get{return Element.Earth;}
}
public Element wind{
get{return Element.Wind;}
}
/// <summary>
/// Different elements to use
/// </summary>
public enum Element
{
None = 1<<0,
Fire = 1<<1,
Water = 1<<2,
Earth = 1<<3,
Wind = 1<<4,
Scorch = 1<<5,
Steam = 1<<6,
Lava = 1<<7,
Gas = 1<<8,
Fluid = 1<<9,
Tsunami = 1<<10,
Ice = 1<<11,
Magma = 1<<12,
Metal = 1<<13,
Wood = 1<<14,
Sand = 1<<15,
Lightning = 1<<16,
Stream = 1<<17,
Tornado = 1<<18,
Poison = 1<<19,
}
/// <summary>
/// Effects
/// </summary>
public enum Effect
{
None,
Fire,
Water,
Earth,
Wind,
Scorch,
Steam,
Lava,
Gas,
Fluid,
Tsunami,
Ice,
Magma,
Metal,
Wood,
Sand,
Lightning,
Tornado,
Stream,
Poison,
}
/// <summary>
/// Elemet to Effect lookup table
/// </summary>
private readonly Dictionary
<int, Effect
> _lookUpTable
= new Dictionary
<int, Effect
>() {
{ (int)( Element.Fire | Element.Fire), Effect.Magma },
{ (int)(Element.Fire | Element.Water), Effect.Steam },
{ (int)(Element.Fire | Element.Earth), Effect.Lava },
{ (int)(Element.Fire | Element.Wind), Effect.Gas },
{ (int)(Element.Water | Element.Water), Effect.Fluid},
{ (int)(Element.Water | Element.Earth), Effect.Tsunami },
{ (int)(Element.Water | Element.Wind), Effect.Ice },
{ (int)(Element.Wind | Element.Earth), Effect.Sand },
{ (int)(Element.Wind | Element.Wind), Effect.Tornado },
{ (int)(Element.Earth | Element.Earth), Effect.Wood },
};
public void YingYangMixing()
{
frstLabel = GameObject.FindWithTag ("FrstEleLabel");
scdLabel = GameObject.FindWithTag ("ScdEleLabel");
label1 = frstLabel.GetComponent<UILabel> ();
label2 = scdLabel.GetComponent<UILabel> ();
Element element
= (Element
)System.Enum.Parse( typeof( Element
), label1
.text); Element element2
= (Element
)System.Enum.Parse( typeof( Element
), label2
.text);
Effect ret = Effect.None;
if (!_lookUpTable.TryGetValue ((int)element | (int)element2, out ret)) {Debug.LogError( "Element does not exist in Lookup table!" );}
else{ Debug.Log(ret);}
}
}