예제 #1
0
        public void Draw(GameTimerEventArgs gameTime)
        {
            if (gameTime == null)
            {
                throw new ArgumentNullException("gameTime");
            }

            // Crate is destroyed, there is nothing to draw
            if (IsDestroyed)
            {
                //base.Draw(gameTime);
                return;
            }

            // Using the last update state makes sure we do not draw
            // before updating animations properly
            switch (lastUpdateState)
            {
            case CrateState.Idle:
                spriteBatch.Draw(idleTexture, Position, Color.White);
                break;

            case CrateState.Hit:
                // Crate hit animation
                animations["explode"].Draw(spriteBatch, Position,
                                           SpriteEffects.None);
                break;

            default:
                break;
            }

            //base.Draw(gameTime);
        }
예제 #2
0
        //public override void HandleInput(InputState input)
        //{
        //    base.HandleInput(input);

        //}

        public virtual void Update(GameTimerEventArgs gameTime)
        {
            #region garbage collection testing
#if DEBUG
            if (gcTest == null)
            {
                gcTest = new WeakReference(new object());
            }
            if (!gcTest.IsAlive)
            {
                gcCount++;
                log.InfoFormat("Garbage has been collected {0} times.", gcCount);

                gcTest = new WeakReference(new object());
            }

            var g = (gameTime).ToString();
            g += "a";
#endif
            #endregion



            _world.Step((float)gameTime.ElapsedTime.TotalSeconds);
        }
예제 #3
0
        public override void Update(GameTimerEventArgs e)
        {
            if (Active)
            {
                int livingEnemyCount = 0;
                foreach (Enemy enemy in Enemies)
                {
                    enemy.HandleAI();
                    enemy.HandleCollisions();
                    if (enemy.Alive)
                    {
                        livingEnemyCount++;
                    }
                }

                if (((GameplayScene)Scene).ShipManager.PlayerShip.Alive)
                {
                    enemySpawnTimer++;

                    if (livingEnemyCount == 0 || enemySpawnTimer >= 300)
                    {
                        SpawnDrones(3 + ((GameplayScene)Scene).ShipManager.PlayerShip.Multiplier / 20);
                        SpawnWanderers(5 + ((GameplayScene)Scene).ShipManager.PlayerShip.Multiplier / 10);
                        SpawnKamikazes(1 + ((GameplayScene)Scene).ShipManager.PlayerShip.Multiplier / 30);

                        enemySpawnTimer = 0;
                    }
                }

                base.Update(e);
            }
        }
예제 #4
0
 void gameTimer_Update(object sender, GameTimerEventArgs e)
 {
     if (OnUpdate != null)
     {
         OnUpdate(e.ElapsedTime);
     }
 }
예제 #5
0
 void gameTimer_Draw(object sender, GameTimerEventArgs e)
 {
     if (OnDraw != null)
     {
         OnDraw();
     }
 }
예제 #6
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            foreach (Ball b in Balls_mas)
            {
                b.DrawBall(spriteBatch);
            }
            spriteBatch.DrawString(font, "Item " + masItem.ToString() + ":  " + time.ToString() + "  " + timeCount.ToString(), new Vector2(0, 0), Color.Red);
            //if (Draw == true)
            //{
            for (int i = 0; i < maxUsers; i++)
            {
                if (i != masItem)
                {
                    spriteBatch.DrawString(font, ("ForItem " + i.ToString() + "Q=  " + Balls_mas[i].Q / 1000 + "   ping= " + Balls_mas[i].time2.ToString()).ToString(), new Vector2(0, (i + 1) * 10), Color.Black);
                }
            }
            //spriteBatch.DrawString(font, (Balls_mas[masItem].Q / 1000).ToString(), new Vector2(100, 100), Color.Black);
            //    Draw = false;

            //}
            spriteBatch.End();
            // TODO: Add your drawing code here
        }
예제 #7
0
 public void Setup()
 {
     idleEventOccured        = false;
     timeChangedEventOccured = false;
     idleEventArgs           = null;
     timeEventArgs           = null;
 }
