Ejemplo n.º 1
0
    protected override void Execute(List <GameEntity> entities)
    {
        List <GameEntity> isDestroyedEntities = new List <GameEntity>();

        var gameBoard = _context.CreateGameBoard().boadGame;

        Debug.Log("gameboard columns:" + gameBoard.columns);

        foreach (var e in entities)
        {
            checkDown(4.5f, e);
        }
    }
Ejemplo n.º 2
0
    protected override void Execute(List <GameEntity> entities)
    {
//        foreach (var e in entities)
//        {
//            Debug.Log("removed : " + e);
//        }


        var gameBoard = _context.CreateGameBoard().boadGame;

        Debug.Log(gameBoard.columns + "va" + gameBoard.row);
        for (var c = 0 * 1.5f; c < gameBoard.columns * 1.5f; c += 1.5f)
        {
            for (var r = 0 * 1.5f; r < gameBoard.row * 1.5f; r += 1.5f)
            {
                var position = new Vector2(c, r);

                //Debug.Log(position.x + " and " + position.y);
                var movables = _context.GetEntitiesWithPosition(position)
                               .ToArray();

                foreach (var e in movables)
                {
//                    Debug.Log("new Pos" + e);

                    MoveDown(e, position);
                }
            }
        }
    }
Ejemplo n.º 3
0
    protected override void Execute(List <GameEntity> entities)
    {
        var gameBoard = gameContext.CreateGameBoard().boadGame;

        //GameEntity[] movables = new GameEntity[100];

        //Debug.Log(gameBoard.columns + "va" + gameBoard.row);
        for (var c = 0 * 1.5f; c < gameBoard.columns * 1.5f; c += 1.5f)
        {
            for (var r = 0 * 1.5f; r < gameBoard.row * 1.5f; r += 1.5f)
            {
                var position = new Vector2(c, r);
                if (visited[(int)(c / 1.5f), (int)(r / 1.5f)])
                {
                    continue;
                }
                Path path = new Path();
                if (!gameContext.GetEntitiesWithPosition(position).Equals(null))
                {
                    CheckAdjacent(c, r, visited, path);
                    Debug.Log("Path : " + path.Count() + "position : " + position);
                }
            }
        }
        //Debug.Log("mmdmd : " + gameContext.GetEntitiesWithPosition(new Vector2(0,1.5f)).SingleEntity());
    }
Ejemplo n.º 4
0
    IEnumerator DelaySomething()
    {
        yield return(new WaitForSeconds(0));

        var gameBoard = gameContext.CreateGameBoard().boadGame;

        //Debug.Log(gameBoard.columns + "va" + gameBoard.row);
        for (var c = 0 * 1.5f; c < gameBoard.columns * 1.5f; c += 1.5f)
        {
            for (var r = 0 * 1.5f; r < gameBoard.row * 1.5f; r += 1.5f)
            {
                var position = new Vector2(c, r);

                //Debug.Log(position.x + " and " + position.y);
                var movables = gameContext.GetEntitiesWithPosition(position)
                               .Where(e => e.isDownable)
                               .ToArray();

                foreach (var e in movables)
                {
                    //Debug.Log("new Pos" + e);
                    MoveDown(e, position);
                }
            }
        }

        var allBlocks = allBlock.GetEntities();

        foreach (var block in allBlocks)
        {
            //block.isOverlay = true;
        }
    }
Ejemplo n.º 5
0
    IEnumerator DelaySomething(float time)
    {
        yield return(new WaitForSeconds(time));

        var gameBoard = gameContext.CreateGameBoard().boadGame;

        //Debug.Log("gameboard columns:" + gameBoard.columns );
        for (var c = 0 * 1.5f; c < gameBoard.columns * 1.5f; c = c + 1.5f)
        {
            var position   = new Vector2(c, gameBoard.row * 1.5f);
            var nextRowPos = CheckEmptyPosition.GetNextEmptyRow(gameContext, position);
            //Debug.Log("position : " + position + " nextRowpos : " + nextRowPos + " row : " + gameBoard.row*1.5f);

            while (nextRowPos != gameBoard.row * 1.5f)
            {
                //Debug.Log("c truoc : " + c  + " nextpos truoc : " + nextRowPos );
                //_context.CreateRandomPiece(c/1.5f, nextRowPos/1.5f);
                GameEntity ge = gameContext.CreateRandomPiece(c / 1.5f, nextRowPos / 1.5f);
                ge.isMovable = true;
                ge.isOverlay = true;
                //ge.isMove = true;
                nextRowPos = CheckEmptyPosition.GetNextEmptyRow(gameContext, position);
                //Debug.Log("c sau : " + c  + " nextpos sau : " + nextRowPos );
            }
        }
    }
