Пример #1
0
		//create a crazy world...
		public static World GenerateCustomWorld(){
			World mainWorld = new World("main_world");

			Score s = new Score("numberScore");
			World machineA = new World("machine_a");
			World machineB = new World("machine_b");

			// machine A
			machineA.BatchAddLevelsWithTemplates(2, null, s, null);

			// machine B

			Gate machineALevel1Complete = new WorldCompletionGate("level1_complete", machineA.GetInnerWorldAt(0).ID);

			machineB.BatchAddLevelsWithTemplates(20, machineALevel1Complete, s, null);

			Mission mission1 = new WorldCompletionMission("level2_complete", "Level 2 Completed Mission!", machineA.GetInnerWorldAt(1).ID);
			Mission mission2 = new RecordMission("level1_record_mission", "Level 1 Record Mission!", machineA.GetInnerWorldAt(0).GetSingleScore().ID, 20.0);
			Mission allMissions = new Challenge("main_challange", "MAIN CHALLENGE", new List<Mission>() { mission1, mission2 });

			machineB.GetInnerWorldAt(5).AddMission(allMissions);

			mainWorld.AddInnerWorld(machineA);
			mainWorld.AddInnerWorld(machineB);

			return mainWorld;
		}
Пример #2
0
        public void BatchAddDependentLevelsWithTemplates(int numLevels, List <Score> scoreTemplates, List <Mission> missionTemplates)
        {
            string previousLvlId = null;

            for (int i = 0; i < numLevels; i++)
            {
                string lvlId = IdForAutoGeneratedLevel(_id, i);
                Level  aLvl  = new Level(lvlId);

                Gate completeGate = null;
                if (previousLvlId != null)
                {
                    completeGate = new WorldCompletionGate(IdForAutoGeneratedCompleteGate(lvlId, previousLvlId), previousLvlId);
                }

                createAddAutoLevel(lvlId, aLvl, completeGate, scoreTemplates, missionTemplates);
                previousLvlId = lvlId;
            }
        }
Пример #3
0
 public void Gate_toJSONObject()
 {
     {
         var gate = new RecordGate("Test_RecordGate_Id", "Test_Score_Id", 100.0);
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_RecordGate_Id"",
     ""className"":""RecordGate"",
     ""associatedScoreId"":""Test_Score_Id"",
     ""desiredBalance"":100
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         List<Schedule.DateTimeRange> timeRanges = new List<Schedule.DateTimeRange>();
         timeRanges.Add(new Schedule.DateTimeRange(DateTime.Parse("01/01/2010"), DateTime.Parse("01/01/2011")));
         timeRanges.Add(new Schedule.DateTimeRange(DateTime.Parse("01/01/2011"), DateTime.Parse("01/01/2012")));
         var schedule = new Schedule(timeRanges, Schedule.Recurrence.EVERY_HOUR, 1);
         var gate = new ScheduleGate("Test_ScheduleGate_Id", schedule);
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_ScheduleGate_Id"",
     ""className"":""ScheduleGate"",
     ""schedule"":{
     ""className"":""Schedule"",
     ""schedRecurrence"":3,
     ""schedApprovals"":1,
     ""schedTimeRanges"":[
     {
         ""className"":""DateTimeRange"",
         ""schedTimeRangeStart"":63397899010048,
         ""schedTimeRangeEnd"":63429435981824
     },
     {
         ""className"":""DateTimeRange"",
         ""schedTimeRangeStart"":63429435981824,
         ""schedTimeRangeEnd"":63460972953600
     }
     ]
     }
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new WorldCompletionGate("Test_WorldCompletionGate_Id", "Test_World_Id");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_WorldCompletionGate_Id"",
     ""className"":""WorldCompletionGate"",
     ""associatedWorldId"":""Test_World_Id""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new BalanceGate("Test_BalanceGate_Id", "Test_Item_Id", 100);
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_BalanceGate_Id"",
     ""className"":""BalanceGate"",
     ""associatedItemId"":""Test_Item_Id"",
     ""desiredBalance"":100
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new PurchasableGate("Test_PurchasableGate_Id", "Test_Item_Id");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_PurchasableGate_Id"",
     ""className"":""PurchasableGate"",
     ""associatedItemId"":""Test_Item_Id""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new SocialLikeGate("Test_SocialLikeGate_Id", Provider.FACEBOOK, "Test_PageName");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_SocialLikeGate_Id"",
     ""className"":""SocialLikeGate"",
     ""provider"":""facebook"",
     ""pageName"":""Test_PageName""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
     {
         var gate = new SocialStatusGate("Test_SocialStatusGate_Id", Provider.GOOGLE, "Test_Status");
         var json = gate.toJSONObject();
         var expect =
             @"{
     ""name"":"""",
     ""description"":"""",
     ""itemId"":""Test_SocialStatusGate_Id"",
     ""className"":""SocialStatusGate"",
     ""provider"":""google"",
     ""status"":""Test_Status""
     }";
         Assert.AreEqual(expect, json.print(true));
     }
 }