public CubeSegment(Vector3 position3, bool isForward) { this.owner = new int[4]; this.isUnlocked = new bool[4]; this.colorOverlay = new Color[4]; for (int i = 0; i < 4; ++i) { this.owner[i] = -1; this.isUnlocked[i] = true; this.colorOverlay[i] = Color.White; } this.isForward = isForward; this.position3 = position3; matWorld = Matrix.CreateTranslation(position3); squares = new MatchPiece[numSquaresTotal]; for (int i = 0; i < numSquaresTotal; ++i) squares[i] = new MatchPiece(this, i % numSquaresAcross - (numSquaresAcross / 2.0f), squareWidth, i / numSquaresAcross, (numSquaresAcross / 2.0f)); //setup normals for each side, from front to left-side normals = new Vector3[4]; normals[0] = new Vector3(0, 0, 1); normals[1] = new Vector3(1, 0, 0); normals[2] = new Vector3(0, 0, -1); normals[3] = new Vector3(-1, 0, 0); //DEBUG - test //Matrix rotMatrix = Matrix.CreateRotationY((float)MathHelper.PiOver4); //matWorld = rotMatrix * Matrix.CreateTranslation(position3); ////rotate the normals //for (int i = 0; i < 4; i++) //{ // normals[i] = Vector3.TransformNormal(normals[i], rotMatrix); //} ////end debug float segWidth = numSquaresAcross* squareWidth/2; //top Cap VertexPositionColorTexture[] top = new VertexPositionColorTexture[4]; top[0] = new VertexPositionColorTexture(new Vector3(segWidth, 0, -segWidth), color, new Vector2(0,0)); top[1] = new VertexPositionColorTexture(new Vector3(segWidth, 0, segWidth), color, new Vector2(1,0)); top[2] = new VertexPositionColorTexture(new Vector3(-segWidth, 0, -segWidth), color, new Vector2(0,1)); top[3] = new VertexPositionColorTexture(new Vector3(-segWidth, 0, segWidth), color, new Vector2(1,1)); topBuff = new VertexBuffer(device, typeof(VertexPositionColorTexture), top.Length, BufferUsage.WriteOnly); topBuff.SetData<VertexPositionColorTexture>(top); //bottom Cap VertexPositionColorTexture[] bottom = new VertexPositionColorTexture[4]; bottom[0] = new VertexPositionColorTexture(new Vector3(segWidth, -squareWidth, segWidth), color, new Vector2(0, 0)); bottom[1] = new VertexPositionColorTexture(new Vector3(segWidth, -squareWidth, -segWidth), color, new Vector2(1, 0)); bottom[2] = new VertexPositionColorTexture(new Vector3(-segWidth, -squareWidth, segWidth), color, new Vector2(0, 1)); bottom[3] = new VertexPositionColorTexture(new Vector3(-segWidth, -squareWidth, -segWidth), color, new Vector2(1, 1)); bottomBuff = new VertexBuffer(device, typeof(VertexPositionColorTexture), bottom.Length, BufferUsage.WriteOnly); bottomBuff.SetData<VertexPositionColorTexture>(bottom); }
public void Attach(MatchPiece piece) { if (grabPiece != null && grabbing) matchPiece = piece; else matchPiece = null; }
private void ResetSide(int j) { for (int i = j*numSquaresAcross; i < (j+1)*numSquaresAcross; ++i) squares[i] = new MatchPiece(this, i % numSquaresAcross - (numSquaresAcross / 2.0f), squareWidth, i / numSquaresAcross, (numSquaresAcross / 2.0f)); owner[j] = -1; isUnlocked[j] = true; colorOverlay[j] = Color.White; GameObject.PlaySound(ROW_COMPLETION_SOUND); }
private void ResetSide(int j) { for (int i = j*numSquaresAcross; i < (j+1)*numSquaresAcross; ++i) squares[i] = new MatchPiece(this, i % numSquaresAcross - (numSquaresAcross / 2.0f), squareWidth, i / numSquaresAcross, (numSquaresAcross / 2.0f)); owner[j] = -1; isUnlocked[j] = true; colorOverlay[j] = Color.White; }