Пример #1
0
 // Use this for initialization
 void Start()
 {
     this.touchControl = new TouchControl(isTouchDevice);
     this.playerControl = new PlayerControl(this);
     this.target = GameObject.FindGameObjectWithTag("Target");
     this.UIControl = this.GetComponent<UIControl>();
 }
Пример #2
0
    protected override void OnTouchBegan(Touch pTouch)
    {
        if(mTouchControl == null)
        {
            mTouchControl = new TouchControl(pTouch);

            HandlerNewTouch();
        }
    }
Пример #3
0
 internal Desktop(Bitmap screenBuffer)
 {
     _screenBuffer = screenBuffer;
     _width        = screenBuffer.Width;
     _height       = screenBuffer.Height;
     _x            = _y = 0;
     _parent       = null;
     _desktopOwner = this;
     _captured     = null;
 }
Пример #4
0
	void Start() {
		controller = GetComponent<Controller2D> ();
		touchControl = TouchControl.Instance;
		touchControl.player = this;
		hoverSlider = GameObject.Find("HoverSlider").GetComponent<Slider>();

		gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
		maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
	}
Пример #5
0
        public override void Dispose()
        {
            _screenBuffer.Dispose();
            _drawBackground = null;
            _captured       = null;

            TouchUp = TouchDown = TouchMove = null;

            base.Dispose();
        }
 /// <summary>
 /// Constructs a two finger drag gesture.
 /// </summary>
 /// <param name="recognizer">The gesture recognizer.</param>
 /// <param name="touch1">The first touch that started this gesture.</param>
 /// <param name="touch2">The second touch that started this gesture.</param>
 public TwoFingerDragGesture(
     TwoFingerDragGestureRecognizer recognizer, TouchControl touch1, TouchControl touch2) :
     base(recognizer)
 {
     this.touch1    = touch1;
     StartPosition1 = touch1.position.ReadValue();
     this.touch2    = touch2;
     StartPosition2 = touch2.position.ReadValue();
     Position       = (StartPosition1 + StartPosition2) / 2;
 }
Пример #7
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
        /// <summary>
        /// Used to determine if a touch is off the edge of the screen based on some slop.
        /// Useful to prevent accidental touches from simply holding the device from causing
        /// confusing behavior.
        /// </summary>
        /// <param name="touch">The touch to check.</param>
        /// <returns>True if the touch is off screen edge.</returns>
        public static bool IsTouchOffScreenEdge(TouchControl touch)
        {
            var slopPixels = InchesToPixels(k_EdgeThresholdInches);

            var result = touch.position.x.ReadValue() <= slopPixels;

            result |= touch.position.y.ReadValue() <= slopPixels;
            result |= touch.position.x.ReadValue() >= Screen.width - slopPixels;
            result |= touch.position.y.ReadValue() >= Screen.height - slopPixels;

            return(result);
        }
Пример #9
0
    public ControlSystem(GameplaySettings gameplaySettings)
    {
        settings        = gameplaySettings;
        Physics.gravity = new Vector3(0, -settings.Gravity, 0);

        touchControl                   = Object.FindObjectOfType <TouchControl>();
        touchControl.onBeginPull      += HandleBeginPull;
        touchControl.onPullHorizontal += HandlePullHorizontal;
        touchControl.onPullVertical   += HandlePullVertical;

        cameraRig = Object.FindObjectOfType <CameraRig>();
        LocalWindZone.getWindForce += () => clampedWindForce;
    }
Пример #10
0
    // Start is called before the first frame update
    void Start()
    {
        box           = GetComponent <ObjectReference>();
        tc            = GetComponent <TouchControl>();
        sc            = GetComponent <SpecialController>();
        randomMap     = MakeArray(Options.width, Options.height);
        selectedBoxes = new GameObject[Options.width * Options.height];

        selections = new GameObject[Options.width * Options.height];
        map        = new GameObject[Options.width, Options.height];
        SetBoxes();
        SetSelection();
    }
    // Start is called before the first frame update
    void Start()
    {
        objectsInGame        = FindObjectsOfType <Controllable>();
        god                  = FindObjectOfType <TouchControl>();
        originalPositions    = new Vector3[objectsInGame.Length];
        originalOrientations = new Quaternion[objectsInGame.Length];

        for (int i = 0; i < objectsInGame.Length; i++)
        {
            originalPositions[i]    = objectsInGame[i].transform.position;
            originalOrientations[i] = objectsInGame[i].transform.rotation;
        }
    }