Ejemplo n.º 6
0
    public void Initialize()
    {
        var gameBoard = _context.CreateGameBoard().boadGame;

        for (var r = 0; r < gameBoard.row; r++)
        {
            for (var c = 0; c < gameBoard.columns; c++)
            {
                _context.CreateRandomPiece(r, c);
            }
        }
    }
Ejemplo n.º 7
0
    public void Initialize()
    {
        var gameBoard = _context.CreateGameBoard().gameBoard;

        for (int row = 0; row < gameBoard.rows; row++)
        {
            for (int column = 0; column < gameBoard.columns; column++)
            {
                if (Random.value > 0.91f)
                {
                    _context.CreateBlocker(column, row);
                }
                else
                {
                    _context.CreateRandomPiece(column, row);
                }
            }
        }
    }
Ejemplo n.º 8
0
    public void Initialize()
    {
        var gameBoard = gameContext.CreateGameBoard().boadGame;

        for (var r = 0; r < gameBoard.row; r++)
        {
            for (var c = 0; c < gameBoard.columns; c++)
            {
                if (Random.value > 0.95f)
                {
                    gameContext.CreateRandomBlock(c, r);
                }
                else
                {
                    gameContext.CreateRandomPiece(c, r);
                }
            }
        }
    }
Ejemplo n.º 9
0
    protected override void Execute(List <GameEntity> entities)
    {
        var gameBoard = _context.CreateGameBoard().boadGame;

        Debug.Log("gameboard columns:" + gameBoard.columns);
        for (var c = 0 * 1.5f; c < gameBoard.columns * 1.5f; c = c + 1.5f)
        {
            var position   = new Vector2(c, gameBoard.row * 1.5f);
            var nextRowPos = CheckEmptyPosition.GetNextEmptyRow(_context, position);
//            Debug.Log("position : " + position + " nextRowpos : " + nextRowPos + " row : " + gameBoard.row*1.5f);

            while (nextRowPos != gameBoard.row * 1.5f)
            {
                //Debug.Log("c truoc : " + c  + " nextpos truoc : " + nextRowPos );
                _context.CreateRandomPiece(c / 1.5f, nextRowPos / 1.5f);
                nextRowPos = CheckEmptyPosition.GetNextEmptyRow(_context, position);
//                Debug.Log("c sau : " + c  + " nextpos sau : " + nextRowPos );
            }
        }
    }
