예제 #1
0
 public QuestionStudyControl(MainWindow mainWin)
 {
     InitializeComponent();
     this.MainWin      = mainWin;
     this.questionList = MainWin.QuesRecord.Questions;
     questionList.ForEach(q => Flag.Add(false));
     Index = 0;
     showTheQuestion();
 }
예제 #2
0
파일: Building.cs 프로젝트: tier6tank/DFWV
        public Building(XDocument xdoc, World world)
            : base(xdoc, world)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value.Trim();
                int valI;
                int.TryParse(val, out valI);
                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "name":
                    Name = val;
                    break;

                case "coordscenter":
                    CoordsCenter = new Point3(
                        Convert.ToInt32(val.Split(',')[0]),
                        Convert.ToInt32(val.Split(',')[1]),
                        Convert.ToInt32(val.Split(',')[2]));
                    break;

                case "coords1":
                    Point TL = new Point(
                        Convert.ToInt32(val.Split(',')[0]),
                        Convert.ToInt32(val.Split(',')[1]));
                    Rect = new Rectangle(TL, new Size(0, 0));
                    break;

                case "coords2":
                    Point BR = new Point(
                        Convert.ToInt32(val.Split(',')[0]),
                        Convert.ToInt32(val.Split(',')[1]));
                    Rect = new Rectangle(Rect.Location, new Size(BR.X - Rect.Left, BR.Y - Rect.Top));
                    break;

                case "mat":
                    if (!Item.Materials.Contains(val))
                    {
                        Item.Materials.Add(val);
                    }
                    Mat = Item.Materials.IndexOf(val);
                    break;

                case "race":
                    if (valI != -1)
                    {
                        Race = World.GetAddRace(val);
                    }
                    break;

                case "type":
                    if (!BuildingTypes.Contains(val))
                    {
                        BuildingTypes.Add(val);
                    }
                    BuildingTypeID = BuildingTypes.IndexOf(val);
                    break;

                case "subtype":
                    if (!BuildingSubTypes.Contains(val))
                    {
                        BuildingSubTypes.Add(val);
                    }
                    BuildingSubTypeID = BuildingSubTypes.IndexOf(val);
                    break;

                case "corpse_unit":
                    CorpseUnitID = valI;
                    break;

                case "corpse_hf":
                    CorpseHFID = valI;
                    break;

                case "owner_unit_id":
                    OwnerUnitID = valI;
                    break;

                case "claimed_by":
                    if (valI != -1)
                    {
                        ClaimedByID = valI;
                    }
                    break;

                case "squad":
                    SquadID = valI;
                    break;

                case "zone_flags":
                    var flags = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var flag in flags)
                    {
                        if (!Flags.Contains(flag))
                        {
                            Flags.Add(flag);
                        }
                        if (Flag == null)
                        {
                            Flag = new List <short>();
                        }
                        Flag.Add((short)Flags.IndexOf(flag));
                    }
                    break;

                case "direction":
                    Direction = valI;
                    break;

                case "reference":
                    if (References == null)
                    {
                        References = new List <Reference>();
                    }
                    References.Add(new Reference(element, this));
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName, element, xdoc.Root.ToString());
                    break;
                }
            }
        }
