コード例 #1
0
ファイル: Game1.cs プロジェクト: PWallacc/HeliDrop
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = 720;
            graphics.PreferredBackBufferWidth = 1280;
            Content.RootDirectory = "Content";
            Runner firstRunner = new Runner();
            LinkedListNode<Runner> firstNode = new LinkedListNode<Runner>(firstRunner);
            runnerList.AddLast(firstNode);

            heli = new Heli();
            debugInfo = new DebugInfo();
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: PWallacc/HeliDrop
 public static void removeRunner(Runner runnerToDelete)
 {
     runnersRunning -= 1;
     runnerLimit -= 1;
     runnersToDelete.AddLast(runnerToDelete);
 }
コード例 #3
0
ファイル: Game1.cs プロジェクト: PWallacc/HeliDrop
 private void clearRunnersToDelete(Runner mRunner)
 {
     if (runnersToDelete.Contains(mRunner))
         runnersToDelete.Remove(mRunner);
 }
コード例 #4
0
ファイル: Game1.cs プロジェクト: PWallacc/HeliDrop
        protected override void Update(GameTime gameTime)
        {
            if (gamestate == gameState.menu)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) == true)
                    gamestate = gameState.play;
            }
            else if (gamestate == gameState.play)
            {
                effectParameter1.SetValue(count);
                foreach (Runner mRunner in runnersToDelete)
                {
                    runnerList.Remove(mRunner);
                }

                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    this.Exit();

                //Runners
                timeElapsed += gameTime.ElapsedGameTime.Milliseconds;
                if (runnersRunning < runnerLimit)
                {
                    if (timeElapsed > 500)
                    {
                        Runner newRunner = new Runner();
                        newRunner.Initialize();
                        newRunner.position = new Vector2(1300, GetRandomNumber(newRunner.srcHorizon, newRunner.srcForeground));
                        newRunner.LoadContent(Content, "run_cycle");
                        LinkedListNode<Runner> newNode = new LinkedListNode<Runner>(newRunner);
                        runnerList.AddLast(newRunner);
                        runnersRunning += 1;
                        timeElapsed = 0;
                    }
                }

                timeSince += gameTime.ElapsedGameTime.Milliseconds;
                if (timeSince >= 1000)
                {
                    totalTime -= 1;
                    timeSince = 0;
                }
                if (totalTime == -1 || runnersRunning == 0)
                {
                    gamestate = gameState.end;
                }

                if ((runnersRunning == 1 && gameTime.TotalGameTime.Seconds > 40) || totalTime <= 5)
                {
                    if (count < 4f && increasing)
                        count += .1f;
                    else
                        increasing = false;

                    if (count > 1 && !increasing)
                        count -= .1f;
                    else
                        increasing = true;
                }
                if (totalTime == 0)
                {
                    count = 10;
                }
                effectParameter1.SetValue(count);

                foreach (Runner mRunner in runnerList)
                {
                    mRunner.m_bIsRunning = true;

                    if (mRunner.velocity.X < -maxRunnerVelocity.X)
                        mRunner.velocity.X -= 0.2f;

                    //Dubug - Make the runner stand still for hit detection testing
                    //runners[i].velocity = new Vector2(0, 0);

                    mRunner.m_eDestSprEff = SpriteEffects.FlipHorizontally;
                    mRunner.m_bIsRunning = true;
                    mRunner.velocity.X -= 15f;

                    //Udpate
                    mRunner.Update(gameTime);

                }

                //Heli Movement
                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    heli.velocity.Y -= 10f;
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    heli.velocity.Y += 10f;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Left))
                {
                    heli.m_eDestSprEff = SpriteEffects.None;
                    heli.velocity.X -= 10f;
                    heli.emitterXOffset = 19;
                    particleEngine.velocityDirection = .3f;
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Right))
                {
                    heli.m_eDestSprEff = SpriteEffects.FlipHorizontally;
                    heli.velocity.X += 10f;
                    heli.emitterXOffset = 18;
                    particleEngine.velocityDirection = -.3f;

                }

                if (Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    heli.dropCrate();
                }

                heli.position.Y = MathHelper.Clamp(heli.position.Y, heli.srcHorizon, 720);
                heli.Update(gameTime);

                //Particle Engine
                particleEngine.EmitterLocation = heli.emitterLocation;
                particleEngine.Update(gameTime);

                //
                debugInfo.Update(gameTime);

            }
            else
            {
                //game over
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) == true)
                    this.Exit();
            }
            base.Update(gameTime);
        }