Update() public method

public Update ( ) : void
return void
Esempio n. 1
0
 public override void Update(float deltaTime)
 {
     base.Update(deltaTime);
     textBox.Update(deltaTime);
     Game.playerName = textBox.text;
     this.deltaTime  = deltaTime;
     parallax.Update(deltaTime);
 }
Esempio n. 2
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            waterParallax.Update(gameTime, 2f, 0);
            skyBGParallax.Update(gameTime, 0.1f, 0);
            cloudsParallax.Update(gameTime, 2f, 0);

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
Esempio n. 3
0
        public override void Update(MouseState _Mouse, KeyboardState _KeyBoard, GameTime _GameTime)
        {
            if (!Pause)
            {
                Background.Update(_Mouse, _KeyBoard, _GameTime);
                worldUpdater.Update(_Mouse, _KeyBoard, _GameTime);
            }
            Camera.Update();

            gameUI.Update(_Mouse, _KeyBoard, _GameTime);

            base.Update(_Mouse, _KeyBoard, _GameTime);
        }
Esempio n. 4
0
 public override void Update(GameTime gameTime)
 {
     if (Compteur <= 3 && !fin)
     {
         Parallax.Update();
         Compteur += (float)gameTime.ElapsedGameTime.TotalSeconds;
     }
     else if (!fin)
     {
         fin      = true;
         Compteur = 0;
         MediaPlayer.Play(RessourceSonic3.AngelIslandAct2Song);
         MediaPlayer.IsRepeating = true;
     }
     else
     {
         Compteur += (float)gameTime.ElapsedGameTime.TotalSeconds;
         if (Compteur >= 2)
         {
             //AddScreen(new cTest(serviceProvider, GraphicsDeviceManager,NumPerso));
             //RemoveScreen(this);
         }
     }
 }
Esempio n. 5
0
 public override void Update(float deltaTime)
 {
     base.Update(deltaTime);
     parallax.Update(deltaTime);
 }
Esempio n. 6
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (otherScreenHasFocus || IsExiting)
            {
                return;
            }
            //xpos++;
            //if (xpos == 320*3) xpos = 0;
            playerShip.Update(gameTime, map);

            waterLevel = 260;
            waterParallax.Position.Y        = waterLevel;
            underwaterBGParallax.Position.Y = waterLevel + 20;

            if (playerShip.Position.X < 0f)
            {
                playerShip.Position.X = (map.TileWidth * map.Width) + playerShip.Speed.X;
                camera.Position.X     = (playerShip.Position.X + playerShip.Speed.X * 20f) - (camera.Target.X - camera.Position.X);
                //particleController.Wrap((map.TileWidth*map.Width));
                //projectileController.Wrap((map.TileWidth * map.Width));
            }
            if (playerShip.Position.X >= (map.TileWidth * map.Width))
            {
                playerShip.Position.X = 0f + playerShip.Speed.X;
                camera.Position.X     = (playerShip.Position.X + playerShip.Speed.X * 20f) - (camera.Target.X - camera.Position.X);
                //particleController.Wrap(-(map.TileWidth * map.Width));
                //projectileController.Wrap(-(map.TileWidth * map.Width));
                //camera.Target.X += playerShip.Speed.X * 20f;
            }

            if (!playerShip.underWater)
            {
                if (playerShip.Position.Y > waterLevel + 10)
                {
                    playerShip.underWater = true;
                    AudioController.PlaySFX("water_enter", 1f, -0.1f, 0.1f);
                    AudioController._songs["overwater-theme"].Volume  = 0f;
                    AudioController._songs["underwater-theme"].Volume = AudioController.MusicVolume;
                }
                waterParallax.HeightScale = MathHelper.Lerp(waterParallax.HeightScale, 0.65f, 0.1f);
            }
            if (playerShip.underWater)
            {
                if (playerShip.Position.Y < waterLevel - 10)
                {
                    AudioController.PlaySFX("water_leave", 0.8f, -0.1f, 0.1f);
                    AudioController._songs["overwater-theme"].Volume  = AudioController.MusicVolume;
                    AudioController._songs["underwater-theme"].Volume = 0f;
                    playerShip.underWater = false;
                    for (int i = 0; i < 30; i++)
                    {
                        Vector2 pos = new Vector2(Helper.RandomFloat(-5f, 5f), 0f);
                        Color   col = Color.Lerp(new Color(0, 81, 147), new Color(211, 234, 254), Helper.RandomFloat(0f, 1f));
                        particleController.Add(playerShip.Position + pos,
                                               (pos * 0.1f) + new Vector2(playerShip.Speed.X, playerShip.Speed.Y * Helper.RandomFloat(0.25f, 2f)),
                                               0, 2000, 500, true, true, new Rectangle(0, 0, 3, 3),
                                               col, particle => { ParticleFunctions.FadeInOut(particle);
                                                                  if (particle.Position.Y > waterLevel)
                                                                  {
                                                                      particle.State = ParticleState.Done;
                                                                  }
                                               }, 1f, 0f, Helper.RandomFloat(-0.1f, 0.1f), 1, ParticleBlend.Alpha);
                    }
                }

                waterParallax.HeightScale = MathHelper.Lerp(waterParallax.HeightScale, 0.1f, 0.05f);
            }

            particleController.Update(gameTime, map);
            if (!_endOfWave)
            {
                enemyController.Update(gameTime, map);
            }
            projectileController.Update(gameTime, map);
            powerupController.Update(gameTime, map);



            camera.Target    = playerShip.Position;
            camera.Target.X += playerShip.Speed.X * 20f;

            //Enemy head = EnemyController.Instance.Enemies.FirstOrDefault(en => en is Boss && ((Boss) en).Head);
            //if (head != null)
            //{
            //    playerShip.Position = head.Position + new Vector2(0, -16);
            //    camera.Target = head.Position;
            //}

            camera.Update(gameTime, playerShip.underWater, waterLevel);

            waterParallax.Update(gameTime, (camera.Target.X - camera.Position.X) * camera.Speed, (int)camera.Position.X);
            underwaterBGParallax.Update(gameTime, ((camera.Target.X - camera.Position.X) * camera.Speed) * 0.5f, (int)camera.Position.X);
            skyBGParallax.Update(gameTime, ((camera.Target.X - camera.Position.X) * camera.Speed) * 0.1f, (int)camera.Position.X);
            rocksParallax.Update(gameTime, (camera.Target.X - camera.Position.X) * camera.Speed, (int)camera.Position.X);
            cloudsParallax.Update(gameTime, (camera.Target.X - camera.Position.X) * camera.Speed, (int)camera.Position.X);

            hud.Update(gameTime, new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight));

            if (enemyController.Enemies.Count == 0 && enemyController.NumToSpawn == 0 && !_endOfWave)
            {
                _endOfWave = true;
                TimerController.Instance.Create("", () =>
                {
                    GameController.Wave++;
                    TweenController.Instance.Create("", TweenFuncs.QuadraticEaseIn, tweenin =>
                    {
                        _waveFade = tweenin.Value;
                        if (tweenin.State == TweenState.Finished)
                        {
                            MapGeneration.Generate(map);
                            enemyController.SpawnInitial(GameController.Wave, map);
                            playerShip.Reset();
                            projectileController.Reset();
                            _firstWave = false;

                            TweenController.Instance.Create("", TweenFuncs.Linear, eowtween =>
                            {
                                //playerShip.Life += 0.2f;
                                _eowTimer = eowtween.Value;
                                if (eowtween.State == TweenState.Finished)
                                {
                                    TweenController.Instance.Create("", TweenFuncs.QuadraticEaseIn, tweenout =>
                                    {
                                        _waveFade = 1f - tweenout.Value;
                                        if (tweenout.State == TweenState.Finished)
                                        {
                                            _endOfWave = false;
                                        }
                                    }, 500, false, false);
                                }
                            }, _tradecost == 0?2000:5000, false, false);
                        }
                    }, 500, false, false);
                }, GameController.Wave > 0?2000:0, false);
            }

            if (playerShip.Life <= 0f && !_gameOver)
            {
                _gameOver = true;
                TimerController.Instance.Create("", () =>
                {
                    TweenController.Instance.Create("", TweenFuncs.QuadraticEaseIn, tweenin =>
                    {
                        _goFade = tweenin.Value;
                        if (tweenin.State == TweenState.Finished)
                        {
                            TweenController.Instance.Create("", TweenFuncs.Linear, eowtween =>
                            {
                                _goTimer = eowtween.Value;
                            }, 2000, false, false);
                        }
                    }, 1000, false, false);
                }, 2000, false);
            }

            TweenController.Instance.Update(gameTime);
            TimerController.Instance.Update(gameTime);

            _tradecost = (int)Math.Ceiling((GameController.Wave * 2f) * (0.01f * (100f - playerShip.Life)));
        }
