Ejemplo n.º 1
0
    public override void onPlayerJoined(PlayerJoinedMessage message)
    {
        Player player = PlayerDatabase.Instance.GetPlayer(message.playerId);

        player.SetPosition(new Position(0, 0));
        setId(new Position(0, 0), player.id);
    }
Ejemplo n.º 2
0
 public override void onPlayerJoined(PlayerJoinedMessage message)
 {
     Debug.Log("PLAYER JOINED! " + message.playerId);
     if (message.playerId == playerId)
     {
         player    = new MainPlayer(PlayerDatabase.Instance.GetPlayer(playerId));
         hasJoined = true;
     }
 }
        public ServerMessage CreateMessage(byte[] bytes)
        {
            var messageType = (bytes?.FirstOrDefault() ?? 0).GetMessageType();

            switch (messageType)
            {
            case ServerMessageType.PlayerJoined:
                var playerJoinedMessage = new PlayerJoinedMessage(bytes);
                Players.Add(playerJoinedMessage.Player);
                return(playerJoinedMessage);

            case ServerMessageType.StartOfGame:
                Players.Clear();
                ResetGameTime();
                return(new StartOfGameMessage(bytes));

            case ServerMessageType.StartOfDay:
            case ServerMessageType.StartOfNight:
                Trial.Clear();
                MoveTimeForward();
                return(new MoveTimeForwardMessage(bytes));

            case ServerMessageType.PlayerVote:
                var playerVoteMessage = new PlayerVoteMessage(bytes);
                Trial.AddVote(playerVoteMessage);
                return(playerVoteMessage);

            case ServerMessageType.PlayerOnStand:
                var playerOnStandMessage = new PlayerOnStandMessage(bytes);
                Trial.SetPlayerOnStand(playerOnStandMessage);
                return(playerOnStandMessage);

            case ServerMessageType.VoteVerdict:
                var voteVerdictMessage = new VoteVerdictMessage(bytes);
                Trial.AddVerdict(voteVerdictMessage);
                return(voteVerdictMessage);

            case ServerMessageType.PlayerIsGuilty:
            case ServerMessageType.PlayerIsInnocent:
                Trial.Complete();
                return(new ServerMessage(bytes));

            case ServerMessageType.Chat: return(new ChatMessage(bytes));

            case ServerMessageType.PlayerDead: return(new PlayerDeadMessage(bytes));

            case ServerMessageType.LocalPlayerReport: return(new LocalPlayerReportMessage(bytes));

            case ServerMessageType.MafiaPlayersReport: return(new MafiaPlayersReportMessage(bytes));

            case ServerMessageType.MayorRevealed: return(new MayorRevealedMessage(bytes));

            case ServerMessageType.PlayerRevived: return(new PlayerRevivedMessage(bytes));

            default: return(new ServerMessage(bytes));
            }
        }
Ejemplo n.º 4
0
        private void PlayerJoinedCallback(PlayerJoinedMessage msg, float travelTime)
        {
            var p = new MatchPlayer(msg.ClientGuid, msg.CtrlType, msg.InitialCharacter);

            players.Add(p);

            if (inLobby)
            {
                SpawnLobbyBall(p);
            }

            StopLobbyTimer();

            if (MatchPlayerAdded != null)
            {
                MatchPlayerAdded(this, new MatchPlayerEventArgs(p, msg.ClientGuid == myGuid));
            }
        }
Ejemplo n.º 5
0
        private void processPlayerJoined(PlayerJoinedMessage message)
        {
            int idJoined = (message).IdJoined();

            if (playerIds.Contains(idJoined))
            {
                return;
            }
            GameObject clientCube = createClient(idJoined, idJoined == this.id);

            if (idJoined == this.id)
            {
                registered            = true;
                myCharacterController = clientCube.GetComponent <CharacterController>();
                this._animator        = clientCube.GetComponent <Animator>();
                clientCube.GetComponentInChildren <Camera>().tag = "MasterClient";
            }
            else
            {
                clientCube.GetComponentInChildren <Camera>().tag = "SecondaryClient";
            }
        }
Ejemplo n.º 6
0
        private void HandleJoinMessage(GameMessage msg)
        {
            PlayerJoinedMessage joinMsg = msg as PlayerJoinedMessage;

            this.logger.LogInformation($"{joinMsg.PlayerId} joined the server");
        }
Ejemplo n.º 7
0
 public virtual void onPlayerJoined(PlayerJoinedMessage message)
 {
 }
Ejemplo n.º 8
0
 void PlayerJoined(PlayerJoinedMessage msg)
 {
     chatLogField.text += $"{msg.userName} joined the room\n";
 }
Ejemplo n.º 9
0
 public override void onPlayerJoined(PlayerJoinedMessage message)
 {
     AddPlayer(message.playerId);
 }
Ejemplo n.º 10
0
    void RecieveMessage(Message msg)
    {
        print("MESSAGE RECIEVED " + msg);
        switch (msg.type)
        {
        case MessageTypes.PlayerJoined:

            print("A NEW CHALLENGER APPROACHES");
            PlayerJoinedMessage pjm = (PlayerJoinedMessage)msg;
            m_playerController.AddPlayer(new PlayerData {
                index = pjm.id, color = pjm.color, icon = (PhoneUserIcon)pjm.icon, name = pjm.name
            });

            if (onPlayerCountChange != null)
            {
                onPlayerCountChange.Invoke(m_playerController.PlayerCount);
            }


            break;

        case MessageTypes.PlayerLeft:

            PlayerLeftMessage plm = (PlayerLeftMessage)msg;
            m_playerController.RemovePlayer(plm.id);

            if (onPlayerCountChange != null)
            {
                onPlayerCountChange.Invoke(m_playerController.PlayerCount);
            }
            SceneManager.LoadScene(0);
            break;

        case MessageTypes.PlayerMove:
            PlayerMoveMessage      pmm    = (PlayerMoveMessage)msg;
            ThirdPersonUserControl player = ThirdPersonUserControl.players[pmm.pid - 1];
            //if(pmm.x != null && pmm.y != null)
            player.setAxis(pmm.x, pmm.y);
            if (pmm.jmp)
            {
                player.jump = pmm.jmp;
            }
            if (pmm.drp)
            {
                player.drop = pmm.drp;
            }
            break;

        case MessageTypes.PlayerAction:
            PlayerActionMessage pam = (PlayerActionMessage)msg;
            print(pam + " sad");
            if (pam.jump)
            {
                ThirdPersonUserControl.players[pam.pid - 1].jump = true;
            }
            else
            {
                ThirdPersonUserControl.players[pam.pid - 1].drop = true;
            }
            break;
        }
    }
Ejemplo n.º 11
0
 private void HandlePlayerJoined(PlayerJoinedMessage msg)
 {
     for (var i = 1; i <= msg.PlayerCount; i++)
     {
         var firstFreePlayerNumber = GetFirstFreePlayerNumber();
         entityFactory.CreatePlayer(CreateEntity(), GetStartPosition(firstFreePlayerNumber), firstFreePlayerNumber, default, msg.PeerId);