Ejemplo n.º 1
0
        private void Start()
        {
            ButtonEvents     = GetComponentInParent <ButtonEvents>();
            CommunicationBus = GetComponentInParent <PlayerToManagerCommunicationBus>();

            subscribeToEvents();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            ManualResetEvent terminateProgram = new ManualResetEvent(false);

            GyroMode[]   modes   = { GyroMode.Angle, GyroMode.AngularVelocity };
            int          modeIdx = 0;
            ButtonEvents buts    = new ButtonEvents();
            var          gyro    = new EV3GyroSensor(SensorPort.In2, GyroMode.Angle);

            LcdConsole.WriteLine("Use gyro on port 1");
            LcdConsole.WriteLine("Up read value");
            LcdConsole.WriteLine("Down rotation count");
            LcdConsole.WriteLine("Left reset");
            LcdConsole.WriteLine("Enter change mode");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Gyro sensor: " + gyro.ReadAsString());
            };
            buts.EnterPressed += () => {
                modeIdx   = (modeIdx + 1) % modes.Length;
                gyro.Mode = modes[modeIdx];
                LcdConsole.WriteLine("Mode: " + modes[modeIdx]);
            };
            buts.DownPressed += () => {
                LcdConsole.WriteLine("Rotation count: " + gyro.RotationCount());
            };
            buts.LeftPressed += () => {
                LcdConsole.WriteLine("Reset");
                gyro.Reset();
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            ManualResetEvent terminateProgram = new ManualResetEvent(false);

            UltraSonicMode[] modes = { UltraSonicMode.Centimeter, UltraSonicMode.Inch, UltraSonicMode.Listen };
            int          modeIdx   = 0;
            ButtonEvents buts      = new ButtonEvents();
            var          sensor    = new EV3UltrasonicSensor(SensorPort.In1, modes[modeIdx]);

            LcdConsole.WriteLine("Use sonic on port1");
            LcdConsole.WriteLine("Up change mode");
            LcdConsole.WriteLine("Enter read");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                modeIdx     = (modeIdx + 1) % modes.Length;
                sensor.Mode = modes[modeIdx];
                LcdConsole.WriteLine("Mode: " + modes[modeIdx]);
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine(sensor.ReadAsString());
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            ButtonEvents buts        = new ButtonEvents();
            var          tokenSource = new CancellationTokenSource();
            var          token       = tokenSource.Token;

            var dialog = new InfoDialog("Attach distance sensor", false);

            dialog.Show();
            var sensor = SensorAttachment.Wait <MSAngleSensor>(token);           //wait for sensor to attached on any port

            LcdConsole.WriteLine("Up reset angle");
            LcdConsole.WriteLine("Down read RMP");
            LcdConsole.WriteLine("Enter read angle");
            LcdConsole.WriteLine("Left read raw");
            LcdConsole.WriteLine("Esc. terminate");

            buts.EscapePressed += () => {
                tokenSource.Cancel();
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Angle: " + sensor.ReadAngle().ToString());
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Reset angle");
                sensor.ResetAngle();
            };
            buts.DownPressed += () => {
                LcdConsole.WriteLine("Read RPM: " + sensor.ReadRPM().ToString());
            };
            buts.LeftPressed += () => {
                LcdConsole.WriteLine("Read raw: " + sensor.ReadRAW().ToString());
            };
            token.WaitHandle.WaitOne();
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            var          soundSensor          = new NXTSoundSensor(SensorPort.In1);
            ButtonEvents buts = new ButtonEvents();

            LcdConsole.WriteLine("Use sound on port1");
            LcdConsole.WriteLine("Up sensor value");
            LcdConsole.WriteLine("Enter read raw");
            LcdConsole.WriteLine("Down change mode");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Sensor value:" + soundSensor.ReadAsString());
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Sensor raw value:" + soundSensor.ReadRaw());
            };
            buts.DownPressed += () => {
                if (soundSensor.Mode == SoundMode.SoundDB)
                {
                    soundSensor.Mode = SoundMode.SoundDBA;
                }
                else
                {
                    soundSensor.Mode = SoundMode.SoundDB;
                }
                LcdConsole.WriteLine("Sensor mode is now: " + soundSensor.Mode);
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            ButtonEvents buts = new ButtonEvents();
            bool         run  = true;

            buts.EscapePressed += () =>
            {
                run = false;
            };

            MotorSync   motori = new MotorSync(MotorPort.OutB, MotorPort.OutD);
            EV3IRSensor ir     = new EV3IRSensor(SensorPort.In3, IRMode.Proximity);

            Thread bg = new Thread(Scan);

            bg.Start();
            while (run && ir.Read() > 80)
            {
                LcdConsole.WriteLine(ir.Read().ToString());
                Thread.Sleep(200);
            }
            bg.Abort();
            motori.Brake();
            motori.Off();
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            var          lightSensor          = new NXTLightSensor(SensorPort.In1);
            ButtonEvents buts = new ButtonEvents();

            LcdConsole.WriteLine("Use light on port1");
            LcdConsole.WriteLine("Up value ");
            LcdConsole.WriteLine("Down change mode");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Sensor value:" + lightSensor.ReadAsString());
            };
            buts.DownPressed += () => {
                if (lightSensor.Mode == LightMode.Ambient)
                {
                    lightSensor.Mode = LightMode.Relection;
                }
                else
                {
                    lightSensor.Mode = LightMode.Ambient;
                }
                LcdConsole.WriteLine("Sensor mode is now: " + lightSensor.Mode);
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 8
0
        public static void Main(string[] args)
        {
            EventWaitHandle stopped = new ManualResetEvent(false);

            ColorMode[]  modes   = { ColorMode.Color, ColorMode.Reflection, ColorMode.Ambient, ColorMode.Blue };
            int          modeIdx = 0;
            var          sensor  = new EV3ColorSensor(SensorPort.In1);
            ButtonEvents buts    = new ButtonEvents();

            LcdConsole.WriteLine("Use color on port1");
            LcdConsole.WriteLine("Up read value");
            LcdConsole.WriteLine("Down raw value");
            LcdConsole.WriteLine("Enter change mode");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                stopped.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Sensor value: " + sensor.ReadAsString());
            };
            buts.DownPressed += () => {
                LcdConsole.WriteLine("Raw sensor value: " + sensor.ReadRaw());
            };
            buts.EnterPressed += () => {
                modeIdx     = (modeIdx + 1) % modes.Length;
                sensor.Mode = modes[modeIdx];
                LcdConsole.WriteLine("Sensor mode is set to: " + modes[modeIdx]);
            };
            stopped.WaitOne();
        }
