示例#1
0
        public void HandleSetName(AdressedMessage adressedMessage)
        {
            if (game.started)
            {
                SendRequestDenied(adressedMessage);
                return;
            }

            SetNameMessage setNameMessage = (SetNameMessage)adressedMessage.message;

            lobby.players[adressedMessage.connectionID].name = setNameMessage.Name;
            int connectionID = adressedMessage.connectionID;
            NewPlayerMessage newPlayerMessage = new NewPlayerMessage {
                PlayerID    = connectionID,
                PlayerColor = ColorExtentions.ToUInt(lobby.players[adressedMessage.connectionID].color),
                PlayerName  = lobby.players[adressedMessage.connectionID].name
            };

            //send new player to lobby
            foreach (KeyValuePair <int, Player> player in lobby.players)
            {
                if (player.Key == connectionID)
                {
                    continue;
                }
                serverBehaviour.QeueMessage(new AdressedMessage(newPlayerMessage, player.Key));
            }
        }
示例#2
0
        public virtual HttpResponseMessage SaveNewPlayer([FromBody] NewPlayerMessage newPlayerMessage, [FromUri] int gamingGroupId)
        {
            var requestedPlayer = new CreatePlayerRequest
            {
                Name               = newPlayerMessage.PlayerName,
                GamingGroupId      = newPlayerMessage.GamingGroupId,
                PlayerEmailAddress = newPlayerMessage.PlayerEmailAddress
            };

            Player newPlayer;

            try
            {
                newPlayer = _playerSaver.CreatePlayer(requestedPlayer, CurrentUser);
            }
            catch (PlayerAlreadyExistsException exception)
            {
                exception.ErrorSubCode = 1;
                throw;
            }
            catch (PlayerWithThisEmailAlreadyExistsException exception)
            {
                exception.ErrorSubCode = 2;
                throw;
            }

            var newlyCreatedPlayerMessage = new NewlyCreatedPlayerMessage
            {
                PlayerId      = newPlayer.Id,
                GamingGroupId = newPlayer.GamingGroupId,
                NemeStatsUrl  = AbsoluteUrlBuilder.GetPlayerDetailsUrl(newPlayer.Id)
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyCreatedPlayerMessage));
        }
    public override void OnClientConnect(NetworkConnection conn)
    {
        NewPlayerMessage msg = new NewPlayerMessage();

        msg.PlayerName = username;
        var res = ClientScene.AddPlayer(conn, 0, msg);
    }
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessage)
    {
        var ap = extraMessage.ReadString();
        NewPlayerMessage newPlayerMsg = new NewPlayerMessage();

        if (newPlayerMsg == null)
        {
            return;
        }

        Transform  startPos     = GetStartPosition();
        GameObject playerObject = Instantiate(playerPrefab, startPos.position, startPos.rotation);

        if (playerObject != null)
        {
            MMOPlayer player = playerObject.GetComponent <MMOPlayer>();
            player.PlayerName = ap;

            NetworkServer.AddPlayerForConnection(
                conn,
                playerObject,
                playerControllerId
                );
        }
    }
示例#5
0
    public INetworkMessage ReadJoingingAreaMessages(NetworkConnection connection, DataStreamReader reader, Message message)
    {
        switch (message.messageType)
        {
        // Send a stay alive message.
        case MessageType.None:
            Send(connection, new Message(0, MessageType.None));
            return(null);

        // Set the name of the player and send NewPlayerMessages to all existing connections.
        case MessageType.SetName:
            var setNameMessage = new SetNameMessage(message.id);
            setNameMessage.Deserialize(ref reader);

            var playerInfo = playerInfoByID[connection.InternalId];
            playerInfo._name = setNameMessage._name;
            playerInfoByID.Remove(connection.InternalId);
            playerInfoByID.Add(connection.InternalId, playerInfo);
            var newPlayerMessage = new NewPlayerMessage(MessageID.nextID, connection.InternalId, playerInfo.color, setNameMessage.name);
            foreach (var otherConnection in connections)
            {
                if (otherConnection == connection)
                {
                    continue;
                }

                Send(otherConnection, newPlayerMessage);
            }

            return(setNameMessage);

        default:
            return(null);
        }
    }
