public void BeginPlay() { intensityRand = new System.Random(MazeGenerator.Seed); hueRand = new System.Random(MazeGenerator.Seed); rand = new System.Random(MazeGenerator.Seed); messageRand = new System.Random(MazeGenerator.Seed); if (!TutorialOn) { Maze = new GameObject("Maze"); Maze.transform.parent = GameParent.transform; } Sections = new List <MazeSection>(); // Start new Session in Analytics // Generate Level // Add Level to Analytics // Add Sections to Analytics // Add Cells to Analytics Dictionary <int, MazeNode[, ]> storedDifficultyMaps = storedMaps[(int)difficulty]; //print(storedDifficultyMaps); if (storedDifficultyMaps.ContainsKey(MazeGenerator.Seed)) { MazeGenerator.DifferentSections = storedMaps[(int)difficulty][MazeGenerator.Seed]; MazeGenerator.connectLadderNodes(difficulty, MazeGenerator.DifferentSections); } else { MazeGenerator.GenerateMaze(difficulty); storedMaps[(int)difficulty].Add(MazeGenerator.Seed, MazeGenerator.DifferentSections); } //print("Something"); if (TutorialOn) { tutorial4[1, 5].AddLadderTo(MazeGenerator.DifferentSections[0, 0]); } lvlID = AnalyticsManager.AddLevel(MazeGenerator.Seed, (int)difficulty); SessionID = AnalyticsManager.AddSession(lvlID, (int)PlayersVRType); int[,] sectionIDs = new int[5, 8]; MazeNode[,] roots = MazeGenerator.DifferentSections; List <MazeNode> nodes; for (int i = 0; i < 5; i++) { for (int j = 0; j < 8; j++) { if (roots[i, j] != null) { MazeSection section = new MazeSection(); section.Root = roots[i, j]; sectionIDs[i, j] = AnalyticsManager.AddSection(lvlID, i, j); section.SectionID = sectionIDs[i, j]; section.Spawned = false; foreach (MazeNode n in MazeGenerator.nodesInSection(roots[i, j])) { n.SectionID = section.SectionID; } Sections.Add(section); } } } // Spawn first section foreach (MazeSection s in Sections) { if (s.Root.Col == 0 && s.Root.Row == 0 && s.Root.Floor == 0) { if (!TutorialOn) { SpawnSection(s); } } } // Spawn Player if (!TutorialOn) { Vector3 location = new Vector3(8, 1, 8); PlayerObj = Instantiate(Resources.Load(PlayerTypeLoc), location, roots[0, 0].GetRotation()) as GameObject; PlayerObj.AddComponent <Actor>().ActorID = AnalyticsManager.AddActor(SessionID, ActorType.Player); PlayerObj.transform.parent = GameParent.transform; } }
public void BeginTutorial() { Maze = new GameObject("Maze"); Maze.transform.parent = GameParent.transform; //floor 1 MazeNode[,] tutorial1 = TutorialGenerator.GenerateFloor1(); //floor 2 MazeNode[,] tutorial2 = TutorialGenerator.GenerateFloor2(); //floor 3 MazeNode[,] tutorial3 = TutorialGenerator.GenerateFloor3(); //floor 4 tutorial4 = TutorialGenerator.GenerateFloor4(); tutorial1[0, 2].AddLadderTo(tutorial2[0, 0]); tutorial2[5, 2].AddLadderTo(tutorial3[0, 2]); tutorial3[4, 4].AddLadderTo(tutorial4[3, 3]); BeginPlay(); for (int i = 0; i < 4; i++) { MazeNode[,] TutorialFloor = new MazeNode[7, 7]; List <MazeNode> nodes; MazeSection section = new MazeSection(); //int[] sectionIDs = new int[4]; switch (i) { case 0: TutorialFloor = tutorial1; break; case 1: TutorialFloor = tutorial2; break; case 2: TutorialFloor = tutorial3; break; case 3: TutorialFloor = tutorial4; break; } section.Root = TutorialFloor[0, 0]; int sectionID = AnalyticsManager.AddSection(lvlID, 0, -4 + i); section.SectionID = sectionID; section.Spawned = false; foreach (MazeNode n in MazeGenerator.nodesInSection(section.Root)) { n.SectionID = section.SectionID; } //Sections.Add(section); nodes = MazeGenerator.nodesInSection(section.Root); SpawnSection(section); } Vector3 location = new Vector3(20, -119, 8); PlayerObj = Instantiate(Resources.Load(PlayerTypeLoc), location, tutorial1[0, 0].GetRotation()) as GameObject; GameObject.FindGameObjectWithTag("Player").AddComponent <Actor>().ActorID = AnalyticsManager.AddActor(SessionID, ActorType.Player); PlayerObj.transform.parent = GameParent.transform; }