Beispiel #1
0
 public void Update(float getDelay)
 {
     if (isAlive)
     {
         SpriteAnim.UpdateAnimation(getDelay);
         Position += Direction * Speed;
     }
 }
Beispiel #2
0
        public void Update(GameTime getGameTime, GUI getGUI)
        {
            //Misc
            DeltaTime = (float)getGameTime.ElapsedGameTime.TotalMilliseconds / 12;
            gui       = getGUI;

            if (isReset)
            {
                Reset();
            }

            if (BulletList.Count >= 100)
            {
                BulletList.RemoveAt(0);
            }

            if (isAlive)
            {
                SetupAnimations();

                if (ControlsEnabled)
                {
                    Weapon();
                    switch (GameMode.Controls)
                    {
                    case GameMode.EControls.Keyboard: KeyboardControls(); break;

                    case GameMode.EControls.Mouse: MouseControls(); break;
                    }
                }

                //Weapon Level Text
                switch (_weaponType)
                {
                case EWeaponType.BASIC:     gui.WepLvl = "Basic"; break;

                case EWeaponType.ADVANCED:  gui.WepLvl = "Adv"; break;

                case EWeaponType.MAX:       gui.WepLvl = "Max"; break;
                }

                //Player Movement
                Direction = GotoPos - Position;
                Speed     = Direction.Length() * 0.13f;
                Direction.Normalize();
                Position += Direction * Speed;

                //Backburner effect
                BackBurnerEffect.UpdateAnimation(0.5f);

                //Shield effect
                ShieldEffect.UpdateAnimation(0.5f);

                //Cursor
                Cursor.currentFrame = 0;
            }
        }
Beispiel #3
0
        public void Draw(SpriteBatch sB)
        {
            if (isAlive)
            {
                foreach (AnimSprite Burner in BackBurners)
                {
                    Burner.UpdateAnimation(0.3f);
                }
                BackBurners[0].Draw(sB, new Vector2(Position.X - 150, Position.Y + 65));
                BackBurners[1].Draw(sB, new Vector2(Position.X - 190, Position.Y + 55));
                BackBurners[2].Draw(sB, new Vector2(Position.X + 135, Position.Y + 65));
                BackBurners[3].Draw(sB, new Vector2(Position.X + 175, Position.Y + 55));

                Sprite.Draw(sB, Position);

                if (isEnabled)
                {
                    MainCannonTimer++;
                    if (MainCannonTimer <= 300)
                    {
                        MainCannonChargeUp.Width  += 1;
                        MainCannonChargeUp.Height += 1;
                    }
                    else if (MainCannonTimer >= 600)
                    {
                        MainCannonChargeUp.Width  = 128;
                        MainCannonChargeUp.Height = 128;
                    }

                    if (MainCannonTimer >= 300 && MainCannonTimer <= 600)
                    {
                        MainCannon.UpdateAnimation(0.4f);
                        MainCannon.Draw(sB, new Vector2(Turret[2].Position.X, Turret[2].Position.Y * 5));
                        MainCannonCollisionBox = new Rectangle((int)Turret[2].Position.X, (int)Turret[2].Position.Y * 2, 100, 650);
                    }
                    else if (MainCannonTimer >= 600)
                    {
                        MainCannonCollisionBox = Rectangle.Empty;
                        MainCannonTimer        = 0;
                    }
                }

                MainCannonChargeUp.UpdateAnimation(0.4f);
                MainCannonChargeUp.Draw(sB, new Vector2(Turret[2].Position.X, Turret[2].Position.Y + 70));

                for (int i = 0; i < 2; i++)
                {
                    Turret[i].Draw(sB);
                }
                Turret[2].Draw(sB);
            }
        }