예제 #8
0
        private void OnUpdate(object sender, GameTimerEventArgs e)
        {
            if (isClose)
            {
                return;
            }
            if (process != null)
            {
                process.Load();
                process.Calls();

                elapsedTime = e.ElapsedTime.Ticks / 10000L;

                process.InputUpdate(elapsedTime);

                ActionControl.Update(elapsedTime);

                timerContext.millisSleepTime     = sleepTime;
                timerContext.timeSinceLastUpdate = elapsedTime;

                process.RunTimer(timerContext);
                process.Unload();
            }
            if (useXNAListener)
            {
                sl_listener.Update(GamePage, e);
            }
        }
예제 #9
0
        public override void Update(GameTimerEventArgs e)
        {
            if (Alive)
            {
                Velocity  += Acceleration;
                Velocity.X = MathHelper.Clamp(Velocity.X, -10.0f, 10.0f);
                Velocity.Y = MathHelper.Clamp(Velocity.Y, -10.0f, 10.0f);
                Velocity  *= 0.95f;
                Position  += Velocity;

                if (Position.X < -500 || Position.X > 500)
                {
                    Velocity.X *= -1;
                }
                if (Position.Y < -500 || Position.Y > 500)
                {
                    Velocity.Y *= -1;
                }

                if (FireDelay > 0)
                {
                    FireDelay--;
                }
            }
            else
            {
                respawnDelay--;

                if (respawnDelay <= 0)
                {
                    Spawn();
                }
            }
        }
예제 #10
0
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            // Render the page to a texture. We do this before clearing as it changes render targets and
            // as such will cause issues if we do it in the middle of our actual drawing.
            uiRenderer.Render();

            // Update the frame rate counter with the time
            frameRateCounter.OnDraw(e.ElapsedTime);

            // Clear the background
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);

            // Draw the current scene
            Renderer.Current.Draw();

            // Draw the UI texture with SpriteBatch
            spriteBatch.Begin();
            spriteBatch.Draw(uiRenderer.Texture, Vector2.Zero, Color.White * uiOpacity);

            // Optionally draw the frame rate counters
            if (Renderer.Current.State.ShowFrameRate)
            {
                spriteBatch.DrawString(font, frameRateCounter.UpdatesPerSecond, new Vector2(10f, 10f), Color.Red);
                spriteBatch.DrawString(font, frameRateCounter.FramesPerSecond, new Vector2(10f, 30f), Color.Red);
            }

            spriteBatch.End();
        }
예제 #11
0
        private void _gameTimer_Draw(object sender, GameTimerEventArgs e)
        {
            BackgroundRenderer.Render();

            foreach (LocationsVM.Location l in myVM.SelectedNearbyLocations)
            {
                l.PlacemarkPresenter.Renderer.Render();
            }

            _device.Clear(Color.Black);

            _spriteBatch.Begin();
            _spriteBatch.Draw(BackgroundRenderer.Texture, Vector2.Zero, Color.White);
            _spriteBatch.End();

            foreach (LocationsVM.Location l in myVM.SelectedNearbyLocations)
            {
                l.PlacemarkPresenter.Object3D.shapeTexture = l.PlacemarkPresenter.Renderer.Texture;

                foreach (EffectPass pass in l.Object3dEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    l.Object3dEffect.Texture = l.PlacemarkPresenter.Object3D.shapeTexture;
                    l.PlacemarkPresenter.Object3D.RenderShape(_device);
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);
            if (Global.loaded)
            {
                Global.GraphicsDevice.Clear(Color.CornflowerBlue);
                spriteBatch.Begin();
                scene.Draw(spriteBatch);

                spriteBatch.Draw(Global.p, new Microsoft.Xna.Framework.Rectangle(0, Global.camera.Height - Global.paddleHeight, Global.camera.Width, Global.paddleHeight), Color.Black);
                //spriteBatch.Draw(Global.p, new Microsoft.Xna.Framework.Rectangle(0, Global.camera.Height - Global.barWidth,  Global.camera.Height, Global.barWidth), Color.Black);
                //spriteBatch.DrawString(contentManager.Load<SpriteFont>("Fonts/font"), padStatus + "", new Vector2(0, 0), Color.White);
                input.pad.Draw(spriteBatch);

                spriteBatch.DrawString(Global.Content.Load <SpriteFont>("Fonts/font"), Global.debugMessage + "\nFPS: " + fps, new Vector2(0, 0), Color.White);
                spriteBatch.End();
            }
            //On Load...
            if (Global.loading && load != null && !Global.loaded)
            {
                spriteBatch.Begin();
                Global.GraphicsDevice.Clear(Color.CornflowerBlue);
                load.Draw(spriteBatch);
                spriteBatch.End();
            }
        }
예제 #13
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(tx_bG, Vector2.Zero, Color.White);

            if (!twoTouches && terminated == 0) // Amíg nincs double tap és a játékos él, addig kirajzoljuk az objektumokat és az adatokat.
            {
                if (player.R > 0)
                {
                    player.Draw(spriteBatch);
                }
                foreach (Objects en in objects)
                {
                    en.Draw(spriteBatch);
                }
                spriteBatch.DrawString(sf, "Level " + level, new Vector2(10, 10), Color.White);
                spriteBatch.DrawString(sf, "Score: " + score, new Vector2(10, 30), Color.White);
            }
            else if (!levelEnd && player.R <= 0)
            {
                spriteBatch.DrawString(sfmgs, "You have been extinct", new Vector2(250, (int)this.ActualHeight / 2), Color.Red);
            }
            if (levelEnd)
            {
                spriteBatch.DrawString(sfmgs, "Level completed, double-tap to new level", new Vector2(150, 10), Color.Green);
            }
            spriteBatch.End();
        }
