コード例 #1
0
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                _radarMap = (RadarMap)e.NewElement;
                _radarMap.AoAtualizaPosicao += (object sender, LocalizacaoInfo local) => {
                    if (!animando)
                    {
                        if (map == null)
                        {
                            return;
                        }
                        CameraPosition.Builder builder = CameraPosition.InvokeBuilder(map.CameraPosition);
                        builder.Target(new LatLng(local.Latitude, local.Longitude));
                        builder.Bearing(local.Sentido);
                        builder.Zoom(PreferenciaUtils.NivelZoom);
                        builder.Tilt(PreferenciaUtils.MapaTilt);
                        CameraPosition cameraPosition = builder.Build();
                        CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                        if (PreferenciaUtils.SuavizarAnimacao)
                        {
                            map.AnimateCamera(cameraUpdate);
                        }
                        else
                        {
                            map.MoveCamera(cameraUpdate);
                        }
                        if (GPSUtils.Simulado)
                        {
                            atualizarMinhaPosicao(local);
                        }
                        animando = true;
                    }
                };
                _radarMap.AoDesenharRadar += (object sender, RadarPin radar) => {
                    desenharRadar(radar);
                };
                ((MapView)Control).GetMapAsync(this);
            }
        }
コード例 #2
0
    void DrawSpawnerUI()
    {
        Rect uiRect = new Rect(0, 0, 100, 20);

        GUI.Label(uiRect, "创建新物种");

        uiRect.y += 20;
        fatherID  = DrawList(uiRect, "选择父系DNA", fatherID, ref showFatherList);
        if (fatherID != -1)
        {
            if (fatherMap == null)
            {
                GameObject frmGO = GameObject.Instantiate <GameObject>(RadarPrefab);
                frmGO.transform.position = RadarMapPosF;
                fatherMap = frmGO.GetComponent <RadarMap>();
            }
            SetRadarMap(fatherMap, Codex.DNAPool[fatherID]);
        }

        uiRect.y += 20;
        motherID  = DrawList(uiRect, "选择母系DNA", motherID, ref showMotherList);
        if (motherID != -1)
        {
            if (motherMap == null)
            {
                GameObject mrmGO = GameObject.Instantiate <GameObject>(RadarPrefab);
                mrmGO.transform.position = RadarMapPosM;
                motherMap = mrmGO.GetComponent <RadarMap>();
            }
            SetRadarMap(motherMap, Codex.DNAPool[motherID]);
        }

        if (fatherID != -1 && motherID != -1)
        {
            uiRect.y += 20;
            if (GUI.Button(uiRect, "繁殖!"))
            {
                SpawnMonster();
            }
        }
    }
