public void Configure(Level.LevelType type, PuzzleState state, int index, Texture image = null) { this.type = type; if (type == Level.LevelType.sided || type == Level.LevelType.simple) { this.colorIndex = state.ColorIndex(index); mr.material = MatPool.GetMaterial(new MaterialKey { colorIndex = colorIndex, type = type }); } else { mr.material = plainMaterial; if (type == Level.LevelType.image) { mr.material.SetTexture("_MainTex", image); float vInc = (float)(1f / state.Count); float startV = vInc * state.ColorIndex(index); var mesh = GetComponent <MeshFilter>().mesh; mesh.uv = GeneratePiecesUVs(vInc, startV); mr.material.color = Color.white; } } }
public void TestStateBasics() { short[] simple = new short[] { 0, 1, 2, 3 }; PuzzleState ps = new PuzzleState(simple, 4); Assert.AreEqual(ps.Count, 4, "State has 4 pieces"); Assert.AreEqual(ps.numColors, 4, "State has 4 colors"); Assert.IsFalse(ps.sided, "state is sided"); for (int i = 0; i < ps.Count; i++) { Assert.False(ps.Rotated(i), "piece not rotated"); Assert.AreEqual(ps.ColorIndex(i), simple[i], "color index matches initial config"); } var ps1 = ps.Flip(new Move(0, Side.Left)); Assert.AreEqual(ps, ps1, "Flipping 1L on simple does not change state"); var ps2 = ps.Flip(new Move(0, Side.Right)).Flip(new Move(0, Side.Right)); Assert.AreEqual(ps, ps2, "Flipping 1R,1R returns same state as original"); }