예제 #1
0
 // Constructor(s)
 public Rock(Player player, Level level)
     : base()
 {
     this.Texture = TextureManager.rock;
     this.Position = new Vector2(Globals.Randomizer.Next(400, Globals.ScreenSize.X - 300), -100);
     this.Direction = (float)Math.Atan2((player.Position - Position).Y, (player.Position - Position).X);
     level.CombatText("|0,0,0|Rock heading |0,0,255|towards you!|255,0,0| Move!");
 }
예제 #2
0
 public static void HitCrit(Ship ship, Level level, Shot shot)
 {
     if (Globals.Randomizer.Next(0, 101) < shot.Chance)
     {
         ship.TakeDamage(shot.Damage * 2, shot.ShieldPiercing, DamageType.laser);
         level.CombatText("CRIT!");
     }
     else
     {
         ship.TakeDamage(shot.Damage, shot.ShieldPiercing, DamageType.laser);
     }
 }
예제 #3
0
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            // Move
            Position += new Vector2(Speed, 0);

            // Outside Screen
            if (Position.X > Globals.ScreenSize.X + 100)
            {
                Dead = true;
            }
        }
예제 #4
0
        public void Action(int tilesMatched, TileType tileType, Level level, bool manuallyMatched)
        {
            if (tileType == TileType.cog)
            {
                Energy.Change(tilesMatched * 5 + (tilesMatched - 3) * 10);
            }
            else if (Energy.Value > 10 || !manuallyMatched)
            {
                if (manuallyMatched)
                {
                    Energy.Change(-10);
                }

                if (tileType == TileType.shoot && Weapons[SelectedWeapon].Disabled < 0)
                {
                    Weapons[SelectedWeapon].ShootMethods[Weapons[SelectedWeapon].Action](new Vector2(Position.X, Position.Y - Texture.Height / 2), Direction, tilesMatched, level, false);
                }

                if (tileType == TileType.left && ShipLocation != Location.left)
                {
                    MoveLeft += 20 * tilesMatched;
                    DirectionSpeed = -0.0005f;
                }

                if (tileType == TileType.right && ShipLocation != Location.right)
                {
                    MoveRight += 20 * tilesMatched;
                    DirectionSpeed = 0.0005f;
                }

                if (tileType == TileType.shield && ShipShield.Value != ShipShield.Width)
                {
                    ShipShield.Change(10 * tilesMatched);
                }
            }
            else
            {
                level.CombatText("NOT ENOUGH ENERGY!");
            }
        }
예제 #5
0
        // Method(s)
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            // Move
            Position += new Vector2((float)Math.Cos(Direction) * 3, (float)Math.Sin(Direction) * 3);

            // Hit Player
            if (Box.Intersects(level.Player.Box))
            {
                Dead = true;
                level.CreatePieces(Position, Texture);
                level.Player.TakeDamage(20, 0, DamageType.rock);
                Camera.ScreenShakeTimer = 30;
            }

            // Outside screen
            if (Position.Y - Texture.Height / 2 > Globals.ScreenSize.Y)
            {
                Dead = true;
            }
        }
예제 #6
0
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            if (level.Started)
            {
                // Shoot
                ShootTimer--;
                if (ShootTimer < 0 && ShipLocation == level.Player.ShipLocation && Weapons[SelectedWeapon].Disabled < 0)
                {
                    ShootTimer = 180;
                    Weapons[SelectedWeapon].ShootMethods[Weapons[SelectedWeapon].Action](Position, Direction, 0, level, false);
                }

                // Move
                if (Globals.Randomizer.Next(0, 1001) < 2)
                {
                    if (ShipLocation < level.Player.ShipLocation)
                    {
                        ShipLocation++;
                        DirectionSpeed = -0.0005f;
                    }
                    else if (ShipLocation > level.Player.ShipLocation)
                    {
                        ShipLocation--;
                        DirectionSpeed = 0.0005f;
                    }
                }

                // Die
                if (Health.Value <= 0)
                {
                    Dead = true;

                    // Pieces
                    level.CreatePieces(Position, Texture);
                }
            }
        }
