Exemple #1
0
    private void addLocationToContainer(LocationState locState, int locationIndex)
    {
        GameObject currLocationObj = Instantiate(locationPointPrefab, new Vector3(), new Quaternion()) as GameObject;

        // Реакция на нажатие
        GameObject LocButton = currLocationObj.transform.FindChild("Button").gameObject;

        LocButton.GetComponent <Button> ().onClick.AddListener(() => onLocationClickListener(locState));

        // Текст
        GameObject LocText       = LocButton.transform.FindChild("Text").gameObject;
        string     locHiddenMark = locState.isVisible ? "" : "[*] ";

        LocText.GetComponent <Text> ().text = locHiddenMark + locState.getName();

        // Позиционирование
        RectTransform AnswRT = currLocationObj.GetComponent <RectTransform> ();

        AnswRT.SetParent(locationsContainer);
        AnswRT.localScale = new Vector3(1, 1, 1);
        AnswRT.anchorMin  = new Vector2(0.2f + Random.Range(0.0f, 0.6f), 0.2f + Random.Range(0.0f, 0.6f));
        AnswRT.anchorMax  = AnswRT.anchorMin;
        AnswRT.offsetMax  = new Vector2(0, 0);
        AnswRT.offsetMin  = new Vector2(0, 0);
    }
Exemple #2
0
    private void onLocationClickListener(LocationState locState)
    {
        GameState currGameState = GlobalData.gameStateManager.GetCurrentGameState();

        currGameState.location = locState;
        levelScreenSelector.SelectScreen((int)LevelScreenIndices.LOADING);
    }
        public LocationBox()
        {
            try
            {
                InitializeComponent();

                LocationState.Text = Default.SetState;

                LocationUrl.Text = Default.AlertFeedUrl;

                LocationState.Focus();

                LocationState.SelectAll();

                LocationState.GotKeyboardFocus += LocationState_GotKeyboardFocus;

                LocationUrl.GotKeyboardFocus += LocationState_GotKeyboardFocus;

                LocationState.TextChanged += LocationState_TextChanged;
                LocationUrl.TextChanged   += LocationUrl_TextChanged;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Exemple #4
0
    // Distance walked (in meters)



    // Use this for initialization
    IEnumerator Start()
    {
        state     = LocationState.Disabled;
        latitude  = 0f;
        longitude = 0f;
        if (Input.location.isEnabledByUser)
        {
            Input.location.Start();
            int waitTime = 15;
            while (Input.location.status == LocationServiceStatus.Initializing && waitTime > 0)
            {
                yield return(new WaitForSeconds(1));

                waitTime--;
            }
            if (waitTime == 0)
            {
                state           = LocationState.TimedOut;
                statusText.text = "TimedOut";
            }
            else if (Input.location.status == LocationServiceStatus.Failed)
            {
                state           = LocationState.Failed;
                statusText.text = "Failed";
            }
            else
            {
                state     = LocationState.Enabled;
                latitude  = Input.location.lastData.latitude;
                longitude = Input.location.lastData.longitude;
            }
        }
    }
    private void loadGameStateFromFile(string filename)
    {
        if (!File.Exists(filename))
        {
            Debug.LogWarning("Save file not exists");
            return;
        }
        XDocument xmlLevelData = XDocument.Load(filename);
        XElement  rootElement  = (XElement)xmlLevelData.LastNode;

        if (rootElement.Name.LocalName != SAVE_ROOT_ELEMENT_NAME)
        {
            Debug.LogWarning("Save file is not compatible format");
            return;
        }

        sector   = null;
        location = null;

        foreach (XElement groupElement in rootElement.Nodes())
        {
            switch (groupElement.Name.LocalName)
            {
            case SAVE_SECTORID_ELEMENT_NAME: {
                sector = GlobalData.resourcesManager.getById <SectorState> (uint.Parse(groupElement.Value));
                break;
            }

            case SAVE_LOCID_ELEMENT_NAME: {
                location = GlobalData.resourcesManager.getById <LocationState> (uint.Parse(groupElement.Value));
                break;
            }
            }
        }
    }
Exemple #6
0
        private SimplyWeatherLocation(double latitude, double longitude)
        {
            Latitude  = latitude;
            Longitude = longitude;

            State = LocationState.LocationReady;
        }
Exemple #7
0
 void Awake()
 {
     _birth_step            = PlayerStateHistory.CURRENT_STEP;
     _last_loc_state.pos    = transform.position;
     _last_loc_state.facing = transform.rotation;
     _next_loc_state        = PlayerStateHistory.state_history[0];
 }
    IEnumerator OnApplicationPause(bool pauseState)
    {
        if (pauseState)
        {
            Input.location.Stop();
            state = LocationState.Disabled;
        }
        else
        {
            Input.location.Start();
            int waitTime = 15;
            while (Input.location.status == LocationServiceStatus.Initializing && waitTime == 0)
            {
                yield return(new WaitForSeconds(1));

                waitTime--;
            }
            if (waitTime == 0)
            {
                state = LocationState.Timeout;
            }
            else if (Input.location.status == LocationServiceStatus.Failed)
            {
                state = LocationState.Failed;
            }
            else
            {
                state     = LocationState.Enabled;
                latitude  = Input.location.lastData.latitude;
                longitude = Input.location.lastData.longitude;
            }
        }
    }
Exemple #9
0
        private string getKey(portCallMessage pcm)
        {
            string key = "";

            if (pcm == null)
            {
                return(null);
            }

            key += pcm.portCallId;
            if (isLocationState(pcm))
            {
                LocationState ls = pcm.locationState;
                key += ls.referenceObject.ToString();
                key += ls.time.ToString();
                if (ls.arrivalLocation != null)
                {
                    LocationStateArrivalLocation al = ls.arrivalLocation;
                    if (al.from != null)
                    {
                        key += al.from.locationMRN ?? "";
                    }
                    if (al.to != null)
                    {
                        key += al.to.locationMRN ?? "";
                    }
                }
                if (ls.departureLocation != null)
                {
                    LocationStateDepartureLocation dl = ls.departureLocation;
                    if (dl.from != null)
                    {
                        key += dl.from.locationMRN ?? "";
                    }
                    if (dl.to != null)
                    {
                        key += dl.to.locationMRN ?? "";
                    }
                }
            }
            else
            {
                ServiceState ss = pcm.serviceState;
                key += ss.serviceObject;
                key += ss.time;
                if (ss.at != null)
                {
                    key += ss.at.locationMRN ?? "";
                }
                else if (ss.between != null)
                {
                    ServiceStateBetween b = ss.between;
                    key += b.from.locationMRN ?? "";
                    key += b.to.locationMRN ?? "";
                }
            }

            return(key);
        }
        private void LocationUrl_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            LocationState.TextChanged -= LocationState_TextChanged;

            LocationState.Clear();

            LocationState.TextChanged += LocationState_TextChanged;
        }
        public void HasChangedSince_Changed(LocationState before, LocationState after)
        {
            // Even though objects have same properties, they are not considered the same object
            Assert.NotEqual(before, after);
            Assert.NotSame(before, after);

            Assert.True(after.HasChangedSince(before));
        }
Exemple #12
0
        public void Reset(GameEngine gameEngine, MainCharacter mainCharacter, ContentManager content)
        {
            if (Interviewees.Count == MaxInterviewees)
            {
                GState = LocationState.ConfirmedReturn;
            }
            else
            {
                GState = LocationState.Normal;
            }
            content.Unload();

            MainCharacter   = mainCharacter;
            Content         = content;
            IsTransitioning = false;
            Point WindowSize = Game1.GetWindowSize();

            // Load Characters
            String CharPath = Path.Combine(Content.RootDirectory, "characters.txt");
            String CharJSON = File.ReadAllText(CharPath);

            CharList = JsonSerializer.Deserialize <AllCharacters>(CharJSON);

            // Load Case Info
            String CasePath = Path.Combine(Content.RootDirectory, "case" + MainCharacter.CurrentCase + ".txt");
            String CaseJSON = File.ReadAllText(CasePath);
            Case   Case     = JsonSerializer.Deserialize <Case>(CaseJSON);

            // Visual Elements
            Background = new Background(content, BGImagePath);
            CharPics   = new Dictionary <string, ClickableTexture>();
            Greetings  = new Dictionary <string, string>();

            Notebook     = Content.Load <Texture2D>("notebook_icon");
            NotebookRect = new Rectangle(WindowSize.X - 100, 20, 70, 70);
            MapIcon      = Content.Load <Texture2D>("map-icon");
            MapIconRect  = new Rectangle(WindowSize.X - 200, 20, 70, 70);

            Arial      = content.Load <SpriteFont>("Fonts/Arial");
            SpeechMenu = null;

            int     NumSuspects = Case.Suspects.Count;
            Vector2 CharPos     = new Vector2(WindowSize.X / 6, WindowSize.Y / 3); // may want to customize position at a given location later

            foreach (string Suspect in Case.Suspects)
            {
                Greetings[Suspect] = CharList.AllChars[Suspect].Greetings[0];
                Texture2D CharTexture = Content.Load <Texture2D>(CharList.AllChars[Suspect].ImagePath);
                CharPics[Suspect] = new ClickableTexture(CharTexture, CharPos);
                CharPos.X        += 0.75f * WindowSize.X / NumSuspects;
            }
            IntervieweeListRect = new Rectangle(WindowSize.X / 4, 2 * WindowSize.Y / 3, WindowSize.X / 2, WindowSize.Y / 4);

            TextOffset = new Vector2(0, Arial.MeasureString("A").Y);

            MouseState     = Mouse.GetState();
            PrevMouseState = MouseState;
        }
Exemple #13
0
        public IActionResult PostLocation(string cmdrName, string gameVersion, [FromBody] LocationState location)
        {
            var locationEntity = ToEntity(location, cmdrName, gameVersion);

            _locationRepoz.Add(locationEntity);

            Log.Info(JsonConvert.SerializeObject(locationEntity));

            return(Ok());
        }
Exemple #14
0
        private static void SaveToXmlFile(Player myHero, string directoryName)
        {
            SaveToXmlFile(myHero, directoryName, GetCharacterFileName());

            foreach (string locationStateKey in GameState.GameLocationStates.Keys)
            {
                LocationState locationState = GameState.GameLocationStates[locationStateKey];
                string        fileName      = GetLocationStateFileName(locationStateKey);
                SaveToXmlFile(locationState, directoryName, fileName);
            }
        }
Exemple #15
0
 public static void PrintLocationState(LocationState state)
 {
     if (!DebugConstants.ALLOW_PRINT_LOCATION_STATE)
     {
         return;
     }
     Debug.Log("LOCATIONSTATE:" +
               "\nPosition: " + state.pos +
               "\nFacing: " + state.facing.eulerAngles +
               "\nRoom: " + state.room_id);
 }
Exemple #16
0
        public object CaptureState()
        {
            LocationState state = new LocationState();

            state.currentLocation   = currentLocation;
            state.locationLookup    = locationLookup;
            state.previousLocation  = previousLocation;
            state.travelDestination = travelDestination;
            state.distanceRemaining = distanceRemaining;
            return(state);
        }
Exemple #17
0
 public static Player? From(LocationState state)
 {
     switch (state)
     {
         case LocationState.X:
             return Player.X;
         case LocationState.O:
             return Player.O;
         default:
             return null;
     }
 }
Exemple #18
0
        public static void SetLocationStateValue(string locationStateKey, string LocationStateName, object locationStateValue)
        {
            LocationState locationState = GetLocationState(locationStateKey);

            if (locationState.ContainsKey(LocationStateName))
            {
                locationState[LocationStateName] = locationStateValue;
            }
            else
            {
                locationState.Add(LocationStateName, locationStateValue);
            }
        }
Exemple #19
0
        private static LocationState LoadLocationStateFromXmlFile(string locationStateKey)
        {
            LocationState returnData;
            string        fileName           = GetLocationStateFileName(locationStateKey);
            string        characterDirectory = GetCharacterDirectoryName(GameState.Hero);


            System.Xml.Serialization.XmlSerializer locationStateXmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LocationState));
            using (System.IO.StreamReader locationStateStreamReader = new System.IO.StreamReader(Path.Combine(GameConfigs.PlayerGameFilesLocation, characterDirectory, fileName)))
            {
                returnData = new LocationState();
                returnData = (LocationState)locationStateXmlSerializer.Deserialize(locationStateStreamReader);
            }

            return(returnData);
        }
        private void SetState(string realloc, LocationState state, string panelno)
        {
            var loc = RealLocations.First(x => x.realloc == realloc);

            if (loc == null)
            {
                throw new Exception($"函数: {nameof(SetState)}, 交地错误: {realloc}");
            }

            // 非禁用的实际交地,修改状态。
            if (loc.priority != Priority.DISABLE)
            {
                loc.state   = state;
                loc.panelno = panelno;
            }
        }
 public void getPositionData(Action <bool> onResult, int timeOutInterval, string address)
 {
     returnToSender = onResult;
     clearErrorLog();
     if (address == "")
     {
         errorCode     = "No address entered|No valid address data for location lookup provided. Please enter your address";
         locationState = LocationState.userinput;
         onResult(false);
     }
     else
     {
         // address data present, get location
         locationState = LocationState.valid;
         getLatLongFromCity(address, timeOutInterval);
     }
 }
Exemple #22
0
        public static object GetLocationStateValue(string locationStateKey, string LocationStateName)
        {
            object        returnData;
            LocationState locationState = GetLocationState(locationStateKey);

            if (locationState.ContainsKey(LocationStateName))
            {
                returnData = locationState[LocationStateName];
            }
            else
            {
                locationState.Add(LocationStateName, null);
                returnData = locationState[LocationStateName];
            }

            return(returnData);
        }
Exemple #23
0
        private static void SaveToXmlFile(LocationState gameObject, string directoryName, string fileName)
        {
            if (Directory.Exists(Path.Combine(GameConfigs.PlayerGameFilesLocation, directoryName)) == false)
            {
                Directory.CreateDirectory(Path.Combine(GameConfigs.PlayerGameFilesLocation, directoryName));
            }

            System.Xml.Serialization.XmlSerializer locationStateXmlSerialization = new System.Xml.Serialization.XmlSerializer(typeof(LocationState));

            using (System.IO.StreamWriter locationStateStreamWriter = new System.IO.StreamWriter(Path.Combine(GameConfigs.PlayerGameFilesLocation, directoryName, fileName)))
            {
                locationStateXmlSerialization.Serialize(locationStateStreamWriter, gameObject);
                locationStateStreamWriter.Close();

                Console.WriteLine(String.Format("{0} saved successfully", fileName));
            }
        }
    // Use this for initialization
    IEnumerator Start()
    {
        if (Screen.dpi > 0f)
        {
            SCREEN_DENSITY = (int)(Screen.dpi / 160f);
        }
        else
        {
            SCREEN_DENSITY = (int)(Screen.currentResolution.height / 600);
        }

        debugStyle                  = new GUIStyle();
        debugStyle.fontSize         = 16 * SCREEN_DENSITY;
        debugStyle.normal.textColor = Color.white;

        state     = LocationState.Disabled;
        latitude  = 0f;
        longitude = 0f;
        dist      = 0f;

        if (Input.location.isEnabledByUser)
        {
            Input.location.Start();
            int waitTime = 15;
            while (Input.location.status == LocationServiceStatus.Initializing && waitTime == 0)
            {
                yield return(new WaitForSeconds(1));

                waitTime--;
            }
            if (waitTime == 0)
            {
                state = LocationState.Timeout;
            }
            else if (Input.location.status == LocationServiceStatus.Failed)
            {
                state = LocationState.Failed;
            }
            else
            {
                state     = LocationState.Enabled;
                latitude  = Input.location.lastData.latitude;
                longitude = Input.location.lastData.longitude;
            }
        }
    }
Exemple #25
0
    IEnumerator OnApplicationPause(bool pauseStatus)
    {
        if (pauseStatus)
        {
            if (mState == LocationState.Enabled)
            {
                Input.location.Stop();
                mState = LocationState.Disabled;
            }
        }
        else
        {
            if (Input.location.isEnabledByUser && mState != LocationState.Stopped)
            {
                // Start service before querying location
                Input.location.Start();
                // Wait until service initializes
                int maxWait = 20;
                while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
                {
                    yield return(new WaitForSeconds(1));

                    maxWait--;
                }
                // Service didn't initialize in 20 seconds
                if (maxWait < 1)
                {
                    mState = LocationState.TimedOut;
                }
                else if (Input.location.status == LocationServiceStatus.Failed)
                {
                    mState = LocationState.Failed;
                }
                else
                {
                    mState     = LocationState.Enabled;
                    mLatitude  = Input.location.lastData.latitude;
                    mLongitude = Input.location.lastData.longitude;
                    // mHorizontalAccuracy = Input.location.lastData.horizontalAccuracy;
                    // mTimestamp = Input.location.lastData.timestamp;
                }
            }
        }
    }
Exemple #26
0
    public void OnClick(int button)
    {
        switch (state)
        {
        case LocationState.Drag:
            if (button == 0)
            {
                Color c = m_Sprite.color;
                c.a            = 1.0f;
                m_Sprite.color = c;

                exitPipeHead.emit = true;

                state = LocationState.Drop;
            }
            else if (button == 1)
            {
                ApplyAngle();
            }
            break;

        case LocationState.Drop:
            if (button == 0)
            {
                ApplyAngle();
            }
            else if (button == 1)
            {
                if (mirror)
                {
                    ++hud.pipeMirror.amount;
                }
                else
                {
                    ++hud.pipeNormal.amount;
                }

                Destroy(gameObject);
            }
            break;
        }
    }
