Beispiel #1
0
        public override void ButtonStateChanged(IGlimDevice src, ButtonStatus btn)
        {
            GlimDescriptor d;

            if (src.HostName == mGlimRedGun.HostName)
            {
                d = mGlimRedGun;
            }
            else if (src.HostName == mGlimBlueGun.HostName)
            {
                d = mGlimBlueGun;
            }
            else
            {
                if (null == src.HostName)
                {
                    DebugClick();
                }
                // only responding to known descriptors
                return;
            }
            if (ButtonStatus.Up == btn)
            {
                if (EnableGame && d.ButtonDownTimestamp.HasValue)
                {
                    int tlimit = Math.Min(100, (int)((CurrentTime - d.ButtonDownTimestamp.Value).TotalSeconds * 20));
                    d.StartComet(tlimit);
                    RecalculateButtonGlimmer(d);
                    if (mButtonUpSynchronizeTimestamp.HasValue)
                    {
                        // compare current time to Up sync time to see if it's game on
                        double diffsec = (CurrentTime - mButtonUpSynchronizeTimestamp.Value).TotalSeconds;
                        if (ButtonTimeEpsilonSeconds > diffsec && 100 == tlimit)
                        {
                            mGameState = GameState.SynchronizedShotsFired;
                            //PrintLine( "mGameState -> " + mGameState.ToString() );
                        }
                        else
                        {
                            mButtonUpSynchronizeTimestamp = null;
                        }
                    }
                    else if (mGlimBlueGun.ButtonDownTimestamp.HasValue && mGlimRedGun.ButtonDownTimestamp.HasValue)
                    {
                        // both buttons were down.. check for epilson sync
                        double diffsec = (mGlimRedGun.ButtonDownTimestamp.Value - mGlimBlueGun.ButtonDownTimestamp.Value).TotalSeconds;
                        if (ButtonTimeEpsilonSeconds > Math.Abs(diffsec))
                        {
                            mButtonUpSynchronizeTimestamp = CurrentTime;
                            //PrintLine( "down push was synchronized" );
                        }
                    }
                }
                d.ButtonDownTimestamp = null;
            }
            else if (!d.ButtonDownTimestamp.HasValue)
            {
                d.ButtonDownTimestamp = CurrentTime;
            }
        }
Beispiel #2
0
 public override void ButtonStateChanged(IGlimDevice src, ButtonStatus btn)
 {
     if (ButtonStatus.Up == btn)
     {
         mColourMode = !mColourMode;
     }
 }
Beispiel #3
0
 public void UpdateFromNetworkData(IGlimDevice args)
 {
     if (0 == BootCount || args.Uptime.TotalSeconds < Uptime.TotalSeconds)
     {
         BootCount++;
         mBtnClr = ButtonColour.Off;                 // reload from binding
     }
     IPEndPoint   = args.IPEndPoint;
     HardwareType = args.HardwareType;
     Uptime       = args.Uptime;
     CPU          = args.CPU;
     RSSI         = args.RSSI;
     dBm          = args.dBm;
     UpdatedFromNetworkData?.Invoke(this, EventArgs.Empty);
 }
Beispiel #4
0
 public void ButtonStateChanged(IGlimDevice src, ButtonStatus btn)
 {
 }