Exemple #1
0
        public static void GetSave(PuzzleObject obj)
        {
            SaveModel sm = new SaveModel();

            sm.id = obj._component.id;
            sm.Loading();

            Debug.Log(sm.obj_id);

            if (sm.obj_id > 0)
            {
                obj._component.rt.gameObject.GetComponent <PuzzleDragAndDrop>().enabled = sm.enabled == 1 ? true : false;
                if (sm.parent > 0)
                {
                    obj.SetParentLocal(new PuzzleObject(sm.parent));
                }
                obj.SetTransform(new Vector3(float.Parse(sm.posx), float.Parse(sm.posy), 0.0f));
            }
        }
Exemple #2
0
        public static void GeneratorPuzzles(int x, int y, string image)
        {
            puzzleArray = new PuzzleObject[y * x];
            backArray   = new PuzzleObject[y * x];
            //horizontal
            for (int i = 0; i < y; i++)
            {
                //vertical
                for (int j = 0; j < x; j++)
                {
                    //formula getting id of puzzle
                    int id = j + (x * i) + 1;

                    PuzzleObject puzzle = new PuzzleObject("puzzle_UI", new Vector3(GeneratePX(), GeneratePZ(), 0), id, Scale(x));
                    //save object
                    puzzleArray[id - 1] = puzzle;

                    //Debug.Log("start id = " + id + " / x=" + x + " / y=" + y);

                    puzzle.SetMaterial(image, GetMatrixPosition(id, x, y));
                    //float off = 1.0f / (float)y * 0.32f;
                    float off_x = 1.0f / (float)x * 0.32f;
                    float off_y = 1.0f / (float)y * 0.32f;
                    puzzle.SetMaterialOffset(new Vector2((1.0f / (float)x * (float)j) - off_x, (1.0f / (float)y * ((float)y - 1 - (float)i)) - off_y));
                    float scale_x = 1.0f / (float)x * 0.609f;
                    puzzle.SetMaterialScale(new Vector2((1.0f / (float)x) + scale_x, (1.0f / (float)y) / 0.609f));

                    PuzzleObject puzzle_back = new PuzzleObject("puzzle_UI_back", back_position(id, x, y), id, Scale(x), "back");
                    backArray[id - 1] = puzzle_back;
                    puzzle_back.SetMaterial("back", puzzle.GetTypeSide());
                    //puzzle_back.SetMaterialOffset(new Vector2((1.0f / (float)x * (float)j) - off_x, (1.0f / (float)y * ((float)y - 1 -(float)i)) - off_y));
                    //puzzle_back.SetMaterialScale(new Vector2((1.0f / (float)x) + scale_x, (1.0f / (float)y) / 0.609f));
                    puzzle_back.AttachToBack();
                    puzzle_back.SetTransform(back_position(id, x, y));
                }
            }
        }