Пример #12
0
        public static Touch GetTouch(int index)
        {
#if NEW_INPUT_SYSTEM_ACTIVE
            TouchControl touch = null;
            if (Touchscreen.current != null && index >= 0 && index < Touchscreen.current.touches.Count)
            {
                touch = Touchscreen.current.touches[index];
            }

            return(ConvertToLegacyTouch(touch));
#else
            return(Input.GetTouch(index));
#endif
        }
Пример #13
0
        // -----------------
        static public TouchControl CreateStretchyControl(
            System.Type controlType,
            TouchControlPanel panel,
            Transform root,
            string name,
            Rect regionRect,
            float localDepth)
        {
            TouchControl c = (TouchControl)CreateStretchyRectTr(controlType, panel.transform, name, regionRect, localDepth);

            c.InvalidateHierarchy();

            return(c);
        }
Пример #14
0
    private void EndTouchInput(TouchControl control)
    {
        int id = control.touchId.ReadValue();

        for (int i = 0; i < 10; i++)
        {
            if (touch_id_order[i] == id)
            {
                m_HighlightPool.GetChild(i).gameObject.SetActive(false);
                return;
            }
        }
        ShowMessage("Touch " + id + " Stopped.");
    }
Пример #15
0
        protected override void FinishSetup(InputDeviceBuilder builder)
        {
            var touchArray = new TouchControl[TouchscreenState.kMaxTouches];

            for (var i = 0; i < TouchscreenState.kMaxTouches; ++i)
            {
                touchArray[i] = builder.GetControl <TouchControl>(this, "touch" + i);
            }

            allTouchControls     = new ReadOnlyArray <TouchControl>(touchArray);
            m_ActiveTouchesArray = new TouchControl[TouchscreenState.kMaxTouches];

            base.FinishSetup(builder);
        }
Пример #16
0
    // When a touch input ends, set the highlight inactive.
    private void EndTouchInput(TouchControl control)
    {
        int       id        = control.touchId.ReadValue();
        Transform highlight = m_HighlightPool.Find(id.ToString());

        if (highlight != null)
        {
            highlight.gameObject.SetActive(false);
        }
        else
        {
            ShowMessage("Touch " + id + " Stopped.");
        }
    }
Пример #17
0
    private void Awake()
    {
        controller = GetComponent <CharacterController>();
        player     = GetComponent <Player>();
        jump       = GetComponent <JumpPlayer>();
        attack     = GetComponent <MainAttackPlayer>();

        touchControl             = FindObjectOfType <TouchControl>();
        playerInputConfiguration = GetComponent <PlayerInputConfiguration>();

        maxMoveSpeed = moveSpeed;

        InitializeInput();

        camTransform = Camera.main.transform;
    }
Пример #18
0
    void Awake()
    {
        controller               = GetComponent <CharacterController>();
        player                   = GetComponent <Player>();
        attack                   = GetComponent <MainAttackPlayer>();
        touchControl             = GameObject.FindObjectOfType <TouchControl>();
        playerInputConfiguration = GetComponent <PlayerInputConfiguration>();


        InitializeInput();


        slopeLimit     = controller.slopeLimit;
        jumpSlopeLimit = Mathf.Clamp(controller.slopeLimit * 2, 0f, 90f);

        maxJumpCount = jumpCount;
    }
Пример #19
0
        // -----------------
        static public TouchControl CreateStaticControl(
            System.Type controlType,
            TouchControlPanel panel,
            Transform root,
            string name,
            Vector2 anchorPos,
            Vector2 offset,
            float size,
            float localDepth)
        {
            TouchControl c = (TouchControl)CreateConstSizeRectTr(controlType, panel.transform, name, anchorPos, offset, Vector2.one * size, localDepth);

            c.InvalidateHierarchy();


            return(c);
        }
Пример #20
0
    void Start()
    {
        if (SystemInfo.supportsGyroscope)
        {
            touchControl         = GetComponent <TouchControl>();
            touchControl.enabled = true;
            userIsOnPhone        = true;

            GameObject.Find("Main Camera").GetComponent <GyroControl>().enabled = true;
        }

        else
        {
            desktopControl         = GetComponent <DesktopControl>();
            desktopControl.enabled = true;
            userIsOnDesktop        = true;
        }
    }
Пример #21
0
 // -------------------
 public void DrawWarnings(TouchControl c)
 {
     if (!c.gameObject.activeInHierarchy)
     {
         EditorGUILayout.HelpBox("This control is inactive!", MessageType.Info);
     }
     else
     {
         if (c.rig == null)
         {
             InspectorUtils.DrawErrorBox("This control is not connected to a CF2 Input Rig!!");
         }
         if (c.panel == null)
         {
             InspectorUtils.DrawErrorBox("This control is not connected to a CF2 Touch Control Panel!");
         }
     }
 }
