Beispiel #1
0
 public static void InitializeContent(ContentManager contentManager)
 {
     HealthBarContainer = contentManager.Load <Texture2D>("UI/healthBar");
     HealthBarSegment   = contentManager.Load <Texture2D>("UI/healthBarSegment");
     OutlineTexture     = contentManager.Load <Texture2D>("Vectors/outline");
     //EnemyShips.Add(contentManager.Load<Texture2D>("Ships/debugEnemy"));
     EnemyShips.Add(contentManager.Load <Texture2D>("Ships/enemyGreen2"));
     EnemyShips.Add(contentManager.Load <Texture2D>("Ships/enemyRed4"));
     EnemyShips.Add(contentManager.Load <Texture2D>("Ships/enemyBlue1"));
     CollsionSphereTexture = contentManager.Load <Texture2D>("Vectors/circle");
     Boulder = contentManager.Load <Texture2D>("Boulders/boulder1");
     //Ship = contentManager.Load<Texture2D>("Ships/debugPlayer");
     Ship                 = contentManager.Load <Texture2D>("Ships/playerShip1_orange");
     SpriteFont           = contentManager.Load <SpriteFont>("Fonts/spriteFont");
     ButtonTexture        = contentManager.Load <Texture2D>("Buttons/grey");
     ButtonPressedTexture = contentManager.Load <Texture2D>("Buttons/grey_pressed");
     Background           = contentManager.Load <Texture2D>("Backgrounds/darkPurple");
     Laser                = contentManager.Load <Texture2D>("Lasers/laserBlue01");
     SideExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle8"));
     SideExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle7"));
     SideExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle8"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle1"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle2"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle3"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle4"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle5"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle6"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle7"));
     ExhaustParticles.Add(contentManager.Load <Texture2D>("Exhausts/particle8"));
 }
        public void SpawnEnemiyShips()
        {
            var enemy = new Enemies();

            if (enemy.CanBeSpawned(EnemyShips))
            {
                EnemyShips.Add(enemy);
            }
        }
Beispiel #3
0
        private void LoadShips(string fileName)
        {
            // Load the XML Document
#if (ANDROID)
            XmlReader reader = XmlReader.Create(Game1.assetManager.Open(fileName));
#else
            XmlReader reader = XmlReader.Create(fileName);
#endif

            string        Name = null, Texture = null, ShipType = null, AI = null;
            int           Health = 0, Hardpoints = 0, WeaponClass = 0, Armour = 0, Cost = 0, Level = 0, Points = 0;
            float         Shield = 0f, Speed = 0f;
            List <Weapon> ShipWeapons = new List <Weapon>();
            bool          Correct_File = false, isPlayer = false;

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Element) && reader.Name == "Ship")
                {
                    if (reader.GetAttribute(0) == "true")
                    {
                        isPlayer = true;
                    }
                    Correct_File = true;
                }

                if (Correct_File)
                {
                    while (reader.NodeType != XmlNodeType.EndElement)
                    {
                        reader.Read();
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            // General Stuff
                            Name = ReadElement(reader, "Name");

                            Health = Convert.ToInt32(ReadElement(reader, "Health"));

                            Shield = (float)Convert.ToDouble(ReadElement(reader, "Shield"));

                            Speed = (float)Convert.ToDouble(ReadElement(reader, "Speed"));

                            Hardpoints = Convert.ToInt32(ReadElement(reader, "Hardpoints"));

                            // Weapon loading
                            WeaponClass = Convert.ToInt32(ReadElement(reader, "WeaponClass"));

                            string weaponName = ReadElement(reader, "Weapon1");
                            if (Hardpoints > 0)
                            {
                                foreach (Weapon weapon in Weapons)
                                {
                                    if (weapon.WeaponName == weaponName)
                                    {
                                        ShipWeapons.Add(weapon);
                                    }
                                }

                                if (Hardpoints > 1)
                                {
                                    weaponName = ReadElement(reader, "Weapon2");
                                    foreach (Weapon weapon in Weapons)
                                    {
                                        if (weapon.WeaponName == weaponName)
                                        {
                                            ShipWeapons.Add(weapon);
                                        }
                                    }
                                    if (Hardpoints > 2)
                                    {
                                        weaponName = ReadElement(reader, "Weapon3");
                                        foreach (Weapon weapon in Weapons)
                                        {
                                            if (weapon.WeaponName == weaponName)
                                            {
                                                ShipWeapons.Add(weapon);
                                            }
                                        }
                                    }
                                }
                            }

                            Armour = Convert.ToInt32(ReadElement(reader, "Armour"));

                            Texture = ReadElement(reader, "Texture");

                            // Player Stuff
                            if (isPlayer)
                            {
                                Cost = Convert.ToInt32(ReadElement(reader, "Cost"));

                                ShipType = ReadElement(reader, "Type");
                            }

                            // Enemy Stuff
                            else
                            {
                                Level = Convert.ToInt32(ReadElement(reader, "Level"));

                                Points = Convert.ToInt32(ReadElement(reader, "Points"));

                                AI = ReadElement(reader, "AI");
                            }
                            reader.Read();
                        }
                    }
                    if (isPlayer)
                    {
                        Ship playerShip  = new Ship(Name, Health, Shield, Speed, WeaponClass, Armour, @"Sprites\Ships\" + Texture, Cost, ShipType, Hardpoints);
                        int  weaponPoint = 0;
                        foreach (Weapon weapon in ShipWeapons)
                        {
                            playerShip.MountWeapon(weaponPoint, weapon);
                            weaponPoint++;
                        }
                        PlayerShips.Add(playerShip);
                    }
                    else
                    {
                        Ship enemyShip   = new Ship(Name, Health, Shield, Speed, WeaponClass, Armour, @"Sprites\Ships\" + Texture, Level, Points, AI, Hardpoints);
                        int  weaponPoint = 0;
                        foreach (Weapon weapon in ShipWeapons)
                        {
                            enemyShip.MountWeapon(weaponPoint, weapon);
                            weaponPoint++;
                        }
                        EnemyShips.Add(enemyShip);
                    }
                }
            }
            reader.Close();

            if (Correct_File == false)
            {
                // Error code here
            }
        }