// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && cam.enabled == true) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); float rayDistance; if (mapPlane.Raycast(ray, out rayDistance)) { Vector3 point = ray.GetPoint(rayDistance); Vector3 pointOnMap = this.transform.InverseTransformPoint(point); Vector2 pointOnMap2D = new Vector2(pointOnMap.x, pointOnMap.z); Gps coord = myMap.flatGeo.getGeolocation(pointOnMap2D); HashSet <ILocationProvider> providers = LocationSourceManager.ActiveProviders; foreach (ILocationProvider provider in providers) { if (provider.GetSourceType() == SourceType.fake) { FakeLocationSource fake = (FakeLocationSource)provider; fake.geoLocation.latitude = coord.Latitude; fake.geoLocation.longitude = coord.Longitude; } } } } }
void Awake() { x = transform.localPosition.x; y = transform.localPosition.z; MapPos = new Vector2((float)x, (float)y); //For dragNdrop movement DragMapObject.mapObjectMoved += (sender, args) => { if (args.arg1 == this) { Gps coord = args.arg1.myMap.flatGeo.getGeolocation(args.arg2); if (LinkedGeoEntity == null) { return; } //Changes coordinates by changing fake location sources coordinates if (LinkedGeoEntity.GetGeoEntityType() == GeoEntityType.player) { HashSet <ILocationProvider> providers = LocationSourceManager.ActiveProviders; foreach (ILocationProvider provider in providers) { if (provider.GetSourceType() == SourceType.fake) { FakeLocationSource fake = (FakeLocationSource)provider; fake.geoLocation.latitude = coord.Latitude; fake.geoLocation.longitude = coord.Longitude; } } } else { //Changes coordinates by changing geoentitys coordinates LinkedGeoEntity.ChangeGeolocation(coord); } } }; }
public void AddSource(FakeLocationSource fls) { this.fls = fls; }