Esempio n. 7
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            parallax.Update(deltaTime);
            deltaTimes = deltaTime;
            time      += deltaTime;
            // Make it shoot the bullets from the ai at the player
            if (time >= 1.5)
            {
                if (tank2.tankObject != null && tank2.ammo > 0)
                {
                    Bullet bullet = new Bullet();
                    bullet.SetUpAI(tank2, tank);
                    bullets2.AddObject(bullet);
                    tank2.ammo -= 1;
                }
                time = 0;
            }

            // End Of Test

            if (tank2.tankObject != null)
            {
                bullets2.Update(deltaTime);
                tank2.MoveAI(deltaTime, tank, ammoBox);
                bullets2.Update(deltaTime);
                bullets2.Des(ref tank);
                if (ammoBox.IsOnAmmo(tank2.collider))
                {
                    tank2.ammo += ammoBox.ammo;
                    ammoBox     = new AmmoBox(1, 30);
                    ammoBox.Inits();
                }
            }
            else
            {
                if (!explodedTank2 && !tankAni.isActive)

                {
                    // Loads win level
                    if (aniTime >= 1)
                    {
                        ChangeLevel("02");
                    }
                    else
                    {
                        aniTime += deltaTime;
                    }
                }
                if (tankAni.isActive)
                {
                    explodedTank2 = true;
                }
            }
            if (tank.tankObject != null)
            {
                tank.Move(deltaTime);

                bullets.Des(ref tank2);
                bullets.Update(deltaTime);
                if (ammoBox.IsOnAmmo(tank.collider))
                {
                    tank.ammo += ammoBox.ammo;
                    ammoBox    = new AmmoBox(1, 30);
                    ammoBox.Inits();
                }
            }
            else
            {
                if (!explodedTank && !tankAni.isActive)
                {
                    // Loads win level
                    if (aniTime >= 1)
                    {
                        ChangeLevel("lose");
                    }
                    else
                    {
                        aniTime += deltaTime;
                    }
                }
                if (tankAni.isActive)
                {
                    explodedTank = true;
                }
            }
            if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) && !tank.stopTank)
            {
                if (tank.tankObject != null && tank.ammo > 0)
                {
                    Bullet bullet = new Bullet();

                    bullet.SetUp(tank);
                    bullets.AddObject(bullet);
                    tank.ammo -= 1;
                }
            }
        }