Beispiel #4
0
        public void Update()
        {
            CollisionBoxTexture = Content.Load <Texture2D>("graphics/collisionbox");

            if (_spriteType == ESpriteType.ANIM)
            {
                SpriteAnim.UpdateAnimation(Delay);
            }

            Position += Direction * Speed;

            if (Position.Y >= 800 || Position.Y <= -100 || GameMode.Mode == GameMode.EGameMode.GAMEOVER || GameMode.Mode == GameMode.EGameMode.MENU)
            {
                isRemoved = true;
                isAlive   = false;
            }
        }
Beispiel #5
0
        public void Draw(SpriteBatch sB)
        {
            if (isAlive)
            {
                for (int i = 0; i < BulletList.Count; i++)
                {
                    BulletList[i].Draw(sB);
                }

                if (SecondaryFireShot)
                {
                    gui.AltBarAmount = 0;

                    if (!SecondaryFireChargeUpAnim.AnimationFinnished)
                    {
                        PlayerAltSFXIns[0].Play();
                        SecondaryFireChargeUpAnim.Height += 3;
                        SecondaryFireChargeUpAnim.Width  += 3;
                        SecondaryFireChargeUpAnim.UpdateAnimation(0.5f);
                        SecondaryFireChargeUpAnim.Draw(sB, new Vector2(Position.X, Position.Y - 20));
                    }
                    else
                    {
                        if (!SecondaryFireAnim.AnimationFinnished)
                        {
                            PlayerAltSFXIns[1].Play();
                            SecondaryFireRect = new Rectangle((int)Position.X - SecondaryFireAnim.Width / 6, (int)Position.Y - SecondaryFireAnim.Height, ScreenSize.Width / 6, ScreenSize.Height);
                            SecondaryFireAnim.UpdateAnimation(0.5f);
                            SecondaryFireAnim.Draw(sB, new Vector2((int)Position.X, (int)Position.Y - SecondaryFireAnim.Height / 2));
                            //sB.Draw(CollisionBoxTexture, SecondaryFireRect, Color.White);
                        }
                        else
                        {
                            SecondaryFireRect = new Rectangle(-100, -100, 0, 0);
                            SecondaryFireShot = false;
                            SecondaryFireAnim.AnimationFinnished         = false;
                            SecondaryFireChargeUpAnim.AnimationFinnished = false;
                            SecondaryFireChargeUpAnim.Height             = 164;
                            SecondaryFireChargeUpAnim.Width = 164;
                        }
                    }
                }

                BackBurnerEffect.Draw(sB, new Vector2(Position.X, Position.Y + 22));
                Sprite.Draw(sB, Position);

                if (isImmune)
                {
                    ImmuneTimer++;
                    if (ImmuneTimer <= 300)
                    {
                        ShieldEffect.Draw(sB, Position, MathHelper.ToRadians(180));
                    }
                    else
                    {
                        ImmuneTimer = 301;
                        isImmune    = false;
                    }
                }

                CollisionBox = new Rectangle((int)Position.X - Sprite.Width / 4, (int)Position.Y - Sprite.Height / 2, Sprite.Width / 2, Sprite.Height);
            }
            else
            {
                CollisionBox = new Rectangle(-100, -100, 0, 0);
                for (int i = 0; i < BulletList.Count; i++)
                {
                    BulletList[i].CollisionBox = new Rectangle(-100, -100, 0, 0);
                }
            }

            if (GameMode.Controls == GameMode.EControls.Mouse)
            {
                Cursor.Draw(sB, new Vector2(GotoPos.X - 5, GotoPos.Y + 5));
            }
        }
