Пример #1
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="room"></param>
        private void gameOver(int userId, FightRoom room)
        {
            int        winIdentity = room.GetPlayerIdeentity(userId);
            int        winBeen     = room.Multiple * 1000;
            List <int> winUIds     = room.GetSameIdentityUIds(winIdentity);

            //给胜利的玩家添加胜场
            for (int i = 0; i < winUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(winUIds[i]);
                um.WinCount++;
                um.Been = winBeen;
                um.Exp += 100;
                int maxExp = um.Lv * 100;
                while (maxExp <= um.Exp)
                {
                    um.Lv++;
                    um.Exp -= maxExp;
                }
                userCache.Update(um);
            }
            //给失败的玩家添加负场
            List <int> loseUIds = room.GetDifferentIdentityUIds(winIdentity);

            for (int i = 0; i < loseUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(loseUIds[i]);
                um.LoseCount++;
                um.Been -= winBeen;
                um.Exp  += 10;
                int maxExp = um.Lv * 100;
                while (maxExp <= um.Exp)
                {
                    um.Lv++;
                    um.Exp -= maxExp;
                }
                userCache.Update(um);
            }
            //给逃跑玩家添加逃跑场次
            for (int i = 0; i < room.LeaveUIdList.Count; i++)
            {
                UserModel um = userCache.GetModelById(room.LeaveUIdList[i]);
                um.RunCount++;
                um.Been -= winBeen * 3;
                um.Exp  += 0;
                userCache.Update(um);
            }
            //给客户端发消息 谁赢了以及赢的豆子,身份?
            OverDto dto = new OverDto();

            dto.WinIdentity = winIdentity;
            dto.WinUIdList  = winUIds;
            dto.BeenCount   = winBeen;
            Brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto);

            //在缓存层销毁房间数据
            fightCache.Destroy(room);
        }
Пример #2
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="room"></param>
        private void gameOver(int userId, FightRoom room)
        {
            //获取获胜身份 所有的玩家id
            int winIdentity = room.GetPlayerIdentity(userId);
            int winBeen     = room.Multiple * 1000;
            //给胜利的玩家添加胜场
            List <int> winUIds = room.GetSameIdentityUIds(winIdentity);

            for (int i = 0; i < winUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(winUIds[i]);
                um.WinCount++;
                um.Been += winBeen;
                um.Exp  += 100;
                userCache.Update(um);
            }
            //给失败的玩家添加负场
            List <int> loseUIds = room.GetDifferentIdentityUIds(winIdentity);

            for (int i = 0; i < loseUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(loseUIds[i]);
                um.LoseCount++;
                um.Been -= winBeen;
                um.Exp  += 10;
                userCache.Update(um);
            }
            //给逃跑玩家添加逃跑场次
            for (int i = 0; i < room.LeaveUIdList.Count; i++)
            {
                UserModel um = userCache.GetModelById(room.LeaveUIdList[i]);
                um.RunCount++;
                um.Been -= (winBeen) * 3;
                um.Been += 0;
                userCache.Update(um);
            }

            //给客户端发消息  赢的身份是什么? 谁赢了? 加多少豆子?
            OverDto dto = new OverDto();

            dto.WinIdentity = winIdentity;
            dto.WinUIdList  = winUIds;
            dto.BeenCount   = winBeen;
            brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto);

            //在缓存层销毁房间数据
            fightCache.Destroy(room);
        }
Пример #3
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="room"></param>
        private void gameOver(int userId, FightRoom room)
        {
            //获取获胜身份 所有玩家id
            int winIdentity = room.GetPlayerIdentity(userId);
            //给胜利玩家添加胜场
            List <int> winUIds = room.GetSameIdentityUIds(winIdentity);

            for (int i = 0; i < winUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(winUIds[i]);
                int       multiple;
                room.multiDict.TryGetValue(winUIds[i], out multiple);
                um.WinCount++;
                foreach (var player in room.PlayerList)
                {
                    if (player.UserId == winUIds[i])
                    {
                        if (player.Identity == Identity.FARMER)
                        {
                            um.winBeen += multiple * 100;
                            um.Been    += um.winBeen;
                        }
                        else if (player.Identity == Identity.LANDLORD)
                        {
                            um.winBeen += 400;
                            um.Been    += um.winBeen;
                        }
                    }
                }
                um.Exp += 100;
                int maxExp = um.Lv * 100;
                while (maxExp <= um.Exp)
                {
                    um.Lv++;
                    um.Exp -= maxExp;
                    maxExp  = um.Lv * 100;
                }
                userCache.Update(um);

                //给客户端发消息 赢得身份是什么?谁赢了?加多少豆子?
                OverDto dto = new OverDto();
                dto.WinIdentity = winIdentity;
                dto.WinUIdList  = winUIds;
                dto.tempUIdList = winUIds;
                dto.BeenCount   = um.winBeen;
                singleBrocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto, winUIds[i]);
                um.winBeen = 0;
            }
            //给失败的玩家添加负场
            List <int> loseUIds = room.GetDifferentIdentityUIds(winIdentity);

            for (int i = 0; i < loseUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(loseUIds[i]);
                int       multiple;
                room.multiDict.TryGetValue(loseUIds[i], out multiple);
                um.LoseCount++;
                foreach (var player in room.PlayerList)
                {
                    if (player.UserId == loseUIds[i])
                    {
                        if (player.Identity == Identity.FARMER)
                        {
                            um.winBeen -= multiple * 100;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                        else if (player.Identity == Identity.LANDLORD)
                        {
                            um.winBeen -= 400;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                    }
                }
                um.Exp += 10;
                int maxExp = um.Lv * 100;
                while (maxExp <= um.Exp)
                {
                    um.Lv++;
                    um.Exp -= maxExp;
                    maxExp  = um.Lv * 100;
                }
                userCache.Update(um);
                //给客户端发消息 赢得身份是什么?谁赢了?加多少豆子?
                OverDto dto = new OverDto();
                dto.WinIdentity = winIdentity;
                dto.WinUIdList  = winUIds;
                dto.tempUIdList = loseUIds;
                dto.BeenCount   = Math.Abs(um.winBeen);
                singleBrocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto, loseUIds[i]);
                um.winBeen = 0;
            }
            //给逃跑玩家添加逃跑场次
            for (int i = 0; i < room.LeaveUIdList.Count; i++)
            {
                UserModel um = userCache.GetModelById(room.LeaveUIdList[i]);
                int       multiple;
                room.multiDict.TryGetValue(loseUIds[i], out multiple);
                um.RunCount++;
                foreach (var player in room.PlayerList)
                {
                    if (player.UserId == winUIds[i])
                    {
                        if (player.Identity == Identity.FARMER)
                        {
                            um.winBeen -= multiple * 100;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                        else if (player.Identity == Identity.LANDLORD)
                        {
                            um.winBeen -= 1200;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                    }
                }
                um.Exp    += 0;
                um.winBeen = 0;
                userCache.Update(um);
            }

            //在缓存层销毁房间数值
            fightCache.Destroy(room);
        }