예제 #14
0
        private void timer_Draw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();
            spriteBatch.Draw(background, Vector2.Zero, Color.White);
            spriteBatch.End();

            // Set render states.
            SharedGraphicsDeviceManager.Current.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            SharedGraphicsDeviceManager.Current.GraphicsDevice.BlendState        = BlendState.Opaque;
            SharedGraphicsDeviceManager.Current.GraphicsDevice.RasterizerState   = RasterizerState.CullNone;
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SamplerStates[0]  = SamplerState.LinearWrap;

            // Draw the model
            model.Draw();

            // Update the Silverlight UI
            uiRenderer.Render();

            // Draw the sprite
            spriteBatch.Begin();
            spriteBatch.Draw(uiRenderer.Texture, Vector2.Zero, Color.White);
            spriteBatch.End();
        }
        /// <summary>
        /// Adds a new Roland to the game
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void addRoland(object sender, GameTimerEventArgs e)
        {
            if (collided)
            {
                return;
            }
            int     ScreenWidth   = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width;
            int     ScreenHeight  = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height;
            Random  rnd           = new Random();
            Vector2 enemyPosition = new Vector2(-100, -100);

            Roland enemy = new Roland();

            enemy.setPreAnimator(preAnimator);

            if (rnd.Next(0, 2) == 1)
            {
                enemy.Initialize(contentManager.Load <Texture2D>("Graphics\\roland_large"), enemyPosition);
            }
            else
            {
                enemy.Initialize(contentManager.Load <Texture2D>("Graphics\\roland_small"), enemyPosition);
            }

            rolands.Add(enemy);
            gameItems.Add(enemy);
        }
예제 #16
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.Black);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            if (model.uselines)
            {
                if (model.usealtlines)
                {
                    PaintAltLines();
                }
                else
                {
                    PaintLines();
                }
            }

            //use all stars
            model.usestars = model.starlists[model.loadedlists - 2];
            PaintStars();

            if (model.usenames)
            {
                PaintNames();
            }
            spriteBatch.End();
        }
 private void OnUpdate(object sender, GameTimerEventArgs e)                                      //发送指令
 {
     Debug.WriteLine(accHelper.GetInfo(), DateTime.Now.ToShortTimeString());
     if (accHelper.GetInfo() == "UpShake" && Control == 1)
     {
         Control = 0;
         Client.SendCommand(@"10|U");
     }
     else if (accHelper.GetInfo() == "DownShake" && Control == 1)
     {
         Control = 0;
         Client.SendCommand(@"10|D");
     }
     else if (accHelper.GetInfo() == "LeftShake" && Control == 1)
     {
         Control = 0;
         Client.SendCommand(@"10|F");
     }
     else if (accHelper.GetInfo() == "RightShake" && Control == 1)
     {
         Control = 0;
         Client.SendCommand(@"10|B");
     }
     else if (accHelper.GetInfo() == "None")
     {
         Control = 1;
     }
 }
