示例#1
0
文件: Game.cs 项目: nyteshade/FTLEdit
        //GuiButton placeRoomRepair;
        //GuiButton placeRoomCombat;
        public void Start()
        {
            game = this;
            ship = new Ship();
            optWnd = new ShipProperties();
            gibs = new Sprite[6];
            //ShipRooms.Add(new FTLRoom(new Vector2i(0, 0), new Vector2i(1, 1)));
            //ShipRooms.Add(new FTLRoom(new Vector2i(2, 2), new Vector2i(1, 1)));
            //ShipRooms.Add(new FTLRoom(new Vector2i(3, 3), new Vector2i(1, 1)));
            //AddRoomBtn_n = new Sprite(new Texture("img/GUI/btns/addroom_n.png"));
            btnAddRoom = new GuiButton(new Vector2f(GUIStartX, 0), new Texture("img/GUI/btns/addroom_n.png"), new Texture("img/GUI/btns/addroom_s.png"));
            btnAddDoor = new GuiButton(new Vector2f(GUIStartX, 37), new Texture("img/GUI/btns/adddoor_n.png"), new Texture("img/GUI/btns/adddoor_s.png"));

            placeRoomCloaking = new GuiButton(new Vector2f(GUIStartX + 5, 65), new Texture("img/GUI/roomfuncs/s_cloaking_overlay.png"));
            placeRoomDoors = new GuiButton(new Vector2f(GUIStartX + 35, 65), new Texture("img/GUI/roomfuncs/s_doors_overlay.png"));
            placeRoomDrones = new GuiButton(new Vector2f(GUIStartX + 65, 65), new Texture("img/GUI/roomfuncs/s_drones_overlay.png"));
            placeRoomEngines = new GuiButton(new Vector2f(GUIStartX + 95, 65), new Texture("img/GUI/roomfuncs/s_engines_overlay.png"));
            placeRoomMedbay = new GuiButton(new Vector2f(GUIStartX + 5, 95), new Texture("img/GUI/roomfuncs/s_medbay_overlay.png"));
            placeRoomOxygen = new GuiButton(new Vector2f(GUIStartX + 35, 95), new Texture("img/GUI/roomfuncs/s_oxygen_overlay.png"));
            placeRoomPilot = new GuiButton(new Vector2f(GUIStartX + 65, 95), new Texture("img/GUI/roomfuncs/s_pilot_overlay.png"));
            placeRoomSensors = new GuiButton(new Vector2f(GUIStartX + 95, 95), new Texture("img/GUI/roomfuncs/s_sensors_overlay.png"));
            placeRoomShields = new GuiButton(new Vector2f(GUIStartX + 5, 125), new Texture("img/GUI/roomfuncs/s_shields_overlay.png"));
            placeRoomTeleporter = new GuiButton(new Vector2f(GUIStartX + 35, 125), new Texture("img/GUI/roomfuncs/s_teleporter_overlay.png"));
            placeRoomWeapons = new GuiButton(new Vector2f(GUIStartX + 65, 125), new Texture("img/GUI/roomfuncs/s_weapons_overlay.png"));
            //AddRoomBtn_s = new Sprite(new Texture("img/GUI/btns/addroom_s.png"));
            //AddDoorBtn_n = new Sprite(new Texture("img/GUI/btns/adddoor_n.png"));
            //AddDoorBtn_s = new Sprite(new Texture("img/GUI/btns/adddoor_s.png"));

            btnOptions = new GuiButton(new Vector2f(GUIStartX, 560), new Texture("img/GUI/btns/options.png"));
            //btnLoad = new GuiButton(new Vector2f(GUIStartX, 150), new Texture("img/GUI/btns/load_n.png"), new Texture("img/GUI/btns/load_s.png"));
            btnLoadFloor = new GuiButton(new Vector2f(GUIStartX, 250), new Texture("img/GUI/btns/loadfloor_n.png"), new Texture("img/GUI/btns/loadfloor_s.png"));
            btnLoadBase = new GuiButton(new Vector2f(GUIStartX, 250 + 37), new Texture("img/GUI/btns/loadbase_n.png"), new Texture("img/GUI/btns/loadbase_s.png"));
            btnToggleFloor = new GuiButton(new Vector2f(GUIStartX, 350), new Texture("img/GUI/btns/showfloor_n.png"), new Texture("img/GUI/btns/showfloor_s.png"));
            btnToggleBase = new GuiButton(new Vector2f(GUIStartX, 350 + 37), new Texture("img/GUI/btns/showbase_n.png"), new Texture("img/GUI/btns/showbase_s.png"));

            btnMoveBG = new GuiButton(new Vector2f(GUIStartX, 400 + 37), new Texture("img/GUI/btns/movebg_n.png"), new Texture("img/GUI/btns/movebg_s.png"));
            btnMoveGibs = new GuiButton(new Vector2f(GUIStartX, 400 + (37 * 2)), new Texture("img/GUI/btns/movegibs_n.png"), new Texture("img/GUI/btns/movegibs_s.png"));
            //LoadBtn_n = new Sprite(new Texture("img/GUI/btns/load_n.png"));
            //LoadBtn_s = new Sprite(new Texture("img/GUI/btns/load_s.png"));
            ViewOffsetter = new Sprite(new Texture("img/GUI/btns/viewshift.png"));
            ViewOffsetter.Position = new Vector2f(GUIStartX + 40, 200);
            //AddRoomBtn_n.Position = new Vector2f(GUIStartX, 0);
            //AddRoomBtn_s.Position = new Vector2f(GUIStartX + 2, 2);
            //AddDoorBtn_n.Position = new Vector2f(GUIStartX, 37);
            //AddDoorBtn_s.Position = new Vector2f(GUIStartX + 2, 37 + 2);
            //LoadBtn_n.Position = new Vector2f(GUIStartX, 140);

            verts[0] = new Vertex();
            verts[1] = new Vertex();
            verts[0].Color = new Color(100, 100, 100, 100);
            verts[1].Color = new Color(100, 100, 100, 100);

            roomFuncs = new List<RoomFunc>();
            roomFuncs.Add(new RoomFunc("pilot", new Texture("img/GUI/roomfuncs/s_pilot_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("doors", new Texture("img/GUI/roomfuncs/s_doors_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("sensors", new Texture("img/GUI/roomfuncs/s_sensors_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("oxygen", new Texture("img/GUI/roomfuncs/s_oxygen_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("engines", new Texture("img/GUI/roomfuncs/s_engines_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("shields", new Texture("img/GUI/roomfuncs/s_shields_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("weapons", new Texture("img/GUI/roomfuncs/s_weapons_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("drones", new Texture("img/GUI/roomfuncs/s_drones_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("medbay", new Texture("img/GUI/roomfuncs/s_medbay_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("teleporter", new Texture("img/GUI/roomfuncs/s_teleporter_overlay.png"), null));
            roomFuncs.Add(new RoomFunc("cloaking", new Texture("img/GUI/roomfuncs/s_cloaking_overlay.png"), null));
        }
示例#2
0
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
                return;

            LoadBlueprints(lastPath);

            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

            // There are various options, set as needed
            htmlDoc.OptionFixNestedTags = true;

            // filePath is a path to a file containing the html
            htmlDoc.Load(lastPath);//OptionsForm.dataPath + "\\data\\blueprints.xml");

            // Use:  htmlDoc.LoadXML(xmlString);  to load from a string

            // ParseErrors is an ArrayList containing any errors from the Load statement
            if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
            {
                // Handle any parse errors as required
                foreach (HtmlParseError error in htmlDoc.ParseErrors)
                {
                    Console.WriteLine(error.ToString());
                }
            }

            if (htmlDoc.DocumentNode != null)
            {
                HtmlNodeCollection weps = htmlDoc.DocumentNode.SelectNodes("//shipblueprint");// SelectSingleNode("//body");

                if (weps != null)
                {
                    // Do something with bodyNode
                    foreach (HtmlNode node in weps)
                    {
                        string shipID = node.GetAttributeValue("name", "#NOT FOUND~");
                        if (shipID == ((ShipInfo)listBox1.SelectedItem).id)
                        {
                            // This is our ship! Let's load it up~~
                            Ship ship = new Ship();
                            ship.id = shipID;
                            ship.img = node.GetAttributeValue("img", "");
                            ship.layout = node.GetAttributeValue("layout", "");
                            if (node.SelectSingleNode(".//class") != null)
                                ship.className = node.SelectSingleNode(".//class").InnerText;

                            if (node.SelectSingleNode(".//name") != null)
                                ship.name = node.SelectSingleNode(".//name").InnerText;
                            if (node.SelectSingleNode(".//desc") != null)
                                ship.desc = node.SelectSingleNode(".//desc").InnerText;

                            HtmlNode sytems = node.SelectSingleNode(".//systemlist");

                            List<string> rooms = new List<string>() { "pilot", "doors", "sensors", "oxygen", "engines", "shields", "weapons", "drones", "medbay", "teleporter", "cloaking" };

                            foreach (string currentRoom in rooms)
                            {
                                if ((sytems.SelectSingleNode(".//" + currentRoom)) != null)
                                {
                                    ship.rooms[currentRoom].power = Convert.ToInt32(sytems.SelectSingleNode(".//" + currentRoom).GetAttributeValue("power", "0"));
                                    ship.rooms[currentRoom].roomId = Convert.ToInt32(sytems.SelectSingleNode(".//" + currentRoom).GetAttributeValue("room", "0"));
                                    if (sytems.SelectSingleNode(".//" + currentRoom).GetAttributeValue("start", "false") == "true")
                                        ship.rooms[currentRoom].start = true;
                                    else
                                        ship.rooms[currentRoom].start = false;
                                }
                            }

                            if (node.SelectSingleNode(".//weaponslots") != null)
                                ship.weaponSlots = Convert.ToInt32(node.SelectSingleNode(".//weaponslots").InnerText);
                            if (node.SelectSingleNode(".//droneslots") != null)
                                ship.droneSlots = Convert.ToInt32(node.SelectSingleNode(".//droneslots").InnerText);

                            if (node.SelectSingleNode(".//health") != null)
                                ship.health = Convert.ToInt32(node.SelectSingleNode(".//health").GetAttributeValue("amount", "0"));
                            if (node.SelectSingleNode(".//maxpower") != null)
                                ship.maxPower = Convert.ToInt32(node.SelectSingleNode(".//maxpower").GetAttributeValue("amount", "0"));
                            HtmlNodeCollection crew = node.SelectNodes(".//crewcount");
                            foreach (HtmlNode crewmembers in crew)
                            {
                                switch (crewmembers.GetAttributeValue("class", "unk"))
                                {
                                    case "human":
                                        ship.crewHuman = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;
                                    case "rock":
                                        ship.crewRock = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;
                                    case "mantis":
                                        ship.crewMantis = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;
                                    case "engi":
                                        ship.crewEngi = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;
                                    case "slug":
                                        ship.crewSlug = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;
                                    case "energy":
                                        ship.crewZoltan = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;
                                    case "crystal":
                                        ship.crewCrystal = Convert.ToInt32(node.SelectSingleNode(".//crewcount").GetAttributeValue("amount", "0"));
                                        break;

                                }
                            }

                            // Load weapons
                            HtmlNode weaponList = node.SelectSingleNode(".//weaponlist");
                            if (weaponList != null)
                            {
                                int weapons = Convert.ToInt32(weaponList.GetAttributeValue("count", "0"));
                                int missiles = Convert.ToInt32(weaponList.GetAttributeValue("missiles", "0"));
                                HtmlNodeCollection actualWeapons = weaponList.SelectNodes(".//weapon");
                                ship.missiles = missiles;

                                if (actualWeapons != null)
                                {
                                    for (int i = 0; i < actualWeapons.Count; i++)
                                    {
                                        string wepname = actualWeapons[i].GetAttributeValue("name", "");
                                        ship.weapons[i] = FindWep(wepname);

                                    }
                                }
                            }

                            // Load drones
                            HtmlNode droneList = node.SelectSingleNode(".//dronelist");
                            if (droneList != null)
                            {
                                int drones = Convert.ToInt32(droneList.GetAttributeValue("count", "0"));
                                int droneParts = Convert.ToInt32(droneList.GetAttributeValue("drones", "0"));
                                HtmlNodeCollection actualDrones = droneList.SelectNodes(".//drone");
                                ship.droneParts = droneParts;

                                if (actualDrones != null)
                                {
                                    for (int i = 0; i < actualDrones.Count; i++)
                                    {
                                        string dronename = actualDrones[i].GetAttributeValue("name", "");
                                        ship.drones[i] = FindDrone(dronename);

                                    }
                                }
                            }

                            // Load augments
                            HtmlNodeCollection augments = node.SelectNodes(".//aug");
                            if (augments != null)
                            {
                                for (int i = 0; i < augments.Count; i++)
                                {
                                    string augname = augments[i].GetAttributeValue("name", "");
                                    ship.augments[i] = FindAug(augname);

                                }
                            }

                            Game.ship = ship;
                            Game.optWnd.UpdateScreen();

                            // Load layout
                            Game.game.ImportShip(ship.layout,ship.img);

                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                            this.Close();
                            return;
                        }

                    }
                    /*
                    string shipName = "No name?";

                    if (node.SelectSingleNode(".//name") != null)
                        shipName = node.SelectSingleNode(".//name").InnerText;

                    listBox1.Items.Add(new ShipInfo(shipID, shipName));*/
                    /*WeaponBlueprints tempWep = new WeaponBlueprints();
                    tempWep.name = node.GetAttributeValue("name", "#NOT FOUND~");

                    if (tempWep.name == "#NOT FOUND~")
                        continue;

                    tempWep.type = node.SelectSingleNode(".//type").InnerText;//reader.ReadElementContentAsString("type", "");
                    tempWep.title = node.SelectSingleNode(".//title").InnerText;
                    if (node.SelectSingleNode(".//short") != null)
                        tempWep.shortname = node.SelectSingleNode(".//short").InnerText;

                    if (node.SelectSingleNode(".//desc") != null)
                        tempWep.desc = node.SelectSingleNode(".//desc").InnerText;
                    weapons.Add(tempWep);*/

                }
            }
        }