private void GameOverBRO(GameOverDto dto)
    {
        transform.DOScale(Vector3.one, 0.3f);

        win.txt_UserName.text  = dto.winDto.userName;
        win.txt_CoinCount.text = dto.winCount.ToString();

        lose_1.txt_UserName.text  = dto.loseDtoList[0].userName;
        lose_1.txt_CoinCount.text = (-dto.loseDtoList[0].stakesSum).ToString();

        lose_2.txt_UserName.text  = dto.loseDtoList[1].userName;
        lose_2.txt_CoinCount.text = (-dto.loseDtoList[1].stakesSum).ToString();

        //判断是否胜利,播放音效
        if (dto.winDto.userId == Models.GameModel.userDto.UserId)
        {
            m_AudioSource.clip = clip_Win;
            m_AudioSource.Play();
        }
        else
        {
            m_AudioSource.clip = clip_Lose;
            m_AudioSource.Play();
        }
    }
Пример #2
0
        public async Task <IActionResult> StopGame([FromBody] GameOverClientDto dto)
        {
            List <ShipInfo> clientShips = _mapper.Map <List <ShipInfo> >(dto.Ships);
            var             game        = await _gameSvc.StopGameAsync(dto.GameId, clientShips);

            if (game == null)
            {
                return(BadRequest());
            }

            _statisticsSvc.EnqueueGameStatistics(clientShips);

            GameOverDto respDto = _mapper.Map <GameOverDto>(game);

            return(Ok(respDto));
        }
Пример #3
0
        public async Task <IActionResult> FireCannonProcessResult([FromBody] P2PFireCannonCallbackDto dto)
        {
            if (string.IsNullOrWhiteSpace(dto.ConnectionId))
            {
                return(BadRequest());
            }

            if (string.IsNullOrWhiteSpace(dto.Code))
            {
                return(BadRequest());
            }

            PeerToPeerSessionState session = await _p2pSvc.FindActiveSessionAsync(dto.Code, dto.ConnectionId);

            if (session == null)
            {
                return(BadRequest());
            }

            List <ShipInfo> ships = dto.ConnectionId == session.HostConnectionId ? session.FriendShips : session.HostShips;

            FireCannonResultDto respDto = new FireCannonResultDto
            {
                CellId               = dto.CellId,
                ShipDestroyed        = dto.ShipDestroyed,
                IsAwaitingServerTurn = !dto.Result,
                IsGameOver           = dto.IsGameOver,
                Result               = dto.Result,
            };

            var connectionId = dto.ConnectionId == session.HostConnectionId ? session.FriendConnectionId : session.HostConnectionId;

            await _gameHubContext.Clients.Client(connectionId).SendAsync("MakeFireProcessResult", respDto);

            if (dto.IsGameOver)
            {
                await _p2pSvc.StopGameAsync(session);

                GameOverDto shipsDto = new GameOverDto {
                    Ships = ships.Select(s => s.Cells).ToList()
                };
                return(Ok(shipsDto));
            }

            return(Ok(new { }));
        }
Пример #4
0
 /// <summary>
 /// 游戏结束
 /// </summary>
 /// <param name="gameOverDto"></param>
 private void over(GameOverDto gameOverDto)
 {
     //先把房间处理一下
     foreach (int uid in Models.GameModel.MutiRoomDto.LeaveUIdList)
     {
         Models.GameModel.MutiRoomDto.Leave(uid);
         Models.GameModel.MutiRoomDto.ReadyUIdList.Clear();
     }
     //结算面板
     Dispatch(AreaCode.UI, UIEvent.MULTI_SHOW_OVER_PANEL, gameOverDto);
     //更新一下用户信息
     for (int i = 0; i < gameOverDto.userDtoList.Count; i++)
     {
         if (Models.GameModel.UserDto.Id == gameOverDto.userDtoList[i].Id)
         {
             Models.GameModel.UserDto = gameOverDto.userDtoList[i];
             break;
         }
     }
     //豆子面板刷新一下
     Dispatch(AreaCode.UI, UIEvent.MULTI_CHANGE_BEEN, Models.GameModel.UserDto.Been);
 }
