Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Question.text = "works";


        //не хватает появлениея ответа при угадывании всех примеров!!!!!!!!!!!!!!!!
        //если категория не выбрана то..
        if (tables.PictureGo == null)
        {
            //в stat string category хранится строковое значения категории которая была выбрана в меню

            switch (tables.Category)
            {
            case tables.Categories.ANIMALS: tables.PictureGo = AnimalsPicters;
                tables.answers_PicturesGo = tables.answers_PictureGo_Animals;
                break;

            case tables.Categories.COUNTRIES: tables.PictureGo = CountriesPicters;
                tables.answers_PicturesGo = tables.answers_PictureGo_Contries;
                break;

            default:
                tables.PictureGo = PictureGo; break;
            }
            //если нужно тестировать эту сценку без меню игры, то можно снять комментарий
            //в результате верхний алгоритм необязателен.
            //tables.PictureGo = PictureGo;
            tables.currentQuestIndex = 0;
            //tables.answers_PicturesGo = new string[]{"домик","пустыня","коала","пингвины"};
            //Sprite curSpr=current.GetComponent<SpriteRenderer>().sprite;
            //curSpr=tables.PictureGo[currentIndexQuest];

            //другой случай, т.е. если picturego уже чему то равен
        }
        else
        {
            //Debug.Log("zoom "+currentIndexQuest);
            tables.currentQuestIndex++;
            //tables.currentQuestIndex = 0;
        }

        /*
         *
         */

        //для эксперимента пока закомментирую данный отрывок внизу
        //SpriteRenderer currentFon = (SpriteRenderer)GameObject.Find ("current_fon").GetComponent<SpriteRenderer>() as SpriteRenderer;

        current.GetComponent <SpriteRenderer>().sprite = tables.PictureGo[tables.currentQuestIndex];
        //currentFon.sprite = current.GetComponent<SpriteRenderer>().sprite;
        currentIndexQuest = tables.currentQuestIndex;


        //вставленный скрипт из creat cubiks2 начало
        //block start

        //создание массива локальных координат для x y
        float[] coords_x = new float[4];
        float[] coords_y = new float[4];
        float   coord_x = -3.85f, coord_y = -2.85f;

        for (int x = 0; x < 4; x++)
        {
            coords_x[x] = coord_x;
            coords_y[x] = coord_y;
            coord_x    += 2.55f;
            coord_y    += 1.9f;
        }


        /*создание таблицы (двухмерного массива клеточек 4 на 4 из Объекта kvadrat
         * присвоение каждому эксземляру родителя.
         * назначение каждому созданному экземляру отображаемый пример из ExampleList
         * который также гегерируется отдельно
         * и запись имени name состоящий из exNum и ans которые будут отображаться в окне
         * иерархии в качестве дочерних элемента в виде списка. exNum (example number) - это индекс по строке от 0 до 3
         * ans (answer)-  это ответ на каждый пример для удобного последовательного
         * считывании другими объектами
         *
         */
        ArrayList ExamplesList = creat_examples2();
        int       i = 0, j = 0, queque = 0;

        while (j < 4)
        {
            while (i < 4)
            {
                GameObject element = Instantiate(kvadrat);
                //в прошлом слыае переменная currentPicture означал спрайт в котором хранится картинка, которую нужно угадать, и которая являлась родителем
                //в новом скрипте ее предположительное название просто current поэтому заменим
                //element.transform.SetParent (currentPicture.transform); //на
                SpriteRenderer sprite = (SpriteRenderer)element.GetComponent <SpriteRenderer> () as SpriteRenderer;
                sprite.sortingOrder = 0;
                element.transform.SetParent(current.transform);
                //однако переменная current имеет теперь тип sprite а мне нужен transform т.к. только этот тип мб родительским в unity
                element.transform.localPosition = new Vector2(coords_x[i], coords_y[j]);
                TextMesh textLabelOnElement = (TextMesh)element.GetComponentInChildren <TextMesh>() as TextMesh;

                Example summa = ExamplesList[queque] as Example;
                textLabelOnElement.text = summa.StrExample();
                element.name            = "exNum" + queque + "ans=" + summa.Answer();
                queque++;
                i++;
            }
            j++;
            i = 0;
        }


        //конец вставленного скрипта creat cubiks2



        /*
         * //okno_calc ();
         * float x_src_pos = -4.65f;
         * float float_x = x_src_pos;//-6.4
         * float float_y = 3.34f;//4.2
         * int i = 1;
         * tables.countSquares = 0;
         * while (float_y>0f) {
         *      int queque=0;
         *      ArrayList ExamplesList = new ArrayList();
         *      ExamplesList.Add(new Summ());
         *      ExamplesList.Add(new DifferenceEx());
         *      ExamplesList.Add(new Multiplication());
         *      ExamplesList.Add(new Division());
         *      ExamplesList.Add(new Multiplication());
         *      ExamplesList.Add(new Multiplication());
         *      ExamplesList.Add(new Multiplication());
         *      ExamplesList.Add(new Multiplication());
         *      helper helperCreateExample = helper.TakeHelper();
         *      int[] seqExamples={0,1,2,3,4,5,6,7};
         *      seqExamples=helperCreateExample.ShuffleInts(seqExamples);
         *      while (float_x<1.5) {
         *              tables.countSquares++;
         *              GameObject go = Instantiate (kvadrat) as GameObject;
         *
         *              go.transform.position = new Vector2 (float_x, float_y);
         *              TextMesh txtOnKvadratik=(TextMesh)go.GetComponentInChildren<TextMesh>() as TextMesh;
         *              //helper helperCreateExample = helper.TakeHelper();
         *
         *              //сюда вставить функцию которая будет взаимоменять примеры между собой example summ differecne
         *              //example ex=func(queque);
         *
         *              Example summa=ExamplesList[seqExamples[queque]] as Example;
         *              queque++;
         *
         *
         *              txtOnKvadratik.text=summa.StrExample();
         *              //Summ summa = new Summ();
         *              //txtOnKvadratik.text=Summ.StrExample();
         *
         *              go.name="exNum"+i+"ans="+summa.Answer();
         *
         *              i++;
         *              float_x += 1.7f;
         *      }
         *      float_x=x_src_pos;
         *      float_y-=0.9f;
         * }*/

        //okno_enter_answer ();
    }