예제 #7
0
 public void FireStandard(Vector2 position, float direction, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(position, direction, ShotDamage(tilesMatched), Shot.HitBasic, Targets, ShieldPiercing, Chance));
     }
 }
예제 #8
0
 public void FireAiming(Vector2 position, float direction, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(position, (float)(Math.Atan2((level.GameObjects.First(item => Targets.Any(target => target == item.GetType().Name)).Position - position).Y, (level.GameObjects.First(item => Targets.Any(target => target == item.GetType().Name)).Position - position).X)), ShotDamage(tilesMatched), Shot.HitBasic, Targets, ShieldPiercing, Chance));
     }
 }
예제 #9
0
파일: Tile.cs 프로젝트: kraban/Outer-Space
        // Method(s)
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);
            base.Update();

            if (ManuallyMoved >= 0)
            {
                ManuallyMoved--;
            }

            // Move
            if (Position != new Vector2(TilePosition.X * 64 + (Globals.ScreenSize.X - 64 * 8), TilePosition.Y * 64 + 100))
            {
                Vector2 move = new Vector2(TilePosition.X * 64 + (Globals.ScreenSize.X - 64 * 8), TilePosition.Y * 64 + 100) - Position;
                Position += move * 0.1f;

                // set move to stop matching when moving
                if (move.Length() > 5)
                {
                    Moving = true;
                }
                else
                {
                    Moving = false;
                }
            }

            // Hide
            if (Hidden && Size > 0)
            {
                Size = 0;
            }
        }
예제 #10
0
        public override void UpdateLevel(Level level)
        {
            if (!Move)
            {
                // Die
                if (Health.Value <= 0)
                {
                    Move = true;
                    Dead = true;
                    SoundManager.die.Play();
                }

                Position = new Vector2(Position.X, (float)MathHelper.Lerp(Position.Y, Globals.ScreenSize.Y - Texture.Height, 0.1f));
                base.UpdateLevel(level);
                // Select weapon
                for (int i = 0; i < Weapons.Count(); i++)
                {
                    if (Weapons[i].Pressed())
                    {
                        SelectedWeapon = i;
                        SoundManager.swapItem.Play();
                        break;
                    }
                }
                if (Globals.KState.IsKeyDown(Keys.D1) && Globals.PrevKState.IsKeyUp(Keys.D1))
                {
                    SelectedWeapon = 0;
                    SoundManager.swapItem.Play();
                }
                else if (Globals.KState.IsKeyDown(Keys.D2) && Globals.PrevKState.IsKeyUp(Keys.D2) && Weapons.Count >= 2)
                {
                    SelectedWeapon = 1;
                    SoundManager.swapItem.Play();
                }
                else if (Globals.KState.IsKeyDown(Keys.D3) && Globals.PrevKState.IsKeyUp(Keys.D3) && Weapons.Count >= 3)
                {
                    SelectedWeapon = 2;
                    SoundManager.swapItem.Play();
                }

                // Right
                if (MoveRight > 0)
                {
                    MoveRight--;
                    if (Globals.KState.IsKeyDown(Keys.D) && Globals.PrevKState.IsKeyUp(Keys.D) && ShipLocation != Location.right)
                    {
                        DirectionSpeed = 0.0005f;
                        ShipLocation++;
                        MoveRight = 0;
                        if (level.GameObjects.Any(item => item is Enemy))
                        {
                            Enemy enemy = (Enemy)level.GameObjects.First(item => item is Enemy);
                            enemy.ShootTimer = 90;
                            enemy.MoveTimer = 30;
                        }
                    }
                }

                // Left
                if (MoveLeft > 0)
                {
                    MoveLeft--;
                    if (Globals.KState.IsKeyDown(Keys.A) && Globals.PrevKState.IsKeyUp(Keys.A) && ShipLocation != Location.left)
                    {
                        DirectionSpeed = -0.0005f;
                        ShipLocation--;
                        MoveLeft = 0;
                        if (level.GameObjects.Any(item => item is Enemy))
                        {
                            Enemy enemy = (Enemy)level.GameObjects.First(item => item is Enemy);
                            enemy.ShootTimer = 90;
                            enemy.MoveTimer = 30;
                        }
                    }
                }
            }
            else
            {
                Animation();
                Direction = MathHelper.Lerp(Direction, (float)Math.PI, 0.03f);
                Speed += 0.1f;
                Position += new Vector2((float)Math.Cos(Direction) * Speed, (float)Math.Sin(Direction) * Speed);

                if (Dead == true)
                {
                    Speed -= 0.06f;
                    Direction += MathHelper.Lerp(-0.15f, 0.15f, (float)Globals.Randomizer.NextDouble());
                    for (int i = 0; i < Globals.Randomizer.Next(1, 2); i++)
                    {
                        level.ToAdd.Add(new Piece(new Vector2(Position.X + Globals.Randomizer.Next(-20, 20), Position.Y + Globals.Randomizer.Next(-20, 20)), Texture, 60, 0.5f));
                        level.ToAdd.Add(new Piece(new Vector2(Position.X + Globals.Randomizer.Next(-20, 20), Position.Y + Globals.Randomizer.Next(-20, 20)), TextureManager.explosion, 60, 1.5f));
                    }
                }
            }
        }
