// 新增收集 public bool Add(ENUM_Weapon Weapon, int iLevel, int iIndex) { if (Weapon == ENUM_Weapon.Null || Weapon == ENUM_Weapon.Count) { return(false); } if (iLevel <= 0 || iLevel > GameDefine.iMaxCollectionLv) { return(false); } if (iIndex <= 0 || iIndex > GameDefine.iMaxCollectionCount) { return(false); } Collection Temp = new Collection(Weapon, iLevel, iIndex); string szTemp = Temp.ToStringData(); if (Data.Any((Itor) => Itor.ToStringData() == szTemp)) { return(false); } Data.Add(new Collection(Weapon, iLevel, iIndex)); return(true); }
// 刪除收集 public void Del(ENUM_Weapon Weapon, int iLevel, int iIndex) { string szTemp = (new Collection(Weapon, iLevel, iIndex)).ToStringData(); int iPos = Data.FindIndex((Itor) => Itor.ToStringData() == szTemp); if (iPos >= 0 && iPos < Data.Count) { Data.RemoveAt(iPos); } }
// 讀檔. public bool Load() { SaveReward Temp = null; if (PlayerPrefs.HasKey(GameDefine.szSaveReward)) { Temp = Json.ToObject <SaveReward>(PlayerPrefs.GetString(GameDefine.szSaveReward)); } if (Temp != null) { MemberLooks = new HashSet <int>(Temp.MemberLooks); MemberInits = new HashSet <int>(Temp.MemberInits); foreach (string Itor in Temp.WeaponLevel) { string[] szTemp = Itor.Split(new char[] { '_' }); if (szTemp.Length >= 2) { WeaponLevel.Add(System.Convert.ToInt32(szTemp[0]), System.Convert.ToInt32(szTemp[1])); } } //for iInitCurrency = Temp.iInitCurrency; iInitBattery = Temp.iInitBattery; iInitLightAmmo = Temp.iInitLightAmmo; iInitHeavyAmmo = Temp.iInitHeavyAmmo; iInitBomb = Temp.iInitBomb; iCrystal = Temp.iCrystal; } else { MemberLooks = new HashSet <int>(GameInit.InitMemberLooks); MemberInits = new HashSet <int>(); WeaponLevel = new Dictionary <int, int>(); iInitCurrency = GameInit.iInitCurrency; iInitBattery = GameInit.iInitBattery; iInitLightAmmo = GameInit.iInitLightAmmo; iInitHeavyAmmo = GameInit.iInitHeavyAmmo; iInitBomb = GameInit.iInitBomb; iCrystal = 0; } //if return(true); }
// 檢查收集是否存在 public bool IsExist(ENUM_Weapon Weapon, int iLevel, int iIndex) { string szTemp = (new Collection(Weapon, iLevel, iIndex)).ToStringData(); return(Data.Any((Itor) => Itor.ToStringData() == szTemp)); }