Example #1
0
 private void OnButton(Cube cube, bool pressed)
 {
     if (pressed) {
     Sound sound = app.sounds[app.imageNames[app.wrappers[cube.UniqueId].index]];
     sound.Play(1,0);
     }
 }
Example #2
0
 public SiftOscCubeEvent(Cube cube, OscClient client, IPEndPoint endPoint, List<SiftOscEventMessage> messages)
 {
     this.cube = cube;
       this.client = client;
       this.endPoint = endPoint;
       this.messages = messages;
 }
Example #3
0
        public CubeWrapper(MathScramble app, Cube cube, int seq)
        {
            mApp = app;
            mCube = cube;
            mCube.userData = this;
            mSpriteIndex = 0;
            //mRectColor = new Color (36, 182, 255);
            //mSelectColor = new Color (255, 0, 0);
            mRotation = 0;
            mCube.TiltEvent += OnTilt;
            mIndex = seq;

            mCube.ButtonEvent += HandleCubeButtonEvent;
            mCube.ShakeStartedEvent += HandleMCubeShakeStartedEvent;

            //Init the State Machine
            mRole = mApp.cubeStates [seq - 1];
            InitStateMachine ();

            //
            mValue = mRole.GenerateValue ();
            mColor = mRole.mColor;
            mSize = mRole.mSize;

            /*
            if (mCubeStateMachine.Current == Constants.HintState) {
                mNeedDraw = true;
                Tick ();
            }*/

            //
        }
 public CubeEventReporter(JsonTcpCommunication com, Cube c)
 {
     _com = com;
     _c = c;
     Reporters.Add (this);
     ReportAllEvents ();
 }
Example #5
0
 public static FaderHelper getFaderHelper(Cube c)
 {
     if (!_lookup.ContainsKey (c.UniqueId)) {
         _lookup [c.UniqueId] = new FaderHelper (c);
     }
     return _lookup [c.UniqueId];
 }
        public CubeWrapper(EColiTest app, Cube cube)
        {
            mApp = app;
            mCube = cube;
            mCube.userData = this; 

            //Ensures that whatever color first appears on the cube is the color instance variable
            if (mCubeType == 0)
            {
                if (mApp.mImageNames[colorIndex].Contains("red")) this.color = "red";
                if (mApp.mImageNames[colorIndex].Contains("blue")) this.color = "blue";
                if (mApp.mImageNames[colorIndex].Contains("yellow")) this.color = "yellow";
            }

            mApp.whitePlasmidController.mCube = this.mCube;
            
            eColiColor = "white";
            plasmidColor = "white";

            //Adding the event handlers
            mCube.ButtonEvent += OnButton;
            mCube.TiltEvent += OnTilt;
            mCube.FlipEvent += OnFlip;

        }
Example #7
0
        private void OnTilt(Cube cube, Cube.Side direction)
        {
            switch (direction)
            {
                case Cube.Side.TOP:
                    cube.FillRect(new Color(0, 200, 0), 54, 54, 20, 20); // increasingly dark green
                    break;

                case Cube.Side.BOTTOM:
                    cube.FillRect(new Color(0, 150, 0), 54, 54, 20, 20);
                    break;

                case Cube.Side.LEFT:
                    cube.FillRect(new Color(0, 100, 0), 54, 54, 20, 20);
                    break;

                case Cube.Side.RIGHT:
                    cube.FillRect(new Color(0, 50, 0), 54, 54, 20, 20);
                    break;
                default:
                    cube.FillRect(Color.White, 54, 54, 20, 20); // extremely light green
                    break;
            }

            cube.Paint();
        }
 int addPrimary(Cube a, Cube b)
 {
     if (a.Neighbors.Right != null || a.Neighbors.Bottom != null)
         AddCubeToArray (a,0);
     else
         AddCubeToArray(b,0);
     return 0;
 }
 private void OnPress(Cube cube, bool press)
 {
     if (!this.justPressed)
       {
       Console.WriteLine("Button pressed");
       app.Answer(cube);
       }
       this.justPressed = !this.justPressed;
 }
