Esempio n. 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            // Turn on chat mode
            if (InputEngine.IsKeyPressed(Keys.F1))
            {
                // line represent the current line to be captured
                line     = string.Empty;
                chatMode = !chatMode;
            }
            // if chatting then do not update game window
            if (chatMode)
            {
                if (InputEngine.IsKeyPressed(Keys.Enter))
                {
                    // replace connection id with name of logged in player
                    chatproxy.Invoke("SendMess", new object[] { connection.ConnectionId, line });
                    line = string.Empty;
                    //chatMessages.Add(line);
                }
                else
                {
                    //if (InputEngine.PressedKeys.Length > 0)

                    if (InputEngine.currentKey != Keys.None)
                    {
                        line += InputEngine.lookupKeys[InputEngine.currentKey];
                    }
                }
            }
            // update game window
            else
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    proxy.Invoke("GetPoint");
                }
                if (!(PlayerAuthentication.PlayerStatus == AUTHSTATUS.OK))
                {
                    Exitcount -= gameTime.ElapsedGameTime.TotalSeconds;
                    if (Exitcount < 1)
                    {
                        Exit();
                    }
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    scores = PlayerAuthentication.getScores(5, "Battle Call");
                    if (scores != null)
                    {
                        _scoreboard = true;
                    }
                }
            }
            // TODO: Add your update logic here
            base.Update(gameTime);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            PlayerProfile currentPlayer;

            PlayerAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "itsPaul$1");

            if (logged)
            {
                currentPlayer = PlayerAuthentication.getPlayerProfile();
                //Console.WriteLine("Token acquired {0}", PlayerAuthentication.PlayerToken);
                List <GameScoreObject> scores = PlayerAuthentication.getScores(4, "Battle Call");
                foreach (var item in scores)
                {
                    Console.WriteLine("Game {0} {1} Score for {1} is {3}", item.GameId, item.GameName, item.GamerTag, item.score);
                }
                if (currentPlayer != null)
                {
                    PlayerAuthentication.PostScore(new PlayerScoreObject
                    {
                        GameId = scores.First().GameId, PlayerId = currentPlayer.id, score = r.Next(900, 1000)
                    });
                }
                Console.WriteLine("Top 4 scores After New score Added");
                foreach (var item in PlayerAuthentication.getScores(4, "Battle Call"))
                {
                    Console.WriteLine("After New score Game {0} {1} Score for {1} is {3}", item.GameId, item.GameName, item.GamerTag, item.score);
                }
            }
            else
            {
                Console.WriteLine("Failed to acquire Token  ");
            }
            Console.ReadKey();
        }
        protected override void Initialize()
        {
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferredBackBufferWidth  = 1280;
            graphics.ApplyChanges();


            proxy    = connection.CreateHubProxy("GameHub");
            clientID = connection.ConnectionId;

            Action <string, Vector2> ReciveNewPosition = reciveNewPlayerPosition;



            proxy.On("updatePosition", ReciveNewPosition);

            try
            {
                bool valid = PlayerAuthentication.login("*****@*****.**", "itsPaul$1").Result;

                if (valid)
                {
                    Message = "Player Logged in with Token " + PlayerAuthentication.PlayerToken;
                }
                else
                {
                    Message = PlayerAuthentication.PlayerToken;
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
            }
            base.Initialize();
        }
        public async Task BetrayCircle(BetrayCircleCommand command, PlayerAuthentication authentication)
        {
            command.BetrayedCircleId = Guid.NewGuid();
            await _playerAuthenticationService.AuthenticateAndAuthorizePlayer(authentication, command.PlayerId);

            ICommandHandler <BetrayCircleCommand> handler = _commandHandlerProvider.GetCommandHandler <BetrayCircleCommand>();
            await handler.HandleAsync(command);
        }
Esempio n. 5
0
 public MainViewModel()
 {
     PlayerAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "itsPaul$1"))
     {
         currentPlayer = PlayerAuthentication.getPlayerProfile();
     }
     list = PlayerAuthentication.getScores(4, "Battle Call");
 }
