Ejemplo n.º 1
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null, TriggerEventHandler healthCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();
        FindHealthPosition();

        // store values used to generate this mesh
        hallWidth  = 1;
        hallHeight = 1;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
        PlaceHealthTrigger(healthCallback);

        FindAndPlaceEnemies();
    }
    public void GenerateNewMaze(int rows, int columns, float trapChance,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (rows % 2 == 0 && columns % 2 == 0)
        {
            Debug.LogError("Use odd numbers for dungeon size.");
        }

        bool valid = false;

        while (!valid)
        {
            DestroyPrevMaze();

            data = mazeGenerator.FromDimensions(rows, columns, trapChance);

            GenerateStart();
            GenerateGoal();

            valid = mazeGenerator.validMaze(startRow, startColumn, goalRow, goalColumn);
            //Debug.Log("valid: " + valid);
        }

        Debug.Log("Maze Start!");

        corridorWidth  = meshGenerator.width;
        corridorHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
Ejemplo n.º 3
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);



        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        Debug.Log("HallWidth" + hallWidth);
        Debug.Log("HallHeight" + hallHeight);

        FindStartPosition1();
        PlaceStartTrigger(startCallback);
        FindStartPosition2();
        PlaceStartTrigger(startCallback);
        FindStartPosition3();
        PlaceStartTrigger(startCallback);
        FindStartPosition4();
        PlaceStartTrigger(startCallback);
        FindGoalPosition();
        DisplayMaze();
        PlaceGoalTrigger(goalCallback);
    }
Ejemplo n.º 4
0
    // parameters data taken form gamecontroller
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        // if the ints are divisible by 2, log an error & reduce by one to prevent errors
        if (sizeRows % 2 == 0)
        {
            sizeRows--;
            Debug.Log(sizeRows + " Odd numbers work better for dungeon size.");
        }
        if (sizeCols % 2 == 0)
        {
            sizeCols--;
            Debug.Log(sizeCols + " Odd numbers work better for dungeon size.");
        }
        // run func
        DisposeOldMaze();
        // data is equal to the fromdimensions func output with the sizerows and sizecols parameters from gamecontroller
        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;
        // run function that adds colliders, meshrenderers etc to new gameobjects
        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
Ejemplo n.º 5
0
    public void GenerateNewMaze(int maxRows, int maxCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null,
                                TriggerEventHandler gunCallback   = null)
    {
        if (maxCols % 2 == 0 || maxRows % 2 == 0)
        {
            //This is because the maze is surrounded by walls
            Debug.LogWarning("Odd numbers work better for maze size");
        }
        DisposeOldMaze();
        data = dataGenerator.FromDimensions(maxRows, maxCols);
        FindStartPosition();
        FindGoalPosition();

        hallHeight = floor.GetComponentInChildren <MeshRenderer>().bounds.size[0];
        hallWidth  = floor.GetComponentInChildren <MeshRenderer>().bounds.size[1];

        GlobalVars.hallHeight = hallHeight;
        GlobalVars.hallWidth  = hallWidth;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
        PlaceGunPickup(gunCallback);
        PlaceLandmarks();

        GlobalVars.freeSpots = freeSpots;
    }
Ejemplo n.º 6
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        //Генерация стен
        // Предупреждение о том, что лучше использовать нечетные числа для генерации лабиринта
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
Ejemplo n.º 7
0
    public int GenerateNewMaze(int sizeRows, int sizeCols, int lvl, TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.Log("Odd numbers work better for dungeon size");
        }

        DisposeOldMaze();

        int pointOfGate = 0;

        data = dataGenerator.FromDimensions(sizeRows, sizeCols, ref pointOfGate);

        sizeOfRows = sizeRows;
        sizeOfCols = sizeCols;

        FindStartPosition();
        FindGoalPosition();

        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback, lvl);
        PlaceGoalTrigger(goalCallback, lvl);

        return(pointOfGate);
    }
Ejemplo n.º 8
0
        void PlaceStartTrigger(Vector3 position, TriggerEventHandler callback)
        {
            var go = GameObject.CreatePrimitive(PrimitiveType.Cube);

            go.transform.position = position;
            go.name = "Start trigger";

            go.GetComponent <BoxCollider>().isTrigger       = true;
            go.GetComponent <MeshRenderer>().sharedMaterial = reachedTriggerMat;

            var tc = go.AddComponent <TriggerEventRouter>();

            tc.callback = callback;
        }
