Пример #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;
                //				}
            }
        }
Пример #2
0
        // ## Neighbor Remove ##
        // This method is a handler for the NeighborRemove event. It is triggered
        // when two cubes that were neighbored are separated.
        //
        // The side arguments for this event are the sides that the cubes
        // _were_ neighbored on before they were separated. If you check the
        // current state of their neighbors on those sides, they should of course
        // be NONE.
        private void OnNeighborRemove(Cube cube1, Cube.Side side1, Cube cube2, Cube.Side side2)
        {
            Log.Debug("Neighbor remove: {0}.{1} <-> {2}.{3}", cube1.UniqueId, side1, cube2.UniqueId, side2);

            CubeWrapper wrapper = (CubeWrapper)cube1.userData;

            if (wrapper != null)
            {
                wrapper.mScale = 1;
                //wrapper.mRotation = 0;
                wrapper.mNeedDraw = true;
            }

            wrapper = (CubeWrapper)cube2.userData;
            if (wrapper != null)
            {
                wrapper.mScale = 1;
                //wrapper.mRotation = 0;
                wrapper.mNeedDraw = true;
            }
        }
Пример #3
0
        // Here we initialize our app.
        public override void Setup()
        {
            // Load up the list of images.
            mImageNames = LoadImageIndex();

            // Load up the list of games.
            ArrayList mGame1 = new ArrayList ("8", "plus", "7", "mult", "3", "res29");
            ArrayList mGame2 = new ArrayList ("6", "mult", "7", "mult", "2", "res84");
            ArrayList mGame3 = new ArrayList ("4", "mult", "5", "minus", "2", "res18");
            ArrayList mGame4 = new ArrayList ("6", "plus", "4", "mult", "8", "res38");
            ArrayList mGame5 = new ArrayList ("9", "mult", "7", "div", "3", "res21");
            ArrayList mGame6 = new ArrayList ("5", "mult", "7", "plus", "8", "res43");
            ArrayList mGame7 = new ArrayList ("6", "div", "2", "mult", "4", "res12");
            ArrayList mGame8 = new ArrayList ("5", "div", "1", "plus", "9", "res14");
            ArrayList mGame9 = new ArrayList ("3", "mult", "8", "mult", "4", "res96");

            ArrayList mGamesArray = new ArrayList (mGame1, mGame2, mGame3, mGame4, mGame5, mGame6, mGame7, mGame8, mGame9);

            int cnt = 0;
            foreach (Cube cube in CubeSet) {

                // Create a wrapper object for each cube. The wrapper object allows us
                // to bundle a cube with extra information and behavior.
                CubeWrapper wrapper = new CubeWrapper(this, cube, 'o');
                mWrappers.Add(wrapper); // add wrapper including individual cube into wrapper-list
                wrapper.DrawSlide(mGame1[cnt][0]);
                cnt++;
            }

            //*******************************************************************
            //TEMP FIRST TEST - FillCube with Color and Rect
            //*******************************************************************
            // ### Color ###
            // A Color object represents an RGB color.
            //Color color = new Color (170, 218, 85);

            // ### FillScreen ###
            // FillScreen paints the cube's entire screen the given color.
            //cube.FillScreen (color);

            // ### FillRect ###
            // FillRect draws a rectangle on the cube's screen at a given location
            // in a given size and color. A cube's screen is 128x128 pixels. Here
            // we draw a big square in the center of the screen.
            //int x = 24;
            //int y = 24;
            //int width = 80;
            //int height = 80;
            //color = new Color (100, 182, 255);
            //cube.FillRect (color, x, y, width, height);
            //*******************************************************************

            // ## Event Handlers ##
            // Objects in the Sifteo API (particularly BaseApp, CubeSet, and Cube)
            // fire events to notify an app of various happenings, including actions
            // that the player performs on the cubes.
            //
            // To listen for an event, just add the handler method to the event. The
            // handler method must have the correct signature to be added. Refer to
            // the API documentation or look at the examples below to get a sense of
            // the correct signatures for various events.
            //
            // **NeighborAddEvent** and **NeighborRemoveEvent** are triggered when
            // the player puts two cubes together or separates two neighbored cubes.
            // These events are fired by CubeSet instead of Cube because they involve
            // interaction between two Cube objects. (There are Cube-level neighbor
            // events as well, which comes in handy in certain situations, but most
            // of the time you will find the CubeSet-level events to be more useful.)
            CubeSet.NeighborAddEvent += OnNeighborAdd;
            CubeSet.NeighborRemoveEvent += OnNeighborRemove;
        }