Esempio n. 6
0
 public bool login(string username, string password)
 {
     if (PlayerAuthentication.login(username, password))
     {
         _token        = PlayerAuthentication.PlayerToken;
         currentPlayer = PlayerAuthentication.getPlayerProfile();
         return(true);
     }
     return(false);
 }
        public async Task <Guid> JoinCircle(JoinCircleCommand command, PlayerAuthentication authentication)
        {
            command.MemberId = Guid.NewGuid();
            await _playerAuthenticationService.AuthenticateAndAuthorizePlayer(authentication, command.PlayerId);

            ICommandHandler <JoinCircleCommand> handler = _commandHandlerProvider.GetCommandHandler <JoinCircleCommand>();
            await handler.HandleAsync(command);

            return(command.MemberId);
        }
 public GamePlayerViewModel()
 {
     if (DesignerProperties.GetIsInDesignMode(
             new System.Windows.DependencyObject()))
     {
         return;
     }
     PlayerAuthentication.baseWebAddress = "http://localhost:50574/";
     ScoreList = new ObservableCollection <GameScoreObject>(PlayerAuthentication.getScores(4, "Battle Call"));
 }
Esempio n. 9
0
        public PlayerInfoViewModel()
        {
            if (DesignerProperties.GetIsInDesignMode(
                    new System.Windows.DependencyObject()))
            {
                return;
            }

            PlayerAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "itsPaul$1"))
            {
                currentPlayer = PlayerAuthentication.getPlayerProfile();
            }
        }
Esempio n. 10
0
        protected override void Initialize()
        {
            oldState = Keyboard.GetState();
            graphics.PreferredBackBufferWidth  = 800; //set the size of the window
            graphics.PreferredBackBufferHeight = 600;
            graphics.ApplyChanges();


            proxy    = connection.CreateHubProxy("GameHub");
            clientID = connection.ConnectionId;
            Action <string, string>           RecivePlayer                = recivePlayerMessage;
            Action <string, Vector2[]>        ReciveBarriersPositions     = reciveBarriers;
            Action <Vector2>                  ReciveNewPosition           = reciveNewPlayerPosition;
            Action <string, Vector2, Vector2> ReciveNewBullet             = reciveNewEnemyBullet;
            Action <Vector2>                  ReciveNewSuperCollectable   = reciveSupercollectable;
            Action <List <Vector2> >          ReciveCollectablePositions  = reciveCollectablePositions;
            Action <Vector2>                  ReciveDiffrentStartposition = reciveDiffrentStartposition;

            proxy.On("sendPositionCollectables", ReciveCollectablePositions);
            proxy.On("sendBarriers", ReciveBarriersPositions);
            proxy.On("otherStartpoint", ReciveDiffrentStartposition);
            proxy.On("sendPlayer", RecivePlayer);
            proxy.On("updatePosition", ReciveNewPosition);
            proxy.On("newBullet", ReciveNewBullet);
            proxy.On("newSuperCollectable", ReciveNewSuperCollectable);

            new InputEngine(this);
            setupChatViewPort();
            // TODO: Add your initialization logic here
            //HubConnection connection = new HubConnection("http://cgmonogameserver2015.azurewebsites.net/");
            connection = new HubConnection("http://*****:*****@itsligo.ie", "itsPaul$1");

            t.Wait();
            Action <string, string> ChatRecieved = ChatRecievedMessage;

            chatproxy.On("heyThere", ChatRecieved);
            chatMessages.Add("Chat-->");
            connection.Start().Wait();
            base.Initialize();
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            PlayerProfile currentPlayer;

            //Added the URL for the Web App that is depolyed to Azure...
            PlayerAuthentication.baseWebAddress = "http://rtjjmonogameserver.azurewebsites.net/";// "http://*****:*****@itsligo.ie", "itsPaul$1");

            if (logged)
            {
                currentPlayer = PlayerAuthentication.getPlayerProfile();
                //Console.WriteLine("Token acquired {0}", PlayerAuthentication.PlayerToken);
                List <GameScoreObject> scores = PlayerAuthentication.getScores(4, "Battle Call");
                foreach (var item in scores)
                {
                    Console.WriteLine("Game {0} {1} Score for {1} is {3}", item.GameId, item.GameName, item.GamerTag, item.score);
                }
                if (currentPlayer != null)
                {
                    PlayerAuthentication.PostScore(new PlayerScoreObject
                    {
                        GameId = scores.First().GameId, PlayerId = currentPlayer.Id, score = r.Next(900, 1000)
                    });
                }
                Console.WriteLine("Top 4 scores After New score Added");
                foreach (var item in PlayerAuthentication.getScores(4, "Battle Call"))
                {
                    Console.WriteLine("After New score Game {0} {1} Score for {1} is {3}", item.GameId, item.GameName, item.GamerTag, item.score);
                }
            }
            else
            {
                Console.WriteLine("Failed to acquire Token  ");
            }
            ExternalGameObject gameInfo = PlayerAuthentication.getExtGame(1);

            Console.WriteLine(" Name: {0} \n Summary {1} \n Image URL : {2}",
                              gameInfo.Name, gameInfo.Summary, gameInfo.Cover);


            Console.ReadKey();
        }
