Exemple #1
0
        private void Update()
        {
            if (!Input.GetMouseButton(0))
            {
                CurrentDirection = EMoveDirection.Stop;
                return;
            }

            float touchRatio = Vector2.Distance(transform.position, Input.mousePosition) / radius;

            if (touchRatio < minTouchRatio || touchRatio > maxTouchRatio)
            {
                return;
            }

            float angle = GlobalFunctions.GetAngle(Input.mousePosition, transform.position);

            if (angle >= -135f && angle < -45f)
            {
                CurrentDirection = EMoveDirection.Down;
            }
            else if (angle >= -45f && angle < 45f)
            {
                CurrentDirection = EMoveDirection.Right;
            }
            else if (angle >= 45f && angle < 135f)
            {
                CurrentDirection = EMoveDirection.Up;
            }
            else if (angle >= 135f || angle < -135f)
            {
                CurrentDirection = EMoveDirection.Left;
            }
        }
Exemple #2
0
        public void SetPosAndCycle()
        {
            Vector3 diffVec = sensingTarget.transform.position - PlayerController.LocalPlayer.transform.position;

            float dist = diffVec.magnitude;

            dist = Mathf.Min(dist, maxSensingDist);
            float m = (maxSensingDist - dist) / maxSensingDist;

            alphaChangeSpeed = 0.5f + 4.5f * m;
            float signScale = 1.0f + 2.0f * m;

            float angle = GlobalFunctions.GetAngle(diffVec, new Vector2());

            if (angle >= quadrantAngles[2] && angle < quadrantAngles[3])
            {
                m = (-Screen.height / 2) / diffVec.y;
            }
            else if (angle >= quadrantAngles[3] && angle < quadrantAngles[0])
            {
                m = (Screen.width / 2) / diffVec.x;
            }
            else if (angle >= quadrantAngles[0] && angle < quadrantAngles[1])
            {
                m = (Screen.height / 2) / diffVec.y;
            }
            else
            {
                m = (-Screen.width / 2) / diffVec.x;
            }

            sameFloorSign.rectTransform.anchoredPosition = diffVec * m;
            sameFloorSign.rectTransform.localScale       = new Vector3(signScale, signScale);
            upstairGroup.anchoredPosition   = diffVec * m - new Vector3(0f, upstairGroup.rect.height / 2);
            downstairGroup.anchoredPosition = diffVec * m + new Vector3(0f, downstairGroup.rect.height / 2);
        }