Example #10
0
        public OperatorController(Cube cube)
        {
            Log.Debug (classname + " Init");
            mCube = cube;
            mWrapper = (CubeWrapper)cube.userData;

            mCube.NeighborAddEvent += OnNeighborAdd;
            mCube.NeighborRemoveEvent += OnNeighborRemove;
        }
 private void NeighborAddNotification(Cube c, Cube.Side side, Cube neighbor, Cube.Side neighborSide)
 {
     Dictionary<String, Object> parameters = new Dictionary<String, Object> ();
     String msg = "neighborAdded";
     parameters.Add ("neighborId", neighbor.UniqueId);
     parameters.Add ("cubeSide", side.ToString ());
     parameters.Add ("neighborSide", neighborSide.ToString ());
     this.NotifyEvent (msg, c, parameters);
 }
Example #12
0
        /*
         * Constructor with color and size
         */
        public StringPainter(Cube cube, String label, System.Drawing.Color color, int size)
        {
            Log.Debug ("StringPainter {0}", label);
            mCube = cube;

            fontSize = size;
            fontColor = color;
            writeWord (label, mCube);
        }
 public CubeWrapper(SorterApp app, Cube cube, int seq)
 {
     mApp = app;
       mCube = cube;
       mCube.userData = this;
       mSpriteIndex = 0;
       mRectColor = new Color(36, 182, 255);
       mIndex = seq;
 }
Example #14
0
        /*
         * Constructor
         */
        public StringPainter(Cube cube, String label)
        {
            Log.Debug ("StringPainter {0}", label);
            mCube = cube;

            fontSize = 50;
            fontColor = System.Drawing.Color.Black;
            writeWord (label, mCube);
        }
Example #15
0
        /*
         * Constructor with color and size
         */
        public StringPainter(Cube cube, String label, System.Drawing.Color color, float size)
        {
            Log.Debug ("StringPainter {0}", label);
            mCube = cube;

            fontSize = size;
            //fontColor = System.Drawing.Color.FromArgb (color.Data);
            fontColor = color;
            writeWord (label, mCube);
        }
 private void ButtonNotification(Cube c, bool isPressed)
 {
     String msg;
     if (isPressed) {
         msg = "pressed";
     } else {
         msg = "released";
     }
     this.NotifyEvent (msg, c);
 }
Example #17
0
        public CubeWrapper(AnimalMatchApp app, Cube cube)
        {
            this.app = app;
            this.cube = cube;
            cube.userData = this;
            index = 0;

            cube.ButtonEvent += OnButton;
            cube.TiltEvent += OnTilt;
        }
Example #18
0
        public ResultController(Cube cube)
        {
            Log.Debug (classname + " Init");
            mCube = cube;
            mWrapper = (CubeWrapper)cube.userData;

            //Event listeners
            mCube.NeighborAddEvent += OnNeighborAdd;
            mCube.NeighborRemoveEvent += OnNeighborRemove;
        }
Example #19
0
        public CubeWrapper(FreeStyleApp app, Cube cube)
        {
            mApp = app;
              mCube = cube;
              mCube.userData = this;

              // Here we attach more event handlers for button and accelerometer actions.
              mCube.ButtonEvent += OnButton;
              mCube.ShakeStoppedEvent += OnShakeStopped;
              mCube.FlipEvent += OnFlip;
        }