示例#6
0
    // Called when a client connect request is sent from a new client. assigns a new id and responds with the current game state
    private void assignClientID(IPEndPoint client, string message)
    {
        RemoteClients  newRemoteClient = new RemoteClients(numberOfconnectedClients);
        ConnectMessage connectMessage  = new ConnectMessage(-2, numberOfconnectedClients, isInProgress);
        Message        recievedMessage = JsonUtility.FromJson <Message>(message);

        newRemoteClient.setEndPoint(client);


        sendToClient(client, connectMessage.constructMessage());

        // Send all existing players to the new player
        foreach (RemoteClients remote in remoteClients)
        {
            NewPlayerMessage existingPlayerMessage = new NewPlayerMessage(-2, remote.clientID, remote.playerName);
            sendToClient(client, existingPlayerMessage.constructMessage());
        }

        remoteClients.Add(newRemoteClient);


        // Send the new client joined to all existing clients
        for (int i = 0; i < numberOfconnectedClients; i++)
        {
            NewPlayerMessage newPlayerMessage = new NewPlayerMessage(-2, numberOfconnectedClients, recievedMessage.clientName);
            sendToClient(remoteClients[i].clientEndPoint, newPlayerMessage.constructMessage());
        }

        numberOfconnectedClients++;
    }
示例#7
0
    public void SpawnSprite(MessageHeader Info)
    {
        NewPlayerMessage message = Info as NewPlayerMessage;
        GameObject       go      = GameObject.Instantiate(spritePrefab);

        go.transform.SetParent(UIManager.Instance.GamePanel.transform, false);
        go.transform.localScale = Vector3.one;
        go.transform.position   = spawnPositions[CurrentPlayer.playerID].transform.position;


        for (int i = 0; i < go.transform.childCount; i++)
        {
            if (go.transform.GetChild(i).name == "Arrow")
            {
                Debug.Log(message.PlayerColor);
                Color playerColor = new Color();
                playerColor.FromUInt(message.PlayerColor);
                Image image = go.transform.GetChild(i).GetComponent <Image>();
                image.color = new Color().FromUInt(message.PlayerColor);
            }

            if (go.transform.GetChild(i).name.Contains("Shield"))
            {
                CurrentPlayer.Shield = go.transform.GetChild(i).gameObject;
                CurrentPlayer.Shield.SetActive(false);
            }
        }
    }
        public void HandleNewPlayer(Message message)
        {
            NewPlayerMessage newPlayerMessage = (NewPlayerMessage)message;
            Player           newPlayer        = new Player(newPlayerMessage.PlayerColor);

            newPlayer.name = newPlayerMessage.PlayerName;
            lobby.players.Add(newPlayerMessage.PlayerID, newPlayer);
            Menu.Singleton.UpdateLobbyWindows(lobby);
        }
示例#9
0
    // Adds all existing and new remote clients to the local client list of connected clients
    private void addNewClient(string message)
    {
        NewPlayerMessage newPlayerMessage = JsonUtility.FromJson <NewPlayerMessage>(message);
        RemoteClients    newClientObject  = new RemoteClients(newPlayerMessage.newPlayerID);

        remoteClients.Add(newClientObject);

        sceneManager.instantiateRemote(message);
    }
示例#10
0
    public void GetNewPlayer(SocketIOEvent e)
    {
        GameObject             player = Instantiate(connectedPlayerPrefab);
        ConnectedPlayerManager pm     = player.GetComponent <ConnectedPlayerManager>();
        NewPlayerMessage       data   = JsonUtility.FromJson <NewPlayerMessage>(e.data.ToString());

        pm.uid = data.uid;
        playerList.Add(pm.uid, player);
    }
示例#11
0
    public void GetPlayer(SocketIOEvent e)
    {
        NewPlayerMessage data = JsonUtility.FromJson <NewPlayerMessage>(e.data.ToString());

        playerId    = data.uid;
        playerReady = true;

        StartCoroutine("PositionUpdateLoop");
    }
    public NewPlayerMessage CreateNewPlayerMessage(NetworkConnection connection)
    {
        PlayerData newPlayerData = GetPlayerData(connection);

        NewPlayerMessage result = new NewPlayerMessage
        {
            PlayerID   = newPlayerData.playerIndex,
            Colour     = colorTouint((Color32)newPlayerData.color),
            PlayerName = newPlayerData.name
        };

        return(result);
    }
        public void SendNewPlayerMessage()
        {
            // create new player message, so everyone in the game can update their player list
            NewPlayerMessage newPlayerMessage = new NewPlayerMessage();

            newPlayerMessage.playerList = StaticResources.PlayerList;

            // convert the NewPlayerMessage model to a JsonString
            string line = JsonConvert.SerializeObject(newPlayerMessage);

            // send the new player message
            ServiceBusHandler.program.topic.SendTopicMessage(line, MessageType.NewPlayer);
        }
