private void Upgrades() { //判断是否能够升级 //花费是否足够 当前等级是否超限 var key = KeysUtil.GetPropertyKeys(DataKeys.UPGRADES + DataKeys.COST_UNIT); var value = DataMgr.Single.Get <string>(key); key = KeysUtil.GetPropertyKeys(DataKeys.UPGRADES + GameStateModel.Single.PlaneLevel); var cost = DataMgr.Single.Get <int>(key); var money = GameStateModel.Single.GetMoney(value); key = KeysUtil.GetPropertyKeys(DataKeys.LEVEL_MAX); var levelMax = DataMgr.Single.Get <int>(key); if (money >= cost && GameStateModel.Single.PlaneLevel < levelMax) { ChangeMenoy(value, cost); ChangeLevel(); ChangeData(); } else { UIManager.Single.ShowDialog("你没钻石了!"); } }
private void InitPlaneConfig() { var config = ReaderMgr.Single.GetReader(Paths.CONFIG_INIT_PLANE_CONFIG); config["planes"].Get <JsonData>(data => { foreach (JsonData item in data) { foreach (var key in item.Keys) { if (key == "planeId") { continue; } var newKey = KeysUtil.GetPropertyKeys(int.Parse(item["planeId"].ToJson()), key); if (!DataMgr.Single.Contains(newKey)) { DataMgr.Single.SetJsonData(newKey, item[key]); } } } }); }
private void ChangeLevel() { var key = KeysUtil.GetPropertyKeys(DataKeys.UPGRADES_RATIO); var level = GameStateModel.Single.PlaneLevel; level++; DataMgr.Single.Set(key, level); }
private void ChangeData() { //获取升级系数,修改数据 var key = KeysUtil.GetPropertyKeys(DataKeys.UPGRADES_RATIO); var ratio = DataMgr.Single.Get <int>(key); ChangeData(ratio, PropertyItem.ItemKey.value, PlaneProperty.Property.attack); ChangeData(ratio, PropertyItem.ItemKey.maxVaue, PlaneProperty.Property.attack); ChangeData(ratio, PropertyItem.ItemKey.grouth, PlaneProperty.Property.attack); ChangeData(ratio, PropertyItem.ItemKey.value, PlaneProperty.Property.life); ChangeData(ratio, PropertyItem.ItemKey.maxVaue, PlaneProperty.Property.life); ChangeData(ratio, PropertyItem.ItemKey.grouth, PlaneProperty.Property.life); }
private void UpdateData(int planeId) { for (ItemKey i = 0; i < ItemKey.grouth; i++) { var trans = transform.Find(ConvertName(i)); if (trans != null) { var key = KeysUtil.GetPropertyKeys(_key + i); trans.GetComponent <Text>().text = DataMgr.Single.GetObject(key).ToString(); } else { Debug.LogError("当前预制名称错误,正确名称:" + ConvertName(i)); } } }
private void UpdateLevelView() { //名称 var key = KeysUtil.GetPropertyKeys(DataKeys.UPGRADES + DataKeys.NAME); var data = DataMgr.Single.Get <string>(key); Util.Get("Upgrades/Text").SetText(data); //花费 key = KeysUtil.GetPropertyKeys(DataKeys.LEVEL); var level = DataMgr.Single.Get <int>(key); key = KeysUtil.GetPropertyKeys(DataKeys.UPGRADES + level); var cost = DataMgr.Single.Get <int>(key); Util.Get("Upgrades/Upgrades/Text").SetText(cost); }
private void AddAction() { var key = KeysUtil.GetPropertyKeys(_key + DataKeys.COST_UNIT); var unit = DataMgr.Single.Get <string>(key); var money = GameStateModel.Single.GetMoney(unit); key = KeysUtil.GetNewKey(PropertyItem.ItemKey.cost, _key); var cost = DataMgr.Single.Get <int>(key); if (money >= cost) { ChangeData(); } else { UIManager.Single.ShowDialog("你没星星了!"); } }