Ejemplo n.º 1
0
        public void UpdateSensorValues(string[] rawValues)
        {
            if (rawValues == null || rawValues.Length == 0)
            {
                throw new Exception("Incomming data is incomplete");
            }

            Slider.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.SliderOrder]));
            LightSensor.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.LightSensorOrder]));
            Temperature.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.TemperatureOrder]));
            Microphone.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.MicrophoneOrder]));

            JoystickSwitch.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickSwitchOrder]));
            JoystickButton.UpdateValue(rawValues[SensorValuesOrderTable.JoystickButtonOrder] != "1");

            AccelerometerX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerXOrder]));
            AccelerometerY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerYOrder]));
            AccelerometerZ.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerZOrder]));

            ButtonDown.UpdateValue(rawValues[SensorValuesOrderTable.ButtonDownOrder] != "1");
            ButtonLeft.UpdateValue(rawValues[SensorValuesOrderTable.ButtonLeftOrder] != "1");
            ButtonUp.UpdateValue(rawValues[SensorValuesOrderTable.ButtonUpOrder] != "1");
            ButtonRight.UpdateValue(rawValues[SensorValuesOrderTable.ButtonRightOrder] != "1");

            JoystickX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickXOrder]));
            JoystickY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickYOrder]));

            LedRed.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedRedOrder]));
            LedGreen.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedGreenOrder]));
            LedBlue.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedBlueOrder]));
        }
Ejemplo n.º 2
0
        void ReleaseDesignerOutlets()
        {
            if (ButtonAdd != null)
            {
                ButtonAdd.Dispose();
                ButtonAdd = null;
            }

            if (ButtonLeft != null)
            {
                ButtonLeft.Dispose();
                ButtonLeft = null;
            }

            if (ButtonRight != null)
            {
                ButtonRight.Dispose();
                ButtonRight = null;
            }

            if (CollectionView != null)
            {
                CollectionView.Dispose();
                CollectionView = null;
            }

            if (UILabelHeader != null)
            {
                UILabelHeader.Dispose();
                UILabelHeader = null;
            }
        }
Ejemplo n.º 3
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     base.Draw(spriteBatch);
     ButtonUp.Draw(spriteBatch);
     ButtonRight.Draw(spriteBatch);
     ButtonDown.Draw(spriteBatch);
     ButtonLeft.Draw(spriteBatch);
     ButtonChange.Draw(spriteBatch);
 }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ ButtonDown.GetHashCode();
         hashCode = (hashCode * 397) ^ ButtonUp.GetHashCode();
         hashCode = (hashCode * 397) ^ ButtonRight.GetHashCode();
         hashCode = (hashCode * 397) ^ ButtonLeft.GetHashCode();
         hashCode = (hashCode * 397) ^ MinusButton.GetHashCode();
         hashCode = (hashCode * 397) ^ CaptureButton.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
    void Update()
    {
        ButtonLeft  left  = buttons.GetComponentInChildren <ButtonLeft>();
        ButtonRight right = buttons.GetComponentInChildren <ButtonRight>();

        if (Input.GetKey(buttonLeft) || left.active)
        {
            horizontal = -1;
        }
        else if (Input.GetKey(buttonRight) || right.active)
        {
            horizontal = 1;
        }
        else
        {
            horizontal = 0;
        }
    }
Ejemplo n.º 6
0
        void ReleaseDesignerOutlets()
        {
            if (ButtonLeft != null)
            {
                ButtonLeft.Dispose();
                ButtonLeft = null;
            }

            if (ButtonRight != null)
            {
                ButtonRight.Dispose();
                ButtonRight = null;
            }

            if (CollectionView != null)
            {
                CollectionView.Dispose();
                CollectionView = null;
            }
        }
Ejemplo n.º 7
0
 // Start is called before the first frame update
 void Start()
 {
     instance = this;
     alpha    = gameObject.GetComponent <Image>().color.a;
 }
