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();
            }
        }
        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();
            }
        }
Exemplo n.º 3
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 Item GetRandomItem()
        {
            Item item;

            if (spawnTimer.Test())
            {
                int randIndex = random.Next(0, spawnableItemTypes.Count);

                item = GetItemAccordingType(spawnableItemTypes[randIndex]);

                if (lastSpawnedItem != null && !lastSpawnedItem.Taken)
                {
                    return(null);
                }

                int randX = random.Next(50, (int)(Globals.screenWidth - item.dimension.X - 50));
                int randY = random.Next(Globals.screenHeight / 2, (int)(Globals.screenHeight - item.dimension.Y - 50));

                item.position   = new Vector2(randX, randY);
                item.jet        = GameGlobals.playerJet;
                lastSpawnedItem = item;

                spawnTimer.ResetToZero();
                return(item);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public void Draw(Vector2 OFFSET)
        {
            bg1.Draw(Vector2.Zero);
            bg2.Draw(Vector2.Zero);

            if (Globals.currentState == State.Playing || Globals.currentState == State.Paused)
            {
                playerJet.Draw(OFFSET);
                bullets.ForEach(projectile => projectile.Draw(offset));

                spawners.ForEach(location => location.Draw(offset));
                items.ForEach(item => item.Draw(offset));
                enemies.ForEach(enemy => enemy.Draw(offset));

                if (Globals.currentState == State.Playing && !levelShowTextTimer.Test())
                {
                    string  levelStr = $"Level {level}";
                    Vector2 strDim   = levelFont.MeasureString(levelStr);
                    Globals.spriteBatch.DrawString(levelFont, levelStr, new Vector2(Globals.screenWidth / 2
                                                                                    - strDim.X / 2,
                                                                                    Globals.screenHeight / 2 - strDim.Y), Color.White);
                }
            }

            ui.Draw(this);
        }
Exemplo n.º 6
0
 private void UpdateShield()
 {
     if (shieldTimer != null)
     {
         shieldTimer.UpdateTimer();
         if (shieldTimer.Test())
         {
             jetColor       = Color.White;
             isShieldActive = false;
             shieldTimer    = null;
         }
     }
 }
Exemplo n.º 7
0
        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;
            }
        }
        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 Shoot()
        {
            if (shootTimer.Test())
            {
                int deflection = rand.Next(0, (int)Physics.GetDistance(position, GameGlobals.playerJet.position) / 4);

                if (rand.Next(0, 2) == 0)
                {
                    deflection = -deflection;
                }

                Bullet2D bullet =
                    new ImprovedBullet(new Vector2(position.X, position.Y),
                                       this, new Vector2(GameGlobals.playerJet.position.X + deflection,
                                                         GameGlobals.playerJet.position.Y), rotation, 8.0f);

                GameGlobals.PassBullet(bullet);
                shootEffect.Play();
                shootTimer.ResetToZero();
            }

            if (missileShootCooldown.Test())
            {
                int deflection = rand.Next(0, (int)Physics.GetDistance(position, GameGlobals.playerJet.position) / 4);

                if (rand.Next(0, 2) == 0)
                {
                    deflection = -deflection;
                }

                float degree = MathHelper.ToDegrees(rotation);

                float leftFirstX = 0, leftFirstY = 0;
                float rightFirstX = 0, rightFirstY = 0;

                float leftSecondX  = 0;
                float leftSecondY  = 0;
                float rightSecondX = 0;
                float rightSecondY = 0;

                float difference = 15;

                if (degree < 45 || (degree >= 150 && degree < 260) && degree > 0)
                {
                    leftFirstX   = position.X - dimension.X / 2;
                    rightFirstX  = position.X + dimension.X / 2;
                    leftFirstY   = rightFirstY = position.Y;
                    leftSecondX  = leftFirstX + difference;
                    leftSecondY  = leftFirstY;
                    rightSecondX = rightFirstX - difference;
                    rightSecondY = rightFirstY;
                }
                else if (degree == 45 || degree > -60 && degree < 0)
                {
                    leftFirstX   = position.X - dimension.X / 2 + 10;
                    rightFirstX  = position.X + dimension.X / 2 - 10;
                    leftFirstY   = rightFirstY = position.Y + 10;
                    leftSecondX  = leftFirstX + difference;
                    leftSecondY  = leftFirstY + difference;
                    rightSecondX = rightFirstX - difference;
                    rightSecondY = rightFirstY - difference;
                }
                else if (degree > 45 && degree < 150 || degree > 260 || (degree < 0 && degree < -60))
                {
                    leftFirstX   = rightFirstX = position.X;
                    leftFirstY   = position.Y + dimension.Y / 2;
                    rightFirstY  = position.Y - dimension.Y / 2;
                    leftSecondX  = leftFirstX + difference;
                    leftSecondY  = leftFirstY;
                    rightSecondX = rightFirstX - difference;
                    rightSecondY = rightFirstY;
                    leftSecondX  = leftFirstX;
                    leftSecondY  = leftFirstY + difference;
                    rightSecondX = rightFirstX;
                    rightSecondY = rightFirstY - difference;
                }

                Bullet2D leftMissileLeft =
                    new Missile(new Vector2(leftFirstX, leftFirstY),
                                this, new Vector2(GameGlobals.playerJet.position.X + deflection,
                                                  GameGlobals.playerJet.position.Y), rotation, 6.0f);

                Bullet2D rightMissileRight =
                    new Missile(new Vector2(rightFirstX, rightFirstY),
                                this, new Vector2(GameGlobals.playerJet.position.X + deflection,
                                                  GameGlobals.playerJet.position.Y), rotation, 6.0f);

                Bullet2D leftMissileSecond =
                    new Missile(new Vector2(leftSecondX, leftSecondY),
                                this, new Vector2(GameGlobals.playerJet.position.X + deflection,
                                                  GameGlobals.playerJet.position.Y), rotation, 6.0f);

                Bullet2D rightMissileSecond =
                    new Missile(new Vector2(rightSecondX, rightSecondY),
                                this, new Vector2(GameGlobals.playerJet.position.X + deflection,
                                                  GameGlobals.playerJet.position.Y), rotation, 6.0f);

                GameGlobals.PassBullet(leftMissileLeft);
                GameGlobals.PassBullet(rightMissileRight);
                GameGlobals.PassBullet(leftMissileSecond);
                GameGlobals.PassBullet(rightMissileSecond);
                missileEffect.Play();
                missileShootCooldown.ResetToZero();
            }
        }