Esempio n. 1
0
    private void placeEnemy()
    {
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);

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

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

        TriggerEventRouter tc = go.AddComponent <TriggerEventRouter>();
    }
Esempio n. 2
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;
    }
Esempio n. 3
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;
    }
Esempio n. 4
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;
    }
    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;
    }
    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;
    }
Esempio n. 7
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;
    }
Esempio n. 8
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;
    }
Esempio n. 9
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;
    }
Esempio n. 10
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;
    }
Esempio n. 11
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;
    }
Esempio n. 12
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;
    }
Esempio n. 13
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;
    }
Esempio n. 14
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;
    }
Esempio n. 15
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;
    }
Esempio n. 16
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;
        }
    }