//public static PlayerData StrLevelUp(RowEquipment data) //{ // PlayerData player = ReadData(); // if (data.strLevel >= 10) { // Prefabs.Alert("强化已满!", null); // return player; // } // if (player.gold < data.price) { // Prefabs.Alert("金币不足!", null); // return player; // } // for (int i = 0; i < player.equips.Count; i++) // { // if (player.equips[i].equipmentID == data.equipmentID && player.equips[i].strLevel == data.strLevel) // { // player.equips[i].count -= 1; // player.gold -= 200; // if (player.equips[i].count == 0) // { // player.equips.RemoveAt(i); // } // break; // } // } // bool isAdd = false; // for (int i = 0; i < player.equips.Count; i++) // { // if (player.equips[i].equipmentID == data.equipmentID && player.equips[i].strLevel == data.strLevel + 1) // { // player.equips[i].count += 1; // isAdd = true; // break; // } // } // if (!isAdd) // { // Equip equip = new Equip(); // equip.equipmentID = data.equipmentID; // equip.count = 1; // equip.strLevel = data.strLevel + 1; // player.equips.Add(equip); // } // Prefabs.Alert("强化成功,消耗200物资", null); // PlayerPrefs.SetString(key, JsonMapper.ToJson(player)); // return player; //} public static PlayerData StrLevelUp(RowEquipment data) { PlayerData player = DynamicDataModel.ReadData(); if (data.strLevel >= 10) { Prefabs.Alert("强化已满!", null); return(player); } if (player.gold < data.price) { Prefabs.Alert("金币不足!", null); return(player); } for (int i = 0; i < player.equips.Count; i++) { if (player.equips[i].equipmentID == data.equipmentID) { player.gold -= 200; player.equips[i].strLevel += 1; break; } } Prefabs.Alert("强化成功,消耗200物资", null); PlayerPrefs.SetString(key, JsonMapper.ToJson(player)); return(player); }
public void StageC2lick() { ButtonSound.ButtonClickPlay(); if (TeamModel.IsAttack()) { Prefabs.SceneSwitch("BattleField3", null); } else { Prefabs.Alert("编队前后排都要有角色!", null); } }
/// <summary> /// 退役 /// </summary> public void RetireOKClick() { if (selectHeroInfo != null) { string json = PlayerPrefs.GetString("HeroData"); List <DynamicDate> date = JsonMapper.ToObject <List <DynamicDate> >(json); for (int i = 0; i < date.Count; i++) { if (date[i].PackageID == selectHeroInfo.PackageID) { date.RemoveAt(i); } } Prefabs.Alert("退役成功", null); string NewDate = JsonMapper.ToJson(date); PlayerPrefs.SetString("HeroData", NewDate); } BackToBuild(); }
public void LoginClick() { if (Username.text == "" || Password.text == "") { Prefabs.Alert("登录信息不能为空", null); return; } //校验用户名和密码 if (PlayerPrefs.GetString("Username") == Username.text && PlayerPrefs.GetString("Password") == Password.text) { Prefabs.Alert("登录成功", null); Destroy(gameObject); main.GetComponent <MainCode>().login = true; } else { Prefabs.Alert("登录失败", null); } }
public void Build() { ButtonSound.ButtonClickPlay(); string json = PlayerPrefs.GetString("HeroData"); List <DynamicDate> date = JsonMapper.ToObject <List <DynamicDate> >(json); switch (Random.Range(1, 5)) { case 1: DynamicDate NewOne = new DynamicDate(1001, 1, 4, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1); date.Add(NewOne); break; case 2: DynamicDate NewOne1 = new DynamicDate(1002, 1, 4, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1); date.Add(NewOne1); break; case 3: DynamicDate NewOne2 = new DynamicDate(5001, 1, 3, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1); date.Add(NewOne2); break; case 4: DynamicDate NewOne3 = new DynamicDate(3001, 1, 3, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1); date.Add(NewOne3); break; case 5: DynamicDate NewOne4 = new DynamicDate(4002, 1, 3, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1); date.Add(NewOne4); break; } Prefabs.Alert("Completion of Draw!", null); string NewDate = JsonMapper.ToJson(date); PlayerPrefs.SetString("HeroData", NewDate); }
public static PlayerData SellPlayerEquip(RowEquipment data) { PlayerData player = DynamicDataModel.ReadData(); for (int i = 0; i < player.equips.Count; i++) { Equip ep = player.equips[i]; if (ep.equipmentID == data.equipmentID && ep.strLevel == data.strLevel) { ep.count -= 1; player.gold += data.price; if (ep.count == 0) { player.equips.RemoveAt(i); } break; } } Prefabs.Alert("卖出" + data.name + "成功,获得金币" + data.price, null); PlayerPrefs.SetString(key, JsonMapper.ToJson(player)); return(player); }
public void RegisterClick() { if (Username.text == "" || Password.text == "" || RPassword.text == "") { Prefabs.Alert("注册信息不能为空", null); return; } if (Password.text != RPassword.text) { Prefabs.Alert("两次密码不一致", null); return; } PlayerPrefs.SetString("Username", Username.text); PlayerPrefs.SetString("Password", Password.text); Prefabs.Alert("注册成功", null); //跨页面传递数据 //UILogin script = transform.parent.Find("Login").GetComponent<UILogin>(); //script.Username.text = Username.text; //script.Password.text = Password.text; }