예제 #1
0
        // ## Neighbor Add ##
        // This method is a handler for the NeighborAdd event. It is triggered when
        // two cubes are placed side by side.
        //
        // Cube1 and cube2 are the two cubes that are involved in this neighboring.
        // The two cube arguments can be in any order; if your logic depends on
        // cubes being in specific positions or roles, you need to add logic to
        // this handler to sort the two cubes out.
        //
        // Side1 and side2 are the sides that the cubes neighbored on.
        private void OnNeighborAdd(Cube cube1, Cube.Side side1, Cube cube2, Cube.Side side2)
        {
            Log.Debug("Neighbor add: {0}.{1} <-> {2}.{3}", cube1.UniqueId, side1, cube2.UniqueId, side2);

            CubeWrapper wrapper = (CubeWrapper)cube1.userData;

            if (wrapper != null)
            {
                // Here we set our wrapper's rotation value so that the image gets
                // drawn with its top side pointing towards the neighbor cube.
                //
                // Cube.Side is an enumeration (TOP, LEFT, BOTTOM, RIGHT, NONE). The
                // values of the enumeration can be cast to integers by counting
                // counterclockwise:
                //
                // * TOP = 0
                // * LEFT = 1
                // * BOTTOM = 2
                // * RIGHT = 3
                // * NONE = 4
                //wrapper.mRotation = (int)side1;
                wrapper.mNeedDraw = true;
            }

            wrapper = (CubeWrapper)cube2.userData;
            if (wrapper != null)
            {
                //wrapper.mRotation = (int)side2;
                wrapper.mNeedDraw = true;
            }


            //TODO: Siegüberprüfung:
            Cube[] row = CubeHelper.FindRow(CubeSet);
            if (row.Length == totalCubes)
            {
                Log.Debug("6 connected");
                //found = true;
                //int lastId = -1;
                //foreach (Cube cube in row) {
                //					CubeWrapper wrapper = (CubeWrapper)cube.userData;
                //					if (wrapper.mIndex < lastId)
                //						found = false;
                //					lastId = wrapper.mIndex;
                //				}
            }
        }