Пример #22
0
    ButtonNormal HeadIcon;                          //头像图标

    // Use this for initialization
    void Start()
    {
        tchScrn = GameObject.Find("Canvas/TouchControl").GetComponent <TouchControl>();
        bkgImg  = GetComponent <Image>();
        //clckPanel = GetComponent<ClickPanel>();
        //添加事件
        onClickOrEsc.AddListener(DisplayWindow_Option);
        Time.timeScale = 1;
        //gameState = GameState.gaming;

        //获取玩家
        player   = GameObject.FindObjectOfType <PlayCharacter>();
        HeadIcon = GameObject.Find("Canvas/Head").GetComponent <ButtonNormal>();
        //重新读取界面信息
        GameManager.Instance.loadCanvas();
        //获取画布
        cvs = GameManager.Instance.UICanvas;
    }
Пример #23
0
    private void UpdateTouchInput(TouchControl control)
    {
        int     id  = control.touchId.ReadValue();
        Vector2 pos = Camera.main.ScreenToWorldPoint(control.position.ReadValue());

        Transform highlight = m_HighlightPool.Find(id.ToString());

        if (highlight != null)
        {
            highlight.position = new Vector3(pos.x, pos.y, 0.5f);

            // Update position text
            Transform posText = highlight.Find("Pos");
            if (posText != null)
            {
                posText.GetComponent <TextMesh>().text = control.position.ReadValue().ToString("F0");
            }
        }
    }
Пример #24
0
    const float m_Distance = 10; // Rayの届く距離

    void Update()
    {
        // タッチされたとき
        if (Input.GetMouseButtonDown(0))
        {
            Vector2    tapPoint    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Collider2D collition2d = Physics2D.OverlapPoint(tapPoint);
            if (collition2d)
            {
                RaycastHit2D hitObject = Physics2D.Raycast(tapPoint, -Vector2.up);
                if (hitObject)
                {
                    //Debug.Log("hit object " + hitObject.collider.gameObject.name);
                    GameObject   selectedGameObject = hitObject.collider.gameObject;
                    TouchControl target             = selectedGameObject.GetComponent(typeof(TouchControl)) as TouchControl;
                    if (target != null)
                    {
                        target.TapDown(ref hitObject);
                    }
                }
            }
        }
        // 指を離したとき
        else if (Input.GetMouseButtonUp(0))
        {
            Vector2    tapPoint    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Collider2D collition2d = Physics2D.OverlapPoint(tapPoint);
            if (collition2d)
            {
                RaycastHit2D hitObject = Physics2D.Raycast(tapPoint, -Vector2.up);
                if (hitObject)
                {
                    //Debug.Log("hit object " + hitObject.collider.gameObject.name);
                    GameObject   selectedGameObject = hitObject.collider.gameObject;
                    TouchControl target             = selectedGameObject.GetComponent(typeof(TouchControl)) as TouchControl;
                    if (target != null)
                    {
                        target.TapUp(ref hitObject);
                    }
                }
            }
        }
    }
        // --------------------------
        protected TouchControl CreateNonDynamicTouchControl(System.Type controlType)
        {
            TouchControl c = null;

            if (this.positionMode == NonDynamicControlWizardBase.PositionMode.ConstantSize)
            {
                c = TouchControlWizardUtils.CreateStaticControl(controlType, this.panel, this.panel.transform, this.controlName,
                                                                this.GetAnchorPos(), this.GetControlOffset(), this.GetControlSize(), this.GetControlDepth());
            }
            else
            {
                c = TouchControlWizardUtils.CreateStretchyControl(controlType, this.panel, this.panel.transform, this.controlName,
                                                                  this.GetRegionRect(), this.GetRegionDepth()); //this.GetControlDepth());
            }

            c.shape = this.controlShape;

            return(c);
        }
