// generation of joints for a piece public DC_CellDraw SetJoints(int posX, int posY) { DC_CellDraw data = new DC_CellDraw(); // data.posX = posX; // data.posY = posY; data.joints = new List <int>(); data.invs = new List <bool>(); // Side 1 if (posY == 0) { data.joints.Add(0); data.invs.Add(false); } else { data.joints.Add(groups [posX + (posY - 1) * sizeBoardX].cells[0].draw.dataDraw.joints [2]); data.invs.Add(!groups [posX + (posY - 1) * sizeBoardX].cells[0].draw.dataDraw.invs [2]); } // Side 2 if (posX == sizeBoardX - 1) { data.joints.Add(0); data.invs.Add(false); } else { data.joints.Add(Random.Range(1, prefGroup.cells[0].draw.jointMasks.Count)); data.invs.Add(Random.Range(0, 2) == 0 ? false : true); } // Side 3 if (posY == sizeBoardY - 1) { data.joints.Add(0); data.invs.Add(false); } else { data.joints.Add(Random.Range(1, prefGroup.cells[0].draw.jointMasks.Count)); data.invs.Add(Random.Range(0, 2) == 0 ? false : true); } // Side 4 if (posX == 0) { data.joints.Add(0); data.invs.Add(false); } else { data.joints.Add(groups [(posX - 1) + posY * sizeBoardX].cells[0].draw.dataDraw.joints [1]); data.invs.Add(!groups [(posX - 1) + posY * sizeBoardX].cells[0].draw.dataDraw.invs [1]); } return(data); }
public float outline; // offset outline public void SetData(DC_Cell data) { this.data = data; dataDraw = new DC_CellDraw(); foreach (Transform child in transform) { child.localPosition = child.localPosition * outline; child.localScale = new Vector3(data.sizeCellX * 2, data.sizeCellY * 2, 1); MeshRenderer meshChild = child.GetComponent <MeshRenderer>(); meshChild.sharedMaterial = new Material(meshChild.sharedMaterial); } mesh.sharedMaterial.SetTextureScale("_MainTex", new Vector2(data.sizeCellX / data.sizePictX * 2, data.sizeCellY / (float)data.sizePictY * 2)); mesh.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(data.posX * 1f / data.sizeBoardX - 1f / data.sizeBoardX / 2f, (data.posY + 1) * -1f / data.sizeBoardY - 1f / data.sizeBoardY / 2f)); }