using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using System;
using System.IO;
using System.Xml;
public class addmagic : MonoBehaviour
{
public GameObject frstLabel;
public GameObject scdLabel;
public GameObject mixLabel;
public GameObject name;
public string ele1;
public string ele2;
public UILabel label1;
public UILabel label2;
public UILabel mixlabelRef;
public UILabel nameRef;
private int temp;
private string magicPath;
List
<KnownElements
> known
= new List
<KnownElements
>();
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,
}
void Awake() {
known
.Add (new KnownElements
("Fire")); known
.Add (new KnownElements
("Water")); known
.Add (new KnownElements
("Wind")); known
.Add (new KnownElements
("Earth"));
frstLabel = GameObject.FindWithTag ("FrstEleLabel");
scdLabel = GameObject.FindWithTag ("ScdEleLabel");
mixLabel = GameObject.FindWithTag ("mixlabel");
name = GameObject.FindWithTag ("name");
label1 = frstLabel.GetComponent<UILabel> ();
label2 = scdLabel.GetComponent<UILabel> ();
mixlabelRef = mixLabel.GetComponent<UILabel> ();
nameRef = name.GetComponent<UILabel> ();
label1.text = "None";
label2.text = "None";
magicPath = Application.dataPath.ToString() + "/Magic";
}
/// <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()
{
Element element
= (Element
)System.Enum.Parse( typeof( Element
), label1
.text); Element element2
= (Element
)System.Enum.Parse( typeof( Element
), label2
.text);
//ADD NEW BUTTON FUNCTION HERE
if (mixlabelRef.text == "Mixing is: on") {
Effect ret = Effect.None;
if (!_lookUpTable.TryGetValue ((int)element | (int)element2, out ret)) {
Debug.LogError ("Element does not exist in Lookup table!");
}
else {
if (System.IO.Directory.Exists (magicPath) != true) {
Debug.Log("Didn't find it so creating it now");
System.IO.Directory.CreateDirectory (magicPath);
}
}
}
}
}