Пример #26
0
    void Awake()
    {
        player = GetComponent <Player>();
        playerInputConfiguration = GetComponent <PlayerInputConfiguration>();
        touchControl             = GameObject.FindObjectOfType <TouchControl>();

        InitializeInput();

        int i = 0;

        foreach (AttackCombo attack in attackCombo)
        {
            attack.attackId = i;
            attack.attack.AttackComboOrder = i;
            attack.attackRange             = attackRange;
            attack.attackReactionPower     = attackReactionPower;
            i++;
        }
    }
        // ----------------------
        protected TouchControl CreateDynamicTouchControl(System.Type controlType)
        {
            TouchControl c = null;

            if (this.dynamicMode == ControlMode.Static)
            {
                c = TouchControlWizardUtils.CreateStaticControl(controlType, this.panel, this.panel.transform, this.controlName,
                                                                this.GetAnchorPos(), this.GetControlOffset(), this.GetControlSize(), this.GetControlDepth());
            }
            else
            {
                c = TouchControlWizardUtils.CreateDynamicControlWithRegion(controlType, this.panel, this.controlName,
                                                                           this.GetControlSize(), this.GetRegionRect(), this.GetRegionDepth(), this.GetControlDepth());
            }

            c.shape = this.controlShape;

            return(c);
        }
        // -----------------
        public void SetSourceControl(TouchControl c)
        {
            if (this.sourceControl != null)
            {
                this.sourceControl.RemoveAnimator(this);
            }

            if ((c != null) && !c.CanBeUsed())
            {
                c = null;
            }

            this.sourceControl = c;

            if (this.sourceControl != null)
            {
                this.sourceControl.AddAnimator(this);
            }
        }
Пример #29
0
        static void Main(string[] args)
        {
            var           radio         = new Radio();
            RemoteControl remoteControl = new BasicRemoteControl(radio, "Radio");

            remoteControl.Device.SetPower(false);
            var volume = remoteControl.ToggleVolume(12, "-");

            Console.WriteLine($"[{remoteControl.DeviceName}] - Status do dispositivo - {remoteControl.Device.GetPower()}");
            Console.WriteLine($"[{remoteControl.DeviceName}] - Volume que esta o dispositivo - {volume}");

            var tv = new TV();
            var remoteTouchControl = new TouchControl(tv, "TV");

            remoteTouchControl.Device.SetPower(true);
            var volumeTV = remoteTouchControl.ToggleVolume(12, "+");

            Console.WriteLine($"[{remoteTouchControl.DeviceName}] - Status do dispositivo - {remoteTouchControl.Device.GetPower()}");
            Console.WriteLine($"[{remoteTouchControl.DeviceName}] - Volume que esta o dispositivo - {volumeTV}");
        }
Пример #30
0
            //public string			joyName;

            // ---------------------
            static public void AddControlListBindingsToMenu(
                GenericMenu menu,
                List <TouchControl> controlList,
                System.Action onRefreshCallback,
                BindingDescription.BindingType typeMask,
                string commandName,
                string menuPath,
                KeyCode digiKey = KeyCode.None,
                string axisName = null)
            //bool                          digiBindToPositiveAxis	= true)
            //string							joyName					= null)
            {
                for (int i = 0; i < controlList.Count; ++i)
                {
                    TouchControl c = controlList[i];

                    AddBindingContainerToMenu(menu, c, onRefreshCallback, typeMask, commandName,
                                              (menuPath + c.name + " (" + c.GetType().Name + ")/"), c, digiKey, axisName);
                }
            }
Пример #31
0
    private void UpdateTouchInput(TouchControl control)
    {
        int     id  = control.touchId.ReadValue();
        Vector2 pos = Camera.main.ScreenToWorldPoint(control.position.ReadValue());

        for (int i = 0; i < 10; i++)
        {
            if (touch_id_order[i] == id)
            {
                Transform highlight = m_HighlightPool.GetChild(i);
                highlight.position = new Vector3(pos.x, pos.y, 0f);

                Transform posText = highlight.Find("Pos");
                if (posText != null)
                {
                    posText.GetComponent <TextMesh>().text = control.position.ReadValue().ToString("F0");
                }
            }
        }
    }
Пример #32
0
    void Update()
    {
        Touchscreen touchscreen = Touchscreen.current;

        if (touchscreen != null && m_touchInfo != null)
        {
            m_touchInfo.MaxISXCount = touchscreen.touches.Count;

            for (int i = 0; i < touchscreen.touches.Count; i++)
            {
                TouchControl touch     = touchscreen.touches[i];
                string       touchInfo = touch.touchId.ReadValue() + "\n"
                                         + touch.phase.ReadValue().ToString() + "\n"
                                         + touch.position.ReadValue().ToString() + "\n"
                                         + touch.pressure.ReadValue().ToString() + "\n"
                                         + touch.radius.ReadValue().ToString() + "\n"
                                         + touch.delta.ReadValue().ToString();
                m_touchInfo.AddNewInputInfo(touchInfo, i);
            }
        }
    }
