void InitSunshineTemplate() { sunshineList = new List <SunshineProperty>(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Resources.Load("Config/Sunshine").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; // Global.CloudType type = (Global.CloudType)System.Enum.Parse(typeof(Global.CloudType), xn.SelectSingleNode("type").InnerText); SunshineProperty property = new SunshineProperty(); property.width = width; property.height = height; property.data = new int[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { property.data[i, j] = data[i * height + j] - '0'; } } sunshineList.Add(property); } } }
void Sunshine() { SunshineProperty property = sunshineList[Random.Range(0, sunshineList.Count)]; property.position = new Vector2Int(Random.Range(0, Global.HorizonalGridNum - property.width), Random.Range(0, Global.VerticalGridNum - property.height)); Ground.GetInstance().Sunshine(property); }
public void Sunshine(SunshineProperty property) { for (int i = property.position.x, m = 0; i < property.position.x + property.width; i++, m++) { for (int j = property.position.y, n = 0; j < property.position.y + property.height; j++, n++) { if (grids[i, j].decreaseLock == false) { grids[i, j].Moisture -= property.data[m, n]; } } } view.HUDManager.GetInstance().Sunshine(grids[property.position.x, property.position.y].transform.position); UpdatePlantOption(); }