示例#14
0
        public void ItSavesTheNewPlayer()
        {
            var newPlayerMessage = new NewPlayerMessage
            {
                PlayerName = "some player name"
            };

            autoMocker.ClassUnderTest.SaveNewPlayer(newPlayerMessage, 0);

            autoMocker.Get <IPlayerSaver>().AssertWasCalled(
                mock => mock.Save(Arg <Player> .Matches(player => player.Name == newPlayerMessage.PlayerName),
                                  Arg <ApplicationUser> .Is.Anything));
        }
        public static void HandleNewPlayerTopicMessage(string message)
        {
            // decode message
            Transfer transfer = JsonConvert.DeserializeObject <Transfer>(message);

            // check if the message is for a new player that has joined
            if (transfer.type == MessageType.NewPlayer)
            {
                // decode message to SessionResponseModel
                NewPlayerMessage response = JsonConvert.DeserializeObject <NewPlayerMessage>(transfer.message);

                // update the player collection with the newly joinend players
                StaticResources.PlayerList = response.playerList;
            }
        }
示例#16
0
        public virtual HttpResponseMessage SaveNewPlayer([FromBody] NewPlayerMessage newPlayerMessage, [FromUri] int gamingGroupId)
        {
            var requestedPlayer = new Player
            {
                Name = newPlayerMessage.PlayerName
            };

            var actualNewlyCreatedPlayer = playerSaver.Save(requestedPlayer, CurrentUser);

            var newlyCreatedPlayerMessage = new NewlyCreatedPlayerMessage
            {
                PlayerId = actualNewlyCreatedPlayer.Id
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyCreatedPlayerMessage));
        }
示例#17
0
        public void ItSavesTheNewPlayer()
        {
            var newPlayerMessage = new NewPlayerMessage
            {
                PlayerName    = "some player name",
                GamingGroupId = _expectedGamingGroupId
            };

            _autoMocker.ClassUnderTest.SaveNewPlayer(newPlayerMessage, _expectedGamingGroupId);

            _autoMocker.Get <IPlayerSaver>().AssertWasCalled(
                mock => mock.CreatePlayer(Arg <CreatePlayerRequest> .Matches(player => player.Name == newPlayerMessage.PlayerName &&
                                                                             player.GamingGroupId == _expectedGamingGroupId),
                                          Arg <ApplicationUser> .Is.Anything,
                                          Arg <bool> .Is.Equal(false)));
        }
示例#18
0
    private void UpdateConnections()
    {
        // Clean up Connections.
        for (int i = 0; i < connections.Length; i++)
        {
            if (!connections[i].IsCreated)
            {
                playerInfoByID.Remove(connections[i].InternalId);
                connections.RemoveAt(i);
                i--;
            }
        }

        // Accept new Connections.
        NetworkConnection connection;

        while ((connection = driver.Accept()) != default)
        {
            if (connectionsLength >= maxConnections)
            {
                driver.Disconnect(connection);
            }
            else
            {
                // Send PlayerMessages and a WelcomeMessage to the new connection.
                var playerInfo = new PlayerInfo
                {
                    color = Random.ColorHSV(),
                    name  = "",
                };
                playerInfoByID.Add(connection.InternalId, playerInfo);

                for (int i = 0; i < connectionsLength; i++)
                {
                    var otherConnection  = connections[i];
                    var otherPlayerInfo  = playerInfoByID[otherConnection.InternalId];
                    var newPlayerMessage = new NewPlayerMessage(MessageID.nextID, otherConnection.InternalId, otherPlayerInfo.color, otherPlayerInfo._name);
                    Send(connection, newPlayerMessage);
                }

                var welcomeMessage = new WelcomeMessage(MessageID.nextID, connection.InternalId, playerInfo.color);
                Send(connection, welcomeMessage);

                connections.AddNoResize(connection);
            }
        }
    }
