private void MoveLeftOrRight()
 {
     if (moveTimer != null)
     {
         moveTimer.UpdateTimer();
         if (movesRight)
         {
             position.X += speed;
             if (Physics.IsOutOfArena(position))
             {
                 movesRight = false;
                 movesLeft  = true;
             }
         }
         else if (movesLeft)
         {
             position.X -= speed;
             if (Physics.IsOutOfArena(position))
             {
                 movesRight = true;
                 movesLeft  = false;
             }
         }
     }
 }
Exemple #2
0
        public override void Update()
        {
            base.Update();

            if (destroyed)
            {
                Globals.currentState = State.StartMenu;
            }

            missileShootCooldown.UpdateTimer();
            shootTimer.UpdateTimer();

            UpdateShield();

            MoveJet();
            Rotate();


            if (Globals.mouse.LeftClick() && shootTimer.Test())
            {
                ShootRegularBullet();
                shootTimer.Reset(1000 - bulletFireSpeed);
            }
            if (Globals.mouse.RightClick() && missileShootCooldown.Test())
            {
                ShootMissile();
                missileShootCooldown.Reset(10000 - missileFireSpeed);
            }
        }
        public override void BehaveArtificially()
        {
            shootTimer.UpdateTimer();
            missileShootCooldown.UpdateTimer();

            MoveLeftOrRight();

            if (moveTimer != null && moveTimer.Test())
            {
                moveTimer = null;
            }

            if (moveTimer == null || (moveTimer != null && moveTimer.Test()))
            {
                Move();
            }

            if (position.Y < Globals.screenHeight / 4)
            {
                position += Physics.RadialMovement(GameGlobals.playerJet.position, position, speed);
            }

            if (!GameGlobals.playerJet.destroyed)
            {
                Rotate();
                Shoot();
            }
        }
        private void HandleLevel()
        {
            levelShowTextTimer.UpdateTimer();

            if (enemies.Count == 0 && spawners.Count == 0)
            {
                Random r = new Random();
                level++;
                spawners.Clear();
                switch (level)
                {
                case 2:
                    spawners.Add(new CorporalSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                 -r.Next(100, 300)), 10));
                    spawners.Add(new KamikazeSpawner(new Vector2(r.Next(-300, Globals.screenWidth + 300),
                                                                 -r.Next(100, 300)), 3));
                    break;

                case 3:
                    spawners.Add(new CorporalSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                 -r.Next(100, 300)), 5));
                    spawners.Add(new SergeantSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                 -r.Next(100, 300)), 10));
                    break;

                case 4:
                    spawners.Add(new MajorSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                              -r.Next(100, 300)), 10));
                    spawners.Add(new SergeantSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                 -r.Next(100, 300)), 10));
                    break;

                case 5:
                    spawners.Add(new MajorSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                              -r.Next(100, 300)), 5));
                    spawners.Add(new GeneralSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                -r.Next(100, 300)), 3));
                    break;

                case 6:
                    spawners.Add(new CorporalSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                 -r.Next(100, 300)), 10));
                    spawners.Add(new SergeantSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                 -r.Next(100, 300)), 5));
                    spawners.Add(new KamikazeSpawner(new Vector2(r.Next(-300, Globals.screenWidth + 300),
                                                                 -r.Next(100, 300)), 3));
                    spawners.Add(new MajorSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                              -r.Next(100, 300)), 5));
                    spawners.Add(new GeneralSpawner(new Vector2(r.Next(0, Globals.screenWidth),
                                                                -r.Next(100, 300)), 5));
                    break;

                default:
                    Globals.currentState            = State.StartMenu;
                    GameGlobals.playerJet.destroyed = true;
                    break;
                }
                levelShowTextTimer.ResetToZero();
            }
        }
 public void Update()
 {
     spawnTimer.UpdateTimer();
     if (lastSpawnedItem != null && lastSpawnedItem.Taken)
     {
         spawnTimer.ResetToZero();
         lastSpawnedItem = null;
     }
 }
Exemple #6
0
 private void UpdateShield()
 {
     if (shieldTimer != null)
     {
         shieldTimer.UpdateTimer();
         if (shieldTimer.Test())
         {
             jetColor       = Color.White;
             isShieldActive = false;
             shieldTimer    = null;
         }
     }
 }
        public override void BehaveArtificially()
        {
            shootTimer.UpdateTimer();

            if (moveTimer != null)
            {
                moveTimer.UpdateTimer();
                if (movesRight)
                {
                    position.X += speed;
                    if (Physics.IsOutOfArena(position))
                    {
                        movesRight = false;
                        movesLeft  = true;
                    }
                }
                else if (movesLeft)
                {
                    position.X -= speed;
                    if (Physics.IsOutOfArena(position))
                    {
                        movesRight = true;
                        movesLeft  = false;
                    }
                }
            }

            if (moveTimer != null && moveTimer.Test())
            {
                moveTimer = null;
            }

            if (moveTimer == null || (moveTimer != null && moveTimer.Test()))
            {
                Move();
            }

            if (position.Y < Globals.screenHeight / 4)
            {
                position += Physics.RadialMovement(GameGlobals.playerJet.position, position, speed);
            }

            if (!GameGlobals.playerJet.destroyed)
            {
                Rotate();
                Shoot();
            }
        }
        public override void Update()
        {
            if (modelCounter < maxModelCount)
            {
                spawnTimer.UpdateTimer();

                if (spawnTimer.Test())
                {
                    modelCounter++;
                    SpawnModel();
                    spawnTimer.ResetToZero();
                }
            }
            else
            {
                finished = true;
            }
        }
        public override void BehaveArtificially()
        {
            shootTimer.UpdateTimer();
            moveTimer.UpdateTimer();

            if (position.Y < Globals.screenHeight / 4)
            {
                position += Physics.RadialMovement(GameGlobals.playerJet.position, position, speed);
            }

            if (moveTimer.Test())
            {
                movesLeft  = !movesLeft;
                movesRight = !movesRight;
                int time;
                if (movesRight)
                {
                    time = (int)(right / speed) * 14;
                }
                else
                {
                    time = (int)(left / speed) * 14;
                }
                moveTimer.Reset(time);
            }

            if (movesLeft)
            {
                position.X -= speed;
            }
            if (movesRight)
            {
                position.X += speed;
            }

            if (!GameGlobals.playerJet.destroyed)
            {
                Rotate();
                Shoot();
            }
        }
        public override void Update()
        {
            hitTimer.UpdateTimer();

            if (explosionTimer != null)
            {
                explosionTimer.UpdateTimer();
                if (explosionTimer.Test())
                {
                    destroyed = true;
                    explosionEffect.Play();
                }
            }

            if (hitTimer.Test() && isHit)
            {
                isHit        = false;
                jetColor     = Color.White;
                dimension.X -= 5;
                dimension.Y -= 5;
            }
        }