Ejemplo n.º 1
0
    public void OnPlayerJoin(PlayerInput input)
    {
        PlayerConfiguration configuration = new PlayerConfiguration();

        settings.players.Add(configuration);

        Transform random = spawnSpots[Random.Range(0, spawnSpots.Count)];

        spawnSpots.Remove(random);

        GameObject go = Instantiate(settings.playerPrefab, random.position, random.rotation, transform);

        SelectionHud hud   = input.transform.parent.GetComponentInChildren <SelectionHud>();
        PlayerMover  mover = go.GetComponent <PlayerMover>();

        mover.PlayerIndex = input.playerIndex;

        _playerJoined.Add(hud, go);

        hud.SetInfo(this, settings, configuration, input);

        _onTimerTriggered    += hud.OnTimerTrigger;
        _onTimerValueChanged += hud.OnTimerValueChanged;

        Leader leader = go.GetComponent <Leader>();

        leader.SetConfiguration(configuration);
        _leaders.Add(leader);

        _inputs.Add(input);
        TimerIsOn = false;
    }
Ejemplo n.º 2
0
    private void SpawnAI()
    {
        while (_leaders.Count < settings.maxAmountOfPlayers)
        {
            PlayerConfiguration configuration = new PlayerConfiguration();
            settings.players.Add(configuration);

            var nickname = settings.RandomNicknameTable();
            nickname.taken = true;
            configuration.SetNickname(nickname.value);

            var skin = settings.RandomSkinTable();
            skin.taken = true;
            configuration.SetSkin(skin.value);

            Transform random = spawnSpots[Random.Range(0, spawnSpots.Count)];
            spawnSpots.Remove(random);

            GameObject go = Instantiate(settings.aiPrefab, random.position, random.rotation, transform);

            Leader leader = go.GetComponent <Leader>();
            leader.SetConfiguration(configuration);
            _leaders.Add(leader);
        }
    }
Ejemplo n.º 3
0
    protected void updateScores()
    {
        if (Player)
        {
            PlayerConfiguration player_info = Player.GetComponent <PlayerConfiguration>();

            if (PlayerNameText && player_info)
            {
                PlayerNameText.text = player_info.PlayerName;
            }

            if (FragsText)
            {
                FragsText.text = Player.Frags.ToString();
            }

            if (DeathsText)
            {
                DeathsText.text = Player.Deaths.ToString();
            }

            if (ScoreText)
            {
                ScoreText.text = Player.Score.ToString();
            }
        }
    }
Ejemplo n.º 4
0
    public void InitialiazePlayer(PlayerConfiguration pc)
    {
        _PlayerConfig = pc;

        //set correct color
        MeshRenderer[] meshRenderers = GetComponentsInChildren <MeshRenderer>();
        for (int t = 0; t < meshRenderers.Length; t++)
        {
            meshRenderers[t].material = _PlayerConfig.PlayerMaterial;
        }

        //controls
        InputBeh = _PlayerConfig.Input.gameObject.GetComponent <InputBehaviour>();

        InputBeh.StartJumpEvent.AddListener(StartJump);
        InputBeh.CancelJumpEvent.AddListener(CancelJump);

        InputBeh.StartPushEvent.AddListener(StartPush);
        InputBeh.EndPushEvent.AddListener(StopPush);

        InputBeh.StartInteractEvent.AddListener(StartInteract);

        //
        ++_PlayersAlive;
    }
