// Use this for initialization
        void Start()
        {
            gameController = GameObject.Find("GameManager").GetComponent <MainGameController>();

            if (gameController.scene == Constants.ROBOT_GUESSING_SCENE)
            {
                guess        = GameObject.Find("RobotGuessingManager").GetComponent <RobotGuesser>();
                childbuilder = GameObject.Find("ExplainerSceneManager").GetComponent <ChildBuilder>();
                guessedHouse = guess.finalHouse;
                builtHouse   = childbuilder.explainerHouse;
                gameController.SendRobotUtterance("child-builder-compare-houses", false, -1, -1, -1);

                /*var cl = GameObject.Find("child_left");
                 * var rr = GameObject.Find("robot_right");
                 *
                 * cl.gameObject.GetComponent<Text>().enabled = true;
                 * rr.gameObject.GetComponent<Text>().enabled = true;*/
            }
            else if (gameController.scene == Constants.CHILD_GUESSING_SCENE)
            {
                if (gameController.tutorial)
                {
                    childTut = GameObject.Find("ChildGuessingManager").GetComponent <ChildGuesserTutorial>();
                    correct  = childTut.chosenHouse;
                    guessed  = childTut.submittedHouse;
                }
                else
                {
                    child   = GameObject.Find("ChildGuessingManager").GetComponent <ChildGuesser>();
                    correct = child.chosenHouse;
                    guessed = child.submittedHouse;
                }

                gameController.SendRobotUtterance("robot-builder-compare-houses", false, -1, -1, -1);

                /*var cr = GameObject.Find("child_right");
                 * var rl = GameObject.Find("robot_left");
                 *
                 * cr.gameObject.GetComponent<Text>().enabled = true;
                 * rl.gameObject.GetComponent<Text>().enabled = true;*/
            }
            level = gameController.levelNumber;

            showOnScreen();
        }
        public void SubmitFinalAnswer()
        {
            if (final_guess != -0)
            {
                if (gameController.internalGameState == Constants.END_GAME)
                {
                    gameController.SendRobotUtterance("end-game", false, -1, -1, -1);
                    Logger.Log("GoingToQuit");
                    //Application.Quit();
                }

                int correct = 1;
                foreach (RandomHouse h in variations)
                {
                    if (h.position == final_guess)
                    {
                        correct        = 0;
                        submittedHouse = h;
                    }
                }
                if (correct == 1)
                {
                    submittedHouse = chosenHouse;
                }

                if (level == 1)
                {
                    SceneManager.LoadScene("Both_houses_L1");
                }
                if (level == 2)
                {
                    SceneManager.LoadScene("Both_houses_L2");
                }
                if (level == 3)
                {
                    SceneManager.LoadScene("Both_houses_L3");
                }
                if (level == 4)
                {
                    SceneManager.LoadScene("Both_houses_L4");
                }
            }
        }
