Ejemplo n.º 1
0
		// OnResume gets called every time the activity starts, so we'll put our RequestLocationUpdates
		// code here, so that 
		protected override void OnResume ()
		{
			base.OnResume (); 
			Log.Debug (tag, "OnResume called");

			// initialize location manager
			locMgr = GetSystemService (Context.LocationService) as LocationManager;

			button.Click += delegate {
				button.Text = "Location Service Running";

				// pass in the provider (GPS), 
				// the minimum time between updates (in seconds), 
				// the minimum distance the user needs to move to generate an update (in meters),
				// and an ILocationListener (recall that this class impletents the ILocationListener interface)
				locMgr.RequestLocationUpdates (LocationManager.NetworkProvider, 2000, 1, this);


				// Comment the line above, and uncomment the following, to test 
				// the GetBestProvider option. This will determine the best provider
				// at application launch. Note that once the provide has been set
				// it will stay the same until the next time this method is called

				/*var locationCriteria = new Criteria();

				locationCriteria.Accuracy = Accuracy.Coarse;
				locationCriteria.PowerRequirement = Power.Medium;

				string locationProvider = locMgr.GetBestProvider(locationCriteria, true);

				Log.Debug(tag, "Starting location updates with " + locationProvider.ToString());
				locMgr.RequestLocationUpdates (locationProvider, 2000, 1, this);*/
			};
		}
		/// <summary>
		/// This method deactivates the location reporting.
		/// </summary>
		void StopLocationUpdates()
		{
			if (locMgr != null) {
				locMgr.RemoveUpdates(this);
			}
			locMgr = null;
		}
Ejemplo n.º 3
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
         instance = this;
     else if (instance != this)
         Destroy(gameObject);
     cities = new MapObject[4];
     labs = new MapObject[4];
 }
Ejemplo n.º 4
0
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     LocationManager mgr = new LocationManager();
     Location obj = new Location();
     obj.Location_ID = (GridView1.SelectedDataKey.Value).ToString();
     obj= mgr.selectLocation(obj);
     AddEditLocationControl1.populateControls(obj);
     MultiView1.ActiveViewIndex = 1;
 }
Ejemplo n.º 5
0
	void Awake () 
    {
        if (Instance == null)
            Instance = this;
        else
        {
            Destroy(this);
            throw new UnityException("Location Manager has already been declared! It cannot exist twice!");
        }
	}
Ejemplo n.º 6
0
        public Location()
        {
            //定位,这里只是模拟
            
			AddMethod("currentPos", (core,args) =>
            {
					var Mgr=new LocationManager(core,args);
					EventHandler<LocationUpdatedEventArgs> handler;
					handler=(sender,e)=>{
						var c = (sender as LocationManager).WoodCore;
						var a=(sender as LocationManager).ServiceArgs;
						var location = e.Location;
						c.InvokeCallback(a.CallbackName, new { lng =location.Coordinate.Longitude, lat = location.Coordinate.Latitude });
						(sender as LocationManager).StopUpdatingLocation();
					};
					Mgr.LocationUpdated+=handler;
					UIApplication.Notifications.ObserveDidEnterBackground((s,a)=>{
						Mgr.LocationUpdated-=handler;
					});
					UIApplication.Notifications.ObserveDidBecomeActive((s,e)=>{
						Mgr.LocationUpdated+=handler;
					});
					Mgr.StartUpdatingLocation();
    		});
            AddMethod("watch", (core,args) =>
            {
					var Mgr=new LocationManager(core,args);

					Mgr.LocationUpdated+=LocationUpdated;
					UIApplication.Notifications.ObserveDidEnterBackground((s,a)=>{
						Mgr.LocationUpdated-=LocationUpdated;
					});
					UIApplication.Notifications.ObserveDidBecomeActive((s,e)=>{
						Mgr.LocationUpdated+=LocationUpdated;
					});
					Mgr.StartUpdatingLocation();
					return Mgr.Id.ToString("N");
            });
            AddMethod("unwatch", (core,args) =>
            {
                var id = args.GetPn(0,(string)null);
					if (!string.IsNullOrWhiteSpace(id) && Mgrs.ContainsKey(id))
                {
						var mgr = Mgrs[id];
						Mgrs.Remove(id);
						if (mgr != null)
                    {
							mgr.StopUpdatingLocation();
							mgr = null;
                    }
                }
            });
        }
		/// <summary>
		/// This method activates the Android LocationManager and begins reporting
		/// location changes through our own LocationChanged event.
		/// </summary>
		public void StartLocationUpdates()
		{
			locMgr = Application.Context.GetSystemService("location") as LocationManager;
			if (locMgr == null)
				return;

			var locationCriteria = new Criteria() {
				Accuracy = Accuracy.NoRequirement,
				PowerRequirement = Power.NoRequirement
			};

			var locationProvider = locMgr.GetBestProvider(locationCriteria, true);
			locMgr.RequestLocationUpdates(locationProvider, 2000, 0, this);
		}
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         LocationManager mgr = new LocationManager();
         Location obj = new Location();
         obj.Location_ID = txtID.Text.Trim();
         lblError.Text = CustomErrors.CHANGES_ACCEDTED_STATUS + mgr.deleteLocation(obj);
         ClearControls();
     }
     catch (Exception ex)
     {
         lblError.Text = ex.Message;
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Add default base layer
            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault);

            LocationManager = new LocationManager();
            LocationManager.Start();

            // Create layer and add object to the layer, finally add layer to the map.
            // All overlay layers must be same projection as base layer, so we reuse it
            markerSource = new LocalVectorDataSource(MapView.Options.BaseProjection);
            var _markerLayer = new VectorLayer(markerSource);
            MapView.Layers.Add(_markerLayer);
        }
Ejemplo n.º 10
0
        private async void ShowPOI()
        {
            var position = await LocationManager.GetPosition();

            BasicGeoposition snPosition = new BasicGeoposition()
            {
                Latitude = position.Coordinate.Latitude, Longitude = position.Coordinate.Longitude
            };
            Geopoint snPoint  = new Geopoint(snPosition);
            MapIcon  mapIcon1 = new MapIcon();

            mapIcon1.Location = snPoint;
            mapIcon1.Title    = "Current location";
            mapIcon1.ZIndex   = 0;

            MapControl1.MapElements.Add(mapIcon1);
            MapControl1.MapServiceToken = "xjPt4JIRIYcbojxbehKX~AFzzIRdosDJXeC5jh5OmSQ~AmtD5GNB_d-DgWlDAyP0G53hphDQN-ggPgyCTFdMdACZVWA5oY67HZSxsxePna3s";
        }
Ejemplo n.º 11
0
 protected override void OnResume()
 {
     base.OnResume();
     locMgr        = GetSystemService(Context.LocationService) as LocationManager;
     button.Click += delegate
     {
         button.Text = "Location Service Running";
         string Provider = LocationManager.GpsProvider;
         if (locMgr.IsProviderEnabled(Provider))
         {
             locMgr.RequestLocationUpdates(Provider, 2000, 1, this);
         }
         else
         {
             Log.Info(tag, Provider + " is not available. Does the device have GPS?");
         }
     };
 }
Ejemplo n.º 12
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Debug.LogError("OOPSALA we have an ERROR! More than one instance bein created");
            Destroy(gameObject);
        }

        _locationManager = GetComponentInChildren <LocationManager> ();
        if (_locationManager == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }
    }
Ejemplo n.º 13
0
        protected override void OnResume()
        {
            base.OnResume();
            Log.Debug(tag, "OnResume called");

            // initialize location manager

            locMgr = GetSystemService(Context.LocationService) as LocationManager;
            if (locMgr.AllProviders.Contains(LocationManager.NetworkProvider) &&
                locMgr.IsProviderEnabled(LocationManager.NetworkProvider))
            {
                locMgr.RequestLocationUpdates(LocationManager.NetworkProvider, 2000, 1, this);
            }
            else
            {
                Toast.MakeText(this, "The Network Provider does not exist or is not enabled!", ToastLength.Long).Show();
            }
        }
Ejemplo n.º 14
0
        /*************** Location ***************/


        private void InitializeLocationManager()
        {
            locationManager = (LocationManager)GetSystemService(LocationService);
            Criteria criteriaForLocationService = new Criteria {
                Accuracy = Accuracy.Fine
            };
            IList <string> acceptableLocationProviders = locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                locationProvider = acceptableLocationProviders.First();
            }
            else
            {
                locationProvider = string.Empty;
            }
            Log.Debug("@string/log_debug_tag", "Using " + locationProvider + ".");
        }
Ejemplo n.º 15
0
        void InitializeLocationManager()
        {
            locationManager = (LocationManager)Application.Context.GetSystemService(Android.Content.Context.LocationService);
            Criteria criteriaForLocationService = new Criteria {
                Accuracy = Accuracy.Fine
            };
            IList <string> providers = locationManager.GetProviders(criteriaForLocationService, true);

            if (providers.Count > 0)
            {
                locationProvider = providers[0];
            }
            else
            {
                locationProvider = "";
            }
            System.Diagnostics.Debug.WriteLine("Using " + locationProvider + ".");
        }
Ejemplo n.º 16
0
        //Sorta initialiser
        public RtGPS(LocationManager LocationManager)
        {
            Criteria LocationServiceCriteria = new Criteria {
                Accuracy = Accuracy.Fine
            };
            IList <string> LocationProviders = LocationManager.GetProviders(LocationServiceCriteria, true);

            if (LocationProviders.Any())
            {
                LocationProvider = LocationProviders.First();

                LocationManager.RequestLocationUpdates(LocationProvider, 0, 0, this);
            }
            else
            {
                _NoGPS = true;
            }
        }
Ejemplo n.º 17
0
        public void MoveForwardFromSouth()
        {
            IOrientationReader orientationReader = new DummyOrientationReader("S");
            ILocationManager   locationManager   = new LocationManager
                                                   (
                2
                , 2
                , 100
                , 100
                , orientationReader
                                                   );

            locationManager.MoveForward();

            var currentLocation = locationManager.GetCurrentLocation();

            Assert.AreEqual("2,1", currentLocation, "Moving forward from 2,2 facing South does not give 2,1");
        }
Ejemplo n.º 18
0
        public void MoveBackwardFromEast()
        {
            IOrientationReader orientationReader = new DummyOrientationReader("E");
            ILocationManager   locationManager   = new LocationManager
                                                   (
                1
                , 1
                , 100
                , 100
                , orientationReader
                                                   );

            locationManager.MoveBackward();

            var currentLocation = locationManager.GetCurrentLocation();

            Assert.AreEqual("0,1", currentLocation, "Moving backward from 1,1 facing East does not give 0,1");
        }
Ejemplo n.º 19
0
        public void MoveBackwardFromNorth()
        {
            IOrientationReader orientationReader = new DummyOrientationReader("N");
            ILocationManager   locationManager   = new LocationManager
                                                   (
                0
                , 0
                , 100
                , 100
                , orientationReader
                                                   );

            locationManager.MoveBackward();

            var currentLocation = locationManager.GetCurrentLocation();

            Assert.AreEqual("0,-1", currentLocation, "Moving forward from 0,0 facing North does not give 0,-1");
        }