Пример #33
0
    private void NewTouchInput(TouchControl control)
    {
        int id = control.touchId.ReadValue();

        foreach (Transform highlight in m_HighlightPool)
        {
            if (!highlight.gameObject.activeSelf)
            {
                touch_id_order[highlight.GetSiblingIndex()] = id;
                highlight.gameObject.SetActive(true);

                Transform idText = highlight.Find("ID");
                if (idText != null)
                {
                    idText.GetComponent <TextMesh>().text = "ID: " + id;
                }

                return;
            }
        }
        ShowMessage("Touch " + id + " Detected.");
    }
Пример #34
0
        public static void ParseChildren(CustomInputControl parent, List<Classes.CustomInput.CustomInputControl> controls, ControlCollection controlContainer)
        {
            Bitmap image_down = Properties.Resources.Custom_Button_Down;
            Bitmap image_up = Properties.Resources.Custom_Button_Up;

            foreach (Classes.CustomInput.CustomInputControl controlDesc in controls)
            {
                HidButton imageButton = null;
                Control control = imageButton;

                switch (controlDesc.InputType)
                {
                    case Classes.CustomInputType.Container:
                        {
                            control = new ContainerPanel(parent, controlDesc);
                        }
                        break;
                    case Classes.CustomInputType.KeyCombination:
                    case Classes.CustomInputType.VirtualKey:
                    case Classes.CustomInputType.ScanCode:
                        {
                            control = imageButton = new KeyboardHidButton(parent, controlDesc);

                            if (!string.IsNullOrEmpty(controlDesc.Image))
                            {
                                imageButton.Image = GetBitmap(controlDesc.Image);
                            }
                            else
                            {
                                imageButton.Image = BuildCustomBitmap(image_up, controlDesc.InputDisplay, parent.Font, Color.Black);
                            }
                            if (!string.IsNullOrEmpty(controlDesc.DownImage))
                            {
                                imageButton.DownImage = GetBitmap(controlDesc.DownImage);
                            }
                            else
                            {
                                imageButton.DownImage = BuildCustomBitmap(image_down, controlDesc.InputDisplay, parent.Font, Color.White);
                            }
                            imageButton.SelectedImage = imageButton.DownImage;
                            imageButton.TransparentBackground = controlDesc.TransparentBackground;
                            imageButton.BackColor = parent.BackColor;
                            imageButton.CanHold = false;
                        }
                        break;
                    case Classes.CustomInputType.ShiftKey:
                    case Classes.CustomInputType.AltKey:
                    case Classes.CustomInputType.WinKey:
                        {
                        }
                        break;
                    case Classes.CustomInputType.LeftMouseButton:
                        {
                            imageButton = new MouseButtonHidButton(parent, controlDesc);
                        }
                        break;
                    case Classes.CustomInputType.RightMouseButton:
                        {
                            imageButton = new MouseButtonHidButton(parent, controlDesc);
                        }
                        break;
                    case Classes.CustomInputType.MouseDPad:
                        {
                            // add a control here to map dpad to mouse
                        }
                        break;
                    case Classes.CustomInputType.Accelerometer:
                        {
                            // add a control here to map accelerometer to mouse
                        }
                        break;
                    case Classes.CustomInputType.TouchPad:
                    case Classes.CustomInputType.TouchPadWithScroll:
                        {
                            control = new TouchControl();
                            ((TouchControl)control).HidWriter = parent.HidWriter;
                        }
                        break;
                    default:
                        {
                            // why are we here?
                        }
                        break;
                }
                control.Width = controlDesc.Width;
                control.Height = controlDesc.Height;
                control.Left = controlDesc.Left;
                control.Top = controlDesc.Top;
                control.Tag = controlDesc;

                if (!(control is ContainerPanel))
                {
                    control.Anchor = controlDesc.Anchor;
                    control.Dock = controlDesc.Dock;
                }

                controlContainer.Add(control);
            }
        }
Пример #35
0
 internal Desktop(Bitmap screenBuffer)
 {
     _screenBuffer = screenBuffer;
     _width = screenBuffer.Width;
     _height = screenBuffer.Height;
     _x = _y = 0;
     _parent = null;
     _desktopOwner = this;
     _captured = null;
 }
Пример #36
0
 internal bool CaptureTouch(TouchControl control)
 {
     if (_captured == null)
     {
         _captured = control;
         return true;
     }
     return false;
 }
Пример #37
0
 internal void ReleaseTouchCapture()
 {
     _captured = null;
 }
Пример #38
0
        public override void Dispose()
        {
            _screenBuffer.Dispose();
            _drawBackground = null;
            _captured = null;

            TouchUp = TouchDown = TouchMove = null;

            base.Dispose();
        }