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 ); } } }
void MoveDown(GameEntity entity, Vector2 position) { var nextRowPos = CheckEmptyPosition.GetNextEmptyRow(_context, position); //Debug.Log("NRP " + nextRowPos + " Y " + position.y); if (nextRowPos != position.y) { //Debug.Log("new Pos " + nextRowPos + " Y " + position.y + " x " + position.x); entity.ReplacePosition(new Vector2(position.x, nextRowPos)); } }
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 ); } } }