public void Puzzle1() { var input = new FileReader() .GetResource("AdventOfCode2020.Tests.Day24.PuzzleInput.txt"); var tiles = TileFinder.FindTiles(input); Assert.Equal(269, tiles.Values.Count(tile => tile.Colour == Colour.Black)); }
public void FlipStartingTile() { const string input = "nwwswee"; var tiles = TileFinder.FindTiles(input); var expectedPosition = new Position(0, 0); Assert.True(tiles.ContainsKey(expectedPosition.GetKey())); Assert.Equal(1, tiles.Values.Count(tile => tile.Colour == Colour.Black)); }
public void Puzzle2() { var input = new FileReader() .GetResource("AdventOfCode2020.Tests.Day24.PuzzleInput.txt"); var tiles = TileFinder.FindTiles(input); var dayFlipper = new DayTileFlipper(); for (var i = 0; i < 100; i++) { tiles = dayFlipper.FlipTilesForDay(tiles); } Assert.Equal(3667, tiles.Values.Count(tile => tile.Colour == Colour.Black)); }
public void TurnOver() { OnDeselect(); if (!IsSpawning) { return; } currentSpawnTimer--; if (currentSpawnTimer > 0) { return; } foreach (var hex in TileFinder.FindTiles(this.gameObject.transform.parent.gameObject, 2)) { if (hex.transform.childCount != 0) { continue; } SpawnHex = hex; break; } if (SpawnHex == null) { Debug.Log(this.name + " unitspawn is blocked"); } else { GameObject unit = Instantiate(Unit, SpawnHex.transform); unit.GetComponent <Unit>().player = Player; unit.GetComponent <Unit>().Render(Player); Player.UnitList.Add(unit); } IsSpawning = false; SpawnHex = null; transform.GetChild(1).GetChild(1).GetComponent <Image>().fillAmount = 0; }
private void FindTiles(GameObject baseHex, bool fromActivePlayer) { Deselect(); Unit unitScript = baseHex.GetComponentInChildren <Unit>(); movementHexes = TileFinder.FindTiles(baseHex, (int)unitScript.rangeLeft); if (fromActivePlayer && unitScript.canAttack) { attackHexes = TileFinder.FindTiles(baseHex, (int)unitScript.attackRange); } foreach (var hex in movementHexes) { if (hex.transform.childCount == 0) { hex.GetComponent <Renderer>().material.color = Color.green; } } foreach (var hex in attackHexes) { if (hex.transform.childCount <= 0) { continue; } if (hex.transform.GetComponentInChildren <Unit>() != null && !hex.transform.GetComponentInChildren <Unit>().player.isCurrentPlayer) { hex.GetComponent <Renderer>().material.color = Color.red; } else if (hex.transform.GetComponentInChildren <newFactory>() != null && !hex.transform.GetComponentInChildren <newFactory>().Player.isCurrentPlayer) { hex.GetComponent <Renderer>().material.color = Color.red; } } }