Exemple #1
0
        public void GameControllerReady(GameController gameController, IInputManager inputManager)
        {
            // This is called twice on a host - once when the client game
            // starts and once when the server game starts.
            if (pInputManager != null)
            {
                return;
            }

            if (eTeam != -1)
            {
                GetComponent <SpriteOverlay>().SetColor(TeamColor.FromIndex(eTeam));
            }

            pInputManager = inputManager;
            pJoystick     = new JoystickControl(inputManager);

            if (isLocalPlayer)
            {
                var leftButton = GameObject.Find("LeftButton");
                if (leftButton != null)
                {
                    pTouchButtons = leftButton.GetComponent <TouchButtons>();
                }
            }

            if (lRb != null)
            {
                Initialize();
                lInitialized = true;
            }
        }
Exemple #2
0
    public static bool GetButton(string buttonName)
    {
        //TODO: Uncomment 4 lines below for Touchpad
//		if (Input.touches.Length > 0) {
//
//			for(int i = 0; i < Input.touches.Length; i++)
//			{
//				Touch buttonTouch = Input.GetTouch (i);

        //TODO: Uncomment 2 lines for Mouse & Keyboard
        if (Input.GetMouseButton(0))
        {
            Vector3 buttonTouch = Input.mousePosition;

            Camera cam = Camera.main;

            //TODO: Uncomment line below for TouchPad
            //Ray rayButton = cam.ScreenPointToRay(buttonTouch.position);

            //TODO: Uncomment for Mouse
            Ray rayButton = cam.ScreenPointToRay(buttonTouch);

            RaycastHit buttonHit      = new RaycastHit();
            bool       buttonHitFound = Physics.Raycast(rayButton, out buttonHit);


            if (DebugTouchPad.DrawTouchRay)
            {
                Debug.DrawRay(cam.transform.position, rayButton.direction, Color.yellow, 3.0f);
            }

            if (buttonHitFound)
            {
                TouchButtons touchedButton = buttonHit.collider.gameObject.GetComponent <TouchButtons> ();

                if (touchedButton)
                {
                    touchedButton.setTouched(true);

                    if (touchedButton.Name == buttonName)
                    {
                        return(true);
                    }
                }
            }
        }
        //}



        return(false);
    }