void EquipItem() { int spendnum = 0; for (int i = 0; i < CharacterEquipItem.Count; i++) { spendnum += CharacterEquipItem[i].Spend; } if (spendnum + ChoosenItem.Spend > 5) { Debug.Log("你已经不能再装备更多的护符了"); return; } if (Choosen == null) { Debug.Log("未选中护符"); return; } if (CharacterEquipItem.Contains(ChoosenItem)) { Debug.Log("你已经装备了这个护符"); return; } CharacterEquipItem.Add(ChoosenItem); ItemEquipView.DisPlay(CharacterEquipItem); }
void OpenBag() { if (Input.GetKeyDown(KeyCode.B) && !GameCtrl.isOpenBag) { if (!PlayerPrefs.HasKey("CharacterItem")) { return; } string savedata = PlayerPrefs.GetString("BuyenItem"); List <ItemData> SaveItem = JsonMapper.ToObject <List <ItemData> >(savedata); if (SaveItem.Count == 0) { return; } GameCtrl.isOpenBag = true; GameObject.Find("UI").transform.Find("Canvas/Bag").gameObject.SetActive(true); ReadCharaterItem(); string equipdata = PlayerPrefs.GetString("CharacterItem"); List <ItemData> characterItem = JsonMapper.ToObject <List <ItemData> >(equipdata); ItemEquipView.DisPlay(characterItem); } else if (Input.GetKeyDown(KeyCode.B) && GameCtrl.isOpenBag) { GameCtrl.isOpenBag = false; GameObject.Find("UI").transform.Find("Canvas/Bag").gameObject.SetActive(false); ReadCharaterItem(); } }