/// <summary> /// 处理游戏结束 /// </summary> private void processGameOver(OverDto overDto) { //显示结束面板 Dispatch(AreoCode.UI, UIEvent.SHOW_LOSE_OVER_PANEL, true); //设置信息并播放音效 Dispatch(AreoCode.UI, UIEvent.SET_OVER_PANEL_MESSAGE, overDto); }
/// <summary> /// 游戏结束 /// </summary> private void GameOver(int userId, FightRoom room) { //确定身份 是农民还是地主 int identity = room.GetPlayerIdentity(userId); List <int> winUids = room.GetSameIdentityUids(identity); int winBeen = room.Mutiple * 1000; //给胜利的玩家 胜场 豆子 经验 等级..之后玩家数据模型刷新 for (int i = 0; i < winUids.Count; i++) { UserModel model = user.GetModelByUserId(winUids[i]); model.winCount++; model.been += winBeen; model.exp += 100; int maxExp = model.lv * 100; while (maxExp <= model.exp) { model.lv++; model.exp -= maxExp; maxExp = model.lv * 100; } user.Update(model); } //给失败的玩家 败场 豆子 经验 等级..之后玩家数据模型刷新 List <int> loseUids = room.GetDifIdentityUids(identity); for (int i = 0; i < winUids.Count; i++) { UserModel model = user.GetModelByUserId(loseUids[i]); model.loseCount++; model.been -= winBeen; model.exp += 10; int maxExp = model.lv * 100;; while (maxExp <= model.exp) { model.lv++; model.exp -= maxExp; maxExp = model.lv * 100; } user.Update(model); } //给逃跑的玩家 逃跑 豆子 经验 等级..之后玩家数据模型刷新 for (int i = 0; i < room.LeaveUidList.Count; i++) { UserModel model = user.GetModelByUserId(room.LeaveUidList[i]); model.runCount++; model.been -= (winBeen) * 3; model.exp += 0; user.Update(model); } //给客户端发消息 谁赢了。身份,豆子多少 OverDto dto = new OverDto(); dto.winIdentity = identity; dto.winUidList = winUids; dto.beenCount = winBeen; Brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto); fight.Destroy(room); }
/// <summary> /// 刷新显示 /// </summary> private void RefreSh(OverDto overDto) { string identity = Identity.GetString(overDto.WinIdentity); int been = overDto.BeenCount; List <int> winList = overDto.WinUidList; //判断自己是否胜利 if (winList.Contains(Caches.UserDto.Id)) { txtWinIdentity.text = identity + "胜利"; if (overDto.WinIdentity == Identity.LANDLORD) { txtBeenNum.text = "+" + overDto.BeenCount * 2; } else { txtBeenNum.text = "+" + overDto.BeenCount; } } else { txtWinIdentity.text = Identity.GetOpposite(overDto.WinIdentity) + "失败"; if (overDto.WinIdentity == Identity.LANDLORD) { txtBeenNum.text = "-" + overDto.BeenCount; } else { txtBeenNum.text = "-" + overDto.BeenCount * 2; } } }
/// <summary> /// 游戏结束 /// </summary> /// <param name="indentity"></param> private void GameOver(OverDto overDto) { //显示结束面板 Dispatch(AreaCode.UI, UIEvent.OVER_PANEL_ACTIVE, true); //刷新信息 Dispatch(AreaCode.UI, UIEvent.REFRESH_OVER_PANEL, overDto); }
/// <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); }
/// <summary> /// 游戏结束 /// </summary> private void OverBro(OverDto dto) { if (dto.winUidList.Contains(Model.gameModel.UserDto.id)) { Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECT_AUDIO, "Fight/MusicEx_Win"); } else { Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECT_AUDIO, "Fight/MusicEx_Lose"); } Dispatch(AreaCode.UI, UIEvent.SHOW_OVER_PANEL, dto); }
private void overBroadcast(OverDto overDto) { if (overDto.WinUserIdList.Contains(Models.GameModel.Id)) { Debug.Log("You Win"); } else { Debug.Log("You Lose"); } Dispatch(AreaCode.UI, UIEvent.SHOW_OVER_PANEL, overDto); }
/// <summary> /// 结束广播 /// </summary> /// <param name="overDto"></param> private void overBro(OverDto overDto) { if (overDto.WinUIdList.Contains(Models.GameModel.Id)) { Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECT_AUDIO, "Fight/MusicEx_win"); } else { Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECT_AUDIO, "Fight/MusicEx_Lose"); } Dispatch(AreaCode.UI, UIEvent.SHOW_OVER_PANEL, overDto); }
/// <summary> /// 游戏结束 /// </summary> /// <param name="userId"></param> /// <param name="room"></param> private void GameOver(int userId, FightRoom room) { //获取获胜玩家身份 Identity winIdentity = room.GetPlayerIdentity(userId); List <int> winUIds = room.GetSameIdentityUId(winIdentity); //豆子 int winBeen = room.Multiple * 1000; //给胜利玩家添加胜场 for (int i = 0; i < winUIds.Count; i++) { UserCharacterInfo user = UserCache.GetUserInfo(winUIds[i]); user.WinCount++; user.Been += winBeen; user.Exp += 100; UserCache.Update(user); } List <int> loseUIds = room.GetDifferentIdentityUId(winIdentity); //给失败玩家添加负场 for (int i = 0; i < loseUIds.Count; i++) { UserCharacterInfo user = UserCache.GetUserInfo(loseUIds[i]); user.LoseCount++; user.Been -= winBeen; user.Exp += 10; UserCache.Update(user); } //逃跑玩家添加逃跑场次 for (int i = 0; i < room.LeaveUIdList.Count; i++) { UserCharacterInfo user = UserCache.GetUserInfo(loseUIds[i]); user.RunCount++; user.Been -= (winBeen) * 3; user.Exp += 0; UserCache.Update(user); } //发送广播 OverDto dto = new OverDto { WinIdentity = winIdentity, WinUIdList = winUIds, BeenCount = winBeen }; socketMsg.SubCode = FightCode.Over_Bro; socketMsg.value = dto; BroCast(room, socketMsg); //销毁房间 FightCache.Destroy(room); }
/// <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); }
private void gameOver(int userId, FightRoom room) { int winIdentity = room.GetPlayerIdentity(userId); int winBean = room.Multiple * 1000; List <int> winUserIdList = room.GetSameIdentityUserId(winIdentity); //win player pluas win count for (int i = 0; i < winUserIdList.Count; i++) { UserModel um = userCache.GetModelByAccountId(winUserIdList[i]); um.WinCount++; um.Been = winBean; um.Exp = um.LV * 100; int maxExp = um.LV * 100; while (maxExp <= um.Exp) { um.LV++; um.Exp -= maxExp; } userCache.Update(um); } //add lose count to loser List <int> loseUIds = room.GetDifferentIdentityUserId(winIdentity); for (int i = 0; i < loseUIds.Count; i++) { UserModel um = userCache.GetModelById(loseUIds[i]); um.LoseCount++; um.Been -= winBean; um.Exp += 10; int maxExp = um.LV * 100; while (maxExp <= um.Exp) { um.LV++; um.Exp -= maxExp; } userCache.Update(um); } OverDto dto = new OverDto(); dto.WinIdentity = winIdentity; dto.WinUserIdList = winUserIdList; dto.BeanCount = winBean; Broadcast(room, OpCode.FIGHT, FightCode.Over_BROADCAST, dto); fightCache.Destroy(room); }
/// <summary> /// 游戏结束 /// </summary> /// <param name="room"></param> /// <param name="userId"></param> private void GameOver(FightRoom room, int userId) { var winIdentity = room.GetPlayerIdentity(userId); var winUserIds = room.GetSameIdentityUserIds(winIdentity); var beens = room.multiple * 1000; //给胜利的玩家结算 for (int i = 0; i < winUserIds.Count; i++) { var userModel = user.GetModelById(winUserIds[i]); userModel.winCount++; userModel.beens += winIdentity == Identity.Landlord ? beens : beens / 2; userModel.exp += 100; user.Update(userModel); } var loseUserIds = room.GetDifferentIdentityUserIds(winIdentity); //给失败的玩家结算 for (int i = 0; i < loseUserIds.Count; i++) { var userModel = user.GetModelById(loseUserIds[i]); userModel.loseCount++; userModel.beens -= winIdentity == Identity.Landlord ? beens / 2 : beens; userModel.exp += 50; user.Update(userModel); } //给逃跑玩家结算 离开的时候已经结算了 //for (int i = 0; i < room.leavePlayerIdList.Count; i++) //{ // var userModel = user.GetModelById(room.leavePlayerIdList[i]); // userModel.runCount++; // userModel.loseCount++; // userModel.beens -= beens * 3;//逃跑的人减3倍 // user.Update(userModel); //} //给客户端发消息 游戏结束了 var dto = new OverDto(winIdentity, winUserIds, beens); Brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto); //游戏结束 fight.Destroy(room); }
private void RefreshShow(OverDto dto) { setPanelActive(true); //显示谁胜利 txtWinIdentity.text = Identity.GetString(dto.WinIdentity); //判断自己是否胜利 if (dto.WinUserIdList.Contains(Models.GameModel.Id)) { txtWinIdentity.text += "Win"; txtWinBeen.text = "Bean:+"; } else { txtWinIdentity.text += "Lose"; txtWinBeen.text = "Bean:-"; } //显示豆子数量 txtWinBeen.text += dto.BeanCount; }
/// <summary> /// 刷新显示 /// </summary> public void RefreshShow(OverDto dto) { SetPanelActive(true); //显示谁胜利 textWinIdrentity.text = Identity.GetString(dto.winIdentity); //判断自己是否胜利 if (dto.winUidList.Contains(Model.gameModel.UserDto.id)) { textWinIdrentity.text += "胜利"; textWinBeen.text = "欢乐豆 + "; } else { textWinIdrentity.text += "失败"; textWinBeen.text = "欢乐豆 - "; } //欢乐豆 textWinBeen.text += dto.beenCount; }
/// <summary> /// 刷新显示 /// </summary> private void refreshPanel(OverDto dto) { setPanelActive(true); //显示谁胜利 txtWinIdentity.text = Identity.GetString(dto.WinIdentity); //判断自己是否胜利 if (dto.WinUIdList.Contains(Models.GameModel.Id)) { txtWinIdentity.text += "胜利"; txtWinBeen.text = "欢乐豆:+"; } else { //失败 txtWinIdentity.text += "失败"; txtWinBeen.text = "欢乐豆:-"; } //显示豆子数量 txtWinBeen.text += dto.BeenCount; }
private void GameOver(OverDto overDto) { var identity = overDto.winIdentity; //var winUser = dto.winUserIdsList; var beens = 0; bool isWin = overDto.winUserIdsList.Contains(Models.gameModel.UserDto.id); if (overDto.winIdentity == Identity.Landlord) { beens = isWin ? +overDto.beens : overDto.beens / 2; } else { beens = isWin ? +overDto.beens / 2 : overDto.beens; } beensTxt.text = "欢乐豆 :" + (isWin ? "+" : "-") + beens; resultTxt.text = identity.ToString() + "胜利"; SetPanelActive(true); }
/// <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); }
private void GameOver(OverDto dto) { Dispatch(AreaCode.UI, UIEvent.GameOver, dto); }
/// <summary> /// 结束游戏 /// </summary> /// <param name="room">房间模型</param> /// <param name="uid">获胜角色id</param> private void GameOver(FightRoomModel room, int uid) { //获取获胜者身份 int identity = room.GetPlayerIdentity(uid); if (identity == Identity.LANDLORD) { //地主获胜 #region 更新地主玩家的信息,增加豆子,增加经验 UserModel userModel = userModelCache.GetModelByUid(uid); userModel.Been += room.Multiple * 100 * 2; userModel.AddExp(20); userModel.Win++; userModelCache.Update(userModel); #endregion #region 更新农民玩家的信息,减少豆子,增加经验 room.GetSameIdentityUids(Identity.FARMER).ForEach(u => { UserModel user = userModelCache.GetModelByUid(u.Uid); user.Been -= room.Multiple * 100; user.Fail++; user.AddExp(10); userModelCache.Update(user); }); #endregion } else { //农民获胜 #region 更新农民玩家的信息,增加豆子,增加经验 room.GetSameIdentityUids(Identity.FARMER).ForEach(u => { UserModel user = userModelCache.GetModelByUid(u.Uid); user.Been += room.Multiple * 100; user.Win++; user.AddExp(20); userModelCache.Update(user); }); #endregion #region 更新地主玩家的信息,减少豆子,增加经验 room.GetSameIdentityUids(Identity.LANDLORD).ForEach(u => { UserModel user = userModelCache.GetModelByUid(u.Uid); user.Been -= room.Multiple * 100 * 2; user.Fail++; user.AddExp(10); userModelCache.Update(user); }); #endregion } //惩罚逃跑者 userModelCache.GetModelsByUids(room.EscapePlayerId).ForEach(u => { u.Been -= room.Multiple * 100; u.Escape++; userModelCache.Update(u); }); OverDto overDto = new OverDto(); overDto.WinIdentity = identity; List <PlayerDto> playerDtos = room.GetSameIdentityUids(identity); List <int> uids = new List <int>(); foreach (var item in playerDtos) { uids.Add(item.Uid); } overDto.WinUidList = uids; overDto.BeenCount = room.Multiple * 100; //广播游戏结束消息 Brocast(room, OpCode.FIGHT, FightCode.OVER, overDto); //摧毁匹配房间 RoomCache roomCache = Caches.RoomCache; roomCache.DestoryRoom(roomCache.GetRoomModelByUid(uid)); //摧毁战斗房间 fightRoomCache.DestoryRoom(room); }