void MakeMove(GameCell targetCell) { Animator animator = GetComponentInChildren <Animator>(); animator.SetBool("isWalk", true); transform.LookAt(positionConverter.ConvertBoardPositionToScene(targetCell.GetCoordinates(), true)); iTween.MoveTo(this.gameObject, iTween.Hash( "position", positionConverter.ConvertBoardPositionToScene(targetCell.GetCoordinates(), true), "oncomplete", "TryMove", "time", 3, "easetype", "linear")); }
private void EnableCellHighlight(GameCell cell) { if (!highlightedCells.Contains(cell)) { if (unusedHighlights.Count == 0) { CreateCellHighlight(); } Component highlight = unusedHighlights.Dequeue(); float posX = (cell.GetCoordinates().x *cubeSize) + cubeSize / 2; float posZ = (cell.GetCoordinates().y *cubeSize) + cubeSize / 2; highlight.transform.localPosition = new Vector3(posX, 0.01f, posZ); highlight.gameObject.SetActive(true); highlightsInUse.Enqueue(highlight); highlightedCells.Add(cell); } }
/* RECURSIVE GETTERS FOR CELLS IN BOMB RANGE */ private HashSet <GameCell> GetCellsToExplode(GameCell bombGameCell, int bombRange) { int initialX = (int)bombGameCell.GetCoordinates().x; int initialY = (int)bombGameCell.GetCoordinates().y; HashSet <GameCell> cells = new HashSet <GameCell>(); cells.Add(bombGameCell); HashSet <Bomb> bombs = new HashSet <Bomb>(); bombs.Add(bombGameCell.bomb); InspectCell(cells, bombs, initialX - 1, initialY, RayDirection.LEFT, bombRange); InspectCell(cells, bombs, initialX, initialY + 1, RayDirection.UP, bombRange); InspectCell(cells, bombs, initialX + 1, initialY, RayDirection.RIGHT, bombRange); InspectCell(cells, bombs, initialX, initialY - 1, RayDirection.BOTTOM, bombRange); return(cells); }
public void SpawnEnemies(Board board, PositionConverter positionConverter, Vector2 originPoint) { List <GameCell> freeCells = board.GetFreeCellsAtMinDistance(originPoint, minDistance); freeCells.Shuffle(); for (int i = 0; i < levelConfig.monstersCount; i++) { if (i >= freeCells.Count) { break; } GameCell monsterCell = freeCells[i]; Vector3 monsterPosition = positionConverter.ConvertBoardPositionToScene(monsterCell.GetCoordinates(), true); SpawnEnemiesInPosition(monsterPosition); } }
private void DoPutBombWithTimer(Player player, BombWithTimer bombPrefab, GameCell gameCell) { Vector3 bombPosition = levelManager.GetPositionConverter().ConvertBoardPositionToScene(gameCell.GetCoordinates(), true); bombPosition.y = bombPrefab.transform.localScale.y / 0.85f; BombWithTimer bomb = Instantiate(bombPrefab, bombPosition, Quaternion.identity) as BombWithTimer; bomb.player = player.gameObject; bomb.detonateDelay = GameManager.instance.GetBombDetonateDelay(); bomb.explosionRange = GameManager.instance.GetPlayer().bombRange; gameCell.bomb = bomb; AddToBombMap(player, bomb, gameCell); StartCoroutine(HandleBombPlaced(player, bomb, gameCell)); }