/// <summary> /// Creates a creep, the entities that seek out the power core /// </summary> /// <param name="type"></param> /// <param name="spot"></param> /// <returns></returns> public Creep CreateCreep(Creep.CreepTypes type, Vector2 spot) { GameObject go = _CreateObject(spot); go.name = "Creep_" + type; go.layer = 10; go.transform.localScale *= 0.5f; // Creep c = go.AddComponent <Creep>(); c.ChangeType(type); // *** Automatically sets the sprite! c.rb.constraints = RigidbodyConstraints2D.FreezeRotation; return(c); }
/// <summary> /// Reads an XML that contains spawn sequences and places them into the database. /// </summary> private void Load_SpawnSequences() { string textData = ((TextAsset)Resources.Load("SpawnSequences")).text; // XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(new StringReader(textData)); string xmlPathPattern = "//SpawnSequences/sequence"; XmlNodeList nodeList = xmlDoc.SelectNodes(xmlPathPattern); // everySpawnSequence = new Dictionary <string, SpawnSequence>(); // SpawnSequence ss; foreach (XmlNode node in nodeList) { ss = new SpawnSequence(); // ss.name = node.FirstChild.InnerXml; foreach (XmlNode entry in node.SelectNodes("entry")) { XmlNode o = entry.FirstChild; // Debug.Log("Node is: " + o.Name + " (" + o.InnerXml + ")"); Creep.CreepTypes creepType = (Creep.CreepTypes)Enum.Parse(typeof(Creep.CreepTypes), o.InnerXml); o = o.NextSibling; float timing = float.Parse(o.InnerXml); // ss.Add(new SpawnSequenceData(creepType, timing)); } // everySpawnSequence.Add(ss.name, ss); } foreach (SpawnSequence Q in everySpawnSequence.Values) { Debug.Log("Entry: " + Q.name); } }
public SpawnSequenceData(Creep.CreepTypes t, float w) { type = t; when = w; }