Ejemplo n.º 20
0
        public void MoveForwardFromEast_WrapAround()
        {
            IOrientationReader orientationReader = new DummyOrientationReader("E");
            ILocationManager   locationManager   = new LocationManager
                                                   (
                100
                , 100
                , 100
                , 100
                , orientationReader
                                                   );

            locationManager.MoveForward();

            var currentLocation = locationManager.GetCurrentLocation();

            Assert.AreEqual("0,100", currentLocation, "Moving Forward from 100,100 facing East does not give 0,100");
        }
Ejemplo n.º 21
0
        public void MoveBackwardFromWest()
        {
            IOrientationReader orientationReader = new DummyOrientationReader("W");
            ILocationManager   locationManager   = new LocationManager
                                                   (
                3
                , 3
                , 100
                , 100
                , orientationReader
                                                   );

            locationManager.MoveBackward();

            var currentLocation = locationManager.GetCurrentLocation();

            Assert.AreEqual("4,3", currentLocation, "Moving backward from 3,3 facing West does not give 4,3");
        }
Ejemplo n.º 22
0
        public void OpenSettings()
        {
            if (!Xamarin.Forms.Forms.IsInitialized)
            {
                return;
            }
            LocationManager LM = (LocationManager)Forms.Context.GetSystemService(Context.LocationService);

            if (LM.IsProviderEnabled(LocationManager.GpsProvider) == false)
            {
                Context ctx = Forms.Context;
                ctx.StartActivity(new Intent(Android.Provider.Settings.ActionLocationSourceSettings));
            }
            else
            {
                //this is handled in the PCL
            }
        }
    public override bool Interact(InteractableObject thisObject, InteractableObject otherObject)
    {
        //If we have no location data, there will be a new one created/found when we load
        //Therefore the next location we go to is the one that has to become linked.
        if (m_Location == null)
        {
            m_LocationManager = thisObject.LocationManager;

            //Make sure we are unsubscribed before subscribing again
            m_LocationManager.LoadLocationEvent -= OnLoadLocation;
            m_LocationManager.LoadLocationEvent += OnLoadLocation;
        }

        thisObject.LocationManager.LoadLocation(m_Location);
        thisObject.PlaySound(m_AudioClip);

        return(true);
    }
        public void init()
        {
            Console.WriteLine("Llamada a la funcion init de GnssCompare en Android");
            if (!enablePermission)
            {
                App.Current.MainPage.DisplayAlert("Alerta", "Es necesario que nos otorgue el permiso se acceder a su localizacion", "Entendido");
                return;
            }
            // TODO, poner un tiempo de espera visual hasta que reciba ongnss

            my_gnss = new MyGnssMeasurementEventCallback();
            LocationManager locationManager = (LocationManager)Android.App.Application.Context.GetSystemService(Context.LocationService);

            locationManager.RegisterGnssMeasurementsCallback(my_gnss);
            fusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(Android.App.Application.Context);
            GetLastLocation();
            locationManager.RegisterGnssMeasurementsCallback(my_gnss);
        }
Ejemplo n.º 25
0
        public override void Draw(SpriteBatch sb)
        {
            if (!isGhost)
            {
                myImage.DrawAt(sb, new Rectangle(currentPos.X + Globals.stdTile / 2, currentPos.Y + Globals.stdTile / 2, Globals.stdTile, Globals.stdTile), direction);
            }
            else
            {
                myImage.DrawGhostAt(sb, new Rectangle(currentPos.X + Globals.stdTile / 2, currentPos.Y + Globals.stdTile / 2, Globals.stdTile, Globals.stdTile), direction);
            }
            base.Draw(sb);

            if (Globals.DEBUG)
            {
                GenericShapeHelper.DrawX(LocationManager.getVectorFromPoint(GetTarget()), 5, sb, Color.Orange);
                GenericShapeHelper.DrawX(new Vector2(base.tile.X * Globals.stdTile, base.tile.Y * Globals.stdTile), 5, sb, Color.Yellow);
            }
        }
Ejemplo n.º 26
0
        public Geolocator(Context _context) : base()
        {
            _locationManager = (LocationManager)_context.GetSystemService(Context.LocationService);
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };

            IsGPSStarted = false;
            IList <string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                _locationProvider = acceptableLocationProviders.First();
                _locationManager.RequestLocationUpdates(_locationProvider, 0, 0, this);
                IsGPSStarted = true;
            }
        }
 private void InitializeLocationManager()
 {
     try
     {
         LocationManager = (LocationManager)GetSystemService(LocationService);
         var criteriaForLocationService = new Criteria
         {
             Accuracy = Accuracy.Fine
         };
         var    acceptableLocationProviders = LocationManager.GetProviders(criteriaForLocationService, true);
         string locationProvider            = acceptableLocationProviders.Any() ? acceptableLocationProviders.First() : string.Empty;
         Console.WriteLine(locationProvider);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 28
0
        protected override void OnResume()
        {
            base.OnResume();

            locationmanager = GetSystemService(Context.LocationService) as LocationManager;

            progress.Show();
            if (locationmanager.AllProviders.Contains(LocationManager.NetworkProvider) && locationmanager.IsProviderEnabled(LocationManager.NetworkProvider))
            {
                locationmanager.RequestLocationUpdates(LocationManager.NetworkProvider, 2000, 1, this);
            }
            else
            {
                progress.Hide();
                Toast.MakeText(this, "The network provider does not exist or is not enabled", ToastLength.Long).Show();
            }
            progress.Hide();
        }
Ejemplo n.º 29
0
        private void InitializeLocation()
        {
            if (this.locationManager == null)
            {
                this.locationManager = (LocationManager)GetSystemService(LocationService);
            }
            var criteriaForLocationService = new Criteria
            {
                CostAllowed   = true,
                SpeedRequired = false,
                Accuracy      = Accuracy.NoRequirement
            };
            var acceptableLocationProviders = this.locationManager.GetProviders(criteriaForLocationService, true);

            this.locationProvider = acceptableLocationProviders.FirstOrDefault() ?? string.Empty;

            this.locationManager.RequestLocationUpdates(this.locationProvider, 0, 0, this);
        }
Ejemplo n.º 30
0
        public Map()
        {
            InitializeComponent();
            BuildApplicationBars();
            ApplicationBar = mapAppBar;
            myPushpin.Background = Application.Current.Resources["PhoneAccentBrush"] as Brush;
            myPushpin.Content = "Annei Klekchyan";

            LocationManager loc = new LocationManager();
            loc.StartLocationCapturing();
            LocationManager.CoordinatesResponseReceived += (position) =>
            {
                map.Children.Remove(myPushpin);
                myPushpin.Location = position; 
                map.Children.Add(myPushpin);
                map.SetView(position, 16f);
            };
        }
Ejemplo n.º 31
0
    /// <summary>
    /// This method activates the Android LocationManager and begins reporting
    /// location changes through our own LocationChanged event.
    /// </summary>
    public void StartLocationUpdates()
    {
        locMgr = Application.Context.GetSystemService("location") as LocationManager;
        if (locMgr == null)
        {
            return;
        }

        var locationCriteria = new Criteria()
        {
            Accuracy         = Accuracy.NoRequirement,
            PowerRequirement = Power.NoRequirement
        };

        var locationProvider = locMgr.GetBestProvider(locationCriteria, true);

        locMgr.RequestLocationUpdates(locationProvider, 2000, 0, this);
    }
Ejemplo n.º 32
0
        public ServiceResult GetStores( )
        {
            string accountUUID = SystemFlag.Default.Account;

            if (CurrentUser != null)
            {
                accountUUID = CurrentUser.AccountUUID;
            }

            LocationManager lm     = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var             stores = lm.GetAll().Where(w => w.AccountUUID == accountUUID &&
                                                       w.Active == true &&
                                                       w.Private == false &&
                                                       w.LocationType.EqualsIgnoreCase("online store")).ToList();
            int count = stores.Count;

            return(ServiceResponse.OK("", stores, count));
        }
Ejemplo n.º 33
0
        private void InitializeLocationManager()
        {
            Criteria locationCriteria = new Criteria();

            locationCriteria.Accuracy         = Accuracy.Fine;
            locationCriteria.PowerRequirement = Power.Low;

            if (locMgr == null)
            {
                locMgr = this.Context.GetSystemService(Context.LocationService) as LocationManager;
            }

            locationProvider = locMgr.GetBestProvider(locationCriteria, true);
            if (locationProvider != null)
            {
                locMgr.RequestLocationUpdates(locationProvider, 100, 1, this);
            }
        }
Ejemplo n.º 34
0
        public bool IsLocationEnabled()
        {
            if ((int)Build.VERSION.SdkInt >= 30)
            {
                // Location is not required on Android 11 and above
                return(true);
            }
            if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
            {
                LocationManager lm = (LocationManager)Current.AppContext.GetSystemService(Context.LocationService);
                return(lm.IsLocationEnabled);
            }

            int mode = Settings.Secure.GetInt(Current.AppContext.ContentResolver, Settings.Secure.LocationMode,
                                              (int)SecurityLocationMode.Off);

            return(mode != (int)SecurityLocationMode.Off);
        }
Ejemplo n.º 35
0
        public ServiceResult Get(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(ServiceResponse.Error("You must provide a name for the location."));
            }

            LocationManager locationManager = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            List <Location> s = locationManager.Search(name);

            if (s == null || s.Count == 0)
            {
                return(ServiceResponse.Error("Location could not be located for the name " + name));
            }

            return(ServiceResponse.OK("", s));
        }
Ejemplo n.º 36
0
        public ServiceResult Delete(string locationUUID)
        {
            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            LocationManager locationManager = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var             res             = locationManager.Get(locationUUID);

            if (res.Code != 200)
            {
                return(res);
            }
            Location p = (Location)res.Result;

            return(locationManager.Delete(p));
        }
Ejemplo n.º 37
0
        void InitializeLocationManager()
        {
            _locationManager = (LocationManager)GetSystemService(LocationService);
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList <string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                _locationProvider = acceptableLocationProviders.First();
            }
            else
            {
                _locationProvider = string.Empty;
            }
        }
Ejemplo n.º 38
0
        public static bool TutorialAndCutsceneSkips(LocationManager __instance, ref LocationDefinition ____currentLocation, ref CutsceneDefinition ____arrivalCutscene)
        {
            //if arriving to airplane, skip to hub
            if (____currentLocation.id == 25)
            {
                __instance.Depart(Game.Data.Locations.Get(21), null);
                AccessTools.Field(typeof(GameManager), "_testMode").SetValue(Game.Manager, false);
                Game.Persistence.playerFile.daytimeElapsed = 8;
                return(false);
            }
            //skip arrival cutscenes for the SIM locations which are 1 through 8
            else if (____currentLocation.id <= 8 && ____arrivalCutscene != null)
            {
                ____arrivalCutscene = null;
            }

            return(true);
        }
        public string InitializeLocationManager()
        {
            LocationManager _locationManager           = Application.Context.GetSystemService(Context.LocationService) as LocationManager;
            Criteria        criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList <string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                return(acceptableLocationProviders.First());
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 40
0
    /// <summary>
    /// Takes two fish and breeds them
    /// </summary>
    /// <param name="fish1">First fish</param>
    /// <param name="fish2">Fish to combine with first fish</param>
    /// <param name="lm">Location Manager</param>
    /// <param name="clock">Game clock</param>
    /// <returns></returns>
    public static Fish CombineFish(Fish fish1, Fish fish2, LocationManager lm, Clock clock)
    {
        fish1.Combined = true;
        fish2.Combined = true;
        var newFishData = new List <KeyValuePair <char, Color> >();

        // Get a new prefix for the combined fish.. takes first fish's prefix and the second fish's title
        var roll   = Random.Range(0, combinationFishPrefixes.Length);
        var prefix = combinationFishPrefixes[roll];

        // Roll and add new prefix
        foreach (var letter in prefix)
        {
            newFishData.Add(letter == ' '
                ? new KeyValuePair <char, Color>(letter, Color.gray)
                : new KeyValuePair <char, Color>(letter, rollColor(letter, lm, clock)));
        }

        // Add space
        newFishData.Add(new KeyValuePair <char, Color>(' ', Color.gray));

        // Add first fish's prefix data
        foreach (KeyValuePair <char, Color> pair in fish1.FishData)
        {
            if (pair.Key != ' ')
            {
                newFishData.Add(pair);
            }
            else
            {
                newFishData.Add(new KeyValuePair <char, Color>(pair.Key, Color.gray));
                break;
            }
        }

        // Add second fish's title
        for (var i = fish2.Prefix.Length + 1; i < fish2.FishData.Count; i++)
        {
            newFishData.Add(fish2.FishData[i]);
        }

        // Return new fish
        return(new Fish(newFishData, lm, true));
    }
    protected void btnOpt_Click(object sender, EventArgs e)
    {
        try
        {
            Location obj = CaptureData();
            LocationManager mgr = new LocationManager();

            if ((string)Session["Flag"] == "New")
            {
                lblError.Text = CustomErrors.CHANGES_ACCEDTED_STATUS + mgr.insertLocation(obj);
                ClearControls();
            }
            else
            {
                lblError.Text = CustomErrors.CHANGES_ACCEDTED_STATUS + mgr.updateLocation(obj);
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Ejemplo n.º 42
0
	void Awake ()
	{
		//编辑模式
		MotionPara.isEditor = isEditor;
		if(MotionPara.isEditor){
			ErrorLocation.Initialize();  //初始化表格填写错误报警信息
		}

		cameraAdministrator.State = CurrentState.Old;
        InterData.InterDataInit();

		//任务初始化
		MotionPara.taskName = taskName;
		TaskInitialize(MotionPara.taskName);
		//Debug.Log("Motion SpeedRate: "  + MotionPara.SpeedRate);
		//MotionPara.SpeedRate = 0.5f;

		//脚本变量初始化
		st_Interface = gameObject.GetComponent<InterfaceManager>();
		gameObject.AddComponent<LocationManager>();
		st_Location = gameObject.GetComponent<LocationManager>();
        GameObject triggerEmpty = new GameObject();
        triggerEmpty.name = "TriggerObject";
        triggerEmpty.AddComponent<TriggerManager>();
		st_Trigger = (TriggerManager)GameObject.FindObjectOfType(typeof(TriggerManager));
		st_Trigger.gameObject.SetActive(false);
		if (isEditor)
		{
			gameObject.AddComponent<EditorManager>();
		}

	}
        /// <summary>
        /// Initializes the service.
        /// </summary>
        protected override void Initialize()
        {
            var context = Catel.Android.ContextHelper.CurrentContext;
            _locationManager = context.GetSystemService(Context.LocationService) as LocationManager;

            _locationListener = new LocationListener();
            _locationListener.StatusChanged += OnStatusChanged;
            _locationListener.LocationChanged += OnLocationChanged;
        }
Ejemplo n.º 44
0
    public override void Start()
    {
        base.Start();

        this.locationManager = (LocationManager) Camera.main.GetComponent("LocationManager");
        this.unitManager = (UnitManager) Camera.main.GetComponent("UnitManager");
    }
Ejemplo n.º 45
0
    /// <summary>
    /// Set basic information for each player, load their decks, and give them their mulliagns. Then pick a player to go first, and start his/her turn. 
    /// </summary>
    public void Start()
    {
        this.switchPlayerMenu.enabled = false;

        this.spriteSheet = Resources.LoadAll<Sprite>("Sprites");

        //Debug.Log(this.spriteSheet.Length + " IS THE NUMBER OF SPRITES LOADED");

        this.locations = GameObject.Find("Location Manager").GetComponent<LocationManager>();

        // Set up the player objects for the match
        try
        {
            this.player1.GetComponent<player>().DeckPath = GameObject.Find("Player1StartData").GetComponent<player>().DeckPath;
            this.player2.GetComponent<player>().DeckPath = GameObject.Find("Player2StartData").GetComponent<player>().DeckPath;

            this.player1.GetComponent<player>().Name = GameObject.Find("Player1StartData").GetComponent<player>().Name;
            this.player2.GetComponent<player>().Name = GameObject.Find("Player2StartData").GetComponent<player>().Name;
        }
        catch
        {
            //Debug.Log("THE PLAYER DATA AINT THERE, SON!");
        }

        this.player1.GetComponent<player>().PlayerSide = 0;
        this.player2.GetComponent<player>().PlayerSide = 1;

        this.player1.GetComponent<player>().ManaMax = 2;
        this.player2.GetComponent<player>().ManaMax = 2;

        // The initial mulligan
        this.player1.GetComponent<player>().loadDeck();
        this.player2.GetComponent<player>().loadDeck();

        DrawCard(player1, 4);
        DrawCard(player2, 4);

        Destroy(GameObject.Find("Player1StartData"));
        Destroy(GameObject.Find("Player2StartData"));

        int chance = UnityEngine.Random.Range(0, 2);

        // Determine who goes first, and start that player's turn
        if (chance == 0)
        {
            //Debug.Log("Player 1 goes first.");

            Transform hand1 = locations.GetLocationTransform(Location.Player1Hand);
            Transform hand2 = locations.GetLocationTransform(Location.Player2Hand);

            StartTurn(player1);

            currentPlayer = player1;

            player1.GetComponent<player>().IsTurn = true;
            player2.GetComponent<player>().IsTurn = false;

            foreach (Transform child in hand1)
            {
                child.Find("Card Back").GetComponent<Image>().sprite = clear;
            }

            foreach (Transform child in hand2)
            {
                child.Find("Card Back").GetComponent<Image>().sprite = cardBackCitadel;
            }

            TogglePlayerChangeMenu();
            switchPlayerMenu.transform.Find("CurrentPlayer").GetComponent<Text>().text = player1.GetComponent<player>().Name + " goes first!" + "\nGet 20 VP to win.";
            switchPlayerMenu.transform.Find("Player1Score").GetComponent<Text>().text = "";
            switchPlayerMenu.transform.Find("Player2Score").GetComponent<Text>().text = "";
        }
        else if (chance == 1)
        {
            //Debug.Log("Player 2 goes first.");

            Transform hand1 = locations.GetLocationTransform(Location.Player1Hand);
            Transform hand2 = locations.GetLocationTransform(Location.Player2Hand);

            currentPlayer = player2;

            StartTurn(player2);

            player1.GetComponent<player>().IsTurn = false;
            player2.GetComponent<player>().IsTurn = true;

            foreach (Transform child in hand1)
            {
                child.Find("Card Back").GetComponent<Image>().sprite = cardBackTemple;
            }

            foreach (Transform child in hand2)
            {
                child.Find("Card Back").GetComponent<Image>().sprite = clear;
            }

            TogglePlayerChangeMenu();
            switchPlayerMenu.transform.Find("CurrentPlayer").GetComponent<Text>().text = player2.GetComponent<player>().Name + " goes first!" + "\nGet 20 VP to win.";
            switchPlayerMenu.transform.Find("Player1Score").GetComponent<Text>().text = "";
            switchPlayerMenu.transform.Find("Player2Score").GetComponent<Text>().text = "";
        }

        this.UpdateCardColors();
    }