Ejemplo n.º 9
0
 public ExButton() : base()
 {
     _enableCustomAppearance = true;
     _customAppearance       = new ButtonUIAppearance(this);
     _currentEvent           = ButtonEvents.NoEvent;
     _checked = false;
 }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            ManualResetEvent   terminateProgram = new ManualResetEvent(false);
            ButtonEvents       buts             = new ButtonEvents();
            HiTecCompassSensor compass          = new HiTecCompassSensor(SensorPort.In1);
            HiTecColorSensor   colorSensor      = new HiTecColorSensor(SensorPort.In2);
            HiTecTiltSensor    tilt             = new HiTecTiltSensor(SensorPort.In3);

            LcdConsole.WriteLine("Use compass on port1");
            LcdConsole.WriteLine("Use color on port2");
            LcdConsole.WriteLine("Use tilt on port3");
            LcdConsole.WriteLine("Up read compass");
            LcdConsole.WriteLine("Down read tilt");
            LcdConsole.WriteLine("Enter read color");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Compass sensor: " + compass.ReadAsString());
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Color sensor: " + colorSensor.ReadAsString());
                LcdConsole.WriteLine("Color index: " + colorSensor.ReadColorIndex());
            };
            buts.DownPressed += () => {
                LcdConsole.WriteLine("Tilt : " + tilt.ReadAsString());
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 11
0
 public ExButton() : base()
 {
     _enableCustomAppearance = true;
     _customAppearance = new ButtonUIAppearance(this);
     _currentEvent = ButtonEvents.NoEvent;
     _checked = false;
 }
Ejemplo n.º 12
0
        private void Start()
        {
            ButtonEvents     = GetComponentInParent <ButtonEvents>();
            CommunicationBus = GetComponentInParent <PlayerToManagerCommunicationBus>();

            Events.OnScored += HandleScored;
            Events.OnDeath  += HandleDeath;
        }
 public SAxis(string[] names, bool sendWhenZeroToo)
 {
     this.names           = names;
     this.sendWhenZeroToo = sendWhenZeroToo;
     events    = new ButtonEvents();
     AxisValue = null;
     isPressed = false;
 }
Ejemplo n.º 14
0
 public void SuspendButtonEvents()
 {
     if (buttonEvents != null)
     {
         buttonEvents.Kill();
         buttonEvents = null;
     }
 }
Ejemplo n.º 15
0
        private void Start()
        {
            ButtonEvents     = GetComponentInParent <ButtonEvents>();
            CommunicationBus = GetComponentInParent <PlayerToManagerCommunicationBus>();

            DroneEvents.OnScored            += HandleScored;
            DroneEvents.OnDroneDeath        += HandleDroneDeath;
            DroneEvents.OnCountdownFinished += HandleCountdownFinished;
        }
Ejemplo n.º 16
0
    public void Clicked(Click obj)
    {
        try
        {
            obj.GetComponent <PlaySound>().Play("Click");
        }
        catch { }

        if (obj.GetComponent <Click>().type == "QuitGameBtn")
        {
            Application.Quit();
        }
        else
        {
            btn = obj;
            ButtonEvents[btn.type]();
        }
    }
Ejemplo n.º 17
0
        public static void Main(string[] args)
        {
            object sensorLock = new object();
            bool   run        = true;

            ISensor[] sensor = new ISensor[4];
            for (int i = 0; i < 4; i++)
            {
                sensor[i] = null;
            }
            using (SensorListner listner = new SensorListner())
            {
                listner.SensorAttached += delegate(ISensor obj)
                {
                    lock (sensorLock)
                    {
                        if (obj != null)
                        {
                            sensor[(int)obj.Port] = obj;
                            Console.WriteLine(obj.GetSensorName() + " attached on " + obj.Port);
                        }
                    }
                };
                listner.SensorDetached += delegate(SensorPort obj)
                {
                    lock (sensorLock)
                    {
                        Console.WriteLine(sensor[(int)obj] + " detached from " + obj);
                        sensor[(int)obj] = null;
                    }
                };
                ButtonEvents buts = new ButtonEvents();
                buts.EscapePressed += delegate
                {
                    run = false;
                };
                while (run)
                {
                    lock (sensorLock)
                    {
                        /*for (int i = 0; i < sensor.Length; i++) {
                         *                            if (sensor[i] != null) {
                         *                                    typeLabel [i].Text = sensor[i].GetSensorName ();
                         *                                    modeLabel [i].Text = sensor[i].SelectedMode ();
                         *                                    valueLabel[i].Text = sensor[i].ReadAsString ();
                         *                            } else {
                         *                                    typeLabel [i].Text = "Not connected";
                         *                                    modeLabel [i].Text = "-";
                         *                                    valueLabel [i].Text = "-";
                         *                            }
                         *                    }*/
                    }
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
Ejemplo n.º 18
0
 private void CreateButtonEvents()
 {
     buttonEvents                = new ButtonEvents();
     buttonEvents.DownPressed   += () => ExecuteButtonAction(activeMenuItem.OnDownPressed);
     buttonEvents.UpPressed     += () => ExecuteButtonAction(activeMenuItem.OnUpPressed);
     buttonEvents.LeftPressed   += () => ExecuteButtonAction(activeMenuItem.OnLeftPressed);
     buttonEvents.RightPressed  += () => ExecuteButtonAction(activeMenuItem.OnRightPressed);
     buttonEvents.EnterPressed  += () => ExecuteButtonAction(activeMenuItem.OnEnterPressed);
     buttonEvents.EscapePressed += () => ExecuteButtonAction(activeMenuItem.OnEscPressed);
 }
 public SVector(Joystick[] names, NormalizationMode normalizationMode, bool sendWhenZeroToo)
 {
     this.names             = names;
     this.normalizationMode = normalizationMode;
     this.sendWhenZeroToo   = sendWhenZeroToo;
     events            = new ButtonEvents();
     JoystickValue     = null;
     JoystickMagnitude = null;
     isPressed         = false;
 }
Ejemplo n.º 20
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// adds a button event on the escape button that throws
        /// an exception and halts the motors
        /// </summary>
        private static void AddEmergencyStopOption()
        {
            ButtonEvents buttonEvents = new ButtonEvents();

            Action emergencyStopAction = () =>
            {
                Robot.HaltMotors();
                throw new Exception();
            };

            buttonEvents.EscapePressed += emergencyStopAction;
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            var terminateProgram = new ManualResetEvent(false);
            var cubeSolver       = new CubeSolver();
            var buts             = new ButtonEvents();

            buts.EscapePressed += () => terminateProgram.Set();

            Task.Factory.StartNew(cubeSolver.Run);

            terminateProgram.WaitOne();
            cubeSolver.Stop();

            //var solution = Search.solution(Tools.randomCube(), 26, false);
        }
Ejemplo n.º 23
0
        static public void ButtonEvent(WinApi.Vk Button, ButtonEvents Event = ButtonEvents.None)
        {
            switch (Event)
            {
            case ButtonEvents.None:
                break;

            case ButtonEvents.Up:
                WinApi.KeyBDEvent(Button, WinApi.KeyBDdwFlags.KEYEVENTF_KEYUP);
                break;

            case ButtonEvents.Down:
                WinApi.KeyBDEvent(Button);
                break;
            }
        }
Ejemplo n.º 24
0
        public static void Main(string[] args)
        {
            using (ButtonEvents buts = new ButtonEvents())
            {
                var tokenSource = new CancellationTokenSource();
                var token       = tokenSource.Token;
                buts.EscapePressed += tokenSource.Cancel;
                var dialog = new InfoDialog("Attach distance sensor");
                dialog.Show();
                var sensor = SensorAttachment.Wait <MSDistanceSensor> (token);               //wait for sensor to attached on any port
                if (!token.IsCancellationRequested)
                {
                    LcdConsole.WriteLine("Up power on");
                    LcdConsole.WriteLine("Down power off");
                    LcdConsole.WriteLine("Enter read sensor");
                    LcdConsole.WriteLine("Left read voltage");
                    LcdConsole.WriteLine("Right read range type");
                    LcdConsole.WriteLine("Esc. terminate");


                    buts.EnterPressed += () =>
                    {
                        LcdConsole.WriteLine("Sensor reading: " + sensor.ReadAsString());
                    };
                    buts.UpPressed += () =>
                    {
                        LcdConsole.WriteLine("Power on");
                        sensor.PowerOn();
                    };
                    buts.DownPressed += () =>
                    {
                        LcdConsole.WriteLine("Power off");
                        sensor.PowerOff();
                    };
                    buts.LeftPressed += () =>
                    {
                        LcdConsole.WriteLine("Voltage: " + sensor.GetVolgage());
                    };
                    buts.RightPressed += () =>
                    {
                        LcdConsole.WriteLine("Sensor range is  : " + sensor.GetRange());
                    };
                }
                token.WaitHandle.WaitOne();
            }
        }
Ejemplo n.º 25
0
        public static void Main(string[] args)
        {
            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            ButtonEvents     buts             = new ButtonEvents();
            var gyro = new HiTecGyroSensor(SensorPort.In1, 600);

            LcdConsole.WriteLine("Use gyro on port1");
            LcdConsole.WriteLine("Enter read value");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Gyro sensor: " + gyro.ReadAsString());
            };
            terminateProgram.WaitOne();
        }
Ejemplo n.º 26
0
        public static void Main(string[] args)
        {
            const string to       = "*****@*****.**";
            const string from     = "*****@*****.**";
            const string password = "******";

            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            var          colorSensor          = new EV3ColorSensor(SensorPort.In1);
            ButtonEvents buts        = new ButtonEvents();
            SmtpClient   smptpClient = new SmtpClient("smtp.gmail.com", 587);

            smptpClient.EnableSsl             = true;
            smptpClient.UseDefaultCredentials = false;
            smptpClient.Credentials           = new NetworkCredential(from, password);
            smptpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
            ServicePointManager.ServerCertificateValidationCallback =
                delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            { return(true); };
            MailMessage message = new MailMessage();

            message.To.Add(to);
            message.From    = new MailAddress(from);
            message.Subject = "Color mail from my EV3";
            LcdConsole.Clear();
            LcdConsole.WriteLine("Use color on port1");
            LcdConsole.WriteLine("Enter send mail");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Sending email");
                try{
                    message.Body = "EV3 read color: " + colorSensor.ReadColor();
                    smptpClient.Send(message);
                    LcdConsole.WriteLine("Done sending email");
                }
                catch (Exception e)
                {
                    LcdConsole.WriteLine("Failed to send email");
                    Console.WriteLine(e.StackTrace);
                }
            };
            terminateProgram.WaitOne();
            message = null;
        }
Ejemplo n.º 27
0
        public static void Main(string[] args)
        {
            EventWaitHandle stopped     = new ManualResetEvent(false);
            int             centerX     = Lcd.Width / 2;
            int             centerY     = Lcd.Height / 2;
            Point           center      = new Point(centerX, centerY);
            int             refreshRate = 100;
            bool            run         = true;
            ButtonEvents    buts        = new ButtonEvents();

            buts.EscapePressed += () => {
                stopped.Set();
                run = false;
            };

            while (run)
            {
                for (int k = 0; k < 4; k++)
                {
                    for (int i = 1; i < centerY; i++)
                    {
                        Lcd.Instance.Clear();
                        Lcd.Instance.DrawCircle(center, (ushort)i, true, true);
                        Lcd.Instance.Update();
                        stopped.WaitOne(refreshRate);
                    }
                    for (int i = centerY - 1; i > 0; i--)
                    {
                        Lcd.Instance.Clear();
                        Lcd.Instance.DrawCircle(center, (ushort)i, true, true);
                        Lcd.Instance.Update();
                        stopped.WaitOne(refreshRate);
                    }
                }

                for (int k = 0; k < 20; k++)
                {
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawHLine(center, centerX / 2, true);
                    stopped.WaitOne(refreshRate);
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawVLine(center, centerY / 2, true);
                }
            }
        }
Ejemplo n.º 28
0
        public static void Main(string[] args)
        {
            new Motor(MotorPort.OutA).Off();

            Lcd lcd = new Lcd();

            lcd.ShowPicture(MonoPicture.Picture);
            Font      f       = Font.MediumFont;
            Point     offset  = new Point(0, 25);
            Point     p       = new Point(10, Lcd.Height - 75);
            Point     boxSize = new Point(100, 24);
            Rectangle box     = new Rectangle(p, p + boxSize);

            ButtonEvents buts = new ButtonEvents();
            int          val  = 7;

            buts.EnterPressed += () =>
            {
                lcd.Clear();
                lcd.WriteTextBox(f, box + offset * 0, "Value = " + val.ToString(), true);
                lcd.WriteTextBox(f, box + offset * 1, "Hello World!!", false);
                lcd.WriteTextBox(f, box + offset * 2, "Hello World!!", true);
                lcd.Update();
                val++;
            };
            buts.UpPressed += () =>
            {
                lcd.Clear();
                lcd.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 10));
                lcd.Update();
            };
            buts.DownPressed += () =>
            {
                lcd.TakeScreenShot();
                lcd.Clear();
                lcd.WriteTextBox(f, box + offset * 1, "Screen Shot", true);
                lcd.Update();
            };
            buts.EscapePressed += () => stopped.Set();
            stopped.WaitOne();
            lcd.WriteTextBox(f, box + offset * 0, "Done!", true);
            lcd.Update();
        }
