Exemplo n.º 1
0
        public void AddCar(Player player, Model model, GamePlayView gameplay)
        {
            if (model == null)
                model = Game.Content.Load<Model>(@"Models/porsche");

            var car = gameplay.MakeCar();
            Cars[player] = car;
        }
Exemplo n.º 2
0
 public override void Update(GameTime gameTime, GamePlayView gamePlay)
 {
     if (TotalRaceTime != TimeSpan.Zero && allStatesFinished)
         gameInstance.GetService<ServerClient>().SendRaceTime(TotalRaceTime);
     if (Statistics != null) {
         var playerHeading = Statistics.CategorizedItems.First(h => h.Updateable);
         playerHeading.Items.Clear();
         int place = 1;
         foreach (var player in players.OrderBy(p => p.RaceTime))
             playerHeading.Items[place++ + ". " + player.PlayerName] = player.RaceTime == TimeSpan.MaxValue ? "" : player.RaceTime.ToString(@"m\:ss\:ff");
     }
     base.Update(gameTime, gamePlay);
 }
Exemplo n.º 3
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)
 {
     GameState nextState = currentView.UpdateState(gameTime);
     if (currentState != nextState)
     {
         switch (nextState)
         {
             case GameState.None:
                 break;
             case GameState.MainMenu:
                 currentView = new MenuView(this, GameState.MainMenu);
                 break;
             case GameState.OptionsMenu:
                 currentView = new OptionsMenu(this);
                 break;
             case GameState.Gameplay:
                 if (!(currentView is GamePlayView))
                     currentView = Components.First(component => component is GamePlayView) as GamePlayView;
                 break;
             case GameState.PausedGameplay:
                 break;
             case GameState.MultiplayerMenu:
                 this.GetService<ServerClient>().Connect(System.Net.IPAddress.Loopback);
                 currentView = new GamePlayView(this, 0, GameModeChoice.SimpleRace);//MultiplayerMenu(this);
                 break;
             case GameState.SingleplayerMenu:
                 break;
             case GameState.Exiting:
                 this.Exit();
                 break;
             default:
                 break;
         }
         currentState = nextState;
     }
     base.Update(gameTime);
 }
Exemplo n.º 4
0
 public override void Update(GameTime gameTime, GamePlayView gamePlay)
 {
     if (StartTime == TimeSpan.Zero && GameStarted)
         StartTime = gameTime.TotalGameTime;
     if (Mode == Mode.Singleplayer && !countdown && gamePlay.Initialized)
     {
         countdown = true;
         StartCountdown();
     }
     /*Console.Write("players: ");
     foreach (var player in players)
     {
         Console.Write(player.PlayerName + " (" + player.Lap + "),");
     }
     Console.WriteLine();*/
     PlayerPlace = CalculatePlayerPosition();
     gameInstance.GetService<HUDComponent>().SetPlayerPosition(PlayerPlace);
     base.Update(gameTime, gamePlay);
 }
Exemplo n.º 5
0
 public virtual void Update(GameTime gameTime, GamePlayView gamePlay)
 {
     if (!allStatesFinished)
     {
         GameModeState current = states[CurrentState];
         if (current.IsStateFinished())
         {
             CurrentState++;
             Console.WriteLine("Passed from state " + (CurrentState - 1) + " to state " + CurrentState);
         }
         if (CurrentState > states.Count - 1)
         {
             Console.WriteLine("Game over!");
             GameOverProcedure();
         }
     }
 }