Ejemplo n.º 5
0
        public async Task TestAcceptMessageBegForInfoAccept()
        {
            BegForInfoForwardedPayload payloadBeg = new BegForInfoForwardedPayload()
            {
                AskingID = 2,
                Leader   = false,
                TeamID   = Team.Red,
            };
            Message messageBeg   = new Message(MessageID.BegForInfoForwarded, agentID, payloadBeg);
            Message messageStart = CreateStartMessage();

            BufferBlock <Message> inputBuffer = new BufferBlock <Message>();

            inputBuffer.Post(messageStart);
            inputBuffer.Post(messageBeg);

            PlayerConfiguration configuration = GenerateSampleConfiguration();
            var player = new Player.Models.Player(configuration, inputBuffer, new TcpSocketClient <Message, Message>(logger), logger);

            await player.AcceptMessage(CancellationToken.None);

            await player.AcceptMessage(CancellationToken.None);

            Assert.Single(player.WaitingPlayers);
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkId=398940
        public void ConfigureServices(IServiceCollection services)
        {
            PlayerConfiguration conf = new PlayerConfiguration();

            Configuration.Bind("DefaultPlayerConfig", conf);

            // For console override;
            Configuration.Bind(conf);
            services.AddSingleton(conf);

            // 'Try' for tests override
            var logger = GetLogger(conf.TeamID, conf.Verbose);

            services.TryAddSingleton <ILogger>(logger);

            services.AddSingleton <ISocketClient <Message, Message>, TcpSocketClient <Message, Message> >();
            services.AddSingleton <BufferBlock <Message> >();
            services.AddSingleton <Models.Player>();

            var sync = new ServiceSynchronization(0, 1);

            services.AddSingleton(sync);
            services.AddHostedService <SocketService>();
            services.AddHostedService <PlayerService>();
        }
Ejemplo n.º 7
0
        public async Task TestAcceptMessageCheckAnswerShouldChangeIsHeldPieceShamToTrue()
        {
            // Arrange
            CheckAnswerPayload payloadCheck = new CheckAnswerPayload()
            {
                Sham = true,
            };
            Message messageCheck = new Message()
            {
                MessageID = MessageID.CheckAnswer,
                Payload   = payloadCheck,
            };
            Message startMessage = CreateStartMessage();

            BufferBlock <Message> inputBuffer = new BufferBlock <Message>();

            inputBuffer.Post(startMessage);
            inputBuffer.Post(messageCheck);

            PlayerConfiguration configuration = GenerateSampleConfiguration();
            var player = new Models.Player(configuration, inputBuffer,
                                           new TcpSocketClient <Message, Message>(logger), logger);

            // Act
            bool expectedResult = true;

            await player.AcceptMessage(CancellationToken.None);

            await player.AcceptMessage(CancellationToken.None);

            bool?result = player.IsHeldPieceSham;

            // Assert
            Assert.Equal(expectedResult, result);
        }
Ejemplo n.º 8
0
        public async Task TestAcceptMessagePickErrorShouldExtendPenaltyTime()
        {
            // Arrange
            PlayerConfiguration              configuration = GenerateSampleConfiguration();
            BufferBlock <Message>            inputBuffer   = new BufferBlock <Message>();
            ISocketClient <Message, Message> client        = GenerateSocketClient();
            var player = new Models.Player(configuration, inputBuffer, client, logger);

            Message messageStart = CreateStartMessage();

            inputBuffer.Post(messageStart);
            await player.AcceptMessage(CancellationToken.None);

            Message errorMessage = new Message(MessageID.PickError, agentID, new PutErrorPayload());

            // Act
            inputBuffer.Post(errorMessage);
            await player.AcceptMessage(CancellationToken.None);

            // Assert
            int expectedPenaltyTime = player.PenaltiesTimes.Pickup;
            int actualPenaltyTime   = player.GetValue <Player.Models.Player, int>("penaltyTime");

            Assert.Equal(expectedPenaltyTime, actualPenaltyTime);
        }
Ejemplo n.º 9
0
        public async Task TestAcceptMessageDiscoverAccept()
        {
            DiscoveryAnswerPayload payloadDiscover = new DiscoveryAnswerPayload()
            {
                DistanceFromCurrent = 0,
                DistanceE           = 0,
                DistanceW           = 0,
                DistanceS           = 0,
                DistanceN           = 0,
                DistanceNE          = 0,
                DistanceSE          = 0,
                DistanceNW          = 0,
                DistanceSW          = 0,
            };
            Message messageDiscover = new Message(MessageID.DiscoverAnswer, agentID, payloadDiscover);
            Message messageStart    = CreateStartMessage();

            BufferBlock <Message> inputBuffer = new BufferBlock <Message>();

            inputBuffer.Post(messageStart);
            inputBuffer.Post(messageDiscover);

            PlayerConfiguration configuration = GenerateSampleConfiguration();
            var player = new Player.Models.Player(configuration, inputBuffer, new TcpSocketClient <Message, Message>(logger), logger);

            await player.AcceptMessage(CancellationToken.None);

            await player.AcceptMessage(CancellationToken.None);

            Assert.Equal(0, player.Board[0, 0].DistToPiece);
        }
Ejemplo n.º 10
0
        public async Task TestAcceptMessagePutAnswerShouldChangeHasPieceValue()
        {
            // Arrange
            PlayerConfiguration              configuration = GenerateSampleConfiguration();
            BufferBlock <Message>            inputBuffer   = new BufferBlock <Message>();
            ISocketClient <Message, Message> client        = GenerateSocketClient();
            var player = new Models.Player(configuration, inputBuffer, client, logger);

            Message messageStart = CreateStartMessage();

            inputBuffer.Post(messageStart);
            await player.AcceptMessage(CancellationToken.None);

            Message pickMessage = new Message(MessageID.PickAnswer, agentID, new EmptyAnswerPayload());

            inputBuffer.Post(pickMessage);
            await player.AcceptMessage(CancellationToken.None);

            PutAnswerPayload payload = new PutAnswerPayload()
            {
                PutEvent = PutEvent.NormalOnGoalField,
            };
            Message putAnswer = new Message(MessageID.PutAnswer, agentID, payload);

            // Act
            inputBuffer.Post(putAnswer);
            await player.AcceptMessage(CancellationToken.None);

            // Assert
            bool hasPiece = player.HasPiece;

            Assert.False(hasPiece);
        }
Ejemplo n.º 11
0
        public async Task TestAcceptMessageEndGameShouldSetWinnerField()
        {
            // Arrange
            PlayerConfiguration   configuration = GenerateSampleConfiguration();
            BufferBlock <Message> inputBuffer   = new BufferBlock <Message>();
            var player = new Models.Player(configuration, inputBuffer,
                                           new TcpSocketClient <Message, Message>(logger), logger);

            Message startMessage = CreateStartMessage();

            inputBuffer.Post <Message>(startMessage);
            await player.AcceptMessage(CancellationToken.None);

            var endGamePayload = new EndGamePayload()
            {
                Winner = Team.Red,
            };
            Message endGameMessage = new Message(MessageID.EndGame, agentID, endGamePayload);

            inputBuffer.Post <Message>(endGameMessage);

            // Act
            await player.AcceptMessage(CancellationToken.None);

            // Assert
            var realWinner = player.GetValue <Player.Models.Player, Team>("winner");

            Assert.Equal(Team.Red, realWinner);
        }
Ejemplo n.º 12
0
        public async Task TestAcceptMessagePutAnswerShouldMarkFields()
        {
            // Arrange
            PlayerConfiguration              configuration = GenerateSampleConfiguration();
            BufferBlock <Message>            inputBuffer   = new BufferBlock <Message>();
            ISocketClient <Message, Message> client        = GenerateSocketClient();
            var player = new Models.Player(configuration, inputBuffer, client, logger);

            Message messageStart = CreateStartMessage();

            inputBuffer.Post(messageStart);
            await player.AcceptMessage(CancellationToken.None);

            PutAnswerPayload payload = new PutAnswerPayload()
            {
                PutEvent = PutEvent.NormalOnGoalField,
            };
            Message putAnswer = new Message(MessageID.PutAnswer, agentID, payload);

            // Act
            inputBuffer.Post(putAnswer);
            await player.AcceptMessage(CancellationToken.None);

            // Assert
            GoalInfo actualGoalInfo = player.Board[player.Position.y, player.Position.x].GoalInfo;

            Assert.Equal(GoalInfo.DiscoveredGoal, actualGoalInfo);
        }
Ejemplo n.º 13
0
    private void InitializePlayer(PlayerConfiguration playerConfiguration)
    {
        StartingPoint startingPoint = GetStartingPoint();
        var           tankObject    = Instantiate(Resources.Load("Tanks/" + playerConfiguration.TankType.ToString()), Vector3.zero, Quaternion.Euler(0, 0, 0)) as GameObject;
        var           camera        = Instantiate(Camera, Vector3.zero, Quaternion.Euler(0, 0, 0));

        var smoothCamera = camera.GetComponent <SmoothCamera>();

        smoothCamera      = camera.GetComponent <SmoothCamera>();
        smoothCamera.tank = tankObject;

        var camObject = camera.Find("Camera").GetComponent <Camera>();

        SetCameraViewport(camObject, playerConfiguration.PlayerIndex);

        var canvas = Instantiate(halfScreen, Vector3.zero, Quaternion.Euler(0, 0, 0));

        canvas.GetComponent <Canvas>().planeDistance = 0.5f;
        canvas.GetComponent <Canvas>().worldCamera   = camera.Find("Camera").GetComponent <Camera>();
        canvas.parent = tankObject.transform;
        canvas.name   = "Canvas";

        var tank = tankObject.GetComponent <Tank>();

        tank.cam         = camera;
        tank.PlayerIndex = playerConfiguration.PlayerIndex;
        tank.Paint(playerConfiguration.Color);
        tank.Controller = TankControllerFactory.GetTankController(playerConfiguration);

        tank.Initialize(new Vector3(startingPoint.Transform.position.x, startingPoint.Transform.eulerAngles.y, startingPoint.Transform.position.z));
        Players.Add(playerConfiguration.PlayerIndex, new Player {
            Tank = tank.transform, Configuration = playerConfiguration
        });
    }
Ejemplo n.º 14
0
        public async Task TestAcceptMessagePickAnswerShouldChangeDistToPieceAndPickPiece()
        {
            EmptyAnswerPayload pickPayload       = new EmptyAnswerPayload();
            Message            pickAnswerMessage = new Message(MessageID.PickAnswer, agentID, pickPayload);
            Message            startMessage      = CreateStartMessage();

            BufferBlock <Message> inputBuffer = new BufferBlock <Message>();

            inputBuffer.Post(startMessage);
            inputBuffer.Post(pickAnswerMessage);

            PlayerConfiguration configuration = GenerateSampleConfiguration();
            var player = new Models.Player(configuration, inputBuffer, new TcpSocketClient <Message, Message>(logger), logger);

            // Act
            bool expectedHasPieceValue = true;
            var  expectedDistance      = int.MaxValue;

            await player.AcceptMessage(CancellationToken.None);

            await player.AcceptMessage(CancellationToken.None);

            var realHasPieceValue      = player.HasPiece;
            var realDistToClosestPiece = player.Board[player.Position.y, player.Position.x].DistToPiece;

            // Assert
            Assert.Equal(expectedHasPieceValue, realHasPieceValue);
            Assert.Equal(expectedDistance, realDistToClosestPiece);
        }
Ejemplo n.º 15
0
        public void LoadFromDatabase()
        {
            PlayerConfiguration configuration = new PlayerConfiguration();

            colorState = configuration.ColorID;
            buttons[0].SetFontColor(TileGrid.ColorComparer(configuration.ColorID));
        }
Ejemplo n.º 16
0
    public void OnPlayerJoined(PlayerInput pi)
    {
        pi.transform.SetParent(transform); //Todo: rework player joining so that there isn't an extra player configuration added when player spawns in

        //check if the player is new. Make sure their index isnt already saved in playerConfigs
        PlayerConfiguration existingConfig = null;

        if (playerConfigs.Count > 0)
        {
            foreach (PlayerConfiguration playerConfig in playerConfigs)
            {
                if (playerConfig.index == pi.playerIndex)
                {
                    existingConfig = playerConfig;
                }
            }
        }
        if (existingConfig == null) //the config in question is new, not in the list yet. Spawn in some shit
        {
            PlayerConfiguration newPlayerConfig = new PlayerConfiguration(pi);
            playerConfigs.Add(newPlayerConfig);
            if (selectOnJoin)
            {
                newPlayerConfig.mpEventSystem.SetSelectedGameObject(selectOnJoin);
            }
            Debug.Log("Player " + pi.playerIndex + " Joined!!");
        }
        else //the config in question exists already, just set it back to connected status
        {
            Debug.Log("New player was already in the game at some point, but still had a config sitting around? Error!");
        }
    }
Ejemplo n.º 17
0
 public static ITankController GetTankController(PlayerConfiguration configuration)
 {
     // Todo: ValidationCheck?
     return(configuration.Controller == ControllerType.Keyboard
         ? new KeyboardController(configuration.PlayerIndex) as ITankController
         : new GamepadController(configuration.PlayerIndex) as ITankController);
 }
Ejemplo n.º 18
0
        private void Awake()
        {
            var playerKeyboard =
                PlayerConfiguration.GetInstance().PlayerKeyboard;

            teleportKey = playerKeyboard.TeleportKey;
        }
    public void HandlePlayerJoin(Gamepad pad)
    {
        if (players.Count == 0)
        {
            FindObjectOfType <MenuManager>().SkipMainMenuScreen();
        }

        if (!players.Any(p => p.config.Input.gamepad == pad))
        {
            var player = Instantiate(playerPreFab.gameObject, transform).GetComponent <PlayerController>();

            var config = new PlayerConfiguration(players.Count);
            config.info  = PlayerLevelingManager.Instance.GetLastPlayerInfo(config.PlayerIndex);
            config.Input = new PlayerInputMethod(player, pad);
            players.Add(player);

            player.config = config;

            if (GameSettings.gameMode.IsTeamBased)
            {
                player.config.Team = GameSettings.gameMode.TeamScores[player.config.PlayerIndex % GameSettings.gameMode.NumberOfTeams];
                FindObjectOfType <JoinRoomManager>().ChangeTeam(player);
            }
            else
            {
                GamemodeBase.AutoAssignTeams();
            }

            StartCoroutine(SetPlayerColorAfterPlayerEnableCall(player));
            RecalculateUsedAndUnusedGamepads();
        }
    }
Ejemplo n.º 20
0
        public async Task UpdateNowPlaying(string itemsJSON, MediaTypes mediaType)
        {
            var           items         = JsonConvert.DeserializeObject <IEnumerable <ListItem <int, int> > >(itemsJSON);
            Configuration configuration = await dataService.Get <Configuration>(item => item.Type == nameof(MediaPages.Player));

            PlayerConfiguration playerConfiguration = new PlayerConfiguration();

            if (configuration == null)
            {
                configuration = new Configuration()
                {
                    Type = nameof(MediaPages.Player), JsonData = JsonConvert.SerializeObject(playerConfiguration)
                };
                await dataService.Insert(configuration);
            }
            else
            {
                playerConfiguration = JsonConvert.DeserializeObject <PlayerConfiguration>(configuration.JsonData) ?? new PlayerConfiguration();
            }

            playerConfiguration.CurrentItemIndex  = items.FirstOrDefault((item) => item.IsSelected)?.Id ?? 0;
            playerConfiguration.SelectedMediaType = mediaType;
            configuration.JsonData = JsonConvert.SerializeObject(playerConfiguration);
            await dataService.Update(configuration);

            if (items != null) /*then*/ playerService {
Ejemplo n.º 21
0
        public async Task TestGiveInfoReturnsAppropriateMessage()
        {
            // Arrange
            PlayerConfiguration              configuration = GenerateSampleConfiguration();
            BufferBlock <Message>            inputBuffer   = new BufferBlock <Message>();
            ISocketClient <Message, Message> client        = GenerateSocketClient();
            var player = new Models.Player(configuration, inputBuffer, client, logger);

            Message messageStart = CreateStartMessage();

            inputBuffer.Post(messageStart);
            await player.AcceptMessage(CancellationToken.None);

            BegForInfoForwardedPayload payload = new BegForInfoForwardedPayload()
            {
                AskingID = 2,
                Leader   = false,
                TeamID   = Team.Red,
            };
            Message beg4Info = new Message(MessageID.BegForInfoForwarded, agentID, payload);

            inputBuffer.Post(beg4Info);
            await player.AcceptMessage(CancellationToken.None);

            // Act
            await player.GiveInfo(CancellationToken.None);

            // Assert
            Assert.Equal(MessageID.GiveInfo, lastSended.MessageID);
        }
Ejemplo n.º 22
0
        public async Task TestAcceptMessageDestructionAnswerShouldDestroyHoldingPiece()
        {
            // Arrange
            EmptyAnswerPayload destructionPayload = new EmptyAnswerPayload();
            Message            destructionMessage = new Message(MessageID.DestructionAnswer, agentID, destructionPayload);

            EmptyAnswerPayload pickPayload  = new EmptyAnswerPayload();
            Message            pickMessage  = new Message(MessageID.PickAnswer, agentID, pickPayload);
            Message            startMessage = CreateStartMessage();

            BufferBlock <Message> inputBuffer = new BufferBlock <Message>();

            inputBuffer.Post(startMessage);
            inputBuffer.Post(pickMessage);
            inputBuffer.Post(destructionMessage);

            PlayerConfiguration configuration = GenerateSampleConfiguration();
            var player = new Player.Models.Player(configuration, inputBuffer, new TcpSocketClient <Message, Message>(logger), logger);

            // Act
            bool expectedHasPieceValue = false;

            await player.AcceptMessage(CancellationToken.None);

            await player.AcceptMessage(CancellationToken.None);

            await player.AcceptMessage(CancellationToken.None);

            bool realHasPieceValue        = player.HasPiece;
            bool?realIsHeldPieceShamValue = player.IsHeldPieceSham;

            // Assert
            Assert.Equal(expectedHasPieceValue, realHasPieceValue);
            Assert.Null(realIsHeldPieceShamValue);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Plays the specified player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="options">The options.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>Task.</returns>
        private async Task Play(IMediaPlayer player, PlayOptions options, PlayerConfiguration configuration)
        {
            if (options.Items[0].IsPlaceHolder ?? false)
            {
                // play a phyical disc in the cdrom drive
                // Will be re-entrant call, so has to be made befpre the interlocked.CompareExchange below
                await PlayExternalDisc(true);

                return;
            }

            if (Interlocked.CompareExchange(ref _isStarting, 1, 0) == 0) // prevent race conditions, thread safe check we are not already starting to play an item
            {
                try
                {
                    if (options.Shuffle)
                    {
                        options.Items = options.Items.OrderBy(i => Guid.NewGuid()).ToList();
                    }

                    var firstItem = options.Items[0];


                    if (options.StartPositionTicks == 0 && player.SupportsMultiFilePlayback && firstItem.IsVideo && firstItem.LocationType == LocationType.FileSystem && options.GoFullScreen)
                    {
                        try
                        {
                            var intros = await _apiClient.GetIntrosAsync(firstItem.Id, _apiClient.CurrentUserId);

                            options.Items.InsertRange(0, intros.Items);
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorException("Error retrieving intros", ex);
                        }
                    }


                    options.Configuration = configuration;

                    await player.Play(options);

                    if (player is IInternalMediaPlayer && player is IVideoPlayer && firstItem.IsVideo)
                    {
                        await _presentationManager.Window.Dispatcher.InvokeAsync(() => _presentationManager.WindowOverlay.SetResourceReference(FrameworkElement.StyleProperty, "WindowBackgroundContentDuringPlayback"));

                        if (options.GoFullScreen)
                        {
                            await _nav.NavigateToInternalPlayerPage();
                        }
                    }
                    OnPlaybackStarted(player, options);
                }
                finally
                {
                    Interlocked.Exchange(ref _isStarting, 0);
                }
            }
        }
Ejemplo n.º 24
0
 public Player(PlayerConfiguration i_PlayerConfiguration, ePlayerTitles i_Title)
 {
     m_Score      = 0;
     m_Soldiers   = new List <Soldier>();
     m_Title      = i_Title;
     m_Type       = i_PlayerConfiguration.PlayerType;
     m_Name       = i_PlayerConfiguration.PlayerName;
     m_PlayerSign = GlobalDefines.GetSoldierSign(i_Title, eSoldierTypes.Regular);
 }
Ejemplo n.º 25
0
 public WindowConfiguration()
 {
     Title      = "Window";
     ShowFPS    = true;
     ShowBorder = true;
     PosX       = PosY = 50;
     Width      = Height = 200;
     Player     = new PlayerConfiguration();
 }
 public void InitializePlayer(PlayerConfiguration pc)
 {
     playerInput = pc; //assign player controller to object
     //TODO:
     //Add code to set player avatar.
     //Should look something like this:
     // pc.Avatar = PlayerAvatr;
     playerInput.Input.onActionTriggered += Input_onActionTriggered;
 }
Ejemplo n.º 27
0
        private void RegisterClicked()
        {
            try
            {
                lblError.Text = String.Empty;

                if (String.IsNullOrEmpty(txtAccountName.Text.Trim()) || String.IsNullOrEmpty(txtPlayerName.Text.Trim()))
                {
                    lblError.Text = "Please enter Account and Player Names.";
                    return;
                }

                osVodigiWS.osVodigiServiceSoapClient ws = new osVodigiWS.osVodigiServiceSoapClient();
                ws.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(PlayerConfiguration.configVodigiWebserviceURL));

                // Validate the account
                osVodigiWS.Account account = ws.Account_GetByName(txtAccountName.Text.Trim());
                if (account == null)
                {
                    lblError.Text = "Invalid Account Name. Please retry.";
                    return;
                }

                PlayerConfiguration.configAccountID   = account.AccountID;
                PlayerConfiguration.configAccountName = account.AccountName;

                // Validate the player
                osVodigiWS.Player player = ws.Player_GetByName(account.AccountID, txtPlayerName.Text.Trim());
                if (player == null)
                {
                    lblError.Text = "Invalid Player Name. Please retry.";
                    return;
                }

                PlayerConfiguration.configPlayerID   = player.PlayerID;
                PlayerConfiguration.configPlayerName = player.PlayerName;

                // Set the remaining properties on PlayerConfiguration and save the configuration
                PlayerConfiguration.configIsPlayerInitialized = true;
                PlayerConfiguration.SavePlayerConfiguration();

                // Since registration can cause accountid/playerid changes, delete the local schedule file
                ScheduleFile.DeleteScheduleFile();

                // Register the player at vodigi.com
                try
                {
                    VodigiWS.VodigiWSSoapClient vws = new VodigiWS.VodigiWSSoapClient();
                    vws.PlayerRegistered("PlayerRegistration");
                }
                catch { }

                FadeOut();
            }
            catch { lblError.Text = "Cannot connect to Vodigi Server. Please retry."; }
        }
Ejemplo n.º 28
0
    /// <summary>
    /// creates configuration and links it with DoAction()
    /// </summary>
    /// <param name="pc">configuration from PlayerSelect scene</param>
    public void InitializePlayer(PlayerConfiguration pc)
    {
        Debug.Log("initialized player " + pc.playerIndex);

        playerConfig = pc;
        playerConfig.theInput.SwitchCurrentActionMap("Gameplay");//make sure we dont start in "Menu"
        playerConfig.theInput.onActionTriggered += DoAction;

        GetComponent <ItemManager>().p_index = playerConfig.playerIndex;
    }
Ejemplo n.º 29
0
    public void Initialize(PlayerConfiguration config, PlayerState state)
    {
        configuration = config;
        playerState   = state;

        playerTransform = transform;
        playerRigidbody = GetComponent <Rigidbody>();

        enabled = true;
    }
Ejemplo n.º 30
0
    public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
    {
        PlayerLobbyConfiguration lobby = lobbyPlayer.GetComponent <PlayerLobbyConfiguration>();
        PlayerConfiguration      game  = gamePlayer.GetComponent <PlayerConfiguration>();

        game.PlayerName  = lobby.Name;
        game.PlayerColor = lobby.AccentColor;

        return(true);
    }