Пример #4
0
        // Here we initialize our app.
        public override void Setup()
        {
            // Load up the list of images.
            mImageNames = LoadImageIndex();

            // Load up the list of games.
            ArrayList mGame1 = new ArrayList("8", "plus", "7", "mult", "3", "res29");
            ArrayList mGame2 = new ArrayList("6", "mult", "7", "mult", "2", "res84");
            ArrayList mGame3 = new ArrayList("4", "mult", "5", "minus", "2", "res18");
            ArrayList mGame4 = new ArrayList("6", "plus", "4", "mult", "8", "res38");
            ArrayList mGame5 = new ArrayList("9", "mult", "7", "div", "3", "res21");
            ArrayList mGame6 = new ArrayList("5", "mult", "7", "plus", "8", "res43");
            ArrayList mGame7 = new ArrayList("6", "div", "2", "mult", "4", "res12");
            ArrayList mGame8 = new ArrayList("5", "div", "1", "plus", "9", "res14");
            ArrayList mGame9 = new ArrayList("3", "mult", "8", "mult", "4", "res96");

            ArrayList mGamesArray = new ArrayList(mGame1, mGame2, mGame3, mGame4, mGame5, mGame6, mGame7, mGame8, mGame9);

            int cnt = 0;

            foreach (Cube cube in CubeSet)
            {
                // Create a wrapper object for each cube. The wrapper object allows us
                // to bundle a cube with extra information and behavior.
                CubeWrapper wrapper = new CubeWrapper(this, cube, 'o');
                mWrappers.Add(wrapper);                 // add wrapper including individual cube into wrapper-list
                wrapper.DrawSlide(mGame1[cnt][0]);
                cnt++;
            }


            //*******************************************************************
            //TEMP FIRST TEST - FillCube with Color and Rect
            //*******************************************************************
            // ### Color ###
            // A Color object represents an RGB color.
            //Color color = new Color (170, 218, 85);

            // ### FillScreen ###
            // FillScreen paints the cube's entire screen the given color.
            //cube.FillScreen (color);

            // ### FillRect ###
            // FillRect draws a rectangle on the cube's screen at a given location
            // in a given size and color. A cube's screen is 128x128 pixels. Here
            // we draw a big square in the center of the screen.
            //int x = 24;
            //int y = 24;
            //int width = 80;
            //int height = 80;
            //color = new Color (100, 182, 255);
            //cube.FillRect (color, x, y, width, height);
            //*******************************************************************



            // ## Event Handlers ##
            // Objects in the Sifteo API (particularly BaseApp, CubeSet, and Cube)
            // fire events to notify an app of various happenings, including actions
            // that the player performs on the cubes.
            //
            // To listen for an event, just add the handler method to the event. The
            // handler method must have the correct signature to be added. Refer to
            // the API documentation or look at the examples below to get a sense of
            // the correct signatures for various events.
            //
            // **NeighborAddEvent** and **NeighborRemoveEvent** are triggered when
            // the player puts two cubes together or separates two neighbored cubes.
            // These events are fired by CubeSet instead of Cube because they involve
            // interaction between two Cube objects. (There are Cube-level neighbor
            // events as well, which comes in handy in certain situations, but most
            // of the time you will find the CubeSet-level events to be more useful.)
            CubeSet.NeighborAddEvent    += OnNeighborAdd;
            CubeSet.NeighborRemoveEvent += OnNeighborRemove;
        }