private void ResBtn_Clicked(GUIItem item) { Button btn = item as Button; Group costGroup = btn.Tag as Group; String cost_name = costGroup.Tag as String; MouseUI mUI = _Manager.GetComponent <MouseUI>()._ModGet_Manager().GetComponent <MouseUI>(); EntityCost cost = Costs.GetEntityCost(cost_name); foreach (GUIItem costItem in costGroup.Items) { TextField txt = null; if (costItem is TextField) { txt = costItem as TextField; } else if (costItem is Group) { foreach (GUIItem gItem in ((Group)costItem).Items) { if (gItem is TextField) { txt = gItem as TextField; break; } } } if (txt != null) { String resource = txt.Tag as String; int val; if (int.TryParse(txt.Text, out val)) { Debug.Log("Setting " + resource + " of " + cost_name + " to " + val); cost.SetCost(resource, val); } else { txt.Text = cost.GetCost(resource).ToString(); Debug.Log("Failed to set " + resource + " of " + cost_name + ": Not a Number"); } } } Costs.SetEntityCost(cost); if (mUI != null) { mUI.updateBuildInfomation("ButtonBuild" + cost.Internal_Name); } ManagerResources res = _Manager.GetComponent <ManagerResources>(); if (res != null && res._ModGet_TileMap() != null) { res.updateResourcePanel(res._ModGet_TileMap()); } }
private void GameEvents_GameLoaded(object sender, Events.GameEvents.SaveLoadEventArgs e) { String path = e.savePath; if (ES2.Exists(path)) { if (ES2.Exists(path + "?tag=CostTweaking_Costs")) { EntityCost[] costsData = ES2.LoadArray <EntityCost>(path + "?tag=CostTweaking_Costs"); foreach (EntityCost data in costsData) { Costs.SetEntityCost(data); if (_fields.ContainsKey(data.Internal_Name)) { foreach (TextField field in _fields[data.Internal_Name]) { field.Text = data.GetCost(field.Tag as String).ToString(); } } } } } }