Beispiel #1
0
        // Constructor(s)
        public Player()
            : base((float)Math.PI * 1.5f)
        {
            this.Texture = TextureManager.boss;
            this.Position = new Vector2(300, Globals.ScreenSize.Y - Texture.Height);

            this.Energy = new Bar(new Vector2(400, Globals.ScreenSize.Y - 35), 100, 20, 100, Color.Orange);
            this.Rank = 1;
            this.Experience = new Bar(new Vector2(Globals.ScreenSize.X / 2 - 330, 50), 300, 25, 100, Color.Green);
            this.Experience.Change(-Experience.MaxValue);
            this.RankPerks = new List<string>();
            Targets.Add("Enemy");
            Targets.Add("Boss");

            this.craft = new Button(new Vector2(700, 400), "Craft", TextureManager.SpriteFont20);
            for (int i = 0; i < 2; i++)
            {
                AddItem(new Item(Globals.Flee));
            }

            // Startmodules
            Inventory[2, 5] = new Weapon(this, 2, -1);
            Inventory[3, 5] = new Weapon(this, 3, -1);
            this.ShipHull = new Hull(this, 6, -1);
            this.ShipShield = new Shield(new Vector2(200, Globals.ScreenSize.Y - 35), 100, 20, 60, 0, -1);
        }
Beispiel #2
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)));
     }
 }
Beispiel #3
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)));
         }
     }
 }
Beispiel #4
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;
     }
 }
Beispiel #5
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);
     }
 }
Beispiel #6
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--;
             }
         }
     }
 }
Beispiel #7
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)));
         }
     }
 }
Beispiel #8
0
 public static void FireBonusDamageLowerHealth(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) * (2 - shooter.Health.Value / shooter.Health.MaxValue), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
     else
     {
         weapon.Damage -= 2;
     }
 }
Beispiel #9
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)));
     }
 }
Beispiel #10
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;
     }
 }
Beispiel #11
0
 public static void FireDamageOverTime(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.HitDamageOverTime, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
     else
     {
         weapon.Damage -= 2;
     }
 }
Beispiel #12
0
 public static void FireChanceToMiss(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         float miss = 0;
         if (Globals.Randomizer.Next(0, 101) > weapon.WeaponChance(shooter))
         {
             miss = MathHelper.Lerp(-0.5f + shooter.ShipHull.WeaponAccuracy, 0.5f - shooter.ShipHull.WeaponAccuracy, (float)Globals.Randomizer.NextDouble());
         }
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction + miss, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
     else
     {
         weapon.Damage += 7;
         weapon.Chance = 60;
     }
 }
Beispiel #13
0
 public static void FireChanceToBreak(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         if (Globals.Randomizer.Next(0, 101) < 100 - weapon.WeaponChance(shooter))
         {
             weapon.Disabled = 180;
             shooter.TakeDamage(weapon.Damage / 2, weapon.ShieldPiercing, DamageType.laser, false);
         }
         level.ToAdd.Add(new Shot(shooter.Position, shooter.Direction, weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
     else
     {
         weapon.Chance += Globals.Randomizer.Next(30, 50);
         weapon.Damage += Globals.Randomizer.Next(5, 7);
     }
 }
Beispiel #14
0
 public static void FireBossX(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     Boss boss = (Boss)shooter;
     float directionRight = (float)Math.Atan2(level.Player.Position.Y - boss.RightShootPosition.Y, (int)boss.ShipLocation * 100 + 100 - boss.RightShootPosition.X);
     float directionLeft = (float)Math.Atan2(level.Player.Position.Y - boss.LeftShootPosition.Y, (int)boss.ShipLocation * 100 + 300 - boss.LeftShootPosition.X);
     if (!initialize)
     {
         for (int i = 0; i < 10; i++)
         {
             weapon.ShotsToShoot.Add(new Shot(boss.RightShootPosition, directionRight, 5, Shot.HitBasic, shooter.Targets, 0, 0));
             weapon.ShotsToShoot.Add(new Shot(boss.LeftShootPosition, directionLeft, 5, Shot.HitBasic, shooter.Targets, 0, 0));
         }
     }
 }
Beispiel #15
0
 public static void FireBoomerang(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.UpdateBoomerang, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
     }
     else
     {
         weapon.Damage += Globals.Randomizer.Next(5, 10);
     }
 }
Beispiel #16
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;
     }
 }
