예제 #1
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();
        }
예제 #2
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);
        }
예제 #3
0
 public MainViewModel()
 {
     PlayerAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "itsPaul$1"))
     {
         currentPlayer = PlayerAuthentication.getPlayerProfile();
     }
     list = PlayerAuthentication.getScores(4, "Battle Call");
 }
 public GamePlayerViewModel()
 {
     if (DesignerProperties.GetIsInDesignMode(
             new System.Windows.DependencyObject()))
     {
         return;
     }
     PlayerAuthentication.baseWebAddress = "http://localhost:50574/";
     ScoreList = new ObservableCollection <GameScoreObject>(PlayerAuthentication.getScores(4, "Battle Call"));
 }
예제 #5
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();
        }
예제 #6
0
 public List <GameScoreObject> getGameScores(int count, string GameName)
 {
     return(PlayerAuthentication.getScores(count, GameName));
 }
예제 #7
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);
        }