// Red cube removes all surroung cubes when shot. public override void Hit(CubesWallHandler cubesWallHandler, CubeGenerator cubeGenerator) { for (uint row = y == 0 ? 0 : y - 1; row <= y + 1; ++row) { for (uint col = x == 0 ? 0 :x - 1; col <= x + 1; ++col) { cubesWallHandler.Remove(col, row, col == x && row == y ? false : true); } } }
// White cube replaces all surroung cubes when shot, with 1 basic color. public override void Hit(CubesWallHandler cubesWallHandler, CubeGenerator cubeGenerator) { cubeGenerator.GetRandomBasicColor(out var colorMaterial, out var colorAnimation); for (uint row = y == 0 ? 0 : y - 1; row <= y + 1; ++row) { for (uint col = x == 0 ? 0 :x - 1; col <= x + 1; ++col) { cubesWallHandler.Replace(col, row, colorMaterial, colorAnimation, "CubeBehavior"); } } cubesWallHandler.Remove(x, y); }
/// <summary> /// Represents the action to take once a cube is shot. /// For basic cubes, the default behaviour is to remove the cube. /// Other classes might override this behaviour such as red and white cubes. /// </summary> virtual public void Hit(CubesWallHandler cubesWallHandler, CubeGenerator cubeGenerator) { cubesWallHandler.Remove(x, y); }