/// <summary> /// 新手礼包 /// </summary> /// <param name="user"></param> /// <param name="item"></param> /// <param name="noviceActivities"></param> /// <returns></returns> public static bool GetNoviceActivities(GameUser user, UserItemInfo item, NoviceActivities noviceActivities) { List <NoviceReward> noviceArray = noviceActivities.Reward.ToList(); var package = UserItemPackage.Get(user.UserID); var userItemArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.BeiBao); int subPackNum = MathUtils.Subtraction(user.GridNum, MathUtils.Subtraction(userItemArray.Count, 5, 0), 0); if (noviceArray.Count > subPackNum) { return(false); } bool isupdate = false; foreach (NoviceReward reward in noviceArray) { if (reward.Type == 1) { isupdate = true; user.EnergyNum = MathUtils.Addition(user.EnergyNum, (short)reward.Num, short.MaxValue); } if (reward.Type == 2) { isupdate = true; user.GameCoin = MathUtils.Addition(user.GameCoin, reward.Num, int.MaxValue); } else if (reward.Type == 3) { ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(reward.Reward); UserGeneral userGeneral = UserGeneral.GetMainGeneral(user.UserID); if (itemInfo.ItemType == ItemType.ZhuangBei && !itemInfo.CheckCareer(userGeneral.CareerID)) { continue; } UserItemHelper.AddUserItem(user.UserID, itemInfo.ItemID, reward.Num); } else if (reward.Type == 4) { //晶石 isupdate = true; user.GiftGold = MathUtils.Addition(user.GiftGold, reward.Num, int.MaxValue); } } UserItemHelper.UseUserItem(user.UserID, item.ItemID, 1); if (isupdate) { //user.Update(); } if (item.ItemID == 5000 || item.ItemID == 5001 || item.ItemID == 5002 || item.ItemID == 5003) { int itemID = MathUtils.Addition(item.ItemID, 1, int.MaxValue); UserItemHelper.AddUserItem(user.UserID, itemID, 1); } return(true); }
/// <summary> /// 新手礼包 /// </summary> /// <param name="user"></param> /// <param name="item"></param> /// <param name="noviceActivities"></param> /// <returns></returns> public static bool GetNoviceActivities(GameUser user, UserItemInfo item, NoviceActivities noviceActivities) { List<NoviceReward> noviceArray = noviceActivities.Reward.ToList(); var package = UserItemPackage.Get(user.UserID); var userItemArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.BeiBao); int subPackNum = MathUtils.Subtraction(user.GridNum, MathUtils.Subtraction(userItemArray.Count, 5, 0), 0); if (noviceArray.Count > subPackNum) { return false; } bool isupdate = false; foreach (NoviceReward reward in noviceArray) { if (reward.Type == 1) { isupdate = true; user.EnergyNum = MathUtils.Addition(user.EnergyNum, (short)reward.Num, short.MaxValue); } if (reward.Type == 2) { isupdate = true; user.GameCoin = MathUtils.Addition(user.GameCoin, reward.Num, int.MaxValue); } else if (reward.Type == 3) { ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(reward.Reward); UserGeneral userGeneral = UserGeneral.GetMainGeneral(user.UserID); if (itemInfo.ItemType == ItemType.ZhuangBei && !itemInfo.CheckCareer(userGeneral.CareerID)) { continue; } UserItemHelper.AddUserItem(user.UserID, itemInfo.ItemID, reward.Num); } else if (reward.Type == 4) { //晶石 isupdate = true; user.GiftGold = MathUtils.Addition(user.GiftGold, reward.Num, int.MaxValue); } } UserItemHelper.UseUserItem(user.UserID, item.ItemID, 1); if (isupdate) { //user.Update(); } if (item.ItemID == 5000 || item.ItemID == 5001 || item.ItemID == 5002 || item.ItemID == 5003) { int itemID = MathUtils.Addition(item.ItemID, 1, int.MaxValue); UserItemHelper.AddUserItem(user.UserID, itemID, 1); } return true; }