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

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

        transform.position = currentPosition;
    }
예제 #2
0
    // Use this for initialization
    void Awake()
    {
        instance = this;

        map = GameObject.Find("Map - Flat").GetComponent <GOMap> ();


        if (map == null)
        {
            Debug.LogWarning("GOObject - Map property not set");
            return;
        }
    }
예제 #3
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;
        }
    }
예제 #4
0
    public static GOObject AddComponentToObject(GameObject container, GOMap map, Coordinates location)
    {
        container.SetActive(false);
        GOObject obj = container.AddComponent <GOObject>() as GOObject;

        // Variable initialization goes here -
        // All of this will be called before Player's awake because
        // the object holding the Player component is currently not active.
        obj.map            = map;
        obj.coordinatesGPS = location;
        container.SetActive(true);
        return(obj);
    }
예제 #5
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;
    }
예제 #6
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;
        }
    }
예제 #7
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);
    }
예제 #8
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);
    }
예제 #9
0
    private void InitializeMapLocations()
    {
        MapObjects = new List <GameObject>();
        List <PointLocation>   banks      = CurrentGame.Instance.gameDetail.banks;
        List <ServerTradePost> tradeposts = CurrentGame.Instance.gameDetail.tradePosts;

        //todo load all into map
        GameObject mapobj    = GameObject.Find("Map");
        GameObject container = new GameObject("TESTEST");        //todo get rid of this

        //GameObject container = GameObject.Find("MapElements");
        if (mapobj != null)
        {
            GOMap map = mapobj.GetComponent <GOMap>();
            if (map != null)
            {
                GameObject serverBanks = new GameObject("Server Banks");
                serverBanks.transform.parent = container.transform;
                foreach (PointLocation bank in banks)
                {
                    GameObject temp = (GameObject)Instantiate(Resources.Load("Bank"), Vector3.zero, Quaternion.identity);
                    temp.transform.parent = serverBanks.transform;
                    Bank bankScript = temp.GetComponent <Bank>();
                    if (bankScript != null)
                    {
                        bankScript.BankId = bank.id;
                    }


                    Coordinates coordinates = new Coordinates(bank.point.latitude, bank.point.longitude, 0);
                    GOObject    obj         = GOObject.AddComponentToObject(temp, map, coordinates);
                    Vector3     pos         = coordinates.convertCoordinateToVector(0);
                    pos.z = -3;
                    temp.transform.localPosition = pos;
                    MapObjects.Add(temp);
                }


                GameObject serverTPs = new GameObject("Server Tradingposts");
                serverTPs.transform.parent = container.transform;
                foreach (ServerTradePost tp in tradeposts)
                {
                    GameObject temp = (GameObject)Instantiate(Resources.Load("Tradingpost"), Vector3.zero, Quaternion.identity);
                    temp.transform.parent = serverTPs.transform;
                    TradingPost tpScript = temp.GetComponent <TradingPost>();
                    if (tpScript != null)
                    {
                        tpScript.TPId = tp.id;
                        //todo load flavorText?
                    }

                    GOObject obj = GOObject.AddComponentToObject(temp, map,
                                                                 new Coordinates(tp.point.latitude, tp.point.longitude, 1.0));
                    MapObjects.Add(temp);
                }

                GameObject playerHolder = new GameObject("Playerholder");                //todo is there a better way to do this?
                playerHolder.transform.parent = container.transform;
                List <ServerPlayer> players = CurrentGame.Instance.PlayerList();
                foreach (ServerPlayer serverPlayer in players)
                {
                    if (serverPlayer.ClientId.Equals(CurrentGame.Instance.LocalPlayer.ClientId))
                    {
                        continue;
                    }

                    GameObject temp = (GameObject)Instantiate(Resources.Load("Player"), Vector3.zero, Quaternion.identity);
                    temp.name             = serverPlayer.name;
                    temp.transform.parent = playerHolder.transform;
                    Person person = temp.GetComponent <Person>();
                    person.Player = serverPlayer;

                    GOObject obj = GOObject.AddComponentToObject(temp, map, new Coordinates(51.164510, 4.140199, 1.0));

                    CurrentGame.Instance.PlayerObjects.Add(serverPlayer.ClientId, temp);
                }
            }
            else
            {
                Debug.Log("ERROR: MAP NOT LOADED");
            }
        }
        else
        {
            Debug.Log("ERROR: MAP NOT LOADED");
        }
    }
예제 #10
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);
    }