Ejemplo n.º 10
0
    protected override void Execute(List <GameEntity> entities)
    {
        var tappedBlocks = tappedBlock.GetEntities();

        foreach (var block in tappedBlocks)
        {
            Debug.Log("tapped block : " + block);
        }
        var   gameBoard = context.CreateGameBoard().boadGame;
        var   topRow    = gameBoard.row * 1.5f;
        var   topCol    = gameBoard.columns * 1.5f;
        float length;

        if (topRow > topCol)
        {
            length = topRow;
        }
        else
        {
            length = topCol;
        }
        var movebleBlock = _movebleBlock.GetEntities();
        List <GameEntity> movebleBlockList = new List <GameEntity>();

        foreach (var m in movebleBlock)
        {
            if (m.asset.name == "Prefabs/Rocket" || m.asset.name == "Prefabs/Boom")
            {
                Debug.Log("ANC " + m);
            }
            movebleBlockList.Add(m);
            m.isMovable = false;
        }
        foreach (var e in entities)
        {
//            Debug.Log("e in enities list : " + e.asset.name + "pos : " + e.position.value);
        }
        for (var r = 0 * 1.5f; r < length; r += 1.5f)
        {
            var count = 0; // count number of block be created in a column
            var tempr = r;
            foreach (var m in movebleBlockList)
            {
                if ((m.view.gameObject.transform.position.x == tempr) && (m.asset.name != "Prefabs/GenerateBrick") &&
                    (m.asset.name != "Prefabs/Boom") &&
                    (m.asset.name != "Prefabs/Rocket"))
                {
                    count++;
                }
            }

            //Debug.Log("COUNT " + count + "tempr " + tempr);
            foreach (var e in entities)
            {
                //Debug.Log("eeeeeee" + e.view.gameObject.transform.position);
                var pos = e.position;
                //Debug.Log("pospospospos" + pos.value.x + "  " + pos.value.y);

                var isTopRow    = (pos.value.y.Equals(topRow - 1.5f));
                var isSecondRow = (pos.value.y.Equals(topRow - 3f));
                var isThirdRow  = (pos.value.y.Equals(topRow - 4.5f));
                var is4thRow    = (pos.value.y.Equals(topRow - 6f));
                var is5thRow    = (pos.value.y.Equals(topRow - 7.5f));
                var is6thRow    = (pos.value.y.Equals(topRow - 9f));
                var is7thRow    = (pos.value.y.Equals(topRow - 10.5f));
                var is8thRow    = (pos.value.y.Equals(topRow - 12f));
                var is9thRow    = (pos.value.y.Equals(topRow - 13.5f));

                bool [] numRow = new bool[10];

                numRow[1] = isTopRow;
                numRow[2] = isTopRow || isSecondRow;
                numRow[3] = isTopRow || isSecondRow || isThirdRow;
                numRow[4] = isTopRow || isSecondRow || isThirdRow || is4thRow;
                numRow[5] = isTopRow || isSecondRow || isThirdRow || is4thRow || is5thRow;
                numRow[6] = isTopRow || isSecondRow || isThirdRow || is4thRow || is5thRow || is6thRow;
                numRow[7] = isTopRow || isSecondRow || isThirdRow || is4thRow || is5thRow || is6thRow || is7thRow;
                numRow[8] = isTopRow || isSecondRow || isThirdRow || is4thRow || is5thRow || is6thRow || is7thRow ||
                            is8thRow;
                numRow[9] = isTopRow || isSecondRow || isThirdRow || is4thRow || is5thRow || is6thRow || is7thRow ||
                            is8thRow || is9thRow;


                if (count == 0)
                {
                    if (e.position.value.x == tempr)
                    {
                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
                    }
                }
                for (int i = 1; i <= 9; i++)
                {
                    if (count == i)
                    {
                        if (e.position.value.x == tempr)
                        {
                            if (numRow[i])
                            {
                                e.view.gameObject.transform.position = new Vector3(pos.value.x, pos.value.y + 1.5f * i);
                            }
                            e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
                        }

                        break;
                    }
                }
//
//                if (count == 1)
//                {
//                    if (e.position.value.x == tempr )
//                    {
//
//                        if (isTopRow)
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x, pos.value.y + 1.5f);
//
//
//                        }
//                        Debug.Log("trc : " + e.view.gameObject.transform.position + " " + e.position.value);
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                        //Debug.Log("sau : " + e.view.gameObject.transform.position + " " + e.position.value);
//                    }
//                }
//                if (count == 2)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow)
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x, pos.value.y + 3f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 3)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow
//                            )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 4.5f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 4)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow || is4thRow
//                            )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 6f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 5)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow|| is4thRow || is5thRow
//                            )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 7.5f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 6)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow|| is4thRow || is5thRow || is6thRow
//                           )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 9f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 7)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow|| is4thRow || is5thRow|| is6thRow || is7thRow
//                           )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 10.5f);
//                            e.view.gameObject.transform.DOScaleY(1.2f, 0.3f)
//                                .OnComplete(
//                                    () => { e.view.gameObject.transform.DOScaleY(1f, 0.3f); }
//                                );
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 8)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow|| is4thRow || is5thRow|| is6thRow || is7thRow || is8thRow
//                            )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 12f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
//                else if (count == 9)
//                {
//                    if (e.position.value.x == tempr)
//                    {
//                        if (isTopRow || isSecondRow || isThirdRow|| is4thRow || is5thRow|| is6thRow || is7thRow
//                            || is8thRow || is9thRow )
//                        {
//                            e.view.gameObject.transform.position = new Vector3(pos.value.x,pos.value.y + 13.5f);
//
//                        }
//
//                        e.view.gameObject.transform.DOMove(new Vector3(pos.value.x, pos.value.y, 0f), SPEED);
//                    }
//
//                }
            }
        }
    }