Esempio n. 12
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            new InputEngine(this);
            setupChatViewPort();
            // TODO: Add your initialization logic here
            //HubConnection connection = new HubConnection("http://cgmonogameserver2015.azurewebsites.net/");
            connection = new HubConnection("http://*****:*****@itsligo.ie", "itsPaul$1");

            t.Wait();
            Action <string, string> ChatRecieved = ChatRecievedMessage;

            chatproxy.On("heyThere", ChatRecieved);
            chatMessages.Add("Chat-->");
            connection.Start().Wait();
            base.Initialize();
        }
Esempio n. 13
0
 public List <GameScoreObject> getGameScores(int count, string GameName)
 {
     return(PlayerAuthentication.getScores(count, GameName));
 }
Esempio n. 14
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            // Turn on chat mode
            if (InputEngine.IsKeyPressed(Keys.F1))
            {
                // line represent the current line to be captured
                line     = string.Empty;
                chatMode = !chatMode;
            }
            // if chatting then do not update game window
            if (chatMode)
            {
                if (InputEngine.IsKeyPressed(Keys.Enter))
                {
                    // replace connection id with name of logged in player
                    chatproxy.Invoke("SendMess", new object[] { connection.ConnectionId, line });
                    line = string.Empty;
                    //chatMessages.Add(line);
                }
                else
                {
                    //if (InputEngine.PressedKeys.Length > 0)

                    if (InputEngine.currentKey != Keys.None)
                    {
                        line += InputEngine.lookupKeys[InputEngine.currentKey];
                    }
                }
            }
            // update game window
            else
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    proxy.Invoke("GetPoint");
                }
                if (!(PlayerAuthentication.PlayerStatus == AUTHSTATUS.OK))
                {
                    Exitcount -= gameTime.ElapsedGameTime.TotalSeconds;
                    if (Exitcount < 1)
                    {
                        Exit();
                    }
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    scores = PlayerAuthentication.getScores(5, "Battle Call");
                    if (scores != null)
                    {
                        _scoreboard = true;
                    }
                }
            }

            newState = Keyboard.GetState(); //set the current keyboardState



            if (currentState == currentDisplay.Selection)
            {
                menu.CheckMouse();

                player = createPlayer(clientID, menu.MenuAction, playerColor);

                if (player != null)
                {
                    proxy.Invoke("SendPlayer", menu.MenuAction);

                    sendBarriers(Barriers);
                }

                menu.MenuAction = null; //reset the selection
            }



            if (currentState == currentDisplay.Game) //if the game is running
            {
                if (gameStarted)
                {
                    if (newState.IsKeyDown(Keys.Escape) && oldState != newState && gameStarted)
                    {
                        currentState = currentDisplay.LeaderBoard;
                    }


                    player.Move(newState); //check for the player movement
                    proxy.Invoke("UpdatePosition", player._position);


                    foreach (var item in Bullets) //check if bullet hit a barrier and destroy it
                    {
                        foreach (var bar in Barriers)
                        {
                            if (item.CollisiionDetection(bar.Rectangle))
                            {
                                if (item.createdPlayerID != bar.createdClientID)
                                {
                                    bar.GotHit(item);
                                    item.IsVisible = false;
                                    destroyBullets.Add(item);
                                    if (!bar.IsVisible)
                                    {
                                        destroyBarrier.Add(bar);
                                    }
                                }
                            }
                        }
                        if (item.CollisiionDetection(Enemy.Rectangle))
                        {
                            Enemy.PlayerChar.GotShoot(item);
                        }

                        if (item.CollisiionDetection(player.Rectangle))
                        {
                            player.PlayerChar.GotShoot(item);
                        }
                    }

                    foreach (var item in Collectables)
                    {
                        if (player.CollisiionDetection(item.Rectangle))
                        {
                            pickUp.Add(item);
                            ammo          += 100;
                            item.IsVisible = false;
                            player.Collect(item);
                        }

                        if (Enemy.CollisiionDetection(item.Rectangle))
                        {
                            pickUp.Add(item);
                            item.IsVisible = false;
                            Enemy.Collect(item);
                        }
                    }



                    if (newState.IsKeyDown(Keys.Space) && oldState != newState && gameStarted)
                    {
                        if (ammo > 0)
                        {
                            newBullet = player.PlayerChar.Shoot(player._position, player.FireDirection, playerColor); //create a bullet
                            if (newBullet != null)
                            {
                                Bullets.Add(newBullet); //add the new bullet to the list
                                proxy.Invoke("NewBullet", newBullet._position, newBullet.flyDirection);
                                ammo -= 100;
                            }
                        }
                    }
                    //Bullets.Add(new Bullet(player.PlayerChar._texture, player.PlayerChar.strength, player.Position, player.FireDirection));

                    foreach (var item in Bullets)
                    {
                        item.Update(); //update the Bullets
                        if (OutsideScreen(item))
                        {
                            destroyBullets.Add(item);
                        }
                    }

                    foreach (var item in destroyBarrier)
                    {
                        Barriers.Remove(item);
                    }
                    foreach (var item in pickUp)
                    {
                        Collectables.Remove(item);
                    }
                    foreach (var item in destroyBullets)
                    {
                        Bullets.Remove(item);
                    }

                    destroyBarrier.Clear();
                    pickUp.Clear();
                    destroyBullets.Clear();

                    if (Collectables.Count == 0)
                    {
                        currentState = currentDisplay.Score;
                    }
                    if (Enemy.PlayerChar.Health <= 0)
                    {
                        currentState = currentDisplay.Score;
                    }
                    if (player.PlayerChar.Health <= 0)
                    {
                        currentState = currentDisplay.Score;
                    }

                    if (currentState == currentDisplay.Score)
                    {
                        gameStarted = false;
                        proxy.Invoke("StartGame", gameStarted);
                        if (player.score > Enemy.score)
                        {
                            gameOutcome = endGameStatuses.Win;
                        }
                        if (player.score < Enemy.score)
                        {
                            gameOutcome = endGameStatuses.Lose;
                        }
                        if (player.score == Enemy.score)
                        {
                            gameOutcome = endGameStatuses.Draw;
                        }
                    }
                }
            }



            if (newState.IsKeyDown(Keys.Escape) && oldState != newState) // go back to the character selection
            {
                Exit();
            }

            // TODO: Add your update logic here
            base.Update(gameTime);
        }