Ejemplo n.º 8
0
        public override void Update()
        {
            #region タッチの検出

            #region 既存のタッチを更新する
            //上ボタン用のタッチが継続している時
            if (Input.touches.ContainsKey(ButtonUp.touchId))
            {
            }
            else
            {
                ButtonUp.touchId = -1;
            }
            //右ボタン用のタッチが継続している時
            if (Input.touches.ContainsKey(ButtonRight.touchId))
            {
            }
            else
            {
                ButtonRight.touchId = -1;
            }
            //下ボタン用のタッチが継続している時
            if (Input.touches.ContainsKey(ButtonDown.touchId))
            {
            }
            else
            {
                ButtonDown.touchId = -1;
            }
            //左ボタン用のタッチが継続している時
            if (Input.touches.ContainsKey(ButtonLeft.touchId))
            {
            }
            else
            {
                ButtonLeft.touchId = -1;
            }
            //切り替えボタン用のタッチが継続している時
            if (Input.touches.ContainsKey(ButtonChange.touchId))
            {
            }
            else
            {
                ButtonChange.touchId = -1;
            }
            //移動用のタッチが継続している時
            if (Input.touches.ContainsKey(moveId))
            {
            }
            else
            {
                moveId = -1;
            }
            #endregion

            #region 新しいタッチを検出する
            foreach (var newInfo in Input.touches.Values)
            {
                if (newInfo.Id == ButtonUp.touchId ||
                    newInfo.Id == ButtonRight.touchId ||
                    newInfo.Id == ButtonDown.touchId ||
                    newInfo.Id == ButtonLeft.touchId ||
                    newInfo.Id == ButtonChange.touchId ||
                    newInfo.Id == moveId)
                {
                    continue;
                }
                if (UIManager.oldIds.Contains(newInfo.Id))
                {
                    continue;
                }
                //新しい上ボタン用タッチを見つけた時
                if (ButtonUp.touchId == -1 && ButtonUp.Pressed(newInfo.Positions[0]))
                {
                    ButtonUp.touchId = newInfo.Id;
                }
                //新しい右ボタン用タッチを見つけた時
                if (ButtonRight.touchId == -1 && ButtonRight.Pressed(newInfo.Positions[0]))
                {
                    ButtonRight.touchId = newInfo.Id;
                }
                //新しい下ボタン用タッチを見つけた時
                if (ButtonDown.touchId == -1 && ButtonDown.Pressed(newInfo.Positions[0]))
                {
                    ButtonDown.touchId = newInfo.Id;
                }
                //新しい左ボタン用タッチを見つけた時
                if (ButtonLeft.touchId == -1 && ButtonLeft.Pressed(newInfo.Positions[0]))
                {
                    ButtonLeft.touchId = newInfo.Id;
                }
                //新しい切り替えボタン用タッチを見つけた時
                if (ButtonChange.touchId == -1 && ButtonChange.Pressed(newInfo.Positions[0]))
                {
                    ButtonChange.touchId = newInfo.Id;
                }
                //新しい移動用タッチを見つけた時
                else if (moveId == -1)
                {
                    moveId = newInfo.Id;
                }
            }
            #endregion

            #endregion

            #region タッチの処理(移動以外の処理の中身は「ボタンのイベントハンドラ」に記述)
            #region  ボタン用タッチの処理
            if (Input.touches.ContainsKey(ButtonUp.touchId))
            {
                switch (Input.touches[ButtonUp.touchId].State)
                {
                case Input.TouchState.Begin:
                    ButtonUp._begin();
                    break;

                case Input.TouchState.OnTouch:
                    ButtonUp._onPress();
                    break;

                case Input.TouchState.End:
                    ButtonUp._end();
                    break;
                }
            }
            #endregion
            #region 右ボタン用タッチの処理
            if (Input.touches.ContainsKey(ButtonRight.touchId))
            {
                switch (Input.touches[ButtonRight.touchId].State)
                {
                case Input.TouchState.Begin:
                    ButtonRight._begin();
                    break;

                case Input.TouchState.OnTouch:
                    ButtonRight._onPress();
                    break;

                case Input.TouchState.End:
                    ButtonRight._end();
                    break;
                }
            }
            #endregion
            #region  ボタン用タッチの処理
            if (Input.touches.ContainsKey(ButtonDown.touchId))
            {
                switch (Input.touches[ButtonDown.touchId].State)
                {
                case Input.TouchState.Begin:
                    ButtonDown._begin();
                    break;

                case Input.TouchState.OnTouch:
                    ButtonDown._onPress();
                    break;

                case Input.TouchState.End:
                    ButtonDown._end();
                    break;
                }
            }
            #endregion
            #region 左ボタン用タッチの処理
            if (Input.touches.ContainsKey(ButtonLeft.touchId))
            {
                switch (Input.touches[ButtonLeft.touchId].State)
                {
                case Input.TouchState.Begin:
                    ButtonLeft._begin();
                    break;

                case Input.TouchState.OnTouch:
                    ButtonLeft._onPress();
                    break;

                case Input.TouchState.End:
                    ButtonLeft._end();
                    break;
                }
            }
            #endregion
            #region 切り替えボタン用タッチの処理
            if (Input.touches.ContainsKey(ButtonChange.touchId))
            {
                switch (Input.touches[ButtonChange.touchId].State)
                {
                case Input.TouchState.Begin:
                    ButtonChange._begin();
                    break;

                case Input.TouchState.OnTouch:
                    ButtonChange._onPress();
                    break;

                case Input.TouchState.End:
                    ButtonChange._end();
                    break;
                }
            }
            #endregion
            #region 移動用タッチの処理
            //            if (Input.touches.ContainsKey(moveId))
            //            {
            //                switch (Input.touches[moveId].State)
            //                {
            //                    case Input.TouchState.Begin:
            //                    case Input.TouchState.OnTouch:
            //                        moveDirection = Vector2.Zero;
            //                        break;
            //                    case Input.TouchState.End:
            //#if ANDROID || __IOS__
            //                        double rad = Math.Atan2(Input.touches[moveId].Positions[0].Y - Input.touches[moveId].Positions[Input.MOUSE_DELAY_FRAME - 1].Y, -Input.touches[moveId].Positions[0].X + Input.touches[moveId].Positions[Input.MOUSE_DELAY_FRAME - 1].X);
            //                        double len = Math.Pow(Input.touches[moveId].Positions[0].X - Input.touches[moveId].Positions[Input.MOUSE_DELAY_FRAME - 1].X, 2) + Math.Pow(Input.touches[moveId].Positions[0].Y - Input.touches[moveId].Positions[Input.MOUSE_DELAY_FRAME - 1].Y, 2);
            //                        if (len < 1000)
            //                        {
            //                            moveDirection = Vector2.Zero;
            //                        }
            //                        else
            //                        {
            //                            moveDirection.X = (rad < 3 * Math.PI / 8 && rad > -3 * Math.PI / 8) ? 1 : (rad > 5 * Math.PI / 8 || rad < -5 * Math.PI / 8) ? -1 : 0;
            //                            moveDirection.Y = (rad > -7 * Math.PI / 8 && rad < -1 * Math.PI / 8) ? 1 : (rad > 1 * Math.PI / 8 && rad < 7 * Math.PI / 8) ? -1 : 0;
            //                            VectorArrow.setVisible();
            //                        }
            //                        VectorArrowAngle = -1 * convertAngle(rad);
            //#else
            //                        double rad = Math.Atan2(Input.mouseInfo.Positions[0].Y - Input.mouseInfo.Positions[Input.MOUSE_DELAY_FRAME - 1].Y, -Input.mouseInfo.Positions[0].X + Input.mouseInfo.Positions[Input.MOUSE_DELAY_FRAME - 1].X);
            //                        double len = Math.Pow(Input.mouseInfo.Positions[0].X - Input.mouseInfo.Positions[Input.MOUSE_DELAY_FRAME - 1].X, 2) + Math.Pow(Input.mouseInfo.Positions[0].Y - Input.mouseInfo.Positions[Input.MOUSE_DELAY_FRAME - 1].Y, 2);
            //                        if (len < 100)
            //                        {
            //                            moveDirection = Vector2.Zero;
            //                        }
            //                        else
            //                        {
            //                            moveDirection.X = (rad < 3 * Math.PI / 8 && rad > -3 * Math.PI / 8) ? 1 : (rad > 5 * Math.PI / 8 || rad < -5 * Math.PI / 8) ? -1 : 0;
            //                            moveDirection.Y = (rad > -7 * Math.PI / 8 && rad < -1 * Math.PI / 8) ? 1 : (rad > 1 * Math.PI / 8 && rad < 7 * Math.PI / 8) ? -1 : 0;
            //                            VectorArrow.setVisible();
            //                        }
            //                        VectorArrowAngle = -1 * convertAngle(rad);
            //#endif
            //                        break;
            //                }
            //            }
            #endregion
            #endregion
        }