Пример #5
0
    private void GameOverBRO(GameOverDto dto)
    {
        transform.DOScale(Vector3.one, 0.3f);

        win.txtName.text = dto.winDto.name;
        win.txtCoin.text = dto.winCount.ToString();

        lose1.txtName.text = dto.loseDtoList[0].name;
        lose1.txtCoin.text = (-dto.loseDtoList[0].stakesSum).ToString();

        lose2.txtName.text = dto.loseDtoList[1].name;
        lose2.txtCoin.text = (-dto.loseDtoList[1].stakesSum).ToString();

        if (dto.winDto.id == Models.GameModel.userDto.id)
        {
            audio.clip = winClip;
            audio.Play();
        }
        else
        {
            audio.clip = loseClip;
            audio.Play();
        }
    }
Пример #6
0
    /// <summary>
    /// 刷新显示
    /// </summary>
    private void refreshPanel(GameOverDto gameOverDto)
    {
        //显示面板
        setPanelActive(true);

        txtDealerSettle.text  = "庄家 :点数 ";
        txtDealerSettle.text += gameOverDto.dealerWeight;
        if (gameOverDto.dealerWeight > 21)
        {
            txtDealerSettle.text += "爆牌";
        }

        txtPlayerSettle.text = "";
        for (int i = 0; i < 4; i++)
        {
            if (gameOverDto.playerWeightListList[i] != null)
            {
                txtPlayerSettle.text += "玩家 ";
                txtPlayerSettle.text += i + 1;
                txtPlayerSettle.text += "\n";
                if (gameOverDto.isLeaveList[i] == true)
                {
                    txtPlayerSettle.text += "中途离开  ";
                    txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][0];
                    txtPlayerSettle.text += "\n";
                }
                else
                {
                    for (int j = 0; j < gameOverDto.playerWeightListList[i].Count; j++)
                    {
                        txtPlayerSettle.text += "点数 ";
                        //1 21点,2 爆牌,3 加倍爆牌 ,4 加倍 赢 ,5 加倍 输,6赢 ,7 输,8 平
                        switch (gameOverDto.playerStateListList[i][j])
                        {
                        case 1:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "黑杰克  + ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 2:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "爆牌  ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 3:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "加倍爆牌  ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 4:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "加倍 赢  + ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 5:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "加倍 输  ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 6:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "赢  +";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 7:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "输  ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }

                        case 8:
                        {
                            txtPlayerSettle.text += gameOverDto.playerWeightListList[i][j];
                            txtPlayerSettle.text += "平  + ";
                            txtPlayerSettle.text += gameOverDto.playerWinBeenListList[i][j];
                            break;
                        }
                        }

                        txtPlayerSettle.text += "\n";
                    }
                }
            }
        }
    }
