public void SpawnActor(MazeNode node, GameObject actors) { GameObject actorObject; Vector3 location = new Vector3(node.Col * 6 + 8, node.Floor * 30, node.Row * 6 + 8); if (node.actor != ActorType.Null) { if (node.actor == ActorType.Okuri_Inu || node.actor == ActorType.Oni || node.actor == ActorType.Taka_Nyudo) { //print("Column: " + node.Col + " Row: " + node.Row); node.EnemyPathNode = true; } if (node.actor == ActorType.Pit_Trap)// || node.actor == ActorType.Spike_Trap) { node.floorPrefab.SetActive(false); } if (node.actor == ActorType.Ladder) { if (node.ladderMazeNode == null) { actorObject = Instantiate(Resources.Load("Prefabs/Level/LadderUp"), location, node.GetRotation()) as GameObject; } else if (node.ladderMazeNode.Floor > node.Floor) { actorObject = Instantiate(Resources.Load("Prefabs/Level/LadderUp"), location, node.GetRotation()) as GameObject; } else { actorObject = Instantiate(Resources.Load("Prefabs/Level/LadderDown"), location, node.GetRotation()) as GameObject; } } else { actorObject = Instantiate(Actors.Prefabs[node.actor], location, node.GetRotation()); } actorObject.transform.parent = actors.transform; if (node.actor == ActorType.Ladder) { node.ladder = actorObject; node.ladder.GetComponent <Ladder>().SectionID = node.SectionID; node.ladder.GetComponent <Ladder>().ConnectedLadderNode = node.ladderMazeNode; node.ladder.GetComponent <Ladder>().location = node; } actorObject.AddComponent <Actor>().ActorID = AnalyticsManager.AddActor(SessionID, node.actor); actorObject.GetComponent <Actor>().type = node.actor; } }
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; }