Beispiel #1
0
    void OnOriginSet(Coordinates currentLocation)
    {
        //Position
        Vector3 currentPosition = currentLocation.convertCoordinateToVector(0);

        if (goMap.useElevation)
        {
            currentPosition = GOMap.AltitudeToPoint(currentPosition);
        }

        transform.position = currentPosition;
    }
Beispiel #2
0
    public void OnTileLoad(GOTile tile)
    {
        Vector3 currentLocation = goMap.locationManager.currentLocation.convertCoordinateToVector();

        if (tile.goTile.vectorIsInTile(currentLocation))
        {
//
            Debug.Log("FIX Start");
//
            currentLocation    = GOMap.AltitudeToPoint(currentLocation);
            transform.position = currentLocation;
        }
    }
Beispiel #3
0
    void OnOriginSet(Coordinates currentLocation)
    {
        //Position
        Debug.Log(currentLocation.latitude.ToString() + " / " + currentLocation.longitude.ToString());
        Vector3 currentPosition = currentLocation.convertCoordinateToVector(0);

        if (goMap.useElevation)
        {
            currentPosition = GOMap.AltitudeToPoint(currentPosition);
        }

        transform.position = currentPosition;
    }
Beispiel #4
0
    public void OnTileLoad(GOTile tile)
    {
        Vector3 currentLocation = goMap.locationManager.currentLocation.convertCoordinateToVector();

        if (tile.goTile.vectorIsInTile(currentLocation))
        {
            if (goMap.useElevation)
            {
                currentLocation = GOMap.AltitudeToPoint(currentLocation);
            }

            transform.position = currentLocation;
        }
    }
Beispiel #5
0
    void CarMotion()
    {
        Vector3 dir = Vector3.ProjectOnPlane(carCamera.transform.forward, Vector3.down);

        if (Input.GetKey(KeyCode.D))
        {
            dir = Quaternion.AngleAxis(10, Vector3.up) * dir;
        }
        else if (Input.GetKey(KeyCode.A))
        {
            dir = Quaternion.AngleAxis(-10, Vector3.up) * dir;
        }

        Debug.DrawLine(carCamera.transform.position, carCamera.transform.position + dir * 100, Color.green, 1);

        Vector3 lastPosition = transform.position;

        bool thrust        = Input.GetKey(KeyCode.W) || autoDrive;
        bool reverseThrust = Input.GetKey(KeyCode.S);

        int reverse = 1;

        if (reverseThrust)
        {
            reverse = -1;
            thrust  = true;
        }

        float speed = 0.8f;

        if (thrust && !GOUtils.IsPointerOverUI())
        {
            transform.Translate(Time.deltaTime * (speed * 60 * avatarFigure.transform.forward * reverse));
            if (goMap.useElevation)
            {
                transform.localPosition = GOMap.AltitudeToPoint(transform.localPosition);

                int f = lastPosition.y > transform.localPosition.y ? -1 : 1;
                dir.y = Math.Abs(lastPosition.y - transform.localPosition.y) * f * reverse;
            }
        }

        rotateAvatar(dir);
    }
Beispiel #6
0
    void OnLocationChanged(Coordinates currentLocation)
    {
        Vector3 lastPosition = transform.position;

        //Position
        Vector3 currentPosition = currentLocation.convertCoordinateToVector(0);

        if (goMap.useElevation)
        {
            currentPosition = GOMap.AltitudeToPoint(currentPosition);
        }

        if (lastPosition == Vector3.zero)
        {
            lastPosition = currentPosition;
        }

        moveAvatar(lastPosition, currentPosition);
    }
Beispiel #7
0
    void OrbitMotion()
    {
        Vector3 dir = Vector3.forward;

        dir = Camera.main.transform.forward;
        dir = Vector3.ProjectOnPlane(dir, Vector3.down);

        Vector3 lastPosition = transform.position;

        Vector3 v1   = Vector3.forward;
        bool    drag = false;

        if (Application.isMobilePlatform)
        {
            drag = Input.touchCount >= 1;
            if (drag)
            {
                v1 = Input.GetTouch(0).position;
            }
        }
        else
        {
            drag = Input.GetMouseButton(0);
            if (drag)
            {
                v1 = Input.mousePosition;
            }
        }


        Vector3 v2 = Camera.main.WorldToScreenPoint(avatarFigure.transform.position);
        float   d  = Vector2.Distance(v1, v2) / Screen.height;

        if (autoDrive)
        {
            d    = 1;
            drag = true;
        }

        if (d < 0.5f)
        {
            d = 0.5f;
        }

        int reverse = 1;

        if (v1.y > v2.y && Mathf.Abs(v2.x - v1.x) < 80)
        {
            reverse = -1;
            d       = -d;
        }


        if (drag && !GOUtils.IsPointerOverUI())
        {
            transform.Translate(Time.deltaTime * (d * 60 * avatarFigure.transform.forward));
            if (goMap.useElevation)
            {
                transform.localPosition = GOMap.AltitudeToPoint(transform.localPosition);

                int f = lastPosition.y > transform.localPosition.y ? -1 : 1;
                dir.y = Math.Abs(lastPosition.y - transform.localPosition.y) * f * reverse;
            }
        }

        rotateAvatar(dir);
    }