예제 #18
0
 private void Draw(object sender, GameTimerEventArgs e)
 {
     SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.DarkCyan);
     spriteBatch.Begin();
     spriteBatch.Draw(texture2D, position, null, Color.White * alpha, rotation, origin, Vector2.One, SpriteEffects.None, 1.0f);
     spriteBatch.End();
 }
예제 #19
0
 /// <summary>
 /// Allows the page to draw itself.
 /// </summary>
 private void OnDraw(object sender, GameTimerEventArgs e)
 {
     try
     {
         if (mNavigationMode == NavigationMode.Back)
         {
             mNavigationMode = NavigationMode.Refresh;
             NavigationService.GoBack();
             return;
         }
         else if (mNavigationMode == NavigationMode.Refresh)
         {
             return;
         }
         SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);
         mSpriteBatch.Begin();
         // Render all parts of the screen
         DrawBackground();
         DrawPlayerTwo(e);
         DrawPlayerOne(e);
         DrawHud();
         mSpriteBatch.End();
     }
     catch (Exception e1)
     {
     }
     // TODO: Add your drawing code here
 }
예제 #20
0
 /// <summary>
 /// Draws the AI's catapult
 /// </summary>
 void DrawPlayerTwo(GameTimerEventArgs gameTime)
 {
     if (!gameOver)
     {
         playerTwo.Draw(gameTime);
     }
 }
예제 #21
0
        /// <summary>
        /// Moves the rectangle around the screen.
        /// </summary>
        /// <param name="e"></param>
        void UpdateSprite(GameTimerEventArgs e)
        {
            // Move the sprite by speed, scaled by elapsed time.
            spritePosition += spriteSpeed * (float)e.ElapsedTime.TotalSeconds;

            int MinX = 0;
            int MinY = 0;
            int MaxX = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width - texture.Width;
            int MaxY = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height - texture.Height;

            // Check for bounce.
            if (spritePosition.X > MaxX)
            {
                spriteSpeed.X   *= -1;
                spritePosition.X = MaxX;
            }

            else if (spritePosition.X < MinX)
            {
                spriteSpeed.X   *= -1;
                spritePosition.X = MinX;
            }

            if (spritePosition.Y > MaxY)
            {
                spriteSpeed.Y   *= -1;
                spritePosition.Y = MaxY;
            }
            else if (spritePosition.Y < MinY)
            {
                spriteSpeed.Y   *= -1;
                spritePosition.Y = MinY;
            }
        }
예제 #22
0
 private void OnDraw(object sender, GameTimerEventArgs e)
 {
     if (isClose)
     {
         return;
     }
     if (LSystem.isLogo)
     {
         if (logoFlag == null)
         {
             LSystem.isLogo = false;
             return;
         }
         lock (logoFlag)
         {
             logoFlag.Draw(process.GL, (long)e.ElapsedTime.TotalMilliseconds);
         }
         if (logoFlag.finish)
         {
             process.GL.Clear();
             LSystem.isLogo = false;
             logoFlag       = null;
             return;
         }
         return;
     }
     if (LSystem.AUTO_REPAINT)
     {
         DrawXNA((float)e.ElapsedTime.TotalSeconds);
     }
     if (useXNAListener)
     {
         sl_listener.Draw(GamePage, e);
     }
 }
예제 #23
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.Black);

            // TODO: Add your drawing code here
            electricEffect.Draw(e.ElapsedTime, e.TotalTime);
        }
예제 #24
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);


            gameLevel.Draw(e);
        }
예제 #25
0
 private void OnUpdate(object sender, GameTimerEventArgs e)
 {
     if (isActive)
     {
         particleSystem.Update(e.ElapsedTime.Milliseconds / 2000f);
     }
 }
예제 #26
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            spriteBatch.Draw(background, ScreenRect, Color.White);
            spriteBatch.Draw(rock, rockrect, Color.White);
            spriteBatch.Draw(scissors, scissorsrect, Color.White);
            spriteBatch.Draw(paper, paperrect, Color.White);
            spriteBatch.Draw(RightHand, RightHandRect, Color.White);

            if (ActionState == 0 || ActionState == 1)
            {
                spriteBatch.Draw(LeftHand, position, null, Color.White, RotationAngle, origin, 1f, SpriteEffects.None, 0f);
            }
            else if (ActionState == 2)
            {
                spriteBatch.Draw(LeftHandPaper, position, null, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f);
            }
            else if (ActionState == 3)
            {
                spriteBatch.Draw(LeftHandScissors, position, null, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f);
            }
            spriteBatch.End();

            // TODO: Add your drawing code here
        }