Example #20
0
        /*
         * Consturctor
         */
        public DominoPainter(Cube cube, int number, System.Drawing.Color color)
        {
            Log.Debug ("DominoPainter {0}", number);
            mCube = cube;
            //System.Drawing.Color.FromArgb (color.Data);
            //String rtn = String.Empty;

            //rtn = "#" + color.R.ToString ("X2") + color.G.ToString ("X2") + color.B.ToString ("X2");
            //rtn = "RGB(" + color.R.ToString () + "," + color.G.ToString () + "," + color.B.ToString () + ")";
            //Log.Debug (rtn);
            mRectColor = new Sifteo.Color (Convert.ToInt32 (color.R.ToString ()), Convert.ToInt32 (color.G.ToString ()), Convert.ToInt32 (color.B.ToString ()));
            //mRectColor = new Sifteo.Color (Convert.ToInt32 (color.R.ToString ("X2")), Convert.ToInt32 (color.G.ToString ("X2")), Convert.ToInt32 (color.B.ToString ("X2")));

            switch (number) {
            case 1:
                one ();
                break;
            case 2:
                two ();
                break;
            case 3:
                three ();
                break;
            case 4:
                four ();
                break;
            case 5:
                five ();
                break;
            case 6:
                six ();
                break;
            case 7:
                seven ();
                break;
            case 8:
                eight ();
                break;
            case 9:
                nine ();
                break;
            default:

                if (number == 0) {
                    //Do Nothing
                } else if (number > 9) {
                    tilePaint2 (number);
                }

                break;

            }
        }
 void AddCubeToArray(Cube c, int index)
 {
     if (index < 0 || index >= cubes.Length)
         return;
     RemoveCubeFromArray (c);
     if (cubes[index] != null)
         RemoveCubeFromArray (cubes[index]);
     c.FillScreen(Color.Black);
     c.Image("heart_"+heartChar+"_"+index, 0, 0, 0, 0, 128, 128, 1, 0);
     c.Paint();
     cubes[index] = c;
 }
Example #22
0
        /*
         * Constructor
         */
        public StringPainter(Cube cube, String label)
        {
            Log.Debug ("StringPainter {0}", label);
            mCube = cube;

            fontSize = 50;

            Sifteo.Color myColor = Sifteo.Color.Black;
            fontColor = System.Drawing.Color.FromArgb (myColor.Data);

            writeWord (label, mCube);
        }
 private void FlipNotification(Cube c, bool newOrientationIsUp)
 {
     if (!c.IsShaking) {//NOTE during the test I noticed that shaking a cube fire randomly some flip event...
         //Thus this test should prevent it
         String msg;
         if (newOrientationIsUp) {
             msg = "flipedUp";
         } else {
             msg = "flipDown";
         }
         this.NotifyEvent (msg, c);
     }
 }
Example #24
0
 public void Answer(Cube cube)
 {
     if (!this.lost && cube.Equals(this.coloredCubeWrapper.cube))
     {
     this.lastFrame = this.currentFrame;
     this.Repaint();
     this.framesBetweenUpdates--;
     if (this.framesBetweenUpdates < 5) this.framesBetweenUpdates = 3;
     }
     else
     {
     this.YouLose("Wrong cube");
     }
 }
Example #25
0
        public CubeWrapper(Groovy app, Cube cube)
        {
            mApp = app;
            mCube = cube;
            mCube.userData = this;
            mIndex = 0;

            // Here we attach more event handlers for button and accelerometer actions.
            mCube.ButtonEvent += OnButton;
            // mCube.TiltEvent += OnTilt;
            mCube.ShakeStartedEvent += OnShakeStarted;
            mCube.ShakeStoppedEvent += OnShakeStopped;
            // mCube.FlipEvent += OnFlip;
        }
        public CubeWrapper(SlideShowApp app, Cube cube, AMQConnector amq)
        {
            mApp = app;
            mCube = cube;
            mCube.userData = this;
            mIndex = 0;
            amqConn = amq;

            // Here we attach more event handlers for button and accelerometer actions.
            mCube.ButtonEvent += OnButton;
            mCube.TiltEvent += OnTilt;
            mCube.ShakeStartedEvent += OnShakeStarted;
            mCube.ShakeStoppedEvent += OnShakeStopped;
            mCube.FlipEvent += OnFlip;
        }
Example #27
0
        public ShuffleCube(GameShuffleController app, Cube cube, int seq)
        {
            mApp = app;
            mCube = cube;
            mCube.userData = this;
            mSpriteIndex = 0;
            mRectColor = new Color (36, 182, 255);
            mSelectColor = new Color (255, 0, 0);
            mRotation = 0;
            mCube.TiltEvent += OnTilt;
            mIndex = seq;

            mCube.ButtonEvent += HandleCubeButtonEvent;

            //mCubeStateController
        }
