示例#1
0
文件: Keypad.cs 项目: drdnar/Tiedye
        /*protected void Log(string text)
         * {
         *  KeyLog = text + " | " + Focused.ToString() + "\r\n" + KeyLog;
         * }*/

        private void Keypad_MouseDown(object sender, MouseEventArgs e)
        {
            MouseEventArgs f = e as MouseEventArgs;

            if (f == null)
            {
                return;
            }
            Bitmap b = keyIdsPicture.Image as Bitmap;
            // Above should never fail. If it does, this is situation worth crashing for anyway.

            /*if (b == null)
             *  return;*/
            //MessageBox.Show("" + f.X + ", " + f.Y + ": " + b.GetPixel(f.X, f.Y));
            Color c = b.GetPixel(f.X, f.Y);

            if (c.R != 16 && c.R != 32)
            {
                return;
            }
            int         group = c.G >> 5;
            int         key   = c.B >> 5;
            bool        on    = c.R == 32;
            KeyLocation data  = new KeyLocation(Group: group, Key: key, On: on);

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                //Log("Click " + Convert.ToString(group, 2) + " " + Convert.ToString(key, 2) + on);
                if (lastKeyTimer.Enabled)
                {
                    // What a fast clicker!
                    // Release last key.
                    lastKeyTimer.Stop();
                    if (KeyReleased != null)
                    {
                        //Log(". . . released. (fast click)");
                        KeyReleased(this, LastKey);
                    }
                }
                LastKey = data;
                lastKeyMouseReleased = false;
                lastKeyTimer.Stop();
                lastKeyTimer.Start();
                if (KeyPressed != null)
                {
                    //Log(". . . pressed.");
                    KeyPressed(this, data);
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                // TODO: Support key locking
            }
        }
示例#2
0
    public override void DoInteraction(bool sentFromPlayerInput = false)
    {
        CheckInteraction();

        if (!CheckForRequiredKeys())
        {
            print("Interactable::Switch::DoInteraction -- We do not have all the keys required from: " + KeyLocation.ToString());
            _canContinue = false;
        }

        if (!_canContinue)
        {
            return;
        }

        if (IsOneUseOnly)
        {
            HasBeenUsedOnce = true;
        }

        switch (IsOn)
        {
        case true:

            SwitchState_TurnOff();
            break;

        case false:

            SwitchState_TurnOn();
            break;
        }
    }