Beispiel #6
0
        public void Draw(SpriteBatch sB)
        {
            LifeTimer++;
            if (LifeTimer < 500 && isAlive)
            {
                isAlive = true;
            }
            else
            {
                LifeTimer = 501;
                isAlive   = false;
            }

            if (!isAlive)
            {
                CollectSFXIns.Volume = 0.3f;

                CollectSFXTimer++;
                if (CollectSFXTimer <= 1)
                {
                    CollectSFXIns.Play();
                }
                else
                {
                    CollectSFXTimer = 2;
                }
            }

            if (IsUp)
            {
                Position.Y += 3;
            }
            else
            {
                Position.Y -= 3;
            }
            if (IsLeft)
            {
                Position.X += 3;
            }
            else
            {
                Position.X -= 3;
            }

            if (Position.X >= 700)
            {
                IsLeft = false;
            }
            if (Position.X <= 0)
            {
                IsLeft = true;
            }
            if (Position.Y >= 700)
            {
                IsUp = false;
            }
            if (Position.Y <= 0)
            {
                IsUp = true;
            }

            if (SpriteType == ESpriteType.BASIC && isAlive)
            {
                Sprite.Draw(sB, Position);
                CollisionBox = new Rectangle((int)Position.X, (int)Position.Y, Sprite.Width, Sprite.Height);
            }
            else
            {
                CollisionBox = Rectangle.Empty;
            }

            if (SpriteType == ESpriteType.ANIM && isAlive)
            {
                CollisionBox = new Rectangle((int)Position.X - SpriteAnim.Width / 2, (int)Position.Y - SpriteAnim.Height / 2, SpriteAnim.Width, SpriteAnim.Height);
                SpriteAnim.UpdateAnimation(0.5f);
                SpriteAnim.Draw(sB, Position);
            }
            else
            {
                CollisionBox = Rectangle.Empty;
            }
        }
Beispiel #7
0
        public void Draw(SpriteBatch sB)
        {
            if (isAlive)
            {
                switch (_spriteType)
                {
                case ESpriteType.BASIC:
                {
                    sprite.Draw(sB, Position, Rotation);
                    CollisionBox = new Rectangle((int)Position.X - sprite.Width / 2, (int)Position.Y - sprite.Height / 2, sprite.Width, sprite.Height);
                }; break;

                case ESpriteType.ANIM:
                {
                    SpriteAnim.Draw(sB, Position, Rotation);
                    CollisionBox = new Rectangle((int)Position.X - SpriteAnim.Width / 2, (int)Position.Y - SpriteAnim.Height / 2, SpriteAnim.Width, SpriteAnim.Height);
                }; break;
                }
                if (DebugMode)
                {
                    sB.Draw(CollisionBoxTexture, CollisionBox, Color.White);
                }

                if (!ShootAnim.AnimationFinnished)
                {
                    isShooting = true;
                }
                else
                {
                    isShooting = false;
                }

                if (isShooting)
                {
                    ShootAnim.UpdateAnimation(1f);
                    ShootAnim.Draw(sB, FirePosition, Rotation);
                }
            }
            else
            {
                CollisionBox.X      = -100;
                CollisionBox.Y      = -100;
                CollisionBox.Width  = 0;
                CollisionBox.Height = 0;

                if (!isRemoved)
                {
                    if (!ExplosionAnim.AnimationFinnished)
                    {
                        isExplosion = true;
                    }
                    else
                    {
                        isExplosion = false;
                    }

                    if (isExplosion)
                    {
                        Speed = 1f;
                        ExplosionAnim.UpdateAnimation(0.6f);
                        ExplosionAnim.Draw(sB, Position);
                    }
                }
            }
        }