Ejemplo n.º 29
0
        static public void MouseButtonEvent(MouseButton Button, ButtonEvents Event = ButtonEvents.None)
        {
            switch (Event)
            {
            case ButtonEvents.None:
                break;

            case ButtonEvents.Up:
                switch (Button)
                {
                case MouseButton.Middle:
                    WinApi.MouseEvent(WinApi.MouseEventFlags.MiddleUp);
                    break;

                case MouseButton.Left:
                    WinApi.MouseEvent(WinApi.MouseEventFlags.LeftUp);
                    break;

                case MouseButton.Right:
                    WinApi.MouseEvent(WinApi.MouseEventFlags.RightUp);
                    break;
                }
                break;

            case ButtonEvents.Down:
                switch (Button)
                {
                case MouseButton.Middle:
                    WinApi.MouseEvent(WinApi.MouseEventFlags.MiddleDown);
                    break;

                case MouseButton.Left:
                    WinApi.MouseEvent(WinApi.MouseEventFlags.LeftDown);
                    break;

                case MouseButton.Right:
                    WinApi.MouseEvent(WinApi.MouseEventFlags.RightDown);
                    break;
                }
                break;
            }
        }
Ejemplo n.º 30
0
    /// <summary>
    /// 检查下一句话的属性
    /// </summary>
    public void CheckNextSentence()
    {
        // 如果对话队列没有对话内容了,则调用对话
        if (sentences.Count == 0)
        {
            // 当对话结束时调用
            EndDialogue();
            return;
        }
        // 取出一条对话信息
        sentence = sentences.Dequeue();

        // 获取当前对话内容的所有选项节点
        XmlNodeList optionNodes = sentence.SelectNodes("option");

        // 如果当前对话内容内容选项节点数目为0,则激活对话面板并现实下一条对话内容,否则激活选择面板
        if (optionNodes.Count == 0)
        {
            // 开启对话面板
            DialoguePanel.SetActive(true);
            // 显示下一句话
            DisplayNextSentence(sentence);
        }
        else
        {
            // 关闭对话面板
            DialoguePanel.SetActive(false);
            // 开启选择面板
            SelectPanel.SetActive(true);
            // 循环遍历选项节点
            for (int i = 0; i < optionNodes.Count; i++)
            {
                options[i].gameObject.SetActive(true);
                options[i].onClick.RemoveAllListeners();
                options[i].gameObject.name = "Option" + i;
                ButtonEvents buttonEvent = options[i].GetComponent <ButtonEvents>();
                buttonEvent.CurrentAction = buttonEvent.CheckOption(optionNodes[i]);
                options[i].onClick.AddListener(buttonEvent.Execute);
            }
        }
    }