예제 #27
0
 public override void Update(GameTimerEventArgs e)
 {
     if (Alive)
     {
         Position += Velocity;
     }
 }
예제 #28
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.Black);
            //draws the bases

            _uiRender.Render();
            spriteBatch.Begin();

            _line.Draw(spriteBatch);
            _missileManager.Draw(spriteBatch, SharedGraphicsDeviceManager.Current.GraphicsDevice);


            for (int i = 0; i < _buildings.Length; i++)
            {
                if (_buildings[i] != null)
                {
                    _buildings[i].Draw(spriteBatch);
                }
            }

            _leftBaseCoolDown.Draw(_leftBase.GetRectangle.Width + 40, spriteBatch);
            _middleBaseCoolDown.Draw(_leftBase.GetRectangle.Width + 40, spriteBatch);
            _rightBaseCoolDown.Draw(_leftBase.GetRectangle.Width + 40, spriteBatch);
            //draws the 3 bases
            _leftBase.Draw(spriteBatch);
            _rightBase.Draw(spriteBatch);
            _middleBase.Draw(spriteBatch);
            //draws overlay
            spriteBatch.Draw(_uiRender.Texture, Vector2.Zero, Color.White);
            spriteBatch.End();
            // TODO: Add your drawing code here
        }
예제 #29
0
        /// <summary>
        /// Allows the page to draw itself.
        /// </summary>
        private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.Wheat);

            spriteBatch.Begin();
            //spriteBatch.DrawString(font1, "X: " + ball.getPos().X, new Vector2(200, 400), Color.White);
            //spriteBatch.DrawString(font1, "Y: " + ball.getPos().Y, new Vector2(200, 500), Color.White);
            ////
            //spriteBatch.DrawString(font1, "X: " + scaledX(100), new Vector2(200, 200), Color.White);
            //spriteBatch.DrawString(font1, "Y: " + ball.getPos().Y, new Vector2(200, 300), Color.White);
            //spriteBatch.DrawString(font1,test, new Vector2(100, 100), Color.Red);

            spriteBatch.Draw(goal.getTex(), goal.getBounds(), Color.Tan);

            for (int i = 0; hole[i] != null; i++)
            {
                spriteBatch.Draw(hole[i].getTex(), hole[i].getBounds(), hole[i].getTex().Bounds, Color.Black);
            }

            for (int i = 0; wall[i] != null; i++)
            {
                spriteBatch.Draw(wall[i].getTex(), wall[i].getBounds(), Color.DarkGray);
            }


            //new Microsoft.Xna.Framework.Rectangle((int)wall.getStart().X, (int)wall.getStart().Y, wall.getLength(), 8)
            spriteBatch.Draw(ball.getTex(), ball.getBounds(), Color.White);

            spriteBatch.End();
            // TODO: Add your drawing code here
        }
예제 #30
0
 private void OnUpdate(object sender, GameTimerEventArgs e)
 {
     uiOpacity = MathHelper.Clamp(uiOpacity + (float)e.ElapsedTime.TotalSeconds * 2f, 0f, 1f);
     frameRateCounter.OnUpdate(e.ElapsedTime);
     Renderer.Current.Update(e.ElapsedTime, e.TotalTime);
     Update(e);
 }
예제 #31
0
 //--------------------------------------------------------------
 void timer_Idle(object sender, GameTimerEventArgs eventArgs)
 {
     idleEventOccured = true;
       idleEventArgs = eventArgs;
 }
예제 #32
0
 public void Setup()
 {
     idleEventOccured = false;
       timeChangedEventOccured = false;
       idleEventArgs = null;
       timeEventArgs = null;
 }
예제 #33
0
 void timer_TimeChanged(object sender, GameTimerEventArgs eventArgs)
 {
     timeChangedEventOccured = true;
       timeEventArgs = eventArgs;
 }