예제 #11
0
 public static void HitEnemyShotDelay(Ship ship, Level level, Shot shot)
 {
     ship.TakeDamage(shot.Damage, shot.ShieldPiercing, DamageType.laser);
     if (Globals.Randomizer.Next(0, 101) < shot.Chance)
     {
         ship.Weapons[Globals.Randomizer.Next(0, ship.Weapons.Count)].Disabled = 120;
         level.CombatText(ship.GetType().Name + " Weapon Jammed!");
     }
 }
예제 #12
0
 public static void FireMatchFourExtraShot(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         if (tilesMatched > 3)
         {
             weapon.ShotsToShoot.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         }
     }
 }
예제 #13
0
 public static void FireIncreasingChanceOfTwo(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         if (Globals.Randomizer.Next(0, 101) < weapon.WeaponChance(shooter))
         {
             weapon.ShotsToShoot.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
             weapon.Chance = 0;
         }
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         weapon.Chance += 15;
     }
 }
예제 #14
0
 public static void FireExtraDamageCollideShot(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.UpdateExtraDamageCollideShot, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
 }
예제 #15
0
 public static void FireEveryOther(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         if (weapon.WeaponChance(shooter) == 100)
         {
             weapon.Chance = 0;
             level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.Chance));
         }
         else
         {
             shooter.KnockBack = 0;
             weapon.Chance = 100;
         }
     }
     else
     {
         weapon.Chance = 0;
         weapon.Damage = weapon.Damage * 2 + weapon.Damage / 4;
     }
 }
예제 #16
0
 public static void HitBasic(Ship ship, Level level, Shot shot)
 {
     ship.TakeDamage(shot.Damage, shot.ShieldPiercing, DamageType.laser);
 }
예제 #17
0
 public static void FireMovingShot(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         int random = Globals.Randomizer.Next(0, 101);
         if (random < weapon.WeaponChance(shooter) / 2)
         {
             if ((int)shooter.ShipLocation < 2)
             {
                 shooter.ShipLocation++;
             }
         }
         else if (random < weapon.WeaponChance(shooter))
         {
             if ((int)shooter.ShipLocation > 0)
             {
                 shooter.ShipLocation--;
             }
         }
     }
 }
예제 #18
0
 public static void HitDamageOverTime(Ship ship, Level level, Shot shot)
 {
     ship.TakeDamage(shot.Damage, shot.ShieldPiercing, DamageType.laser);
     ship.SetDamageOverTime(shot.Damage / 6, 6, shot.ShieldPiercing);
 }
예제 #19
0
 public static void FireRandom(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.UpdateRandom, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
     else
     {
         weapon.Damage = (int)(weapon.Damage * 1.5f);
     }
 }
