Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (GvrViewer.Instance.Triggered)// || Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            bool       u          = Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity);//, 1 << 8);
            Collider   tempHolder = hit.collider;

            if (u)
            {
                //print("Raycast hit: " + tempHolder);

                /*TempHolder here gets the Objects collider, therefor searching for a component in Parent works.
                 * Searching for a Child component will therefor not work since the objects collider doesn't have components
                 * underneath itself, it's the object itself that holds the collider that has the children components.
                 * We also check if our tempHolder has a parent since as of this moment, the object is root in the hierachy.
                 * This might change when we add more objects. */

                objectScript rayCast = tempHolder.GetComponentInParent <objectScript>();

                //This functions checks if the object is initiated and then does something with the choice you picked.
                if ((rayCast.getFade() == 0) && (rayCast.getClick() == 1) && (tempHolder.transform.parent != null))
                {
                    canvasScript canvScript = tempHolder.gameObject.GetComponentInParent <canvasScript>();
                    answer = tempHolder.GetComponentInChildren <Text>().text.ToString();
                    //print("tempHolder: " + answer.ToString());
                    //print("racCast " + rayCast.getAnswer().ToString());
                    if (answer == rayCast.getAnswer())
                    {
                        canvScript.pickChoice(tempHolder);
                        playScript.rightAnswer(rayCast);
                        //fades everything.
                        rayCast.setFade();
                    }
                    else
                    {
                        canvScript.pickChoice(tempHolder);
                        playScript.wrongAnswer(rayCast);
                    }
                }

                //This function initiates the model choices and sets them to initiated so you can't initiate them again.
                else if (rayCast.getInstantiate() == 0)
                {
                    model = tempHolder.GetComponent <objectScript>();
                    model.click();
                    model.setInstantiate();
                }
            }
        }
    }
Пример #2
0
    //public InputField MazeWidth;
    //static public int _width
    //public InputField MazeHeight;
    //static public int _height;

    void Start()
    {
        canvasScriptRef = GameObject.Find("Canvas").GetComponent <canvasScript>();


        _width  = StaticWidth._width1;
        _height = StaticHeight._height1;

        //Debug.Log("                  " + _width);
        // Debug.Log("                  " + _height);

        cells = new Cell[_width, _height];
        Init();
    }
Пример #3
0
    //public InputField MazeWidth;
    //static public int _width
    //public InputField MazeHeight;
    //static public int _height;

    void Start()
    {
        canvasScriptRef = GameObject.Find("Canvas").GetComponent <canvasScript>();


        _width  = StaticWidth._width1;
        _height = StaticHeight._height1;

        targetObj.transform.position = new Vector3((_width - 1) * 3, 2.2f, (_height) * 3);
        //Debug.Log("                  " + _width);
        // Debug.Log("                  " + _height);

        cells = new Cell[_width, _height];
        Init();
    }
Пример #4
0
 void Awake()
 {
     ins = this;
 }