예제 #3
0
파일: Item.cs 프로젝트: tier6tank/DFWV
        public Item(XDocument xdoc, World world)
            : base(xdoc, world)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value.Trim();
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "type":
                    if (!ItemTypes.Contains(val))
                    {
                        ItemTypes.Add(val);
                    }
                    ItemTypeId = ItemTypes.IndexOf(val);
                    break;

                case "subtype":
                    if (valI != -1)
                    {
                        if (!ItemSubTypes.Contains(val))
                        {
                            ItemSubTypes.Add(val);
                        }
                        ItemSubTypeId = ItemSubTypes.IndexOf(val);
                    }
                    break;

                case "description":
                    Description = val;
                    break;

                case "mat":
                    if (!Materials.Contains(val))
                    {
                        Materials.Add(val);
                    }
                    Mat = Materials.IndexOf(val);
                    break;

                case "maker":
                    if (valI != -1)
                    {
                        MakerID = valI;
                    }
                    break;

                case "quality":
                    if (valI != -1)
                    {
                        QualityVal = valI;
                    }
                    break;

                case "skill_used":
                    if (valI != -1)
                    {
                        SkillUsed = valI;
                    }
                    break;

                case "masterpiece_event":
                    if (valI != -1)
                    {
                        MasterpieceEventID = valI;
                    }
                    break;

                case "flags":
                    var flags = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var flag in flags)
                    {
                        if (!Flags.Contains(flag))
                        {
                            Flags.Add(flag);
                        }
                        if (Flag == null)
                        {
                            Flag = new List <short>();
                        }
                        Flag.Add((short)Flags.IndexOf(flag));
                    }
                    break;

                case "coords":
                    Coords = new Point3(
                        Convert.ToInt32(val.Split(',')[0]),
                        Convert.ToInt32(val.Split(',')[1]),
                        Convert.ToInt32(val.Split(',')[2]));
                    break;

                case "temperature":
                    Temperature = Convert.ToDouble(val);
                    break;

                case "topic":
                    if (valI != -1)
                    {
                        TopicId = valI;
                    }
                    break;

                case "engraving_type":
                    if (valI != -1)
                    {
                        EngravingType = valI;
                    }
                    break;

                case "title":
                    Title = val;
                    break;

                case "age":
                    if (valI != -1)
                    {
                        Age = valI;
                    }
                    break;

                case "wear":
                    if (valI != -1)
                    {
                        Wear = valI;
                    }
                    break;

                case "handedness":
                    if (val.Count(x => x == ',') == 1)
                    {
                        Handedness = Convert.ToInt32(val.TrimEnd(','));
                    }
                    break;

                case "shape":
                    if (valI != -1)
                    {
                        Shape = valI;
                    }
                    break;

                case "dye_mat":
                    if (!Materials.Contains(val))
                    {
                        Materials.Add(val);
                    }
                    DyeMat = Materials.IndexOf(val);
                    break;

                case "unit_id":
                    if (valI != -1)
                    {
                        UnitId = valI;
                    }
                    break;

                case "hist_figure_id":
                    if (valI != -1)
                    {
                        HistFigureId = valI;
                    }
                    break;

                case "bone1":
                    if (!Materials.Contains(val))
                    {
                        Materials.Add(val);
                    }
                    BoneMat = Materials.IndexOf(val);
                    break;

                case "weight":
                    if (valI != -1)
                    {
                        Weight = valI;
                    }
                    break;

                case "ingredients":
                    foreach (var inv in element.Elements())
                    {
                        if (Ingredients == null)
                        {
                            Ingredients = new List <ItemIngredient>();
                        }
                        Ingredients.Add(new ItemIngredient(new XDocument(inv), world));
                    }
                    break;

                case "image":
                    if (!ImageId.HasValue)
                    {
                        ImageId     = Convert.ToInt32(element.Element("id").Value);
                        ImageSubId  = Convert.ToInt32(element.Element("subid").Value);
                        ImageCivId  = Convert.ToInt32(element.Element("civ_id").Value);
                        ImageSiteId = Convert.ToInt32(element.Element("site_id").Value);
                    }
                    break;

                case "reference":
                    if (References == null)
                    {
                        References = new List <Reference>();
                    }
                    References.Add(new Reference(element, this));
                    break;

                case "improvements":
                    foreach (var imp in element.Elements())
                    {
                        if (Improvements == null)
                        {
                            Improvements = new List <ItemImprovement>();
                        }
                        Improvements.Add(new ItemImprovement(new XDocument(imp), world));
                    }
                    break;

                case "stockpile":
                    StockpileId     = Convert.ToInt32(element.Element("id").Value);
                    StockpileCoords = new Point(
                        Convert.ToInt32(element.Element("x").Value),
                        Convert.ToInt32(element.Element("y").Value));
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName, element, xdoc.Root.ToString());
                    break;
                }
            }
            Name = $"{(Mat.HasValue ? Materials[Mat.Value] + " " : "")}{(ItemSubTypeId.HasValue ? ItemSubTypes[ItemSubTypeId.Value] + " " : ItemTypes[ItemTypeId.Value])}"
                   .Trim().ToTitleCase();
        }
예제 #4
0
 public Int32 i_Negate(Int32 arg)
 {
     Flag.Add(10); return(-arg);
 }
예제 #5
0
 public Int32 i_Square(Int32 arg)
 {
     Flag.Add(100); return(arg * arg);
 }
예제 #6
0
 public Int32 i_Double(Int32 arg)
 {
     Flag.Add(1); return(arg * 2);
 }
예제 #7
0
 public static Int32 s_Negate(Int32 arg)
 {
     Flag.Add(10); return(-arg);
 }
예제 #8
0
 public static Int32 s_Double(Int32 arg)
 {
     Flag.Add(1); return(arg * 2);
 }