예제 #20
0
        public void Action(int tilesMatched, TileType tileType, Level level, bool manuallyMatched)
        {
            if (tileType == TileType.cog)
            {
                Energy.Change(tilesMatched * 5 + (tilesMatched - 3) * 10);
                SoundManager.match.Play();
            }
            else if (Energy.Value > 10 || !manuallyMatched)
            {
                SoundManager.match.Play();
                if (manuallyMatched)
                {
                    Energy.Change(-10);
                }

                if (tileType == TileType.shoot && Weapons[SelectedWeapon].Disabled < 0)
                {
                    KnockBack = 3;
                    Weapons[SelectedWeapon].Method(this, Weapons[SelectedWeapon], tilesMatched, level, false);
                }

                if (tileType == TileType.left && ShipLocation != Location.left)
                {
                    MoveLeft += 20 * tilesMatched;
                }

                if (tileType == TileType.right && ShipLocation != Location.right)
                {
                    MoveRight += 20 * tilesMatched;
                }

                if (tileType == TileType.shield && ShipShield.Value != ShipShield.Width)
                {
                    ShipShield.Change((ShipShield.ShieldHeal / 3) * tilesMatched);
                }
            }
            else
            {
                level.CombatText("NOT ENOUGH ENERGY!");
                SoundManager.notEnoughEnergy.Play();
            }
        }
예제 #21
0
 public static void FireScattered(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         for (int i = 0; i < Globals.Randomizer.Next(3, 6); i++)
         {
             weapon.ShotsToShoot.Add(new Shot(shooter.Position, shooter.Direction + MathHelper.Lerp(-0.5f + shooter.ShipHull.WeaponAccuracy, 0.5f - shooter.ShipHull.WeaponAccuracy, (float)Globals.Randomizer.NextDouble()), weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         }
     }
     else
     {
         weapon.Damage /= 3;
     }
 }
예제 #22
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            // Mouse
            IsMouseVisible = true;

            // Globals
            Globals.Initialize();

            // TextureManager
            TextureManager.Initialize(Content, GraphicsDevice);

            level = new Level();
            level.InitializeTiles();

            // Scene
            SceneManager.Initialize();

            Camera.Position = new Vector3(-Globals.ScreenSize.X, 0, 0);

            base.Initialize();
        }
예제 #23
0
 public static void FireThreeShots(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter) / 3, Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         for (int i = 0; i < 2; i++)
         {
             weapon.ShotsToShoot.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter) / 3, Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         }
     }
 }
예제 #24
0
 public static void FireTwoInV(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction + 0.2f, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction - 0.2f, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
 }
예제 #25
0
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            if (Disabled >= 0)
            {
                Disabled--;
            }

            // Shots to shoot
            if (ShotsToShoot.Count > 0 && Disabled < 0)
            {
                shotsToShootTimer++;
                if (shotsToShootTimer > 5)
                {
                    shotsToShootTimer = 0;
                    level.ToAdd.Add(ShotsToShoot[0]);
                    ShotsToShoot.RemoveAt(0);
                }
            }

            string key = "D" + (level.Player.SelectedWeapon + 1);
            if (Globals.KState.GetPressedKeys().Any(item => item.ToString() == key))
            {
                drawDescriptionTimer++;
            }

            if ((level.Player.Weapons[level.Player.SelectedWeapon] == this &&  drawDescriptionTimer > 40 || Globals.MRectangle.Intersects(Box)))
            {
                drawDescription = true;
            }
            else
            {
                drawDescription = false;
            }

            if (!Globals.KState.GetPressedKeys().Any(item => item.ToString() == key) && drawDescriptionTimer > 40)
            {
                drawDescriptionTimer = 0;
                drawDescription = false;
            }
        }
예제 #26
0
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            Update();
        }
