Пример #1
0
        private void GameOverProcedure()
        {
            allStatesFinished = true;

            // remove triggers from trigger manager
            var triggerManager = gameInstance.GetService <TriggerManager>();
            var inputManager   = gameInstance.GetService <InputComponent>();

            inputManager.InputEnabled = false;
            foreach (var trigger in addedTriggers)
            {
                if (triggerManager.Triggers.ContainsKey(trigger))
                {
                    triggerManager.Triggers.Remove(trigger);
                }
            }
            foreach (var trigger in addedObjTriggers)
            {
                if (triggerManager.ObjectTriggers.ContainsKey(trigger))
                {
                    triggerManager.ObjectTriggers.Remove(trigger);
                }
            }

            // disable keyboard for 3 seconds, then exit gameplay
            Timer timer = new Timer(3 * 1000);

            timer.Elapsed += (s, e) =>
            {
                inputManager.InputEnabled = true;
                GameOver = true;
            };
            timer.Start();
            PrepareStatistics();
        }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            Receiver.ReceiveMessages();
            // If not received handshake, has tried to connect, and has waited 1 sec, try again
            if (!connected)
            {
                bool connectionTimeOut = ConnectTryCount > MAX_CONNECT_TRIES;
                if (connectionTimeOut)
                {
                    Game.GetService <HUDConsoleComponent>().WriteOutput("Could not connect to server");
                    Disconnect();
                }
                else if (TryConnectedTime != DateTime.MinValue && DateTime.Now - TryConnectedTime >= WaitConnect)
                {
                    Sender.SendPlayerInfo();
                    TryConnectedTime = DateTime.Now;
                    ConnectTryCount++;
                }
                return;
            }
            if (!started && GamePlay != null && GamePlay.Initialized)
            {
                Sender.SendReadySignal();
            }

            base.Update(gameTime);
        }
Пример #3
0
        public SimpleRaceMode(GameManager gameInstance, int laps, int noOfCheckpoints, RaceTrack raceTrack, Car localCar)
            : base(gameInstance)
        {
            this.laps = laps;
            this.checkpoints = noOfCheckpoints;
            this.raceTrack = raceTrack;
            this.car = localCar;
            this.placementRasterization = raceTrack.GetCurveRasterization(100);
            PlayerPlace = 1;
            GameStarted = false;
            TotalRaceTime = TimeSpan.Zero;

            var player = gameInstance.GetService<Player>();
            player.Lap = 0;
            players.Add(player);

            Initialize();
        }
Пример #4
0
        public SimpleRaceMode(GameManager gameInstance, int laps, int noOfCheckpoints, RaceTrack raceTrack, Car localCar)
            : base(gameInstance)
        {
            this.laps                   = laps;
            this.checkpoints            = noOfCheckpoints;
            this.raceTrack              = raceTrack;
            this.car                    = localCar;
            this.placementRasterization = raceTrack.GetCurveRasterization(100);
            PlayerPlace                 = 1;
            GameStarted                 = false;
            TotalRaceTime               = TimeSpan.Zero;

            var player = gameInstance.GetService <Player>();

            player.Lap = 0;
            players.Add(player);

            Initialize();
        }
Пример #5
0
 public CarControlComponent(GameManager game)
     : base(game)
 {
     this.input = game.GetService<InputComponent>();
     this.simulationStrategy = new DeadReckoningStrategy(Game);
 }
Пример #6
0
 public CarControlComponent(GameManager game)
     : base(game)
 {
     this.input = game.GetService <InputComponent>();
     this.simulationStrategy = new DeadReckoningStrategy(Game);
 }