Exemplo n.º 1
0
        public object Clone()
        {
            Puzzle puzzle = new Puzzle();

//            puzzle.AssetName = AssetName;
            puzzle.BgFgOrigin            = BgFgOrigin;
            puzzle.BackgroundTextureName = BackgroundTextureName;
            puzzle.CollisionLayer        = (collisionLayer != null ? CollisionLayer.Clone() as int[] : null);
            puzzle.Dimensions            = Dimensions;
            puzzle.ForegroundTextureName = ForegroundTextureName;
            puzzle.GridOrigin            = GridOrigin;
            puzzle.IsCleared             = IsCleared;
            puzzle.IsGridShiftX          = IsGridShiftX;
            puzzle.isGridShiftY          = IsGridShiftY;
            puzzle.IsLocked        = IsLocked;
            puzzle.Key             = Key;
            puzzle.MusicCueName    = MusicCueName;
            puzzle.Name            = Name;
            puzzle.Place           = Place;
            puzzle.OurSolution     = OurSolution;
            puzzle.PlayerSolution  = PlayerSolution;
            puzzle.portraitTexture = portraitTexture;
            puzzle.PuzzleLayer     = (puzzleLayer != null ? PuzzleLayer.Clone() as int[] : null);
            puzzle.ShapeLayer      = (shapeLayer != null ? ShapeLayer.Clone() as int[] : null);
            puzzle.Size            = Size;
            puzzle.Statistics      = Statistics;
            puzzle.TileLayer       = (tileLayer != null ? TileLayer.Clone() as int[] : null);
            puzzle.TileSize        = TileSize;
            puzzle.tilesPerRow     = tilesPerRow;

            return(puzzle);
        }
Exemplo n.º 2
0
        public PuzzleScene(CCGameView gameView, string[] puzzle) : base(gameView)
        {
            //Création de l'arrière-plan
            var backgroundLayer = new CCLayer();

            CreateBackground(gameView, backgroundLayer);
            AddChild(backgroundLayer);
            //Création du Layer de jeu
            puzzleLayer = new PuzzleLayer(puzzle);
            AddChild(puzzleLayer);
        }
    // Update is called once per frame
    void Update()
    {
        if (!resetting) {
            switch (currentPuzzle) {

            case PuzzleLayer.Layer1:
                EnableLayer (blockLayer1);
                AddBlockForce (blockLayer1);

                break;

            case PuzzleLayer.Layer2:
                EnableLayer (blockLayer2);
                AddBlockForce (blockLayer2);

                break;

            case PuzzleLayer.Layer3:
                EnableLayer (blockLayer3);
                AddBlockForce (blockLayer3);

                break;

            case PuzzleLayer.Layer4:
                EnableLayer (blockLayer4);
                AddBlockForce (blockLayer4);

                break;
            }
        } else {
            bool finishedReset = true;
            for (int i = 0; i < pillars.Length; i++) {
                pillars[i].GetComponent<PillarController>().Fall();
                pillars[i].GetComponent<PillarController>().grow = false;
                if (!pillars[i].GetComponent<PillarController>().atGroundHeight)
                    finishedReset = false;
            }

            wall.transform.localPosition = Vector3.MoveTowards(wall.transform.localPosition, new Vector3(0f,wallHeight,0f), 0.5f);

            switch (currentPuzzle) {
            case PuzzleLayer.Layer1:
                Debug.Log ("should never happen");
                break;

            case PuzzleLayer.Layer2:
                VanishBlocks(blockLayer1, 0);
                break;

            case PuzzleLayer.Layer3:
                VanishBlocks(blockLayer2, 1);
                break;

            case PuzzleLayer.Layer4:
                VanishBlocks(blockLayer3, 2);
                break;
            }

            if (finishedReset) {
                resetting = false;
            }
        }

        ////////////////////////////////Puzzle has been completed
        if (puzzleCompleted) {
            for (int i = 0; i < pillars.Length; i++) {
                pillars[i].GetComponent<PillarController>().Fall();
                pillars[i].GetComponent<PillarController>().grow = false;
            }
            VanishBlocks(blockLayer4, 3);
        }

        MatchCylinderHeight();
        MatchCylinderColor ();

        if (Mathf.Abs(key.transform.position.y - 18.5f) < 0.1f && currentPuzzle == PuzzleLayer.Layer1) {
            resetting = true;
            currentPuzzle = PuzzleLayer.Layer2;
            icons[1].GetComponent<Renderer>().material = redMat;
            wallHeight -= 1.0f;
        }
        if (Mathf.Abs(key.transform.position.y - 17.5f) < 0.1f && currentPuzzle == PuzzleLayer.Layer2) {
            resetting = true;
            currentPuzzle = PuzzleLayer.Layer3;
            icons[2].GetComponent<Renderer>().material = redMat;
            wallHeight -= 1.0f;
        }
        if (Mathf.Abs(key.transform.position.y - 16.5f) < 0.1f && currentPuzzle == PuzzleLayer.Layer3) {
            resetting = true;
            currentPuzzle = PuzzleLayer.Layer4;
            icons[3].GetComponent<Renderer>().material = redMat;
            wallHeight -= 1.0f;
        }
        if (Mathf.Abs(key.transform.position.y - 15.5f) < 0.1f && currentPuzzle == PuzzleLayer.Layer4) {
            puzzleCompleted = true;
        }

        if (Mathf.Abs(key.transform.position.y - 14.5f) < 0.1f && currentPuzzle == PuzzleLayer.Layer4) {
            icons[4].GetComponent<Renderer>().material = redMat;
        }

        //		if (Input.GetKey (KeyCode.Z)) {
        //			blockLayer1[2].GetComponent<Rigidbody>().MovePosition(new Vector3(blockLayer1[2].position.x - 0.05f, blockLayer1[2].position.y, blockLayer1[2].position.z));
        //		}
    }