public void ClientConnected(MultiplayerClient client)
        {
            Player player = (Player)CreateAvatar("player_remote", Graphics.TilePositionToVector3(GetPlayerResetPosition()));

            player.resetPosition = GetPlayerResetPosition();
            FillPlayerInventory(player.inventory);

            client.id = player.objectId;

            MultiplayerAction initialDataAction = new MultiplayerAction(MultiplayerAction.Action.INITIAL_DATA, GetInitialData(client, player));

            client.AddAction(initialDataAction);

            //Send others avatars
            foreach (Avatar avatar in world.avatarManager.Avatars)
            {
                if (avatar.objectId != player.objectId)
                {
                    client.AddAction(new MultiplayerAction(
                                         MultiplayerAction.Action.AVATAR_CREATE,
                                         new String[] {
                        avatar.objectId.ToString(),
                        "player_remote",
                        avatar.position.x.ToString(),
                        avatar.position.y.ToString(),
                        avatar.position.z.ToString(),
                        avatar.rotation.x.ToString(),
                        avatar.rotation.y.ToString(),
                        avatar.rotation.z.ToString()
                    }));
                }
            }

            stats.multiplayerConnectedClients++;
        }
Example #2
0
        public override void TileClicked(TilePosition tilePosition)
        {
            //base.TileClicked(tilePosition);

            client.AddAction(
                new MultiplayerAction(MultiplayerAction.Action.TILE_CLICKED,
                                      new String[] {
                tilePosition.x.ToString(),
                tilePosition.y.ToString(),
                tilePosition.z.ToString()
            }));
        }