示例#1
0
    public void EnterSection(GameObject ladder, GameObject player)
    {
        print("Made it here as well!");
        if (ladder.GetComponent <Ladder>().ConnectedLadder == null)
        {
            print("Even managed to make it here!");
            foreach (MazeSection sec in GameManager.Sections)
            {
                if (sec.SectionID == ladder.GetComponent <Ladder>().ConnectedLadderNode.SectionID)
                {
                    if (!sec.Spawned)
                    {
                        SpawnSection(sec);
                    }
                }
            }
            print("made it here2");
            ladder.GetComponent <Ladder>().ConnectedLadder = ladder.GetComponent <Ladder>().ConnectedLadderNode.ladder;
            ladder.GetComponent <Ladder>().ConnectedLadder.GetComponent <Ladder>().ConnectedLadder = ladder;
        }
        print("made it here as well!2");
        print("Even managed to make it here!2");
        //Debug.Log(collider.gameObject.tag + " entered Cell R: " + Row + " C: " + Col + " at Time: " + Time.time);
        //ladder.GetComponent<Ladder>().ConnectedLadder.transform.parent.gameObject.SetActive(true);

        ladder.GetComponent <Ladder>().ConnectedLadder.transform.parent.gameObject.transform.parent.gameObject.SetActive(true);
        ladder.GetComponent <Ladder>().ConnectedLadder.GetComponent <Ladder>().teleportable = true;

        if (ladder.GetComponent <Ladder>().teleportable == true && ladder.GetComponent <Ladder>().ConnectedLadder.GetComponent <Ladder>().teleportable == true)
        {
            //print(ladder.GetComponent<Ladder>().ConnectedLadder.GetComponent<Ladder>().location.Floor + " " + ladder.GetComponent<Ladder>().ConnectedLadder.GetComponent<Ladder>().location.Col + " " + ladder.GetComponent<Ladder>().ConnectedLadder.GetComponent<Ladder>().location.Row);
            if (!(ladder.GetComponent <Ladder>().ConnectedLadderNode.Floor == -1 && ladder.GetComponent <Ladder>().ConnectedLadderNode.Col == 1 && ladder.GetComponent <Ladder>().ConnectedLadderNode.Row == 5))
            {
                ladder.GetComponent <Ladder>().teleportable = false;
                ladder.GetComponent <Ladder>().ConnectedLadder.GetComponent <Ladder>().teleportable = false;
                player.transform.position = ladder.GetComponent <Ladder>().ConnectedLadder.transform.position;
                ladder.transform.parent.gameObject.transform.parent.gameObject.SetActive(false);
                foreach (MazeSection sec in GameManager.Sections)
                {
                    if (sec.SectionID == ladder.GetComponent <Ladder>().ConnectedLadderNode.SectionID)
                    {
                        PlayersCurrentSection = sec;
                    }
                }
                PlayersCurrentSection.section = ladder.GetComponent <Ladder>().ConnectedLadder.transform.parent.gameObject.transform.parent.gameObject;
            }
        }

        else
        {
            //print(ladder.GetComponent<Ladder>().teleportable + " " + ladder.GetComponent<Ladder>().ConnectedLadder.GetComponent<Ladder>().teleportable);
            ladder.GetComponent <Ladder>().ConnectedLadder.transform.parent.gameObject.transform.parent.gameObject.SetActive(false);
        }
    }
示例#2
0
    public void SpawnSection(MazeSection msection)
    {
        sectionLanternColor = getRandomColor();
        NavMeshSurface surface;
        GameObject     SectionObject = new GameObject("Section " + msection.SectionID);

        SectionObject.transform.parent = Maze.transform;
        msection.Spawned = true;
        msection.section = SectionObject;
        if (!TutorialOn || msection.Root.Floor > 0 || msection.Root.Floor == -4)
        {
            PlayersCurrentSection = msection;
        }

        GameObject cells = new GameObject("Cells");

        cells.transform.parent = SectionObject.transform;
        GameObject actors = new GameObject("Actors");

        actors.transform.parent = SectionObject.transform;
        GameObject lanterns = new GameObject("Lanterns");

        lanterns.transform.parent = SectionObject.transform;
        GameObject messages = new GameObject("Messages");

        messages.transform.parent = SectionObject.transform;

        foreach (MazeNode n in MazeGenerator.nodesInSection(msection.Root))
        {
            SpawnPiece(n, cells, msection.SectionID);
        }

        surface = msection.section.AddComponent <NavMeshSurface>();
        if (surface != null)
        {
            surface.BuildNavMesh();
        }

        foreach (MazeNode n in MazeGenerator.nodesInSection(msection.Root))
        {
            SpawnActor(n, actors);
            SpawnLantern(n, lanterns);
            SpawnMessage(n, messages);
        }
        // Spawn Actors
        // Add Actors to Analytics
    }
示例#3
0
    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;
        }
    }
示例#4
0
    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;
    }