Esempio n. 1
0
 private void UnpickBlocks()
 {
     BlockData.first  = null;
     BlockData.second = null;
     targetLight.SetActive(false);
     movePhaseEnum = MoveStageEnum.PlayerMakeMove;
 }
Esempio n. 2
0
    private bool Swap(BlockData frst, BlockData scnd)
    {
        movePhaseEnum = MoveStageEnum.BlocksMoving;

        //boot first pos
        Vector3 bootPos = frst.transform.position;
        int     bootX   = frst.x;
        int     bootY   = frst.y;

        StartCoroutine(MoveBlockToNextPosition(frst, scnd.transform.position));
        StartCoroutine(MoveBlockToNextPosition(scnd, bootPos));

        // first data same as second
        frst.x = scnd.x;
        frst.y = scnd.y;

        //second data same as boot
        scnd.x = bootX;
        scnd.y = bootY;

        //block type on board data;
        board[frst.x, frst.y] = frst.type;
        board[scnd.x, scnd.y] = scnd.type;

        return(true);
    }
Esempio n. 3
0
    private void Start()
    {
        movePhaseEnum      = MoveStageEnum.PlayerMakeMove;
        scoreCounterScript = ScoreCounter.instance;

        blockPoolScript = BlockPool.instance;
        blockTypes      = BlockPool.instance.blockWhatNeedToPool.Count;
    }
Esempio n. 4
0
    public void CreateDesk(int sizeX, int sizeY)
    {
        RemoveBoard(); //remove previous desk

        deskSizeX = sizeX;
        deskSizeY = sizeY;
        board     = new int[sizeX, sizeY];

        for (int x = 0; x < board.GetLength(0); x++)
        {
            for (int y = 0; y < board.GetLength(1); y++)
            {
                int blockType = Random.Range(0, blockTypes);
                SpawnBlockAtPosition(x, y, blockType);
            }
        }
        CameraPosition(sizeX, sizeY);
        movePhaseEnum = MoveStageEnum.PlayerMakeMove;
    }
Esempio n. 5
0
    MoveStageEnum ChangeStageEnum(MoveStageEnum nextStage)
    {
        movePhaseEnum = nextStage;

        if (movePhaseEnum == MoveStageEnum.PlayerMakeMove)
        {
            scoreMultiplier = 1;
            scoreCounterScript.AddScore(0, 1);
        }

        if (movePhaseEnum == MoveStageEnum.AfterFallCheck)
        {
            bool getMatch = false;


            BlockData[] allBlockData = FindObjectsOfType(typeof(BlockData)) as BlockData[];

            foreach (BlockData _blockData in blocksWhatNeedCheck)
            {
                if (_blockData)
                {
                    if (CheckMatch(_blockData, allBlockData))
                    {
                        getMatch = true;
                    }
                }
            }
            blocksWhatNeedCheck.RemoveAll(BlockData => BlockData == null);

            if (!getMatch)
            {
                ChangeStageEnum(MoveStageEnum.PlayerMakeMove);
            }
            else
            {
                MoveAllBlockDown();
                AddScoreToScoreCounter();
            }
        }
        return(nextStage);
    }
Esempio n. 6
0
    public void LoadLevel(TextAsset levelTextAsset)
    {
        RemoveBoard();

        List <string> levelStringData;

        levelStringData = levelTextAsset.text.Split(';').ToList();

        int[] lvlData = new int[levelStringData.Count];



        for (int i = 0; i < levelStringData.Count; i++)
        {
            if (int.TryParse(levelStringData[i], out int stringInt))
            {
                lvlData[i] = stringInt;
            }
            else
            {
                Debug.LogError($"Not correct levelConfig on {i} string");
            }
        }
        deskSizeX = lvlData[0];
        deskSizeY = lvlData[1];

        board = new int[deskSizeX, deskSizeY];
        int blockTypeCount = 2;

        for (int y = deskSizeY - 1; y >= 0; y--)//levels load left-right > up-down;
        {
            for (int x = 0; x < deskSizeX; x++)
            {
                SpawnBlockAtPosition(x, y, lvlData[blockTypeCount]);
                blockTypeCount++;
            }
        }
        CameraPosition(lvlData[0], lvlData[1]);
        movePhaseEnum = MoveStageEnum.PlayerMakeMove;
    }