Example #28
0
        public static void DisplayMessage(Cube c, String msg, SiftColor color)
        {
            ImageSurface sr = new ImageSurface (Format.ARGB32, 128, 128);
            Cairo.Context context = new Cairo.Context (sr);

            context.Color = new Cairo.Color (0, 0, 0, 0);
            context.Paint ();
            Pango.Layout pango = Pango.CairoHelper.CreateLayout (context);

            pango.FontDescription = Pango.FontDescription.FromString ("Arial 16");
            pango.Alignment = Alignment.Center;
            pango.Wrap = WrapMode.WordChar;
            pango.Width = 128 * 1016;
            pango.SetText (msg);

            context.Color = color.ToCairo ();
            int pWidth = 0, pHeight = 0;
            pango.GetPixelSize (out pWidth, out pHeight);
            Log.Debug ("pango Pixel size: " + pWidth + "x" + pHeight);

            context.MoveTo (0, 64 - (pHeight / 2));
            CairoHelper.ShowLayout (context, pango);
            sr.Flush ();
            byte[] data = sr.Data;

            for (int i = 0, x = 0, y = 0; i < data.Length; i += 4, x++) {
                if (x >= 128) {
                    x = 0;
                    y++;
                }
                byte b = data [i],
                g = data [i + 1],
                r = data [i + 2],
                a = data [i + 3];
                if (a != 0 || r != 0 || g != 0 || b != 0) {
                    SiftColor sc = new SiftColor (r, g, b);
                    c.FillRect (sc.ToSifteo (), x, y, 1, 1);
                } else {
                    // we ignore it
                }
            }
            ((IDisposable)context).Dispose ();
            ((IDisposable)pango).Dispose ();
            ((IDisposable)sr).Dispose ();
        }
Example #29
0
 public void DoButton(Cube c, bool pressed)
 {
     if ( FlippedCubes.Count == this.CubeSet.Count - 1 )
     {
       if ( pressed )
     {
       CubeDooms[c].Pause = true;
       SetupCube.Cube = c;
     }
       else
     {
       if ( ! SetupCube.Active )
         {
       CubeDooms[c].Pause = false;
           SetupCube.Cube = null;
         }
     }
     }
       else
     {
       if ( SetupCube.Cube != null )
     {
       CubeDooms[c].Pause = false;
       SetupCube.Cube = null;
     }
     }
       if ( pressed )
     {
       if ( ! this.ButtonPressed.ContainsKey(c.UniqueId) )
     {
       this.ButtonPressed.Add(c.UniqueId, DateTime.Now);
     }
     }
       else
     {
       if ( this.ButtonPressed.ContainsKey(c.UniqueId) )
     {
       this.ButtonPressed.Remove(c.UniqueId);
     }
     }
       Log.Debug("A CLICK -> " + c.UniqueId.ToString() + " : " + pressed.ToString());
 }
Example #30
0
        public void DrawOperator(Cube cube)
        {
            mCube.FillScreen (bgColor);

            Log.Debug ("Draw Operator");
            Cube[] connected = CubeHelper.FindConnected (cube);
            if (connected.Length > 2) {

                //Loop through each cube
                foreach (Cube neighbor in connected) {

                    CubeWrapper neighborWrapper = (CubeWrapper)neighbor.userData;

                    //Skip any other cube other than an Operand cube
                    if (neighborWrapper.mCubeStateMachine.Current == Constants.OperandState) {

                        //Determine the side it is on
                        //DrawDiagnals ();
                        DrawVerticleSeparator ();
                        //Log.Debug ("side of Operator: " + cube.Neighbors.SideOf (neighbor).ToString () + " num: " + neighborWrapper.mValue.ToString ());
                        CubeWrapper wrapper = (CubeWrapper)neighbor.userData;
                        //Paint that side of the cube //TODO: get the relative side to the hint cube.
                        DominoPainter painter = new DominoPainter (mCube, wrapper.mValue, cube.Neighbors.SideOf (neighbor), neighborWrapper.mColor);

                        painter = null; //Release Resource //TODO: I don't think this works like it does in Objective-C -- Need to follow up on that

                    } else {
                        //Do nothing
                    }

                }

                //Draw Left Side

                //Draw Right side

            }
        }