void TryPlaceAfterHitting(short hitX, short hitZ) { TileMap tileMap = GameManager.Instance.TileMap; bool canPlaceX = !tileMap.HasBlock((short)(Velocity.x < 0 ? hitX + 1 : hitX - 1), hitZ); bool canPlaceZ = !tileMap.HasBlock(hitX, (short)(Velocity.z < 0 ? hitZ + 1 : hitZ - 1)); if (!canPlaceX && !canPlaceZ) { // Place diagonal if (Velocity.x < 0) { hitX++; } else { hitX--; } if (Velocity.z < 0) { hitZ++; } else { hitZ--; } } else { if ((Mathf.Abs(Velocity.x) > Mathf.Abs(Velocity.z) && canPlaceX) || !canPlaceZ) { if (Velocity.x < 0) { hitX++; } else { hitX--; } } else { if (Velocity.z < 0) { hitZ++; } else { hitZ--; } } } if (ColorType != null && !GameManager.Instance.IsOutOfBounds(hitX, hitZ)) { GameManager.Instance.PlayCrystaliseSound(); tileMap.SetBlock(hitX, hitZ, ColorType ?? Game.ColorType.RED); } }
void GenerateStartMap() { for (short x = (short)-xRadius; x <= xRadius; x++) { TileMap.SetBlock(x, (short)-yRadius, ColorUtils.GetRandomColorType(), false); TileMap.SetBlock(x, (short)yRadius, ColorUtils.GetRandomColorType(), false); } for (short y = (short)(-yRadius + 1); y < yRadius; y++) { TileMap.SetBlock((short)-xRadius, y, ColorUtils.GetRandomColorType(), false); TileMap.SetBlock((short)xRadius, y, ColorUtils.GetRandomColorType(), false); } }
public void StartNewRound() { WaveCount++; WaveTimer = WaveDuration; int oldXRadius = xRadius; int oldYRadius = yRadius; xRadius = 16 + (WaveCount - 1) * SizePerWaveIncrement; yRadius = 16 + (WaveCount - 1) * SizePerWaveIncrement; Walls.Resize(xRadius, yRadius); // Left for (int x = -xRadius; x < -oldXRadius; x++) { for (int y = -yRadius; y <= yRadius; y++) { TileMap.SetBlock((short)x, (short)y, ColorUtils.GetRandomColorType(), false); } } // Right for (int x = oldXRadius + 1; x <= xRadius; x++) { for (int y = -yRadius; y <= yRadius; y++) { TileMap.SetBlock((short)x, (short)y, ColorUtils.GetRandomColorType(), false); } } // Up for (int x = -oldXRadius; x <= oldXRadius; x++) { for (int y = -yRadius; y < -oldYRadius; y++) { TileMap.SetBlock((short)x, (short)y, ColorUtils.GetRandomColorType(), false); } } // Down for (int x = -oldXRadius; x <= oldXRadius; x++) { for (int y = oldYRadius + 1; y <= yRadius; y++) { TileMap.SetBlock((short)x, (short)y, ColorUtils.GetRandomColorType(), false); } } }