Exemplo n.º 1
0
        public static void Set(ServerEnvKey envKey, Object value)
        {
            var          cacheSet = new ShareCacheStruct <ServerEnvSet>();
            ServerEnvSet envSet   = cacheSet.FindKey(envKey);

            if (envSet == null)
            {
                envSet = new ServerEnvSet()
                {
                    EnvKey = envKey, EnvValue = value.ToNotNullString()
                };
                cacheSet.Add(envSet, 0);
            }
            else
            {
                envSet.EnvValue = value.ToNotNullString();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 奖励物品
        /// </summary>
        /// <param name="prize"></param>
        /// <returns></returns>
        public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count)
        {
            var treasure = new TreasureInfo();
            treasure.UserID = user.UserID;
            treasure.Type = dialInfo.RewardType;
            treasure.ItemID = dialInfo.ItemID;
            treasure.Num = dialInfo.ItemNum;
            treasure.ItemLv = 1;
            UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(user.UserID);
            if (userDial == null)
            {
                userDial = new UserDial();
            }
            userDial.GroupID = 0;
            userDial.RefreshDate = DateTime.Now;
            userDial.Treasure.Add(treasure);
            if (count == 0)
            {
                userDial.PrizeInfo = treasure;
                userDial.HeadID = dialInfo.HeadID;
            }
            if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure)
            {
                for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++)
                {
                    userDial.Treasure.Remove(userDial.Treasure[i]);
                }
            }

            if (dialInfo.IsShow)
            {
                var cacheSet = new ShareCacheStruct<ServerEnvSet>();
                var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure);
                if (serverEnvSet == null)
                {
                    serverEnvSet = new ServerEnvSet();
                    serverEnvSet.EnvKey = ServerEnvKey.UserTreasure;
                    cacheSet.Add(serverEnvSet, GameEnvironment.CacheGlobalPeriod);
                }
                var treasureInfoList = ServerEnvSetTreasure(treasure);
                serverEnvSet.EnvValue = JsonUtils.Serialize(treasureInfoList);
            }

            if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent))
            {
                TjxChatService chatService = new TjxChatService();
                chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName));

            }
            if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge)
            {
                if (dialInfo.RewardType == RewardType.Recharge)
                {
                    userDial.ReturnRatio = treasure.Num;
                }
                return;
            }
            ChestGetUserTake(treasure, user);
        }
Exemplo n.º 3
0
 public static void Set(ServerEnvKey envKey, Object value)
 {
     var cacheSet = new ShareCacheStruct<ServerEnvSet>();
     ServerEnvSet envSet = cacheSet.FindKey(envKey);
     if (envSet == null)
     {
         envSet = new ServerEnvSet() { EnvKey = envKey, EnvValue = value.ToNotNullString() };
         cacheSet.Add(envSet, 0);
     }
     else
     {
         envSet.EnvValue = value.ToNotNullString();
     }
 }