示例#19
0
        public void ItSavesTheNewPlayerUsingTheGamingGroupIdOnTheRequestInsteadOfFromTheUri()
        {
            var newPlayerMessage = new NewPlayerMessage
            {
                PlayerName    = "some player name",
                GamingGroupId = _expectedGamingGroupId
            };
            int someGamingGroupIdThatWontGetUsed = -100;

            _autoMocker.ClassUnderTest.SaveNewPlayer(newPlayerMessage, someGamingGroupIdThatWontGetUsed);

            _autoMocker.Get <IPlayerSaver>().AssertWasCalled(
                mock => mock.CreatePlayer(Arg <CreatePlayerRequest> .Matches(player => player.Name == newPlayerMessage.PlayerName &&
                                                                             player.GamingGroupId == _expectedGamingGroupId),
                                          Arg <ApplicationUser> .Is.Anything,
                                          Arg <bool> .Is.Anything));
        }
示例#20
0
        /************* CLIENT CALLBACKS *************/

        // called on client when connected to a server
        public override void OnClientConnect(NetworkConnection connectionToServer)
        {
            bool isLocalClient = NetworkServer.active;

            if (isLocalClient)
            {
                if (state != DNMState.Host)
                {
                    Debug.LogError("Invalid state");
                }
                if (gameState != GameState.NoGame)
                {
                    Debug.LogError("Invalid state");
                }

                // add hosted players
                for (int i = 0; i < cachedLocalPlayers.Count; i++)
                {
                    NewPlayerMessage newPlayerMessage = new NewPlayerMessage();
                    newPlayerMessage.playerName = cachedLocalPlayers[i].playerName;

                    ClientScene.AddPlayer(connectionToServer, (short)i, newPlayerMessage);
                }

                OnClientConnected(true);
            }
            else
            {
                if (state != DNMState.Connecting)
                {
                    Debug.LogError("Invalid state");
                }
                state = DNMState.Client;
                SetServerInfo("Client", "");

                //ClientScene.Ready(connectionToServer); // TODO is ready ??

                NewPlayerMessage newPlayerMessage = new NewPlayerMessage();
                newPlayerMessage.playerName = GetPlayerName();

                // ask the server to add player for this remote client
                ClientScene.AddPlayer(connectionToServer, 0, newPlayerMessage);

                OnClientConnected(false);
            }
        }
示例#21
0
    public INetworkMessage ReadJoingingAreaMessage(DataStreamReader reader, Message message)
    {
        switch (message.messageType)
        {
        // Read a NewPlayer message.
        case MessageType.NewPlayer:
            var newPlayerMessage = new NewPlayerMessage(message.id);
            newPlayerMessage.Deserialize(ref reader);
            return(newPlayerMessage);

        // Set your playedID and playerInfo.
        case MessageType.Welcome:
            var welcomeMessage = new WelcomeMessage(message.id);
            welcomeMessage.Deserialize(ref reader);

            playerID         = welcomeMessage.playerID;
            playerInfo.color = welcomeMessage.color;

            Send(new SetNameMessage(MessageID.nextID, playerInfo.name));

            return(welcomeMessage);

        // Read a PlayerLeft message.
        case MessageType.PlayerLeft:
            var playerLeftMessage = new PlayerMessage(message.id, message.messageType);
            playerLeftMessage.Deserialize(ref reader);
            return(playerLeftMessage);

        // Load Cave Quest and initialize the players stats.
        case MessageType.StartGame:
            var startGameMessage = new StartGameMessage(message.id);
            startGameMessage.Deserialize(ref reader);

            var caveQuestPlayer = gameObject.AddComponent <CaveQuestPlayer>();
            SceneManager.LoadSceneAsync("Cave Quest").completed += (asyncOperation) =>
            {
                caveQuestPlayer.Initialize(startGameMessage.startHP);
            };

            return(startGameMessage);

        default:
            return(null);
        }
    }
    private void PlayerJoined(ref DataStreamReader reader)
    {
        var message = new NewPlayerMessage();

        message.DeserializeObject(ref reader);
        PlayerData newData = new PlayerData
        {
            playerIndex = message.PlayerID,
            color       = UIntToColor(message.Colour),
            name        = message.PlayerName
        };

        if (newData.playerIndex == dataHolder.myData.playerIndex)
        {
            dataHolder.myData.name = newData.name;
        }
        dataHolder.players.Add(newData);
        dataHolder.lobby.UpdateLobby(dataHolder.players.ToArray());
    }
        public void ItSavesTheNewPlayer()
        {
            var newPlayerMessage = new NewPlayerMessage
            {
                PlayerName         = "some player name",
                GamingGroupId      = _expectedGamingGroupId,
                PlayerEmailAddress = "some email address"
            };

            _autoMocker.ClassUnderTest.SaveNewPlayer(newPlayerMessage, _expectedGamingGroupId);

            var args = _autoMocker.Get <IPlayerSaver>().GetArgumentsForCallsMadeOn(
                mock => mock.CreatePlayer(Arg <CreatePlayerRequest> .Is.Anything, Arg <ApplicationUser> .Is.Anything,
                                          Arg <bool> .Is.Anything));
            var firstCall = args.AssertFirstCallIsType <CreatePlayerRequest>();

            firstCall.Name.ShouldBe(newPlayerMessage.PlayerName);
            firstCall.GamingGroupId.ShouldBe(newPlayerMessage.GamingGroupId);
            firstCall.PlayerEmailAddress.ShouldBe(newPlayerMessage.PlayerEmailAddress);
        }
