Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        //Initialise fields
        gameManager       = GameObject.FindGameObjectWithTag("GameManager");
        sceneHandleScript = gameManager.GetComponent <SceneHandler>();
        rewardScript      = gameManager.GetComponent <RewardScript>();


        currentQuestion = 0;
        isCorrect       = true;
        answerIds       = new string[4];
        correctIds      = new string[4];


        faceGameObjects = new GameObject[] { brows, eyes, nose, mouth };
        spriteRenderers = new SpriteRenderer[4];

        for (int i = 0; i < faceGameObjects.Length; i++)
        {
            spriteRenderers[i] = faceGameObjects[i].GetComponent <SpriteRenderer>();
        }

        sprites = new Sprite[4];

        //Set answer panel
        answerPanel       = GameObject.FindGameObjectWithTag("Answer");
        answerPanelScript = answerPanel.GetComponent <FaceAnswerPanel>();

        //Load Face Data
        faces         = Faces.Load("FacesData");
        facesArray    = faces.facesArray;
        faceArrayRand = new Face[facesArray.Length];

        //shuffle question order
        faceArrayRand = ShuffleFaceArray(facesArray);
        SetCorrectID();

        SetPrompt(prompt);
        answerPanelScript.SetExplanationTextAndImage(faceArrayRand[currentQuestion]);
    }