Пример #7
0
        private void gameOver(_21MutiFightRoom room)
        {
            //给庄家发牌
            brocast(room, OpCode._21Multi, _21MultiCode.TURN_DEALER_BRO, null, null);
            //把所有的state遍历一遍,都爆牌了就不用要了
            while (room.GetDealerWeight() < 17)
            {
                CardDto card = room.DealerHit();
                brocast(room, OpCode._21Multi, _21MultiCode.DEALER_HIT_BRO, card, null);
            }

            //结算
            //结算对象
            GameOverDto gameOverDto = new GameOverDto();
            //todo 写一个总结算的对象,把玩家信息和这轮游戏的信息都发过去 状态 1 2 3 4 5
            //庄家的权值
            int dealerWeight = room.GetDealerWeight();

            gameOverDto.dealerWeight = dealerWeight;
            for (int i = 0; i < 4; i++)
            {
                //不为空
                if (room.PlayerList[i] != null)
                {
                    List <int> StateList   = new List <int>();
                    List <int> WeightList  = new List <int>();
                    List <int> WinBeenList = new List <int>();

                    UserModel um = userCache.GetModelById(room.PlayerList[i].UserId);
                    //ClientPeer client = userCache.GetClientPeer(room.PlayerList[i].UserId);
                    int wager = room.PlayerList[i].Wager;

                    //一名掉线玩家
                    if (room.LeaveUIdList.Contains(room.PlayerList[i].UserId))
                    {
                        //扣双倍豆
                        um.Been -= wager * 2;
                        gameOverDto.isLeaveList[i] = true;
                        WinBeenList.Add(-wager * 2);
                        gameOverDto.playerWinBeenListList[i] = WinBeenList;
                    }
                    //正常玩家
                    else
                    {
                        //每一把牌经验豆子结算
                        for (int j = 0; j < room.PlayerList[i].CardListList.Count; j++)
                        {
                            int multi = 1;

                            PlayerCardDto tempPlayerCardDto = room.PlayerList[i].CardListList[j];
                            int           tempWeight        = tempPlayerCardDto.Weight;
                            WeightList.Add(tempWeight);
                            int  tempState    = tempPlayerCardDto.CardState;
                            bool tempIsDouble = tempPlayerCardDto.isDouble;
                            if (tempIsDouble)
                            {
                                multi = 2;
                            }


                            //21点
                            if (tempState == 1)
                            {
                                um.Been += (int)(wager * 1.5);
                                WinBeenList.Add((int)(wager * 1.5));
                                StateList.Add(1);
                                um.Exp += 150;
                            }
                            //闲家爆牌
                            else if (tempState == 2)
                            {
                                um.Been -= wager * multi;
                                WinBeenList.Add(-wager * multi);
                                if (multi == 1)
                                {
                                    StateList.Add(2);
                                }
                                else
                                {
                                    StateList.Add(3);
                                }
                                um.Exp += 50;
                            }
                            //不要 权值小于
                            else if (tempState == 3)
                            {
                                //庄家爆牌
                                if (dealerWeight > 21)
                                {
                                    um.Been += wager * multi;
                                    WinBeenList.Add(wager * multi);
                                    if (multi == 1)
                                    {
                                        StateList.Add(6);
                                    }
                                    else
                                    {
                                        StateList.Add(4);
                                    }

                                    um.Exp += 100;
                                }
                                //闲家点大
                                else if (dealerWeight < tempWeight)
                                {
                                    um.Been += wager * multi;
                                    WinBeenList.Add(wager * multi);
                                    if (multi == 1)
                                    {
                                        StateList.Add(6);
                                    }
                                    else
                                    {
                                        StateList.Add(4);
                                    }
                                    um.Exp += 100;
                                }
                                //庄家点大
                                else if (dealerWeight > tempWeight)
                                {
                                    um.Been -= wager * multi;
                                    WinBeenList.Add(-wager * multi);
                                    if (multi == 1)
                                    {
                                        StateList.Add(7);
                                    }
                                    else
                                    {
                                        StateList.Add(5);
                                    }
                                    um.Exp += 50;
                                }
                                //平局
                                else
                                {
                                    WinBeenList.Add(0);
                                    StateList.Add(8);

                                    um.Exp += 75;
                                }
                            }
                        }
                    }
                    gameOverDto.playerWeightListList[i]  = WeightList;
                    gameOverDto.playerStateListList[i]   = StateList;
                    gameOverDto.playerWinBeenListList[i] = WinBeenList;

                    int maxExp = um.Lv * 100;
                    while (maxExp <= um.Exp)
                    {
                        um.Lv++;
                        um.Exp -= maxExp;
                        maxExp  = um.Lv * 100;
                    }
                    userCache.Update(um);
                    UserDto dto = new UserDto(um.Id, um.Name, um.Been, um.WinCount, um.LoseCount, um.RunCount, um.Lv, um.Exp);
                    gameOverDto.userDtoList[i] = dto;
                }
            }

            //掉线的 不用发了,改一下这个函数 主要用在overpanel
            brocast(room, OpCode._21Multi, _21MultiCode.OVER_BRO, gameOverDto, null);

            //房间设置为等待
            fightCache.SetRoomWait(room);
            //删除离开列表里的用户
            foreach (int uid in room.LeaveUIdList)
            {
                fightCache.Leave(uid);
            }
            //重置房间
            room.resetRoom();
        }