示例#24
0
        public void HandleNewConnection(int connectionID)
        {
            //welcome to new player
            var color = new Color(
                UnityEngine.Random.Range(0.2f, 0.5f),
                UnityEngine.Random.Range(0.2f, 0.5f),
                UnityEngine.Random.Range(0.2f, 0.5f)
                );
            var color32 = (Color32)color;

            Debug.Log(color32);
            var welcomeMessage = new WelcomeMessage {
                PlayerID = connectionID,
                Color    = ((uint)color32.r << 24) | ((uint)color32.g << 16) | ((uint)color32.b << 8) | color32.a
            };

            serverBehaviour.QeueMessage(new AdressedMessage(welcomeMessage, connectionID));

            //send lobby to new player
            foreach (KeyValuePair <int, Player> player in lobby.players)
            {
                if (player.Key == connectionID)
                {
                    continue;
                }

                NewPlayerMessage newPlayerMessage = new NewPlayerMessage {
                    PlayerID    = player.Key,
                    PlayerColor = ColorExtentions.ToUInt(player.Value.color),
                    PlayerName  = player.Value.name
                };
                serverBehaviour.QeueMessage(new AdressedMessage(newPlayerMessage, connectionID));
            }

            lobby.players.Add(connectionID, new Player(color));
        }
    public void NewPlayerJoined(NetworkConnection newPlayerConnection)
    {
        PlayerData newPlayerData = GetPlayerData(newPlayerConnection);


        //send all players the info of new player
        NewPlayerMessage newPlayermessage = new NewPlayerMessage
        {
            PlayerID   = newPlayerData.playerIndex,
            Colour     = colorTouint((Color32)newPlayerData.color),
            PlayerName = newPlayerData.name
        };

        SendMessageToAll(newPlayermessage);


        //send all the other player data to the new player
        foreach (NetworkConnection conn in connections)
        {
            if (conn == newPlayerConnection)
            {
                return;
            }

            PlayerData otherPlayerData = GetPlayerData(conn);
            //if (otherPlayerData.name == "") return; //this caused bug that it doesnt add the other players who joined but didnt added a name

            NewPlayerMessage otherPlayerMessage = new NewPlayerMessage
            {
                PlayerID   = otherPlayerData.playerIndex,
                Colour     = colorTouint((Color32)otherPlayerData.color),
                PlayerName = otherPlayerData.name
            };
            SendMessage(otherPlayerMessage, newPlayerConnection);
        }
    }
示例#26
0
 // handler for NewPlayer messages
 public void HandleNewPlayerMessage(NewPlayerMessage m)
 {
     chatLog += m.MessageValue + ", PlayerGUID=" + m.PlayerGUID.ToString() + "\n";
 }
