public void GetInput()
        {
            #region [1-9] SuitDemos
            for (int i = 0; i < AllDemos.Length; i++)
            {
                if (AllDemos[i] != null)
                {
                    if (Input.GetKeyDown(AllDemos[i].ActivateHotkey))
                    {
                        SelectSuitDemo(AllDemos[i]);
                    }
                }
            }
            #endregion

            #region [7] Massage Toggle
            if (Input.GetKeyDown(KeyCode.Alpha7))
            {
                ToggleMassage();
            }
            #endregion

            #region [Space] Clear all effects
            if (Input.GetKeyDown(KeyCode.Space))
            {
                ClearAllEffects();
            }
            #endregion

            #region [Arrows] Direction Controls
            bool  moving = false;
            float velVal = 350;

            if ((Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) && myRB.transform.position.x > -Extent)
            {
                myRB.AddForce(Vector3.left * velVal);
            }
            if ((Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) && myRB.transform.position.x < Extent)
            {
                myRB.AddForce(Vector3.right * velVal);
            }
            if ((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && myRB.transform.position.y < Extent)
            {
                myRB.AddForce(Vector3.up * velVal);
            }
            if ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && myRB.transform.position.y > -Extent)
            {
                myRB.AddForce(Vector3.down * velVal);
            }

            if (!moving)
            {
                myRB.velocity = Vector3.zero;
            }
            #endregion

            #region Clicking on SuitBodyCollider
            if (Input.GetMouseButtonDown(0))
            {
                //Where the mouse is
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                //Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue, 3.5f);

                //Raycast to see if we hit
                if (Physics.Raycast(ray, out hit, 100))
                {
                    //Get the clicked SuitBodyCollider
                    HardlightCollider clicked = hit.collider.gameObject.GetComponent <HardlightCollider>();

                    //Assuming there is one
                    if (clicked != null)
                    {
                        //Do whatever our current demo wants to do with that click info.
                        CurrentDemo.OnSuitClicked(clicked, hit);
                    }
                }
            }
            #endregion

            #region Clicking on SuitBodyCollider
            if (Input.GetMouseButton(0))
            {
                //Where the mouse is
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                //Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue, 3.5f);

                //Raycast to see if we hit
                if (Physics.Raycast(ray, out hit, 100))
                {
                    //Get the clicked SuitBodyCollider
                    HardlightCollider clicked = hit.collider.gameObject.GetComponent <HardlightCollider>();

                    //Assuming there is one
                    if (clicked != null)
                    {
                        //Do whatever our current demo wants to do with that click info.
                        CurrentDemo.OnSuitClicking(clicked, hit);
                    }
                }
            }
            else
            {
                if (CurrentDemo != null)
                {
                    CurrentDemo.OnSuitNoInput();
                }
            }
            #endregion

            #region [Esc] Application Quit Code
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }
            #endregion
        }
Пример #2
0
        void Update()
        {
            bool  moving = false;
            float velVal = 350;

            #region Direction Controls
            if ((Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) && myRB.transform.position.x > -Extent)
            {
                myRB.AddForce(Vector3.left * velVal);
            }
            if ((Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) && myRB.transform.position.x < Extent)
            {
                myRB.AddForce(Vector3.right * velVal);
            }
            if ((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && myRB.transform.position.y < Extent)
            {
                myRB.AddForce(Vector3.up * velVal);
            }
            if ((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && myRB.transform.position.y > -Extent)
            {
                myRB.AddForce(Vector3.down * velVal);
            }

            if (!moving)
            {
                myRB.velocity = Vector3.zero;
            }
            #endregion

            #region Clicking on SuitBodyCollider
            if (Input.GetMouseButtonDown(0))
            {
                //Where the mouse is
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                //Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue, 3.5f);

                //Raycast to see if we hit
                if (Physics.Raycast(ray, out hit, 100))
                {
                    //Get the clicked SuitBodyCollider
                    SuitBodyCollider clicked = hit.collider.gameObject.GetComponent <SuitBodyCollider>();

                    //Assuming there is one
                    if (clicked != null)
                    {
                        //Do whatever our current demo wants to do with that click info.
                        CurrentDemo.OnSuitClicked(clicked, hit);
                    }
                }
            }
            #endregion

            #region Application Quit Code
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }
            #endregion
        }