Ejemplo n.º 31
0
        public static void Main(string[] args)
        {
            Bitmap          monoLogo = Bitmap.FromResouce(Assembly.GetExecutingAssembly(), "monologo.bitmap");
            EventWaitHandle stopped  = new ManualResetEvent(false);

            Lcd.ShowPicture(MonoPicture.Picture);
            Font      f       = Font.MediumFont;
            Point     offset  = new Point(0, 25);
            Point     p       = new Point(10, Lcd.Height - 75);
            Point     boxSize = new Point(100, 24);
            Rectangle box     = new Rectangle(p, p + boxSize);

            using (ButtonEvents buts = new ButtonEvents())
            {
                int val = 7;
                buts.EnterPressed += () => {
                    Lcd.Clear();
                    Lcd.WriteTextBox(f, box + offset * 0, "Value = " + val.ToString(), true);
                    Lcd.WriteTextBox(f, box + offset * 1, "Hello EV3!!", false);
                    Lcd.WriteTextBox(f, box + offset * 2, "Hello World!!", true);
                    Lcd.Update();
                    val++;
                };
                buts.UpPressed += () => {
                    Lcd.Clear();
                    Lcd.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 10));
                    Lcd.Update();
                };
                buts.DownPressed += () => {
                    Lcd.TakeScreenShot();
                    Lcd.Clear();
                    Lcd.WriteTextBox(f, box + offset * 1, "Screen Shot", true);
                    Lcd.Update();
                };
                buts.EscapePressed += () => stopped.Set();
                stopped.WaitOne();
            }
            Lcd.WriteTextBox(f, box + offset * 0, "Done!", true);
            Lcd.Update();
        }
Ejemplo n.º 32
0
 // Use this for initialization
 void Start()
 {
     Instance = this;
 }
Ejemplo n.º 33
0
 protected override void OnMouseLeave(EventArgs e)
 {
     _currentEvent = ButtonEvents.MouseLeave;
     Invalidate();
     base.OnMouseLeave(e);
 }
Ejemplo n.º 34
0
 protected override void OnMouseDown(MouseEventArgs mevent)
 {
     _currentEvent = ButtonEvents.MouseDown;
     Invalidate();
     base.OnMouseDown(mevent);
 }