コード例 #1
0
 void Start()
 {
     workAnimation = FindObjectOfType <WorkAnimation>().GetComponent <WorkAnimation>();
     switchActive  = FindObjectOfType <SwitchActive>().GetComponent <SwitchActive>();
     //boxStackAnimation = GameObject.Find("BoxStack_Animation");
     //Debug.Log(boxStackAnimation);
     truckAnimation = FindObjectOfType <TruckAnimation>().GetComponent <TruckAnimation>();
 }
コード例 #2
0
    private void CheckAnswer()//Checks the answer with what is being placed on the pallet
    {
        Check = true;
        if (Check && answer != null)// are we checking and has the answer been predefined
        {
            if (answer == EG.answer)
            {
                EG.EquationText.color = Color.green;
                GameManager.Instance.CorrectAnswer();
                changeColor = true;
                numbers.Clear();
                boxes.Clear();
                Check = false;
                spwn.DestroyBoxes();
                stmp.gameobjectHere = false;
                correctAnswers++;
                scre.score += 10;
                timer.time += 10f;
                //tape.startfunciton = true;
                if (correctAnswers >= 10)
                {
                    scre.score    += 100;
                    correctAnswers = 0;
                }

                // Update the score to the PlayerPrefs
                scre.CheckHighScore();

                // Trigger of Animator in Test_Scene
                GameObject[] temp = SceneManager.GetSceneByName("Test_Scene").GetRootGameObjects();
                for (int i = 0; i < temp.Length; i++)
                {
                    // Debug.Log(temp[i]);
                    if (temp[i].name == "Animator")
                    {
                        // Debug.Log(temp[i]);
                        workAnimation             = temp[i].GetComponent <WorkAnimation>();
                        workAnimation.isAnimating = true;
                        //temp[i].GetComponent<WorkAnimation>().isAnimating = true;
                        //FindObjectOfType<WorkAnimation>().GetComponent<WorkAnimation>().isAnimating = true;
                    }
                }
            }

            else
            {
                EG.EquationText.color = Color.red;
                Debug.Log("Wrong");
                changeColor = true;
                numbers.Clear();
                answer      = 0;
                timer.time -= 5f;
                //boxes.Clear();
                Check = false;
            }
        }
    }