예제 #27
0
파일: Boss.cs 프로젝트: kraban/Outer-Space
        public override void UpdateLevel(Level level)
        {
            // Animation
            AnimationTimer++;
            if (AnimationTimer > 7)
            {
                AnimationTimer = 0;
                if (Frame < MaxFrame)
                {
                    Frame++;
                }
                else
                {
                    Frame = 0;
                }
            }

            // Renew attacks
            if (possibleAttacks.Count() == 0)
            {
                possibleAttacks.Add(0);
                possibleAttacks.Add(1);
                possibleAttacks.Add(1);
                possibleAttacks.Add(2);
                possibleAttacks.Add(2);
                possibleAttacks.Add(2);
            }

            DamageOverTime();
            // Weapons
            foreach (Weapon w in Weapons)
            {
                w.UpdateLevel(level);
            }
            // Move to normal position after knockback
            if (charge == ChargeState.NotCharging)
            {
                Position = new Vector2(Position.X, (float)MathHelper.Lerp(Position.Y, Texture.Height, 0.05f));
            }
            if (level.Started)
            {
                // Die
                if (Health.Value <= 0 && deathTimer == 0 && dodge == DodgeState.NotDodging && charge == ChargeState.NotCharging)
                {
                    deathTimer = 180;
                    SoundManager.die.Play();
                }
                if (deathTimer > 0)
                {
                    deathTimer--;
                    if (deathTimer % 5 == 0)
                    {
                        dodge = DodgeState.Dodge;
                        List<int> possibleLocations = new List<int>();
                        for (int i = 0; i < 3; i++)
                        {
                            if (i != (int)ShipLocation)
                            {
                                possibleLocations.Add(i);
                            }
                        }
                        ShipLocation = (Location)possibleLocations[Globals.Randomizer.Next(0, possibleLocations.Count())];
                    }
                }
                if (deathTimer == 1)
                {
                    Dead = true;
                    SoundManager.explosion.Play();
                    for (int i = 0; i < 100; i++)
                    {
                        level.ToAdd.Add(new Piece(Position, Texture, 60, 3f));
                    }
                    SceneManager.ChangeScene(SceneManager.winScene);
                }

                attackCooldown--;
                // Choose attack
                if (dodge == DodgeState.NotDodging && charge == ChargeState.NotCharging && shootTimer < -20 && Globals.Randomizer.Next(0, 101) < 3 && attackCooldown < 0 && deathTimer == 0)
                {
                    attackCooldown = 60;
                    int attack = possibleAttacks[Globals.Randomizer.Next(0, possibleAttacks.Count())];
                    possibleAttacks.Remove(attack);
                    if (attack == 0)
                    {
                        if (ShipLocation == level.Player.ShipLocation)
                        {
                            charge = ChargeState.Initialize;
                            SoundManager.bossChargeAttack.Play();
                        }
                        else
                        {
                            SoundManager.bossTeleport.Play();
                            dodge = DodgeState.Dodge;
                            ShipLocation = level.Player.ShipLocation;
                            possibleAttacks.Add(0);
                        }
                    }
                    else if (attack == 1)
                    {
                        shootTimer = 200;
                        Opacity = 0;
                        SoundManager.bossChargeShot.Play();
                    }
                    else if (attack == 2)
                    {
                        // Place mine in tiles
                        int random = Globals.Randomizer.Next(0, level.Tiles.Count());
                        level.Tiles[random][Globals.Randomizer.Next(0, level.Tiles[random].Count() - 2)].Mine = true;
                        SoundManager.bossMine.Play();
                    }
                }

                // Shoot
                shootTimer--;
                if (shootTimer > 0)
                {
                    if (shootTimer > 100)
                    {
                        Opacity += 0.015f;
                    }
                    else if (shootTimer < 20)
                    {
                        Opacity -= 0.07f;
                    }
                    if (shootTimer == 100)
                    {
                        if (ShipLocation == level.Player.ShipLocation)
                        {
                            Weapon.FireBossV(this, Weapons[1], 0, level, false);
                        }
                        else
                        {
                            Weapon.FireBossX(this, Weapons[1], 0, level, false);
                        }
                    }
                }

                // Shield
                if (dodge == DodgeState.Dodge)
                {
                    Weapons[1].ShotsToShoot.Clear();
                    Size = MathHelper.Lerp(Size, 0, 0.1f);
                    if (Size < 0.1f)
                    {
                        dodge = DodgeState.NotDodging;
                        Position = new Vector2((int)ShipLocation * 100 + 200, Position.Y);
                        Size = 1;
                    }
                }

                // Back away to gain more power for charge
                if (charge == ChargeState.Initialize)
                {
                    accelerate = -2;
                    charge = ChargeState.Beginning;
                }
                if (charge == ChargeState.Beginning)
                {
                    Position += new Vector2((float)Math.Cos(Direction) * accelerate, (float)Math.Sin(Direction) * accelerate);
                    accelerate += 0.023f;
                    if (accelerate > 0)
                    {
                        charge = ChargeState.Charge;
                    }
                }

                // Charge
                if (charge == ChargeState.Charge)
                {
                    Position += new Vector2((float)Math.Cos(Direction) * accelerate, (float)Math.Sin(Direction) * accelerate);
                    accelerate += 0.2f;
                }
                else if (charge == ChargeState.Finished) // Return to normal position
                {
                    if (accelerate < 4)
                    {
                        accelerate = 4;
                    }
                    Position += new Vector2((float)Math.Cos(Direction) * accelerate, (float)Math.Sin(Direction) * accelerate);
                    Vector2 afterChargeTarget = new Vector2((int)ShipLocation * 100 + 200, -400);
                    Direction = MathHelper.Lerp(Direction, (float)Math.Atan2(afterChargeTarget.Y - Position.Y, afterChargeTarget.X - Position.X), 0.03f);
                    if (Position.Y < -300)
                    {
                        charge = ChargeState.NotCharging;
                        Direction = StandardDirection;
                        Position = new Vector2((int)ShipLocation * 100 + 200, Position.Y);
                        accelerate = 0f;
                    }
                }
                // Hit player with charge
                if (level.Player.Box.Intersects(chargeRectangle) && charge == ChargeState.Charge)
                {
                    charge = ChargeState.Finished;
                    level.Player.KnockBack = 10;
                    level.Player.TakeDamage(50, 0.5f, DamageType.rock, false);
                    Camera.ScreenShakeTimer = 30;
                }

                // Miss
                if (Position.Y > Globals.ScreenSize.Y)
                {
                    charge = ChargeState.Finished;
                }
            }
        }
