Esempio n. 1
0
        /// <summary>
        /// 假日狂欢活动--竞技场幸运数字七
        /// </summary>
        /// <param name="userID"></param>
        public static void HolidayFestival(string userID)
        {
            GameUser         userInfo   = new GameDataCacheSet <GameUser>().FindKey(userID);
            int              festivalID = 0;// 1004;
            FestivalRestrain restrain   = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID);

            if (restrain != null)
            {
                if (restrain.RefreashDate.Date != DateTime.Now.Date)
                {
                    restrain.RestrainNum  = 0;
                    restrain.RefreashDate = DateTime.Now;
                }
            }
            var          chatService = new TjxChatService();
            FestivalInfo festival    = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);

            if (festival != null)
            {
                List <PrizeInfo> rewardsArray = festival.Reward.ToList();
                if (NoviceHelper.IsFestivalOpen(festivalID))
                {
                    if (restrain != null && restrain.RestrainNum <= festival.RestrainNum)
                    {
                        restrain.RestrainNum  = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue);
                        restrain.RefreashDate = DateTime.Now;
                        //restrain.Update();
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null)
                        {
                            chatService.SystemSendWhisper(userInfo, LanguageManager.GetLang().St_HolidayFestival);
                        }
                    }
                    else if (restrain == null)
                    {
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null)
                        {
                            chatService.SystemSendWhisper(userInfo, LanguageManager.GetLang().St_HolidayFestival);
                        }
                        restrain = new FestivalRestrain
                        {
                            UserID       = userID,
                            FestivalID   = festivalID,
                            RefreashDate = DateTime.Now,
                            RestrainNum  = 1,
                        };
                        new GameDataCacheSet <FestivalRestrain>().Add(restrain);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 七夕、端午节奖励
        /// </summary>
        public static void DragonBoatFestival(string userID, int festivalID)
        {
            GameUser         userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);
            FestivalRestrain restrain = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID);
            FestivalInfo     festival = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);
            var chatService           = new TjxChatService();

            if (festival != null)
            {
                CacheList <PrizeInfo> rewardsArray = festival.Reward;
                if (NoviceHelper.IsFestivalOpen(festivalID))
                {
                    if (restrain != null && restrain.RestrainNum <= festival.RestrainNum)
                    {
                        restrain.RestrainNum  = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue);
                        restrain.RefreashDate = DateTime.Now;
                        //restrain.Update();
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null && festival.FestivalExtend != null)
                        {
                            chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc);
                        }
                    }
                    else if (restrain == null)
                    {
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null && festival.FestivalExtend != null)
                        {
                            chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc);
                        }
                        restrain = new FestivalRestrain
                        {
                            UserID       = userID,
                            FestivalID   = festivalID,
                            RefreashDate = DateTime.Now,
                            RestrainNum  = 1,
                        };
                        new GameDataCacheSet <FestivalRestrain>().Add(restrain);
                    }
                }
            }
        }
Esempio n. 3
0
        public override bool TakeAction()
        {
            if (NoviceHelper.IsFestivalOpen(festivalID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().ZhongYuanHuodong;
                return(false);
            }
            var          package  = UserItemPackage.Get(Uid);
            UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID));

            if (userItem != null)
            {
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID);
                if (itemInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    //ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough;
                    return(false);
                }
                if (userItem.ItemID == 7003 || userItem.ItemID == 5200)
                {
                    //双倍材料掉落卡
                    if (!DoCaiLiaoYueBingItem(userItem, itemInfo))
                    {
                        return(false);
                    }
                }
                else
                {
                    //其他类型的道具
                    if (!UseProps(ContextUser.UserID, itemInfo))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1608_CombatPowerNotEnough;
                        return(false);
                    }
                }
                PictureID = itemInfo.PictrueID;
                UserItemHelper.UseUserItem(ContextUser.UserID, userItem.ItemID, 1);
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 假日狂欢活动通关获得金币
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotID"></param>
        public static void GetHolidayFestivalReward(string userID, int plotID)
        {
            var          chatService = new TjxChatService();
            int          festivalID  = 0;// 1003;
            FestivalInfo festival    = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);

            if (festival != null)
            {
                GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);
                PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(plotID);
                if (plotInfo != null)
                {
                    TimePriod priod = festival.TimePriod;
                    if (NoviceHelper.IsFestivalOpen(festivalID))
                    {
                        DateTime priodStart = DateTime.Parse(DateTime.Now.ToString("d") + " " + priod.Start.ToString("T"));
                        DateTime priodEnd   = DateTime.Parse(DateTime.Now.ToString("d") + " " + priod.End.ToString("T"));
                        if (priodStart <= DateTime.Now && DateTime.Now < priodEnd)
                        {
                            if (RandomUtils.IsHit(plotInfo.FestivalProbability))
                            {
                                List <FestivalReward> rewardsArray = plotInfo.FestivalReward.ToList();
                                double[] probability = new double[rewardsArray.Count];
                                for (int i = 0; i < rewardsArray.Count; i++)
                                {
                                    probability[i] = rewardsArray[i].Probability;
                                }
                                int index2 = RandomUtils.GetHitIndex(probability);
                                int itemID = rewardsArray[index2].Item;
                                UserItemHelper.AddUserItem(userID, itemID, 1);
                                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID);
                                if (userInfo != null && itemInfo != null)
                                {
                                    string content = string.Empty;
                                    if (itemID == 5008)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName);
                                        chatService.SystemSendWhisper(userInfo, content);
                                    }
                                    else if (itemID == 5009)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName);
                                        chatService.SystemSendWhisper(userInfo, content);
                                    }
                                    else if (itemID == 5010)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName);
                                        chatService.SystemSendWhisper(userInfo, content);
                                    }
                                    else if (itemID == 5011)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGoinGift, userInfo.NickName);
                                        new TjxChatService().SystemSend(ChatType.World, content);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }