/**
     * @return void
     *
     * Função responsável por capturar o movimento da nave na tela
     *
     * */
    private void shipMoving()
    {
        ScreenTouch touchController = new ScreenTouch();

        int s = touchController.getSideTouch(transform.position, halfScreen);

        if (s == 0)
        {
            if (transform.position.x > -maxDist)
            {
                transform.Translate(Vector3.left * vel * Time.deltaTime);
            }

            if (transform.position.x < -maxDist)
            {
                transform.position = new Vector3(-maxDist, 0, 0);
            }
        }

        else if (s == 1)
        {
            if (transform.position.x < maxDist)
            {
                transform.Translate(Vector3.right * vel * Time.deltaTime);
            }

            if (transform.position.x > maxDist)
            {
                transform.position = new Vector3(maxDist, 0, 0);
            }
        }
    }
Exemplo n.º 2
0
    void controlLight()
    {
//		//The first
//		if(screenTouches.Count==2&&lastScreenTouches.Count!=0)
//		{}
        if (screenTouches.Count == 2 && lastScreenTouches.Count == 2)
        {
            ScreenTouch lastTouch1 = lastScreenTouches [0];
            ScreenTouch lastTouch2 = lastScreenTouches [1];

            ScreenTouch touch1 = screenTouches [0];
            ScreenTouch touch2 = screenTouches [1];

            if (lastTouch1.getId() == screenTouches [1].getId())
            {
                touch1 = screenTouches [1];
                touch2 = screenTouches [0];
            }

            float dis1 = Vector2.Distance(lastTouch1.getTouchPosition(), touch1.getTouchPosition());
            float dis2 = Vector2.Distance(lastTouch2.getTouchPosition(), touch2.getTouchPosition());



            float lastDis = Vector2.Distance(lastTouch1.getTouchPosition(), lastTouch2.getTouchPosition());
            float dis     = Vector2.Distance(touch1.getTouchPosition(), touch2.getTouchPosition());

            float disVariance = dis - lastDis;

            lightTheta += disVariance / 2;

            Vector2 lastVec = new Vector2();
            Vector2 vec     = new Vector2();

            if (dis1 > dis2)
            {
                lastVec = lastTouch1.getTouchPosition() - lastTouch2.getTouchPosition();
                vec     = touch1.getTouchPosition() - touch2.getTouchPosition();
            }
            if (dis1 < dis2)
            {
                lastVec = lastTouch2.getTouchPosition() - lastTouch1.getTouchPosition();
                vec     = touch2.getTouchPosition() - touch1.getTouchPosition();
            }

            lastVec.Normalize();
            vec.Normalize();
            float cross         = lastVec.x * vec.y - lastVec.y * vec.x;
            float alphaVariance = Mathf.Acos(Vector2.Dot(lastVec, vec));
            if (cross > 0)
            {
                lightAlpha += alphaVariance;
            }
            if (cross < 0)
            {
                lightAlpha -= alphaVariance;
            }
        }
    }
Exemplo n.º 3
0
        public TouchRecognizer(Element element, UIView view, ScreenTouch touchEffect)
        {
            this.element     = element;
            this.view        = view;
            this.touchEffect = touchEffect;

            viewDictionary.Add(view, this);
        }
Exemplo n.º 4
0
    float getDistance(ScreenTouch touch1, ScreenTouch touch2)
    {
        float disX = touch1.getTouchPosition().x - touch2.getTouchPosition().x;
        float disY = touch1.getTouchPosition().y - touch2.getTouchPosition().y;

        float dis = Mathf.Sqrt(disX * disX + disY * disY);

        return(dis);
    }
Exemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        //ネットワークへの接続
        PhotonNetwork.ConnectUsingSettings();

        //TitleTapのScriptを使う
        screenTouch = GameObject.Find("ScreenTouch").GetComponent <ScreenTouch>();

        JoinedRoom();
    }
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }

        instance = this;
    }
    /// <summary>
    /// タップした箇所にオブジェクトがあったらそのオブジェクトの関数を呼ぶ
    /// </summary>
    void ObjectSearch()
    {
        GameObject block = ScreenTouch.GetRayGameObject();

        if (moveSwich || blockTouch || block == null)
        {
            return;
        }

        Ray        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, blockToDistance))
        {
            if (block.tag == "Item" && hit.transform.gameObject == block)
            {
                hit.transform.gameObject.GetComponent <item>().ItemCatch();
                blockTouch = true;
                return;
            }

            if (block.tag == "Block" && hit.transform.gameObject == block)
            {
                hit.transform.gameObject.GetComponent <Block>().Touched();
                StateAnimation(PlayerState.Mining);
                blockTouch = true;
                return;
            }
            if (hit.transform.tag == "Trap" && isTouch)
            {
                isTouch = false;
                hit.transform.gameObject.GetComponent <TrapBase>().OnTouch();
            }
        }

        ray = new Ray(transform.position, transform.up * -1.0f);
        if (Physics.Raycast(ray, out hit, blockToDistance))
        {
            if (block.tag == "Item" && hit.transform.gameObject == block)
            {
                hit.transform.gameObject.GetComponent <item>().ItemCatch();
                blockTouch = true;
                return;
            }

            if (block.tag == "Block" && hit.transform.gameObject == block)
            {
                hit.transform.gameObject.GetComponent <Block>().Touched();
                StateAnimation(PlayerState.MiningUnder);
                blockTouch = true;
                return;
            }
        }
    }
Exemplo n.º 8
0
    void GetValidInput()
    {
        InputManager.getLastHands().Clear();
        InputManager.getLastHands().AddRange(InputManager.getHands());
        InputManager.getLastFingers().Clear();
        InputManager.getLastFingers().AddRange(InputManager.getFingers());
        InputManager.getLastScreenTouches().Clear();
        InputManager.getLastScreenTouches().AddRange(InputManager.getScreenTouches());

        InputManager.getHands().Clear();
        InputManager.getFingers().Clear();
        InputManager.getScreenTouches().Clear();



        for (int i = 0; i < handsData.Length; ++i)
        {
            if (handsData [i].valid == true)
            {
                Hand hand = new Hand(handsData [i]);
                InputManager.getHands().Add(hand);
            }
        }

        for (int i = 0; i < fingersData.Length; ++i)
        {
            if (fingersData [i].valid == true)
            {
                Finger finger = new Finger(fingersData [i]);
                InputManager.getFingers().Add(finger);
            }
        }

        for (int i = 0; i < touchesData.Length; ++i)
        {
            if (touchesData [i].valid == true)
            {
                ScreenTouch touch = new ScreenTouch(touchesData [i]);
                InputManager.getScreenTouches().Add(touch);

                SceneManager sceneManager = (SceneManager)GameObject.Find("Scene").GetComponent("SceneManager");

                Vector3 touchPos = touchesData[i].touchPosition.x * sceneManager.newVec2 * sceneManager.screenWidth + touchesData[i].touchPosition.y * sceneManager.newVec1 * sceneManager.screenHeight;
//				print (touchPos);
            }
        }

//		if(InputManager.getLastScreenTouches().Count!=0&&InputManager.getScreenTouches().Count!=0)
//		{
//			print ("frame "+InputManager.getScreenTouches()[0].getFrame()+" last "+InputManager.getLastScreenTouches()[0].getTouchPosition()+" this "+InputManager.getScreenTouches()[0].getTouchPosition());
//		}
    }
Exemplo n.º 9
0
        private string GetScreenDescription()
        {
            var descriptionBuilder = new StringBuilder();

            descriptionBuilder.AppendLine("========================================");
            descriptionBuilder.AppendLine("Component: Screen");
            descriptionBuilder.AppendLine();
            descriptionBuilder.AppendLine($"Touch Screen Type: {ScreenTouch.ToString()}");
            descriptionBuilder.AppendLine($"Screen Aspect Ratio: {ScreenTouch.AspectRatio}");
            descriptionBuilder.AppendLine($"Screen Diagonal In Inches: {ScreenTouch.DiagonalInInches}");
            descriptionBuilder.AppendLine("========================================");
            return(descriptionBuilder.ToString());
        }
Exemplo n.º 10
0
        protected override void OnAttached()
        {
            view = Control == null ? Container : Control;


            ScreenTouch effect = (ScreenTouch)Element.Effects.FirstOrDefault(e => e is ScreenTouch);

            if (effect != null && view != null)
            {
                recognizer = new TouchRecognizer(Element, view, effect);
                view.AddGestureRecognizer(recognizer);
            }
        }
Exemplo n.º 11
0
        protected override void OnAttached()
        {
            Console.WriteLine("touch attached exe wow!");
            touchEffect = (ScreenTouch)Element.Effects.FirstOrDefault(e => e is ScreenTouch);
            capture     = touchEffect.Capture;


            if (Control != null && touchEffect != null)
            {
                //  viewDictionary.Add(Control, this);

                Control.Touch += OnTouch;

                fromPixels = Control.Context.FromPixels;
            }
        }
    void Update()
    {
        DontMoveInterval();
        if (MainState.playResult == state || MainState.playStop == state)
        {
            return;
        }

        ObjectSearch();

        if (!isTouch)
        {
            SetPosition(ScreenTouch.GetPosition());
            return;
        }

        MovingSetPosition(ScreenTouch.GetDeltaPosition());
    }
Exemplo n.º 13
0
    float CheckRotateAngle(ref bool rotate)
    {
        float rotateAngle = 0;

        if (screenTouches.Count == 1 && lastScreenTouches.Count == 1)
        {
            ScreenTouch touch     = (ScreenTouch)screenTouches [0];
            ScreenTouch lastTouch = (ScreenTouch)lastScreenTouches [0];

            if (touch.getId() == lastFingerId)
            {
                rotateAngle = touch.getTouchPosition().y - lastTouch.getTouchPosition().y;
                rotate      = true;
            }
            lastFingerId = touch.getId();
        }

        return(rotateAngle / 50);
    }
Exemplo n.º 14
0
    bool CheckReverse()
    {
        int size = stroke.getStrokePoints().Count;

        ScreenTouch startPoint   = (ScreenTouch)stroke.getStrokePoints() [0];
        ScreenTouch lastEndPoint = (ScreenTouch)stroke.getStrokePoints() [size - 2];
        ScreenTouch endPoint     = (ScreenTouch)stroke.getStrokePoints() [size - 1];

        float lastDis = getDistance(startPoint, lastEndPoint);
        float dis     = getDistance(startPoint, endPoint);

        //Check the distance between the end point and the start point
        if ((lastDis - dis) > 1)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 15
0
        void Awake()
        {
            StatusBar.Hide();
            instant                        = this;
            ARCamera                       = Camera.main;
            cloudRightPosition             = cloudRight.transform.position;
            cloudLeftPosition              = cloudLeft.transform.position;
            guanyinPosition                = guanyin.transform.localPosition;
            guanyinScale                   = guanyin.transform.localScale.x;
            guanyinRotation                = guanyin.transform.localRotation;
            guanyinCloud                   = guanyin.GetChildByNameInChildren("Cloud_GuanYin");
            headPosition                   = guanyin.GetChildByNameInChildren("HeadPosition").transform;
            headLightObj                   = guanyin.GetChildByNameInChildren("HeadLight").transform;
            scanner                        = canvas.GetChildByName("Scanner");
            btnBack                        = canvas.GetChildByName("BtnBack");
            btnInfo                        = canvas.GetChildByName("BtnInfo");
            infoPanel                      = canvas.GetChildByName("InfoPanel");
            origGuanyinScale               = guanyin.transform.localScale.x;
            screenTouch                    = gameObject.GetComponent <ScreenTouch> ();
            screenTouch.onDoubleTouchBegin = () => guanyinTouchedScale = guanyin.transform.localScale.x;
            guanyinContainer               = guanyin.transform.parent.gameObject;
            cameraObjectContainer          = ARCamera.gameObject.transform.parent.gameObject.GetChildByName("ObjectContainer");
//		dizuoPosition = dizuo.transform.localPosition;
//		if (SystemInfo.supportsGyroscope) {
//			Input.gyro.enabled = true;
//			text.text = "gyro supported";
//			startGyroY = Input.gyro.attitude.eulerAngles.y;
//		}else
//			text.text = "gyro not supported";
            startGyroY = Camera.main.transform.localRotation.eulerAngles.y;
            raysContainer.SetActive(false);
            //sceneComponents.Add("scroll", new Scroll (enterNameObj));
            sceneComponents.Add("falun", new Falun(falun));
            sceneComponents.Add("sparkle", new Sparkle(sparkle));
            //dizuo.transform.localScale = Vector3.one * .001f;
            headLight.enabled = false;
            //qifuPanel.SetActive (false);
            GetRandomFu();
            StartCoroutine(LoadAudio());
        }
Exemplo n.º 16
0
    /**
     * @return void
     *
     * Função responsável por capturar o movimento da nave na tela
     *
     * */
    private void shipMoving()
    {
        ScreenTouch touchController = new ScreenTouch();

        int s = touchController.getSideTouch(transform.position, halfScreen);

        if (s == 0)
        {

            if (transform.position.x > -maxDist)
            {
                transform.Translate(Vector3.left * vel * Time.deltaTime);
            }

            if (transform.position.x < -maxDist)
            {
                transform.position = new Vector3(-maxDist, 0, 0);
            }
        }

        else if (s == 1)
        {

            if (transform.position.x < maxDist)
            {
                transform.Translate(Vector3.right * vel * Time.deltaTime);
            }

            if (transform.position.x > maxDist)
            {
                transform.position = new Vector3(maxDist, 0, 0);
            }

        }
    }