예제 #28
0
 public void FireChanceToMiss(Vector2 position, float direction, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         float miss = 0;
         if (Globals.Randomizer.Next(0, 101) > Chance)
         {
             miss = MathHelper.Lerp(-0.5f, 0.5f, (float)Globals.Randomizer.NextDouble());
         }
         level.ToAdd.Add(new Shot(position, direction + miss, ShotDamage(tilesMatched), Shot.HitBasic, Targets, ShieldPiercing, Chance));
     }
     else
     {
         Damage += 15;
         Chance = 40;
     }
 }
예제 #29
0
        // Method(s)
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            // Move
            Position += new Vector2((float)Math.Cos(Direction) * 5, (float)Math.Sin(Direction) * 5);

            // Outside screen
            if (OutsideScreen())
            {
                Dead = true;
            }

            // Hit targets
            if (level.GameObjects.Any(item => Targets.Any(target => target == item.GetType().Name) && item.Box.Intersects(Box)))
            {
                Ship ship = (Ship)level.GameObjects.First(item => Targets.Any(target => target == item.GetType().Name) && item.Box.Intersects(Box));
                Effect(ship, level, this);
                Dead = true;
            }

            // Hit rock
            if (level.GameObjects.Any(item => item.GetType().Name == "Rock" && item.Box.Intersects(Box)))
            {
                Rock rock = (Rock)level.GameObjects.First(item => item.GetType().Name == "Rock" && item.Box.Intersects(Box));
                rock.Dead = true;
                Dead = true;
            }
        }
예제 #30
0
        public override void UpdateLevel(Level level)
        {
            base.UpdateLevel(level);

            if (Disabled >= 0)
            {
                Disabled--;
            }

            string key = "D" + (level.Player.SelectedWeapon + 1);
            if (Globals.KState.GetPressedKeys().Any(item => item.ToString() == key))
            {
                drawDescriptionTimer++;
            }

            if ((level.Player.Weapons[level.Player.SelectedWeapon] == this &&  drawDescriptionTimer > 40 || Globals.MRectangle.Intersects(Box)))
            {
                drawDescription = true;
            }
            else
            {
                drawDescription = false;
            }

            if (!Globals.KState.GetPressedKeys().Any(item => item.ToString() == key) && drawDescriptionTimer > 40)
            {
                drawDescriptionTimer = 0;
                drawDescription = false;
            }
        }
예제 #31
0
파일: Shot.cs 프로젝트: kraban/Outer-Space
 public static void UpdateRandom(Level level, Shot shot)
 {
     shot.Position += new Vector2(Globals.Randomizer.Next(-20, 21), 0);
     HitBasic(level, shot);
 }