public ForumController(IThreadEntity threadEntityService, IForumEntity forumEntityService, IBoardEntity boardEntityService, IUpload uploadService, IConfiguration configService) { _boardEntityService = boardEntityService; _forumEntityService = forumEntityService; _threadEntityService = threadEntityService; _uploadService = uploadService; //For file upload handling, ex. profile pictures. _configuration = configService; }
public void previewIngredient(Ingredient ingredient, Position position) { clearPreviewDisplacement(); if (!canPreviewIngredient(ingredient, position)) { return; } foreach (IBoardEntity oldBoardEntity in previewBoardEntities) { Destroy(oldBoardEntity.gameObject); } previewBoardEntities.Clear(); foreach (KeyValuePair <Position, IBoardEntity> boardEntity in ingredient.boardEntities) { GameObject gameObject = Instantiate(boardEntity.Value.gameObject); gameObject.transform.localScale = new Vector3(beScalar, beScalar, 1); IBoardEntity be = gameObject.GetComponent <IBoardEntity>(); previewBoardEntities.Add(be); be.transform.SetParent(bEHolder.transform, false); be.transform.localPosition = positionToVector(position + boardEntity.Key); if (!positionInBoard(boardEntity.Key + position)) { GameObject tile = Instantiate(tilePf); //tile.GetComponent<Fade>().setShow(true); tile.transform.SetParent(be.transform, false); tile.transform.localPosition = new Vector3(0, 0, -.75f); tile.GetComponent <Tile>().background.GetComponent <ColorLerp>().lerpToColor(Color.red); tile.GetComponent <Tile>().background.GetComponent <Fade>().setShow(true); } else { positionToTile[boardEntity.Key + position].background.GetComponent <ColorLerp>().lerpToColor(highlightColor); positionToTile[boardEntity.Key + position].background.GetComponent <Fade>().setShow(true, true); } if (ingredient.showAdjacent) { foreach (Position adjacentPosition in ingredient.getAdjacentPositions()) { Position tempPosition = adjacentPosition + position; if (positionInBoard(tempPosition)) { positionToTile[adjacentPosition + position].background.GetComponent <ColorLerp>().lerpToColor(adjacentColor); positionToTile[adjacentPosition + position].background.GetComponent <Fade>().setShow(true, true); } } } } previewDisplacements(ingredient.getDisplacements(position)); }
public IBoardEntity removeBoardEntitySlow(Position position) { if (board.ContainsKey(position)) { IBoardEntity boardEntity = board[position]; boardEntity.GetComponent <FadeOnDestroy>().setDuration(2.0f); return(removeBoardEntity(position)); } else { return(null); } }
public IBoardEntity removeBoardEntity(Position position) { if (board.ContainsKey(position)) { IBoardEntity boardEntity = board[position]; board.Remove(position); boardEntity.GetComponent <FadeOnDestroy>().Destroy(.25f); return(boardEntity); } else { return(null); } }
private float moveBoardEntity(IBoardEntity boardEntity, Position position, bool remove = true, bool immediate = false, float fallingSpeed = fallingSpeed) { if (board.ContainsKey(position)) { return(-1f); } if (remove) { board.Remove(boardEntity.position); } board.Add(position, boardEntity); boardEntity.setPosition(position); if (immediate) { boardEntity.lerpToTimed(positionToVector(boardEntity.position), 0); return(0); } return(boardEntity.lerpTo(positionToVector(boardEntity.position), fallingSpeed)); }
private IBoardEntity addBoardEntity(IBoardEntity boardEntity, Position position, bool show = true) { if (!board.ContainsKey(position)) { GameObject newGem = Instantiate(boardEntity.gameObject); newGem.transform.SetParent(bEHolder.transform, false); newGem.transform.localPosition = positionToVector(position); newGem.GetComponent <IBoardEntity>().setPosition(position); newGem.GetComponent <IBoardEntity>().StartBE(positionToLocalVector); newGem.transform.localScale = new Vector2(beScalar, beScalar); newGem.GetComponent <Fade>().setShow(show, true); board.Add(position, newGem.GetComponent <IBoardEntity>()); return(newGem.GetComponent <IBoardEntity>()); } else { return(null); } }
public List <BoardMatch> getMatches(Dictionary <Position, IBoardEntity> board, int width, int height) { List <BoardMatch> matches = new List <BoardMatch>(); //check cols for (int x = 0; x < width; x++) { for (int y = 0; y < height - 2; y++) { IBoardEntity be1 = get(board, x, y); IBoardEntity be2 = get(board, x, y + 1); IBoardEntity be3 = get(board, x, y + 2); if (be1 != null && be2 != null && be3 != null && be1.getMatchable() && be2.getMatchable() && be3.getMatchable() && be1.getType() == be2.getType() && be2.getType() == be3.getType()) { matches.Add(new BoardMatch(new List <IBoardEntity>() { be1, be2, be3 }, be1.getType())); } } } //check rows for (int y = 0; y < height; y++) { for (int x = 0; x < width - 2; x++) { IBoardEntity be1 = get(board, x, y); IBoardEntity be2 = get(board, x + 1, y); IBoardEntity be3 = get(board, x + 2, y); if (be1 != null && be2 != null && be3 != null && be1.getMatchable() && be2.getMatchable() && be3.getMatchable() && be1.getType() == be2.getType() && be2.getType() == be3.getType()) { matches.Add(new BoardMatch(new List <IBoardEntity>() { be1, be2, be3 }, be1.getType())); } } } List <BoardMatch> combinedMatches = new List <BoardMatch>(); ISet <BoardMatch> usedMatches = new HashSet <BoardMatch>(); foreach (BoardMatch match1 in matches) { foreach (BoardMatch match2 in matches) { if (match1 == match2 || usedMatches.Contains(match1) || usedMatches.Contains(match2)) { continue; } if (match1.boardEntities.Intersect(match2.boardEntities).Count() > 0) { List <IBoardEntity> combindedHashSet = new List <IBoardEntity>(match1.boardEntities); combindedHashSet.AddRange(match2.boardEntities); usedMatches.Add(match1); usedMatches.Add(match2); combinedMatches.Add(new BoardMatch(combindedHashSet)); } } } List <BoardMatch> newMatches = new List <BoardMatch>(); foreach (BoardMatch match in matches) { if (!usedMatches.Contains(match)) { newMatches.Add(match); } } newMatches.AddRange(combinedMatches); return(newMatches); }
public BoardController(IBoardEntity boardEntityService) { _boardEntityService = boardEntityService; }