Beispiel #8
0
        public void Draw(SpriteBatch sB)
        {
            foreach (Bullet bullet in BulletList)
            {
                bullet.Draw(sB);
            }

            if (isWarpIn)
            {
                if (!WarpInEffect.AnimationFinnished)
                {
                    WarpInSFXIns.Play();
                    WarpInEffect.UpdateAnimation(0.4f);
                    WarpInEffect.Draw(sB, new Vector2(Position.X, Position.Y), MathHelper.ToRadians(270));
                }
            }

            if (isAlive)
            {
                switch (_spriteType)
                {
                case ESpriteType.BASIC:
                {
                    Sprite.Draw(sB, Position, Rotation);
                    CollisionBox = new Rectangle((int)Position.X - Sprite.Width / 2, (int)Position.Y - Sprite.Height / 2, Sprite.Width, Sprite.Height);
                }; break;

                case ESpriteType.ANIM:
                {
                    SpriteAnim.Draw(sB, Position, Rotation);
                    CollisionBox = new Rectangle((int)Position.X - SpriteAnim.Width / 2, (int)Position.Y - SpriteAnim.Height / 2, SpriteAnim.Width, SpriteAnim.Height);
                }; break;
                }

                if (DebugMode)
                {
                    sB.Draw(CollisionBoxTexture, CollisionBox, Color.White);
                }
            }
            else
            {
                CollisionBox.X      = -100;
                CollisionBox.Y      = -100;
                CollisionBox.Width  = 0;
                CollisionBox.Height = 0;

                if (!isRemoved)
                {
                    if (!ExplosionAnim.AnimationFinnished)
                    {
                        isExplosion = true;
                    }
                    else
                    {
                        isExplosion = false;
                    }

                    if (isExplosion)
                    {
                        ExplosionSFXIns.Play();
                        Speed = 0;
                        ExplosionAnim.UpdateAnimation(0.5f);
                        ExplosionAnim.Draw(sB, Position);
                        ShockWaveAnim.UpdateAnimation(0.5f);
                        ShockWaveAnim.Draw(sB, Position);
                        if (Score != 0)
                        {
                            DisplayScore.Draw(sB, Score.ToString(), Position, .5f, Color.White);
                        }
                    }
                }
            }
        }
Beispiel #9
0
        public void Update(GUI getGUI, Rectangle getScreenSize, Player getPlayer)
        {
            ScreenSize          = getScreenSize;
            player              = getPlayer;
            CollisionBoxTexture = Content.Load <Texture2D>("graphics/collisionbox");

            if (_spriteType == ESpriteType.ANIM)
            {
                SpriteAnim.UpdateAnimation(Delay);
            }

            switch (EnemyType)
            {
            case EEnemyType.Turret: Turret_Type(); break;

            case EEnemyType.Asteroid: Asteroid_Type(); break;

            case EEnemyType.Warp_CurvLeft: Warp_CurvLeft_Type(); break;

            case EEnemyType.Warp_CurvRight: Warp_CurvRight_Type(); break;

            case EEnemyType.Warp_CurvUpLeft: Warp_CurvUpLeft_Type(); break;

            case EEnemyType.Warp_CurvUpRight: Warp_CurvUpRight_Type(); break;

            case EEnemyType.Warp_JumpLeftRightDown: Warp_JumpLeftRightDown_Type(); break;

            case EEnemyType.Warp_JumpRightLeftDown: Warp_JumpRightLeftDown_Type(); break;
            }

            if (EnemyType == EEnemyType.Asteroid || EnemyType == EEnemyType.Turret)
            {
                if (EnemyType == EEnemyType.Asteroid)
                {
                    Position += Direction * Speed;
                }
                if (EnemyType == EEnemyType.Turret)
                {
                    Rotation = (float)Math.Atan2((double)player.Position.X - (double)Position.X, (double)player.Position.Y - (double)Position.Y);
                }
            }
            else
            {
                Direction = GotoPos - Position;
                Speed     = Direction.Length() * 0.01f;
                Direction.Normalize();
                Position += Direction * Speed;
            }

            if (HasWeapon)
            {
                Weapon();
            }

            if (Health <= 0)
            {
                isAlive = false;

                ScoreTimer++;
                if (ScoreTimer <= 1)
                {
                    getGUI.Score += Score;
                }
                else
                {
                    ScoreTimer = 2;
                }
            }

            if (Position.Y >= 800 || Position.Y <= -300 || Position.X >= 800 || Position.X <= -100 ||
                GameMode.Mode == GameMode.EGameMode.GAMEOVER || GameMode.Mode == GameMode.EGameMode.MENU)
            {
                isRemoved = true;
                isAlive   = false;
            }
        }