Ejemplo n.º 9
0
    //Create object for start trigger and fill its properties
    public void PlaceStartTrigger(TriggerEventHandler callback)
    {
        GameObject gObj = Instantiate(startPortal,
                                      new Vector3(startCol * hallWidth, 0, startRow * hallHeight), Quaternion.identity);

        gObj.name = "Start Trigger";
        gObj.tag  = "Generated";

        gObj.GetComponent <BoxCollider>().isTrigger = true;

        TriggerEventRouter tc = gObj.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 10
0
    //Create object for treasure and fill its properties
    public void PlaceGoalTrigger(TriggerEventHandler callback)
    {
        GameObject gObj = Instantiate(treasure, new Vector3(goalCol * hallWidth, 0, goalRow * hallHeight), Quaternion.identity);

        GlobalVars.goalPos = new Vector3(gObj.transform.position.x, 1, gObj.transform.position.z);
        gObj.name          = "Treasure";
        gObj.tag           = "Generated";
        gObj.layer         = LayerMask.NameToLayer("AIGuard");


        TriggerEventRouter tc = gObj.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
    private void PlaceStartTrigger(TriggerEventHandler callback)
    {
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

        go.transform.position = new Vector3(startColumn * corridorWidth, .5f, startRow * corridorWidth);
        go.name = "Start Trigger";
        go.tag  = "Generated";

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = startMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
    private void EnemyTest(TriggerEventHandler callback)
    {
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

        go.transform.position = new Vector3(10 * hallWidth, 2f, 5 * hallWidth);
        go.name = "Enemy";
        go.tag  = "Generated";

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = enemyMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 13
0
 // 主线程循环
 internal static void MainThreadUpdate()
 {
     FocusEventHandler.MainThreadUpdate();
     ScreenResizeEventHandler.MainThreadUpdate();
     CollisionEventHandler.MainThreadUpdate();
     TriggerEventHandler.MainThreadUpdate();
     PointerEventHandlerForScreen.MainThreadUpdate();
     PointerEventHandlerForUI.MainThreadUpdate();
     PointerEventHandlerForMesh.MainThreadUpdate();
     KeyboardEventHandler.MainThreadUpdate();
     FrameLoopEventHandler.MainThreadUpdate();
     IntervalEventHandler.MainThreadUpdate();
     CustomEventHandler.MainThreadUpdate();
     TraceEventHandler.MainThreadUpdate();
 }
Ejemplo n.º 14
0
    private void PlaceGoalTrigger(TriggerEventHandler callback)
    {
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

        go.transform.position = new Vector3(goalCol * hallWidth, .5f, goalRow * hallWidth);
        go.name = "Treasure";
        go.tag  = "Generated";

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = treasureMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 15
0
    // Создание визуального элемента конечной точки
    private void PlaceGoalTrigger(TriggerEventHandler callback)
    {
        GameObject go = GameObject.Instantiate(foodObject, new Vector3(goalCol * hallWidth, .5f, goalRow * hallWidth), foodObject.transform.rotation);

        go.transform.position = new Vector3(goalCol * hallWidth, .5f, goalRow * hallWidth);

        go.name = "Treasure";
        go.tag  = "Generated";

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = foodMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 16
0
    private void PlaceHealthTrigger(TriggerEventHandler callback)
    {
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

        go.transform.position = new Vector3(healthCol * hallWidth, -0.5f, healthRow * hallWidth);
        go.name = "Health";
        go.tag  = "Health";
        go.transform.localScale = new Vector3(1f, 0.5f, 1f);

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = healthMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 17
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();

        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
Ejemplo n.º 18
0
    public void PlaceGunPickup(TriggerEventHandler callback)
    {
        int randomPlace = Random.Range(0, freeSpots.Count);
        int gunRow      = freeSpots[randomPlace][0];
        int gunCol      = freeSpots[randomPlace][1];
        // int gunRow = freeSpots[0][0];
        // int gunCol = freeSpots[0][1];
        GameObject gObj = Instantiate(gunPickup, new Vector3(gunCol * hallWidth, 0, gunRow * hallHeight), Quaternion.identity);

        gObj.name = "GunPickup";
        gObj.tag  = "Generated";

        freeSpots.RemoveAt(randomPlace);

        TriggerEventRouter tc = gObj.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 19
0
    private void PlaceGoalTrigger(TriggerEventHandler callback)
    {
        var        gameObjects = Resources.FindObjectsOfTypeAll(typeof(GameObject));
        GameObject open_chest  = (GameObject)gameObjects.SingleOrDefault(o => o.name == "chest_open");
        //GameObject coins = (GameObject)gameObjects.SingleOrDefault(o => o.name == "coins");
        //GameObject open_chest = (GameObject)Resources.Load("ChestFree/chest_open", typeof(GameObject));
        GameObject go = (GameObject)Instantiate(open_chest, new Vector3(goalCol * hallWidth, .5f, goalRow * hallWidth), new Quaternion(0, 0, 0, 0));

        //go.AddComponent<Component>();

        go.name = "Treasure";
        go.tag  = "Generated";

        go.GetComponent <BoxCollider>().isTrigger = true;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 20
0
    private void PlaceStartTrigger(TriggerEventHandler callback)
    {
        GameObject go           = startPrefab;
        var        startPostion = go.transform.position;

        startPostion = new Vector3(startCol * hallWidth, .15f, startRow * hallWidth);
        Quaternion startRotation = Quaternion.identity;


        go.name = "Start Trigger";

        go.GetComponent <BoxCollider>().isTrigger = true;
        Debug.Log("starttriggerassigned");
        Instantiate(go, startPostion, startRotation);

        TriggerEventRouter tc = go.GetComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 21
0
    private void PlaceGoalTrigger(TriggerEventHandler callback)
    {
        GameObject go = treasurePrefab;
        var        treasurePostion = go.transform.position;

        treasurePostion = new Vector3(goalCol * hallWidth, .2f, goalRow * hallWidth);
        Quaternion treasureRotation = Quaternion.identity;


        go.name = "Treasure";

        go.GetComponent <BoxCollider>().isTrigger = true;
        Debug.Log("goaltriggerassigned");
        Instantiate(go, treasurePostion, treasureRotation);

        TriggerEventRouter tc = go.GetComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 22
0
    private void PlaceGoalTrigger(TriggerEventHandler callback)
    {
        Instantiate(portal, new Vector3(7.0f * hallWidth, 2f, 5.0f * hallWidth), Quaternion.identity);
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

        Debug.Log("GoalRow" + "" + goalRow);
        Debug.Log("GoalCol" + "" + goalCol);

        go.transform.position = new Vector3(goalCol * hallWidth, .5f, goalRow * hallWidth);
        go.name = "Treasure";
        go.tag  = "Generated";

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = treasureMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 23
0
    public void GenerateNewMaze(int sizeCols, int sizeRows,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        // DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        // FindStartPosition();
        // FindGoalPosition();

        DisplayMaze();

        // PlaceStartTrigger(startCallback);
        // PlaceGoalTrigger(goalCallback);
    }
Ejemplo n.º 24
0
    // place trigger in the scene at the start
    private void PlaceStartTrigger(TriggerEventHandler callback)
    {
        GameObject go   = GameObject.CreatePrimitive(PrimitiveType.Cube);
        Collider   goC  = go.GetComponent <Collider>();
        GameObject go2  = GameObject.FindGameObjectWithTag("Player");
        Collider   go2C = go2.GetComponent <Collider>();

        //sets start block
        go.transform.position = new Vector3(startCol * hallWidth, .5f, startRow * hallWidth); // new Vector3(startCol * hallWidth, startRow * hallWidth, -1f);
        go.name = "Start Trigger";
        go.tag  = "Generated";

        //so that play and collider don't collide
        Physics.IgnoreCollision(goC, go2C);

        go.GetComponent <BoxCollider>().isTrigger       = true;
        go.GetComponent <MeshRenderer>().sharedMaterial = startMat;

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 25
0
    private void PlaceStartTrigger(TriggerEventHandler callback, int lvl)
    {
        GameObject go = Instantiate(startGate);
        float      x  = startCol * hallWidth;
        float      y  = -5.00f;
        float      z  = startRow * hallWidth;

        go.transform.position = new Vector3(x - 10.82f, y, z - 3.15f);
        go.tag = "Generated";
        go.AddComponent <BoxCollider>();

        if (PlayerPrefs.GetString("QuizzesDataTable" + (lvl - 1)).Length > 5)
        {
            QuizEntry quiz = new QuizEntry();
            quiz = JsonUtility.FromJson <QuizEntry>(PlayerPrefs.GetString("QuizzesDataTable" + (lvl - 1)));
            go.transform.Find("Cube (3)").GetComponent <Transform>().Find("Cube").GetComponent <Transform>().Find("Canvas").GetComponent <Transform>().Find("Button").GetComponent <Transform>().Find("Text").GetComponent <Text>().text = quiz.question;
        }

        // Set is trigger
        //mc.convex = true;

        GameObject startSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        startSphere.transform.position = new Vector3(startCol * hallWidth, .5f, startRow * hallWidth);
        startSphere.name = "Start Trigger";
        startSphere.tag  = "Generated";

        // Set is trigger
        startSphere.GetComponent <SphereCollider>().isTrigger = true;

        // Set material
        startSphere.GetComponent <MeshRenderer>().enabled = false;

        TriggerEventRouter tc = startSphere.AddComponent <TriggerEventRouter>();

        tc.callback = callback;
    }
Ejemplo n.º 26
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");//Для размеров лучше использовать нечётные числа, потому что сгенерированный лабиринт будет окружён стенами.
        }

        DisposeOldMaze();                                        //Вызываем метод DisposeOldMaze() для удаления лабиринта

        data = dataGenerator.FromDimensions(sizeRows, sizeCols); //Вызываем FromDimensions() в GenerateNewMaze() передавая размер сетки и сохраняя получившиеся данные.

        FindStartPosition();                                     //находим стартовую позицию для игрока
        FindGoalPosition();                                      //находим позицию для цели

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();                    //Вызываем метод DisplayMaze() для отображения лабиринта

        PlaceStartTrigger(startCallback); //устанавливаем стартовые координаты игрока
        PlaceGoalTrigger(goalCallback);   //устанавливаем координаты цели
    }
Ejemplo n.º 27
0
        public void CreateDoors(TriggerEventHandler startCallback, TriggerEventHandler reachCallback, string name = null)
        {
            bool hadStart   = false;
            var  targetList = new List <Vector3>();
            var  start      = new Vector3();

            for (int i = 0; i < 4; i++)
            {
                if (GetToTarget[i] != null)
                {
                    if (roomInstance.lastNode != null && roomInstance.lastNode == GetToTarget[i])
                    {
                        start = GetToTarget[i].worldPosition;
                        PlaceStartTrigger(start, startCallback);
                        hadStart = true;
                    }
                    else
                    {
                        var pos = GetToTarget[i].worldPosition;

                        // var pos = GetToTarget[i].worldPosition + new Vector3(SizeWidth * gridOffset, 0, SizeWidth * gridOffset);
                        PlaceReachTrigger(pos, reachCallback);
                        targetList.Add(pos);
                    }
                }
            }

            if (!hadStart)
            {
                start = GetToTarget[4].worldPosition;
                PlaceStartTrigger(start, startCallback);
            }

            targetPathCount = targetList.Count;
            PathFinder(targetList, start);
        }
Ejemplo n.º 28
0
 /// <summary> 添加触发器事件侦听 ( Mesh ) </summary>
 /// <param name="target">侦听对象 ( Mesh GameObject ) </param>
 /// <param name="listener">触发器事件侦听函数 ( Params - 侦听对象,触发器事件类型,触发触发器的对象 ) </param>
 /// <param name="priority">设置侦听函数执行优先级,数值越高优先级越高。同数值情况下,先添加的侦听函数优先级更高,默认为 0 </param>
 public void AddTriggerListenerForMesh(GameObject target, Action <GameObject, TriggerEventType, GameObject> listener, int priority = 0)
 => TriggerEventHandler.AddListener(target, listener, priority);
Ejemplo n.º 29
0
 void Start()
 {
     teh = triggerHandler.GetComponent<TriggerEventHandler> ();
 }
Ejemplo n.º 30
0
    private void PlaceGoalTrigger(TriggerEventHandler callback, int lvl)
    {
        bool isSecond = false;

        Debug.Log("Count of goald = " + goalPos.Count);
        foreach (Point point in goalPos)
        {
            GameObject go = Instantiate(exitGate);
            float      x  = point.posY * hallWidth;
            float      y  = 14.18f;
            float      z  = point.posX * hallWidth;

            if (point.posX == 0)
            {
                go.transform.position = new Vector3(x - 0.41f, y, z + 9.845f);

                go.transform.eulerAngles = new Vector3(
                    go.transform.eulerAngles.x,
                    go.transform.eulerAngles.y - 180f,
                    go.transform.eulerAngles.z);
            }
            else if (point.posY == sizeOfCols - 1)
            {
                go.transform.position = new Vector3(x - 9.81f, y, z - 0.49f);

                go.transform.eulerAngles = new Vector3(
                    go.transform.eulerAngles.x,
                    go.transform.eulerAngles.y + 90f,
                    go.transform.eulerAngles.z);
            }
            else
            {
                go.transform.position = new Vector3(x + 0.43f, y, z - 9.845f);
            }

            go.tag = "Generated";
            if (point.type == Identificators.TRUE_EXIT_GATE)
            {
                go.name = ("Exit Gate T");
                if (PlayerPrefs.GetString("QuizzesDataTable" + (lvl - 1)).Length > 5)
                {
                    QuizEntry quiz = new QuizEntry();
                    quiz = JsonUtility.FromJson <QuizEntry>(PlayerPrefs.GetString("QuizzesDataTable" + (lvl - 1)));
                    go.transform.Find("Cube (3)").GetComponent <Transform>().Find("Cube").GetComponent <Transform>().Find("Canvas").GetComponent <Transform>().Find("Button").GetComponent <Transform>().Find("Text").GetComponent <Text>().text = quiz.correctAnswer;
                }
            }
            else
            {
                go.name = ("Exit Gate " + point.posX);
                if (PlayerPrefs.GetString("QuizzesDataTable" + (lvl - 1)).Length > 5)
                {
                    QuizEntry quiz = new QuizEntry();
                    quiz = JsonUtility.FromJson <QuizEntry>(PlayerPrefs.GetString("QuizzesDataTable" + (lvl - 1)));

                    string temp;
                    if (isSecond)
                    {
                        temp = quiz.wrongAnswer2;
                    }
                    else
                    {
                        temp = quiz.wrongAnswer;
                    }

                    go.transform.Find("Cube (3)").GetComponent <Transform>().Find("Cube").GetComponent <Transform>().Find("Canvas").GetComponent <Transform>().Find("Button").GetComponent <Transform>().Find("Text").GetComponent <Text>().text = temp;
                }
                isSecond = true;
            }
            //

            Debug.Log("Goal point is detected" + point.posX + " " + point.posY);
            GameObject goal = GameObject.CreatePrimitive(PrimitiveType.Cube);
            goal.transform.position = new Vector3(point.posY * hallWidth, .5f, point.posX * hallWidth);
            if (point.type == Identificators.TRUE_EXIT_GATE)
            {
                goal.name = ("True Exit");
            }
            else
            {
                goal.name = ("Exit" + point.posX);
            }
            goal.tag = "Generated";

            BoxCollider bc = goal.GetComponent <BoxCollider>();
            bc.isTrigger = true;
            bc.size      = new Vector3(bc.size.x + 2, bc.size.y, bc.size.z);
            goal.GetComponent <MeshRenderer>().enabled = false;

            TriggerEventRouter tc = goal.AddComponent <TriggerEventRouter>();
            tc.callback = callback;
        }
    }
Ejemplo n.º 31
0
 /// <summary> 移除触发器事件侦听 ( Mesh ) </summary>
 /// <param name="target">侦听对象 ( Mesh GameObject ) </param>
 /// <param name="listener">触发器事件侦听函数 ( Params - 侦听对象,触发器事件类型,触发触发器的对象 ) </param>
 public void RemoveTriggerListenerForMesh(GameObject target, Action <GameObject, TriggerEventType, GameObject> listener)
 => TriggerEventHandler.RemoveListener(target, listener);