コード例 #1
0
ファイル: XMLTest.cs プロジェクト: johnfn/Illumination
        public static void Test()
        {
            ProfessionCondition professionCondition1 = new ProfessionCondition(Person.ProfessionType.Educator, 3, ComparisonCondition.GREATER | ComparisonCondition.EQUAL);
            ProfessionCondition professionCondition2 = new ProfessionCondition(Person.ProfessionType.Worker, 0, ComparisonCondition.EQUAL);
            ProfessionCondition professionCondition3 = new ProfessionCondition(Person.ProfessionType.Educator, 3, ComparisonCondition.LESS);
            PotentialProfessionCondition professionCondition4 = new PotentialProfessionCondition(Person.ProfessionType.Educator, 3, ComparisonCondition.LESS);

            TurnCondition turnCondition = new TurnCondition(5, ComparisonCondition.LESS | ComparisonCondition.EQUAL);
            TurnCondition turnCondition2 = new TurnCondition(5, ComparisonCondition.GREATER);

            Objective objective1 = new Objective("Have at least 3 educators.");
            objective1.SuccessConditions.Add(professionCondition1);
            objective1.FailureConditions.Add(professionCondition4);

            Objective objective2 = new Objective("Give every worker a profession.");
            objective2.SuccessConditions.Add(professionCondition2);

            Objective objective3 = new Objective("No more than five days may elapse");
            objective3.FailureConditions.Add(turnCondition2);

            Mission currentMission = new Mission();

            currentMission.PrimaryObjectives.Add(objective1);
            currentMission.PrimaryObjectives.Add(objective2);
            currentMission.PrimaryObjectives.Add(objective3);

            currentMission.AddTrigger(new Trigger(
                new ProfessionCondition(Person.ProfessionType.Environmentalist, 0, ComparisonCondition.GREATER),
                new MoneyAdjustmentEvent(10)));

            XmlSerializer serializer = new XmlSerializer(typeof(Mission));
            TextWriter writer = new StreamWriter("test.xml");
            serializer.Serialize(writer, currentMission);
            writer.Close();
        }
コード例 #2
0
ファイル: World.cs プロジェクト: johnfn/Illumination
        public static void InitalizeWorld(int numRows, int numCols)
        {
            grid = new Tile[numRows, numCols];
            for (int row = 0; row < numRows; row++) {
                for (int col = 0; col < numCols; col++) {
                    grid[row, col] = new Tile(row, col, Tile.TileType.Grass);
                }
            }

            personSet = new HashSet<Person>();
            buildingSet = new HashSet<Building>();
            treeSet = new HashSet<Tree>();
            itemSet = new HashSet<Item>();
            locationsWithAirports = new HashSet<Point>();
            inventory = new Dictionary<ShopItem, int>();

            highlightedTiles = new HashSet<Tile>();

            isNight = false;
            timeLeft = DAY_TIME_LIMIT;
            dayCount = 0;
            money = 0;

            XmlSerializer serializer = new XmlSerializer(typeof(Mission));
            FileStream fs = new FileStream("test.xml", FileMode.Open);
            currentMission = (Mission) serializer.Deserialize(fs);
        }