示例#3
0
        void CreateVariations()
        {
            System.Random rnd = new System.Random();

            if (level == 1)
            {
                List <int> takenPos = new List <int>();
                takenPos.Add(chosenIndex);
                RandomHouse var1 = new RandomHouse();
                RandomHouse var2 = new RandomHouse();
                RandomHouse var3 = new RandomHouse();
                //var1 changes wall and roof
                //var2 changes wall and door
                //var3 changes roof and door
                if (chosenHouse.wall == 0)
                {
                    var1.wall = 1;
                    var2.wall = 1;
                    var3.wall = 0;
                }
                else
                {
                    var1.wall = 0;
                    var2.wall = 0;
                    var3.wall = 1;
                }
                if (chosenHouse.roof == 0)
                {
                    var1.roof = 1;
                    var3.roof = 1;
                    var2.roof = 0;
                }
                else
                {
                    var1.roof = 0;
                    var3.roof = 0;
                    var2.roof = 1;
                }
                if (chosenHouse.door1 == 0)
                {
                    var2.door1 = 1;
                    var3.door1 = 1;
                    var1.door1 = 0;
                }
                else
                {
                    var2.door1 = 0;
                    var3.door1 = 0;
                    var1.door1 = 1;
                }


                for (int i = 0; i < 3; i++)
                {
                    int newPos = rnd.Next(1, house_numbers + 1);
                    while (takenPos.IndexOf(newPos) != -1)
                    {
                        newPos = rnd.Next(1, house_numbers + 1);
                    }

                    takenPos.Add(newPos);
                    if (i == 0)
                    {
                        var1.position = newPos;
                    }
                    if (i == 1)
                    {
                        var2.position = newPos;
                    }
                    if (i == 2)
                    {
                        var3.position = newPos;
                    }
                }

                variations.Add(var1);
                variations.Add(var2);
                variations.Add(var3);
            }

            if (level == 2)
            {
                List <int> takenPos = new List <int>();
                takenPos.Add(chosenIndex);
                for (int i = 0; i < 5; i++)
                {
                    RandomHouse variation = new RandomHouse();
                    int         diff      = 0;
                    while (diff != 1)
                    {
                        int w = rnd.Next(0, 3);
                        int r = rnd.Next(0, 3);
                        int d = rnd.Next(0, 3);
                        int p = rnd.Next(0, 3);
                        if ((w != chosenHouse.wall) && (r != chosenHouse.roof) && (d != chosenHouse.door1) && (p != chosenHouse.plant1))
                        {
                            diff             = 1;
                            variation.wall   = w;
                            variation.door1  = d;
                            variation.plant1 = p;
                            variation.roof   = r;
                        }
                    }
                    int newPos = rnd.Next(1, house_numbers + 1);
                    while (takenPos.IndexOf(newPos) != -1)
                    {
                        newPos = rnd.Next(1, house_numbers + 1);
                    }

                    takenPos.Add(newPos);
                    variation.position = newPos;
                    variations.Add(variation);
                }
            }

            if (level == 3)
            {
                int newPos = 1;
                for (int i = 0; i < 9; i++)
                {
                    RandomHouse variation = new RandomHouse();
                    int         diff      = 0;
                    while (diff != 1)
                    {
                        int w  = rnd.Next(0, 4);
                        int r  = rnd.Next(0, 4);
                        int d  = rnd.Next(0, 4);
                        int p  = rnd.Next(0, 4);
                        int d2 = rnd.Next(0, 4);
                        if ((w != chosenHouse.wall) && (r != chosenHouse.roof) && (d != chosenHouse.door1) && (p != chosenHouse.plant1) && (d2 != chosenHouse.door2))
                        {
                            diff             = 1;
                            variation.wall   = w;
                            variation.door1  = d;
                            variation.plant1 = p;
                            variation.roof   = r;
                            variation.door2  = d2;
                        }
                    }
                    if (newPos == chosenIndex)
                    {
                        newPos++;
                    }

                    variation.position = newPos;
                    variations.Add(variation);
                    newPos++;
                }
            }
            if (level == 4)
            {
                int newPos = 1;
                for (int i = 0; i < 9; i++)
                {
                    RandomHouse variation = new RandomHouse();
                    int         diff      = 0;
                    while (diff != 1)
                    {
                        int w  = rnd.Next(0, 6);
                        int r  = rnd.Next(0, 6);
                        int d  = rnd.Next(0, 6);
                        int p  = rnd.Next(0, 6);
                        int d2 = rnd.Next(0, 6);
                        int p2 = rnd.Next(0, 6);
                        if ((w != chosenHouse.wall) && (r != chosenHouse.roof) && (d != chosenHouse.door1) && (p != chosenHouse.plant1) && (d2 != chosenHouse.door2) && (p2 != chosenHouse.plant2))
                        {
                            diff             = 1;
                            variation.wall   = w;
                            variation.door1  = d;
                            variation.plant1 = p;
                            variation.roof   = r;
                            variation.door2  = d2;
                            variation.plant2 = p2;
                        }
                    }
                    if (newPos == chosenIndex)
                    {
                        newPos++;
                    }

                    variation.position = newPos;
                    variations.Add(variation);
                    newPos++;
                }
            }
        }