コード例 #3
0
        protected override void inicializarComponente()
        {
            base.inicializarComponente();

            _map = new RadarMap
            {
                IsShowingUser   = true,
                HeightRequest   = 100,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            _map.MapType = (PreferenciaUtils.ImagemSatelite) ? MapType.Hybrid : MapType.Street;
            AbsoluteLayout.SetLayoutBounds(_map, new Rectangle(0, 0, 1, 0.9));
            AbsoluteLayout.SetLayoutFlags(_map, AbsoluteLayoutFlags.All);
            _map.PropertyChanged += (sender, e) =>
            {
                Debug.WriteLine(e.PropertyName + " just changed!");
                if (e.PropertyName == "VisibleRegion" && _map.VisibleRegion != null)
                {
                    _map.atualizarAreaVisivel(_map.VisibleRegion);
                }
            };

            _velocidadeFundo = new BoxView {
                BackgroundColor = Color.White,
            };
            AbsoluteLayout.SetLayoutBounds(_velocidadeFundo, new Rectangle(0, 1, 1, 0.1));
            AbsoluteLayout.SetLayoutFlags(_velocidadeFundo, AbsoluteLayoutFlags.All);
            _velocidadeLabel = new Label
            {
                FontSize                = 30,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                Text = "Parado"
            };
            AbsoluteLayout.SetLayoutBounds(_velocidadeLabel, new Rectangle(0, 1, 1, 0.1));
            AbsoluteLayout.SetLayoutFlags(_velocidadeLabel, AbsoluteLayoutFlags.All);
        }
コード例 #4
0
    void DrawBreedingUI()
    {
        Rect uiRect = new Rect(0, 0, 100, 20);

        GUI.Label(uiRect, "繁殖后代");

        uiRect.y += 20;
        otherID   = DrawList(uiRect, "选择配偶DNA", otherID, ref showOtherList);
        if (otherID != -1)
        {
            if (otherMap == null)
            {
                GameObject ormGO = GameObject.Instantiate <GameObject>(RadarPrefab);
                ormGO.transform.position = RadarMapPosO;
                otherMap = ormGO.GetComponent <RadarMap>();
            }
            SetRadarMap(otherMap, Codex.DNAPool[otherID]);
            uiRect.y += 20;
            if (GUI.Button(uiRect, "繁殖!"))
            {
                BreedingNextGeneration();
            }
        }
    }
コード例 #5
0
 // Start is called before the first frame update
 void Start()
 {
     RadarMap.RegisterRadarObject(this.gameObject, image);
 }
コード例 #6
0
 public void OnDestroy()
 {
     RadarMap.DestroyRadarObjects(this.gameObject);
 }
コード例 #7
0
        //UIView customPinView;
        //bool animando = false;

        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);
            var map = e.NewElement;

            if (e.OldElement != null)
            {
                _nativeMap = Control as MKMapView;
                //_nativeMap.GetViewForAnnotation = null;
            }

            if (e.NewElement != null)
            {
                //RadarPin radar = new RadarPin();
                //RadarMKAnnotation radarMKAnnotation = new RadarMKAnnotation(radar);
                _radarMap = (RadarMap)e.NewElement;
                //SetNativeControl(new MKMapView(CGRect.Empty));
                _nativeMap = Control as MKMapView;
                //MeuCustomPin customPin = new MeuCustomPin();
                //_nativeMap.Delegate = customPin;
                //_nativeMap.AddAnnotation(new MKPointAnnotation()
                //{
                //	Coordinate = new CLLocationCoordinate2D(radar.Pin.Position.Latitude, radar.Pin.Position.Longitude)
                //});
                //_nativeMap.GetViewForAnnotation = GetViewForAnnotation;
                _radarMap.AoAtualizaPosicao += (object sender, LocalizacaoInfo local) => {
                    CLLocationCoordinate2D target = new CLLocationCoordinate2D(local.Latitude, local.Longitude);

                    MKMapCamera camera = MKMapCamera.CameraLookingAtCenterCoordinate(target, PreferenciaUtils.NivelZoom, local.Sentido, local.Sentido);
                    _nativeMap.Camera = camera;
                    //MKCoordinateRegion mapRegion = MKCoordinateRegion.FromDistance(target, 100, 100);
                    //_nativeMap.CenterCoordinate = target;
                    //_nativeMap.Region = mapRegion;
                    _nativeMap.ZoomEnabled = true;
                    //_nativeMap.ShowsUserLocation = true;
                    //MeuCustomPin customPin = new MeuCustomPin();

                    _nativeMap.UserInteractionEnabled = PreferenciaUtils.RotacionarMapa;

                    //_nativeMap.UserInteractionEnabled = false;

                    /*
                     * if (!animando)
                     * {
                     *  if (map == null)
                     *      return;
                     *  CameraPosition.Builder builder = CameraPosition.InvokeBuilder(map.CameraPosition);
                     *  builder.Target(new LatLng(local.Latitude, local.Longitude));
                     *  builder.Bearing(local.Sentido);
                     *  builder.Zoom(Configuracao.MapaZoom);
                     *  builder.Tilt(Configuracao.MapaTilt);
                     *  CameraPosition cameraPosition = builder.Build();
                     *  CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                     *  map.AnimateCamera(cameraUpdate);
                     *  animando = true;
                     * }
                     */
                };
                _radarMap.AoDesenharRadar += (object sender, RadarPin radar) => {
                    var marker = new MKPointAnnotation()
                    {
                        Coordinate = new CoreLocation.CLLocationCoordinate2D(radar.Pin.Position.Latitude, radar.Pin.Position.Longitude),
                        Title      = radar.Pin.Label,
                        Subtitle   = radar.Pin.Address
                    };

                    _nativeMap.AddAnnotation(marker);
                    desenharRadar(radar);
                };
            }
        }
コード例 #8
0
 void SetRadarMap(RadarMap map, DNA dna)
 {
     map.ResetMap(dna);
 }