Exemplo n.º 1
0
        private Point GetEnemyCoordinates(Label clickedLabel)
        {
            var row    = EnemyShips.GetRow(clickedLabel);
            var column = EnemyShips.GetColumn(clickedLabel);

            return(new Point(row, column));
        }
Exemplo n.º 2
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"));
 }
Exemplo n.º 3
0
        public void SpawnEnemiyShips()
        {
            var enemy = new Enemies();

            if (enemy.CanBeSpawned(EnemyShips))
            {
                EnemyShips.Add(enemy);
            }
        }
Exemplo n.º 4
0
        public void Shot2(Ship x)
        {
            if (x != null)
            {
                try
                {
                    TcpClient client = new TcpClient();
                    client.Connect("127.0.0.1", 11111);
                    NetworkStream tcpStream = client.GetStream();

                    string send = x.Name.ToString(); // начало формирования ответа
                    byte[] msg  = Encoding.UTF8.GetBytes(send);
                    tcpStream.Write(msg, 0, msg.Length);

                    byte[] bytes = new byte[client.ReceiveBufferSize]; // буфер входящей информации
                    tcpStream.Read(bytes, 0, bytes.Length);
                    string input   = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
                    int    shoting = Convert.ToInt32(input);
                    _dispatcher.Invoke(new Action(() =>
                    {
                        if (shoting == 0)
                        {
                            EnemyShips.RemoveAt(Convert.ToInt32(x.Name));
                            Ship shot      = new Ship();
                            shot.Content   = "";
                            shot.Name      = "O";
                            shot.IsEnabled = false;
                            EnemyShips.Insert(Convert.ToInt32(x.Name), shot);
                        }
                        else
                        {
                            if (shoting == 1)
                            {
                                EnemyShips.RemoveAt(Convert.ToInt32(x.Name));
                                Ship shot      = new Ship();
                                shot.Content   = "";
                                shot.Name      = "X";
                                shot.IsEnabled = false;
                                EnemyShips.Insert(Convert.ToInt32(x.Name), shot);
                            }
                        }
                    }));

                    tcpStream.Close();
                    client.Close();
                }
                catch (SocketException ex)
                { MessageBox.Show(ex.ToString()); }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
            }
        }
Exemplo n.º 5
0
        public void DeleteEnemies(List <Enemies> deleted)
        {
            foreach (var e in deleted)
            {
                for (int i = 0; i < 3; i++)
                {
                    Console.SetCursorPosition(e.Position.x, e.Position.y + i);

                    Console.WriteLine(new String(' ', 7));
                }
                Console.Beep();
                EnemyShips.Remove(e);
            }
        }
Exemplo n.º 6
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
            }
        }