Exemplo n.º 1
0
    private void InitTemplet()
    {
        //read from xml

        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.LoadXml(Resources.Load("Config/CloudOptionTemplet").ToString());
        if (xmlDoc != null)
        {
            XmlNodeList cloudList = xmlDoc.SelectSingleNode("main").ChildNodes;
            foreach (XmlNode xn in cloudList)
            {
                int              width  = int.Parse(xn.SelectSingleNode("width").InnerText);
                int              height = int.Parse(xn.SelectSingleNode("height").InnerText);
                string           data   = xn.SelectSingleNode("data").InnerText;
                string           tex    = xn.SelectSingleNode("textureName").InnerText;
                Global.CloudType type   = (Global.CloudType)System.Enum.Parse(typeof(Global.CloudType), xn.SelectSingleNode("type").InnerText);

                CloudProperty cloudProperty = null;
                switch (type)
                {
                case Global.CloudType.SPECIAL_3_3:
                    cloudProperty = new CloudProperty_Special_3_3();
                    break;

                default:
                    cloudProperty = new CloudProperty();
                    break;
                }

                cloudProperty.width   = width;
                cloudProperty.height  = height;
                cloudProperty.data    = new int[width, height];
                cloudProperty.texture = Resources.Load("Textures/" + tex) as Texture2D;
                cloudProperty.type    = type;
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        cloudProperty.data[i, j] = data[i * height + j] - '0';
                    }
                }

                if (type == Global.CloudType.NORMAL)
                {
                    options.Add(cloudProperty);
                }
                else
                {
                    specialOptions.Add(type, cloudProperty);
                }
            }
        }
    }
Exemplo n.º 2
0
    public CloudProperty RandomNewCloud(Global.CloudType type = Global.CloudType.NORMAL)
    {
        //if (options.Count == 0)
        //    return null;

        if (type == Global.CloudType.NORMAL)
        {
            return(options[Random.Range(0, options.Count)]);
        }
        else
        {
            return(specialOptions[type]);
        }
    }