Beispiel #17
0
        public void UpdateInventory()
        {
            // Crafting
            if (currentlyCrafting > 0)
            {
                for (int i = 0; i < Globals.Randomizer.Next(5, 10); i++)
                {
                    SceneManager.GameObjects.Add(new Piece(new Vector2(864, 350), TextureManager.explosion, 90, 1.5f));
                }
            }

            craft.Update();
            currentlyCrafting--;
            if (CanCraft() && currentlyCrafting < 0)
            {
                if (craft.Press())
                {
                    currentlyCrafting = 60;
                    SoundManager.craft.Play();
                }
            }
            if (currentlyCrafting == 0)
            {
                SoundManager.explosion.Play();
                int itemLevel = (int)((Inventory[0, 6].ItemLevel + Inventory[1, 6].ItemLevel + Inventory[2, 6].ItemLevel) / 3 + MathHelper.Lerp(-0.2f, 0.2f, (float)Globals.Randomizer.NextDouble()));
                Inventory[0, 6] = new Item(Globals.Nothing);
                Inventory[1, 6] = new Item(Globals.Nothing);
                Inventory[2, 6] = new Item(Globals.Nothing);
                if (Inventory[3, 6].Type != ItemType.nothing)
                {
                    AddItem(Inventory[3, 6]);
                }
                int random = Globals.Randomizer.Next(0, 3);
                if (random == 0)
                {
                    Inventory[3, 6] = new Weapon(this, Globals.Randomizer.Next(0, Weapon.ListOfMethods().Count()), itemLevel);
                }
                else if (random == 1)
                {
                    Inventory[3, 6] = new Hull(this, Globals.Randomizer.Next(0, Hull.ListOfHullMethods().Count()), itemLevel);
                }
                else if (random == 2)
                {
                    Inventory[3, 6] = new Shield(new Vector2(200, Globals.ScreenSize.Y - 35), 100, 20, 60 + itemLevel * 20 + Globals.Randomizer.Next(-5, 15), Globals.Randomizer.Next(0, Shield.ListOfShieldMethods().Count()), itemLevel);
                }
            }

            for (int i = 0; i < Inventory.GetLength(0); i++)
            {
                for (int j = 0; j < Inventory.GetLength(1); j++)
                {
                    if (Inventory[i, j].Pressed() && Inventory[i, j].Type != ItemType.nothing)
                    {
                        selectedItem = Inventory[i, j];
                        selectedItemArrayPosition = new Point(i, j);
                    }

                    // Right click
                    if (Inventory[i, j].PressedRight() && Inventory[i, j].Type != ItemType.nothing)
                    {
                        Inventory[i, j].UseItem(this, Inventory[i, j]);
                    }
                }
            }

            if (Globals.MState.LeftButton == ButtonState.Released)
            {
                if (selectedItem != null)
                {
                    // Move item in inventory
                    for (int i = 0; i < Inventory.GetLength(0); i++)
                    {
                        for (int j = 0; j < Inventory.GetLength(1); j++)
                        {
                            if (Inventory[i, j].HoverOver())
                            {
                                if ((i == 0 && j == 5) || (selectedItemArrayPosition.X == 0 && selectedItemArrayPosition.Y == 5)) // shield
                                {
                                    if (selectedItem.Type == ItemType.shield && Inventory[i, j].Type == ItemType.shield)
                                    {
                                        SwapItem(new Point(i, j));
                                        break;
                                    }
                                }
                                else if ((i == 1 && j == 5) || (selectedItemArrayPosition.X == 1 && selectedItemArrayPosition.Y == 5)) // hull
                                {
                                    if (selectedItem.Type == ItemType.hull && Inventory[i, j].Type == ItemType.hull)
                                    {
                                        SwapItem(new Point(i, j));
                                        break;
                                    }
                                }
                                else if ((i > 1 && j == 5) || (selectedItemArrayPosition.X > 1 && selectedItemArrayPosition.Y == 5)) // weapons
                                {
                                    if ((((selectedItem.Type == ItemType.weapon || Inventory[i, j].Type == ItemType.weapon) && Inventory[i, j].Type == ItemType.nothing) && (Weapons.Count > 1 || !Weapons.Any(item => item == selectedItem)) || (selectedItem.Type == ItemType.weapon && Inventory[i, j].Type == ItemType.weapon)))
                                    {
                                        int numberOfWeapons = Weapons.Count();
                                        SwapItem(new Point(i, j));
                                        if (numberOfWeapons > Weapons.Count())
                                        {
                                            SelectedWeapon = 0;
                                        }
                                        break;
                                    }
                                }
                                else if (!(i > 2 && j == 6)) // inventory
                                {
                                    SwapItem(new Point(i, j));
                                    break;
                                }
                            }
                        }
                    }
                }

                selectedItem = null;
                selectedItemArrayPosition = new Point(0, 0);

                // remove
                for (int i = Inventory.GetLength(0) - 1; i >= 0; i--)
                {
                    for (int j = Inventory.GetLength(1) - 1; j >= 0; j--)
                    {
                        if (Inventory[i, j].Dead)
                        {
                            Inventory[i, j] = new Item(Item.Nothing, ItemType.nothing, TextureManager.none, "", "");
                        }
                    }
                }
            }
        }
Beispiel #18
0
 public static void FireAiming(Ship shooter, Weapon weapon, int tilesMatched, Level level, bool initialize)
 {
     if (!initialize)
     {
         if (level.GameObjects.Any(item => shooter.Targets.Any(target => target == item.GetType().Name)))
         {
             level.ToAdd.Add(new Shot(shooter.Position, (float)(Math.Atan2((level.GameObjects.First(item => shooter.Targets.Any(target => target == item.GetType().Name)).Position - shooter.Position).Y, (level.GameObjects.First(item => shooter.Targets.Any(target => target == item.GetType().Name)).Position - shooter.Position).X)), weapon.ShotDamage(tilesMatched, shooter), Shot.HitBasic, shooter.Targets, weapon.ShieldPiercing, weapon.WeaponChance(shooter)));
         }
         else
         {
             FireStandard(shooter, weapon, tilesMatched, level, false);
         }
     }
     else
     {
         weapon.Damage -= 6;
     }
 }