예제 #9
0
        public Unit(XDocument xdoc, World world)
            : base(xdoc, world)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value.Trim();
                int valI;
                int.TryParse(val, out valI);
                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "name":
                    Name = val;
                    break;

                case "name2":
                    AltName = val;
                    break;

                case "profession":
                    if (!JobTypes.Contains(val))
                    {
                        JobTypes.Add(val);
                    }
                    ProfessionId = JobTypes.IndexOf(val);
                    break;

                case "profession2":
                    if (!JobTypes.Contains(val))
                    {
                        JobTypes.Add(val);
                    }
                    Profession2Id = JobTypes.IndexOf(val);
                    break;

                case "race":
                    if (valI != -1)
                    {
                        Race = World.GetAddRace(val);
                    }
                    break;

                case "caste":
                    if (valI != -1)
                    {
                        if (!HistoricalFigure.Castes.Contains(val))
                        {
                            HistoricalFigure.Castes.Add(val);
                        }
                        CasteID = HistoricalFigure.Castes.IndexOf(val);
                    }
                    break;

                case "coords":
                    Coords = new Point3(
                        Convert.ToInt32(val.Split(',')[0]),
                        Convert.ToInt32(val.Split(',')[1]),
                        Convert.ToInt32(val.Split(',')[2]));
                    break;

                case "sex":
                    Sex = valI;
                    break;

                case "civ_id":
                    if (valI != -1)
                    {
                        CivID = valI;
                    }
                    break;

                case "population_id":
                    if (valI != -1)
                    {
                        PopID = valI;
                    }
                    break;

                case "squad_id":
                    if (valI != -1)
                    {
                        SquadID = valI;
                    }
                    break;

                case "opponent_id":
                    if (valI != -1)
                    {
                        OpponentID = valI;
                    }
                    break;

                case "mood":
                    Mood = valI;
                    break;

                case "hist_figure_id":
                    if (valI != -1)
                    {
                        HistFigureID = valI;
                    }
                    break;

                case "hist_figure_id2":
                    if (valI != -1)
                    {
                        HistFigureID2 = valI;
                    }
                    break;

                case "labors":
                    var labors = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var labor in labors)
                    {
                        if (!Labors.Contains(labor))
                        {
                            Labors.Add(labor);
                        }
                        if (Labor == null)
                        {
                            Labor = new List <short>();
                        }
                        Labor.Add((short)Labors.IndexOf(labor));
                    }
                    break;

                case "flags":
                    var flags = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var flag in flags)
                    {
                        if (!Flags.Contains(flag))
                        {
                            Flags.Add(flag);
                        }
                        if (Flag == null)
                        {
                            Flag = new List <short>();
                        }
                        Flag.Add((short)Flags.IndexOf(flag));
                    }
                    break;

                case "health":
                    var healthflags = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var healthflag in healthflags)
                    {
                        if (!HealthFlags.Contains(healthflag))
                        {
                            HealthFlags.Add(healthflag);
                        }
                        if (HealthFlag == null)
                        {
                            HealthFlag = new List <short>();
                        }
                        HealthFlag.Add((short)HealthFlags.IndexOf(healthflag));
                    }
                    break;

                case "used_items":
                    UsedItemIds = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
                    break;

                case "owned_items":
                    OwnedItemIds = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
                    break;

                case "owned_buildings":
                    OwnedBuildingIds = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
                    break;

                case "traded_items":
                    TradedItemIds = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
                    break;

                case "inventory":
                    foreach (var inv in element.Elements())
                    {
                        if (InventoryItems == null)
                        {
                            InventoryItems = new List <UnitInventoryItem>();
                        }
                        InventoryItems.Add(new UnitInventoryItem(new XDocument(inv), world));
                    }
                    break;

                case "reference":
                    if (References == null)
                    {
                        References = new List <Reference>();
                    }
                    References.Add(new Reference(element, this));
                    break;

                case "in_item_id":
                case "nestbox_id":
                case "civzone_id":
                    break;

                case "nemesis_id":     // Relations with HFs
                case "pregnancy_spouse":
                case "following_unit":
                case "pet_owner_id":
                case "spouse_id":
                case "mother_id":
                case "father_id":
                case "last_attacker_id":
                case "group_leader_id":
                case "draggee_id":
                case "dragger_id":
                case "rider_mount_id":
                case "lover_id":
                    if (valI != -1)
                    {
                        if (RelationIDs == null)
                        {
                            RelationIDs = new Dictionary <string, int>();
                        }
                        RelationIDs.Add(string.Join(" ", element.Name.LocalName.Split('_').Reverse().Skip(1).Reverse().ToArray()), valI);
                    }
                    break;

                case "pregnancy_timer":
                case "pregnancy_caste":
                case "mood_copy":
                case "anon_1":
                case "birth_year":
                case "birth_time":
                case "curse_year":
                case "curse_time":
                case "birth_year_bias":
                case "birth_time_bias":
                case "old_year":
                case "old_time":
                case "unk_238":
                case "mount_type":
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName, element, xdoc.Root.ToString());
                    break;
                }
            }
        }
예제 #10
0
파일: Race.cs 프로젝트: tier6tank/DFWV
        internal override sealed void Plus(XDocument xdoc)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value;
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                    Id = valI;
                    break;

                case "key":
                    Key = val.ToLower();
                    break;

                case "nameS":
                    Name = val.ToLower();
                    break;

                case "nameP":
                    PluralName = val.ToLower();
                    break;

                case "caste":
                    var newCaste = new Caste(element, this);
                    if (Castes == null)
                    {
                        Castes = new List <Caste>();
                    }
                    Castes.Add(newCaste);
                    break;

                case "flags":
                    var flags = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var flag in flags)
                    {
                        if (!Flags.Contains(flag))
                        {
                            Flags.Add(flag);
                        }
                        if (Flag == null)
                        {
                            Flag = new List <short>();
                        }
                        Flag.Add((short)Flags.IndexOf(flag));
                    }
                    break;

                case "sphere":
                    if (!HistoricalFigure.Spheres.Contains(val))
                    {
                        HistoricalFigure.Spheres.Add(val);
                    }
                    if (Sphere == null)
                    {
                        Sphere = new List <short>();
                    }
                    Sphere.Add((short)HistoricalFigure.Spheres.IndexOf(val));
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t Race", element, xdoc.Root.ToString());
                    break;
                }
            }
        }