Exemple #27
0
    public void UpdateLocationState()
    {
        LocationState new_state;

        new_state.pos    = transform.position;
        new_state.facing = transform.rotation;
        int new_room_id = GetRoomId();

        new_state.room_id = new_room_id;

        _last_location_state    = _current_location_state;
        _current_location_state = new_state;

        if (CURRENT_LOCATION_STATE.room_id != new_room_id)
        {
            PlayerStateHistory.PlayerRoomChangeEvent();
        }

        DebugText.player_room_text = new_room_id.ToString() + " (" + Time.time.ToString("0") + ")";
    }
 public void getTimezoneData(Action <bool> onResult, int timeOutInterval, float latitude = -1, float longitude = -1)
 {
     returnToSender = onResult;
     clearErrorLog();
     if (latitude == -1 && longitude == -1)
     {
         // we have no valid GSP or other lat/long data,
         // so we need user input to proceed
         errorCode     = "No valid geocoordinates available|No valid geo data for location lookup provided. Please enter your address";
         locationState = LocationState.failed;
         onResult(false);
     }
     else
     {
         // GPS data present, get location
         errorCode     = "";
         locationState = LocationState.valid;
         getTimeZone(latitude, longitude, timeOutInterval);
     }
 }
        public static string state_s(LocationState s)
        {
            var v = "";

            switch (s)
            {
            case LocationState.BUSY:
                v = "忙";
                break;

            case LocationState.FULL:
                v = "满板";
                break;

            case LocationState.IDLE:
                v = "空闲";
                break;
            }
            return(v);
        }
Exemple #30
0
    IEnumerator Start()
    {
        if (Screen.dpi > 0f)
        {
            SCREEN_DENSITY = (int)(Screen.dpi / 160f);
        }
        else
        {
            SCREEN_DENSITY = (int)(Screen.currentResolution.height / 600);
        }

        state     = LocationState.Disabled;
        latitude  = 0f;
        longitude = 0f;

        if (Input.location.isEnabledByUser)
        {
            Input.location.Start();
            int waitTime = 15;
            while (Input.location.status == LocationServiceStatus.Initializing && waitTime > 0)
            {
                yield return(new WaitForSeconds(1));

                waitTime--;
            }
            if (waitTime == 0)
            {
                state = LocationState.TimedOut;
            }
            else if (Input.location.status == LocationServiceStatus.Failed)
            {
                state = LocationState.Failed;
            }
            else
            {
                state     = LocationState.Enabled;
                latitude  = Input.location.lastData.latitude;
                longitude = Input.location.lastData.longitude;
            }
        }
    }
Exemple #31
0
        public void RestoreState(object state)
        {
            LocationState locationState = (LocationState)state;

            locationLookup    = locationState.locationLookup;
            currentLocation   = locationState.currentLocation;
            previousLocation  = locationState.previousLocation;
            travelDestination = locationState.travelDestination;
            distanceRemaining = locationState.distanceRemaining;
            currentNode       = TownNodeList.Main;

            foreach (Location location in locationDB.GetLocations())
            {
                if (locationLookup.ContainsKey(location.location))
                {
                    continue;
                }

                Location newLocation = new Location();
                newLocation.location     = location.location;
                newLocation.name         = location.name;
                newLocation.description  = location.description;
                newLocation.distance     = location.distance;
                newLocation.isAvailable  = location.isAvailable;
                newLocation.isCombatArea = location.isCombatArea;
                newLocation.hasTraveled  = location.hasTraveled;

                locationLookup[newLocation.location] = newLocation;
            }

            BuildAvailableList();
            CheckIfTraveled();
            if (!locationLookup[currentLocation].isCombatArea)
            {
                menuManager.MakeMainMenu(currentLocation);
            }
        }
Exemple #32
0
 public void SetLocationState(LocationState state)
 {
     currentState = state;
 }
 public VacuumEnvironment(LocationState locAState, LocationState locBState)
 {
     envState = new VacuumEnvironmentState(locAState, locBState);
 }
Exemple #34
0
 public void SetLocation(int x, int y, LocationState state, int weight=0)
 {
     Locations[x, y].X = x;
     Locations[x, y].Y = y;
     Locations[x, y].State = state;
     Locations[x, y].Weight = weight;
     LocationsFilled++;
 }
Exemple #35
0
 bool PlayerWins(LocationState stateToCheck)
 {
     string currentState = Serialize();
     foreach (List<StateValue> gameState in WinningPlays)
     {
         bool stateMatched = true;
         foreach (StateValue pos in gameState)
         {
             string posState = pos.State.ToString();
             string checkState = stateToCheck.ToString();
             if (GetLocation(pos.X, pos.Y).State != stateToCheck)
             {
                 stateMatched = false;
             }
         }
         if (stateMatched)
         {
             return true;
         }
     }
     return false;
 }