示例#27
0
        public static async void HandleQueueMessage(string message)
        {
            // check if player is identified
            if (StaticResources.user != null)
            {
                // decode message
                Transfer transfer = JsonConvert.DeserializeObject <Transfer>(message);
                Player   source;

                // check if message type is JoinRequest, so we know how to decode the message inside the transfer object and we know how to use it
                if (transfer.type == MessageType.JoinRequest)
                {
                    //check if the player is the host, because only the host may handel messages of the type JoinRequest
                    if (StaticResources.user.type == PlayerType.Host)
                    {
                        // decode message
                        source = JsonConvert.DeserializeObject <Player>(transfer.message);

                        // count amount of people in the game
                        int playerCount = StaticResources.PlayerList.Count();

                        // check if the player is already in the game
                        int exists = StaticResources.PlayerList.Where(p => p.userId == source.userId).Count();

                        // check if there are less than 4 people in the game and the new request is from a new player
                        if (playerCount < 4 && exists == 0)
                        {
                            // set the player order, by increasing the playerCount before assigning it to the ordernumber
                            source.orderNumber = ++playerCount;

                            // add new player to the player list
                            List <Player> players = StaticResources.PlayerList;
                            players.Add(source);

                            // create response model
                            SessionResponse response = new SessionResponse();
                            response.Player    = source;
                            response.accepted  = true;
                            response.topicData = new TopicData()
                            {
                                TopicConnectionString = program.topic.TopicData.TopicConnectionString, // get newly created topic connection string
                                topic        = program.topic.TopicData.topic,                          // get newly created topic name
                                subscription = subscription[playerCount]                               // assign subscription to the new player
                            };

                            // convert the response model to a JsonString
                            string line = JsonConvert.SerializeObject(response);

                            // create writer program
                            await program.CreateQueueWriter(PlayerType.Host, transfer.QueueData);

                            // send response data on the newly joined writer queue
                            program.QueueWriter.SendQueueMessage(line, MessageType.Response);

                            // disconnect from the writer queue
                            //program.QueueWriter.DisconnectFromQueue();

                            // create new player message, so everyone in the game can update their player list
                            NewPlayerMessage newPlayerMessage = new NewPlayerMessage();
                            newPlayerMessage.playerList = players;

                            // convert the NewPlayerMessage model to a JsonString
                            line = JsonConvert.SerializeObject(newPlayerMessage);

                            // send the new player message
                            program.topic.SendTopicMessage(line, MessageType.NewPlayer);
                        }
                    }
                }

                // check if the message type is response
                if (transfer.type == MessageType.Response)
                {
                    // message type is response
                    // decode message to SessionResponseModel
                    SessionResponse response = JsonConvert.DeserializeObject <SessionResponse>(transfer.message);

                    // get the player from the response model
                    Player player = response.Player;

                    // check if the response is meant for me
                    if (player.userId == StaticResources.user.userId && player.name == StaticResources.user.name && player.type == StaticResources.user.type)
                    {
                        // the response is for me
                        // update player data
                        StaticResources.user = player;

                        // store service bus topic data in program
                        program.CreateTopicConnection(response.topicData);

                        program.QueueWriter.DisconnectFromQueue();
                        program.QueueListner.DisconnectFromQueue();

                        program.DeleteListnerQueue();
                    }
                }
            }
        }
示例#28
0
        public override bool Reveal(Player player)
        {
            return(true);

            if (!base.Reveal(player))
            {
                return(false);
            }

            if (this != player)
            {
                /*HeroStateData hsd = new HeroStateData()
                 * {
                 *  Field0 = 0,
                 *  Field1 = 0,
                 *  Field2 = 0,
                 *  Field3 = 0,
                 *  PlayerFlags = 0,
                 *  QuestRewardHistoryEntriesCount = 0,
                 *  PlayerSavedData = new PlayerSavedData()
                 *  {
                 *      HotBarButtons = new HotbarButtonData[6],
                 *  }
                 * };
                 * hsd.PlayerSavedData.HotBarButtons = this.PowerSet.HotbarButtonData;*/
                NewPlayerMessage npm = new NewPlayerMessage()
                {
                    dynamicId = 5, // player index
                    //ToonId = new EntityId() { High = (long)1, Low = (long)1 }, //Toon
                    //GameAccountId = new EntityId() { High = (long)1, Low = (long)1 }, //GameAccount
                    ToonName         = "machivito", //joinedPlayer.name,
                    Field3           = 0x00000002,  //party frame class
                    Field4           = 0x4,         //party frame level
                    snoActorPortrait = 32001,       //party frame portrait //ojo
                    Level            = 15,
                    //StateData = hsd,
                    IsMainPlayer = false, //ACA ES FALSOOOOOOOOOOOO
                    Field9       = 0x00000001,
                    ActorID      = this.DynamicID,
                    SNO          = 32001
                };

                if (player.GameClient != null)
                {
                    player.GameClient.SendMessage(npm);
                }

                /*ACDCreateActorMessage createdActor = ACDEnterKnown();
                 *
                 *
                 * if (player.GameClient != null)
                 *  player.GameClient.SendMessage(createdActor);
                 *
                 * // Reveal actor (creates actor and makes it visible to the player)
                 * if (player.GameClient != null)
                 *  player.GameClient.SendMessage(new ACDEnterMapMessage(this.DynamicID));*/
            }

            /*if (this == player) // only send this when player's own actor being is revealed.
             * {
             *  player.GameClient.SendMessage(new PlayerWarpedMessage()
             *  {
             *      Field0 = 9,
             *      Field1 = 0f,
             *  });
             * }
             *
             * player.GameClient.SendMessage(new PlayerEnterKnownMessage()
             * {
             *  PlayerIndex = this.PlayerIndex,
             *  ActorId = this.DynamicID,
             * });
             *
             * //this.Inventory.SendVisualInventory(player);
             * }*/

            //this.Inventory.Reveal(player);

            return(true);
        }
