public bool GetPropperPiece(AddCubeCfg[] adds, int category, ref int rotation, ref int meshNumber, List <AdaptableBlock> blocks) { UpdateCubeConfig(blocks); if (config.IsVisible()) { meshNumber = 0; int maxCoopt = -1; for (int i = 0; i < adds.Length; i++) { AddCubeCfg addy = adds[i]; if (((category == addy.Category) || (category == 0))) { int newRotation = 0; int newCoopt = config.CompareWithWorld(addy, ref newRotation); if (newCoopt > maxCoopt) { rotation = newRotation; meshNumber = i; maxCoopt = newCoopt; // Debug.Log("Success at " + bestRotation); } } } return(true); } return(false); }
public void CopyFrom(AddCubeCfg from) { for (int i = 0; i < 27; i++) { p[i] = from.p[i]; } }
static int Compare(AddCubeCfg a, AddCubeCfg b) { int sum = 0; for (int i = 0; i < 27; i++) { if (a.p[i] == b.p[i]) { sum += (a.p[i] == BlockSetting.Any ? 0 : 1); } else if ((a.p[i] != BlockSetting.Any) && (b.p[i] != BlockSetting.Any)) { return(-1); } } return(sum); }
public void WriteCubeCfg(AddCubeCfg a) { String str = "fdsf "; for (int i = 0; i < 27; i++) { str += a.p[i] + " "; } Debug.Log(str); for (int i = 2; i >= 0; i--) { for (int j = 2; j >= 0; j--) { Debug.Log(a.p[i * 9 + j * 3] + "," + a.p[i * 9 + j * 3 + 1] + "," + a.p[i * 9 + j * 3 + 2] + " ----- " + UnityEngine.Random.Range(0, 99999).ToString()); } } }
public int CompareWithWorld(AddCubeCfg w, ref int rot) { AddCubeCfg tmp = Playtime_Painter.MeshManager.Inst.tmpCubeCfg; tmp.CopyFrom(this); int maxScore = -1; for (int i = 0; i < 4; i++) { int val = Compare(w, tmp); if (val > maxScore) { maxScore = val; rot = i; } if (i < 3) { tmp.Spin(); } } return(maxScore); }