Exemplo n.º 1
0
        // Constructor(s)
        public Ship(float standardDirection)
            : base()
        {
            this.ShipLocation      = Location.middle;
            this.StandardDirection = standardDirection;
            this.Direction         = StandardDirection;
            this.EngineAnimation   = TextureManager.none;
            this.Depth             = 0.3f;
            this.FrameWidth        = 64;
            this.FrameHeight       = 64;
            this.Targets           = new List <string>();

            this.Inventory = new Item[5, 7];
            // Fill inventory
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    Inventory[i, j] = (new Item(Item.Nothing, ItemType.nothing, TextureManager.none, "", ""));
                }
            }

            Inventory[2, 5] = new Weapon(this, Globals.Randomizer.Next(0, Weapon.ListOfMethods().Count()), 0);
            Inventory[3, 5] = new Weapon(this, Globals.Randomizer.Next(0, Weapon.ListOfMethods().Count()), 0);

            this.ShipHull = new Hull(this, Globals.Randomizer.Next(0, Hull.ListOfHullMethods().Count()), 0);

            this.Health     = new Bar(new Vector2(0, Globals.ScreenSize.Y - 35), 100, 20, 140, Color.Red);
            this.ShipShield = new Shield(new Vector2(200, Globals.ScreenSize.Y - 35), 100, 20, 60, Globals.Randomizer.Next(0, Shield.ListOfShieldMethods().Count()), 0);
        }
Exemplo n.º 2
0
        public void RankUp()
        {
            int random = Globals.Randomizer.Next(0, 7);

            SceneManager.mapScene.NewRank.Flash = 10;
            if (random == 0)
            {
                AddItem(new Shield(new Vector2(200, Globals.ScreenSize.Y - 35), 100, 20, 60 + Globals.Randomizer.Next(-10, 20), Globals.Randomizer.Next(0, Shield.ListOfShieldMethods().Count()), Rank - 1));
                RankPerks.Add("Shield Module");
            }
            else if (random == 1)
            {
                AddItem(new Hull(this, Globals.Randomizer.Next(0, Hull.ListOfHullMethods().Count()), Rank - 1));
                RankPerks.Add("Hull Module");
            }
            else if (random == 2)
            {
                AddItem(new Weapon(this, Globals.Randomizer.Next(0, Weapon.ListOfMethods().Count()), Rank - 1));
                RankPerks.Add("Weapon Module");
            }
            else if (random == 3)
            {
                for (int i = 0; i < 2; i++)
                {
                    AddItem(new Item(Globals.Heal));
                    AddItem(new Item(Globals.Flee));
                }
                RankPerks.Add("Misc items");
            }
            else if (random == 4)
            {
                Health.MaxValue += 10;
                Health.Change(10);
                RankPerks.Add("Increase health by 10");
            }
            else if (random == 5)
            {
                shieldRegeneration += 0.01f;
                RankPerks.Add("Increase shield regeneration");
            }
            else if (random == 6)
            {
                BonusDamage += 2;
                RankPerks.Add("Increase damage");
            }
        }
Exemplo n.º 3
0
        public void Initialize(Player player)
        {
            if (EnemyDifficulty != Difficulty.Boss)
            {
                SoundManager.ChangeMusic(SoundManager.combat);
            }
            else
            {
                SoundManager.ChangeMusic(SoundManager.boss);
            }
            Started = false;
            if (!Initialized)
            {
                GameObjects.Clear();
                GameObjects.Add(player);
                if (EnemyDifficulty != Difficulty.Boss)
                {
                    GameObjects.Add(new Enemy(EnemyDifficulty));
                }
                else
                {
                    GameObjects.Add(new Boss());
                }
                // Reward for defeating enemy
                for (int i = 0; i < Globals.Randomizer.Next(1, 3); i++)
                {
                    int random = Globals.Randomizer.Next(0, 3);
                    if (random == 0)
                    {
                        Rewards.Add(new Weapon(Player, Globals.Randomizer.Next(0, Weapon.ListOfMethods().Count()), (int)EnemyDifficulty));
                    }
                    else if (random == 1)
                    {
                        Rewards.Add(new Shield(new Vector2(200, Globals.ScreenSize.Y - 35), 100, 20, 60 + (int)EnemyDifficulty * 20 + Globals.Randomizer.Next(-5, 15), Globals.Randomizer.Next(0, Shield.ListOfShieldMethods().Count()), (int)EnemyDifficulty));
                    }
                    if (random == 2)
                    {
                        Rewards.Add(new Hull(Player, Globals.Randomizer.Next(0, Hull.ListOfHullMethods().Count()), (int)EnemyDifficulty));
                    }

                    // Consumable
                    if (Globals.Randomizer.Next(0, 101) < 55)
                    {
                        random = Globals.Randomizer.Next(0, 101);
                        if (random < 35)
                        {
                            Rewards.Add(new Item(Globals.Flee));
                        }
                        else
                        {
                            Rewards.Add(new Item(Globals.Heal));
                        }
                    }
                }
                InitializeTiles();
                Initialized = true;
            }
            else
            {
                GameObjects.RemoveAll(item => !(item is Enemy));
                GameObjects.Add(player);
            }
            Player.Position    += new Vector2(0, 70);
            Player.ShipLocation = Location.middle;
            Player.MoveLeft     = 0;
            Player.MoveRight    = 0;
            player.ShipShield.Change(player.ShipShield.MaxValue);
            player.Energy.Change(1000);
            SceneManager.mapScene.KilledPlayer = (Enemy)GameObjects.First(item => item is Enemy);
        }
Exemplo n.º 4
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, "", "");
                        }
                    }
                }
            }
        }