示例#29
0
 public virtual HttpResponseMessage SaveNewPlayer([FromBody] NewPlayerMessage newPlayerMessage)
 {
     return(SaveNewPlayer(newPlayerMessage, CurrentUser.CurrentGamingGroupId));
 }
示例#30
0
 public virtual HttpResponseMessage SaveNewPlayer([FromBody] NewPlayerMessage newPlayerMessage)
 {
     //--gamingGroupId is obsolete here and will be on the request or else used from the current user context -- so just pass "0"
     return(SaveNewPlayer(newPlayerMessage, 0));
 }
    public void Update()
    {
        networkJobHandle.Complete();

        if (!connection.IsCreated)
        {
            return;
        }

        DataStreamReader reader;

        NetworkEvent.Type cmd;
        while ((cmd = connection.PopEvent(networkDriver, out reader)) != NetworkEvent.Type.Empty)
        {
            if (cmd == NetworkEvent.Type.Connect)
            {
                Debug.Log("Connected to server");
            }
            else if (cmd == NetworkEvent.Type.Data)
            {
                var messageType = (Message.MessageType)reader.ReadUShort();
                Debug.Log("Client Received: " + messageType + " from Host");

                Message message = null;
                switch (messageType)
                {
                case Message.MessageType.None: break;

                case Message.MessageType.NewPlayer: message = new NewPlayerMessage(); break;

                case Message.MessageType.Welcome: message = new WelcomeMessage(); break;

                case Message.MessageType.RequestDenied: message = new RequestDeniedMessage(); break;

                case Message.MessageType.PlayerLeft: message = new PlayerLeftMessage(); break;

                case Message.MessageType.StartGame: message = new StartGameMessage(); break;

                case Message.MessageType.PlayerTurn: message = new PlayerTurnMessage(); break;

                case Message.MessageType.RoomInfo: message = new RoomInfoMessage(); break;

                case Message.MessageType.PlayerEnterRoom: message = new PlayerEnterRoomMessage(); break;

                case Message.MessageType.PlayerLeaveRoom: message = new PlayerLeaveRoomMessage(); break;

                case Message.MessageType.ObtainTreasure: message = new ObtainTreasureMessage(); break;

                case Message.MessageType.HitMonster: message = new HitMonserMessage(); break;

                case Message.MessageType.HitByMonster: message = new HitByMonserMessage(); break;

                case Message.MessageType.PlayerDefends: message = new PlayerDefendsMessage(); break;

                case Message.MessageType.PlayerLeftDungeon: message = new PlayerLeftDungeonMessage(); break;

                case Message.MessageType.PlayerDies: message = new PlayerDiesMessage(); break;

                case Message.MessageType.EndGame:   break;

                default: break;
                }
                if (message != null)
                {
                    message.DeserializeObject(ref reader);
                    receivedMessagesQueue.Enqueue(message);
                }
            }
            else if (cmd == NetworkEvent.Type.Disconnect)
            {
                Debug.Log("Disconnected from server");
                connection = default;
            }
        }
        ProcessMessagesQueue();

        if (Time.time - lastSendTime > STAY_ALIVE_AFTER_SECONDS)
        {
            SendMessage(new NoneMessage());
        }
        networkJobHandle = networkDriver.ScheduleUpdate();
    }