Ejemplo n.º 1
0
    public void configure(LevelDesc desc)
    {
        _desc = desc;

        CustomerSpawn cs = (CustomerSpawn)_desc.customersQueue[0];
        _spawnDelay = cs.delay;

        _lastSpawnTime = Time.time;
    }
Ejemplo n.º 2
0
    public void parse(TextAsset sources)
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(sources.text);

        XmlNode rootNode = doc.FirstChild;
        XmlNode levels = doc.SelectSingleNode("Levels");

        XmlNodeList levelsList = levels.ChildNodes;
        foreach (XmlNode node in levelsList)
        {
            LevelDesc desc = new LevelDesc();
            string name = node.Name;

            XmlNodeList linesList = node.SelectNodes("Lines/SpawnLine");
            foreach(XmlNode line in linesList)
            {
                foreach(XmlNode customer in line.ChildNodes)
                {
                    CustomerSpawn cs = new CustomerSpawn();
                    cs.delay = float.Parse(customer.Attributes["Delay"].Value);
                    cs.type = customer.Name;

                    int ordersCount = customer.SelectNodes("Order").Count;
                    cs.orders = new string[ordersCount];

                    int i = 0;
                    foreach(XmlNode order in customer.SelectNodes("Order"))
                    {
                        cs.orders[i++] = order.Attributes["Name"].Value;
                    }

                    desc.customersQueue.Add(cs);
                }
            }

            _levelsDict.Add(name, desc);
        }
    }