public override void Save(StateInfo state) { state["Position"] = _body.Position; state["Rotation"] = _body.Rotation; state["LinearVelocity"] = _body.LinearVelocity; state["AngularVelocity"] = _body.AngularVelocity; }
public override void Restore(StateInfo state) { _body.Position = state.Get<Vector2>("Position"); _body.Rotation = state.Get<float>("Rotation"); _body.LinearVelocity = state.Get<Vector2>("LinearVelocity"); _body.AngularVelocity = state.Get<float>("AngularVelocity"); }
public void Save(StateInfo state) { state["fullScreen"] = Render.Viewport.IsFullScreen; state["x"] = Render.Viewport.X; state["y"] = Render.Viewport.Y; state["currentResolution"] = _resolutions.CurrentIndex; }
public void SetUp() { Fake<CountryInfo, CountryInfoProvider>(); Fake<StateInfo, StateInfoProvider>(); Fake().DocumentType<Contact>(Contact.CLASS_NAME); var country = new CountryInfo { CountryName = "USA", CountryTwoLetterCode = "US" }; var state = new StateInfo { StateName = "Illinois", StateDisplayName = "Illinois" }; var contact = TreeNode.New<Contact>().With(x => x.Fields.Country = "USA;Illinois"); var socialLinkRepository = Substitute.For<ISocialLinkRepository>(); var cafeRepository = Substitute.For<ICafeRepository>(); var contactRepository = Substitute.For<IContactRepository>(); var countryRepository = Substitute.For<ICountryRepository>(); var localizationService = Substitute.For<LocalizationService>(); var outputCacheDependencies = Substitute.For<IOutputCacheDependencies>(); contactRepository.GetCompanyContact().Returns(contact); countryRepository.GetCountry(country.CountryName).Returns(country); countryRepository.GetState(state.StateName).Returns(state); mFormItemRepository = Substitute.For<IFormItemRepository>(); mController = new ContactsController(cafeRepository, socialLinkRepository, contactRepository, mFormItemRepository, countryRepository, localizationService, outputCacheDependencies); mMessageModel = CreateMessageModel(); }
public StateInfo FileSaveAs(HttpPostedFile _postedFile, bool _isWater, string ImgType) { StateInfo info = new StateInfo(); try { string str = _postedFile.FileName.Substring(_postedFile.FileName.LastIndexOf(".") + 1); if (!this.CheckFileExt(this.wsi.WebFileType, str)) { info.State = 0; info.Info = "不允许上传" + str + "类型的文件!"; } if ((this.wsi.WebFileSize > 0) && (_postedFile.ContentLength > (this.wsi.WebFileSize * 0x400))) { info.State = 0; info.Info = "文件超过限制的大小啦!"; } string str2 = DateTime.Now.ToString("yyyyMMddHHmmssff") + "." + str; if (!this.wsi.WebFilePath.StartsWith("jquery.easyui/")) { this.wsi.WebFilePath = "jquery.easyui/" + this.wsi.WebFilePath; } if (!this.wsi.WebFilePath.EndsWith("/")) { this.wsi.WebFilePath = this.wsi.WebFilePath + "/"; } string str3 = ImgType + "/"; this.wsi.WebFilePath = this.wsi.WebFilePath + str3; string imgPath = this.wsi.WebFilePath + str2; string path = HttpContext.Current.Server.MapPath(this.wsi.WebFilePath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string filename = path + str2; _postedFile.SaveAs(filename); if (((this.wsi.IsWatermark > 0) && _isWater) && this.CheckFileExt("BMP|JPEG|JPG|GIF|PNG|TIFF", str)) { switch (this.wsi.IsWatermark) { case 1: ImageWaterMark.AddImageSignText(imgPath, this.wsi.WebFilePath + str2, this.wsi.WaterText, this.wsi.WatermarkStatus, this.wsi.ImgQuality, this.wsi.WaterFont, this.wsi.FontSize); break; case 2: ImageWaterMark.AddImageSignPic(imgPath, this.wsi.WebFilePath + str2, this.wsi.ImgWaterPath, this.wsi.WatermarkStatus, this.wsi.ImgQuality, this.wsi.ImgWaterTransparency); break; } } info.State = 1; info.Info = str3 + str2; } catch { info.State = 0; info.Info = "传过程中发生意外错误!"; } return info; }
internal StateInfoWrapper(StateInfo[] table, int current) { this.table = table; this.current = current; for (var i = 0; i < table.Length; i++) { table[i] = new StateInfo(); } }
public void getdatainfo() { HttpRequest request = HttpContext.Current.Request; StateInfo o = new StateInfo(); for (int i = 0; i < 0x5f5e100; i++) { o.State = i; } JSONHelper.Write(JSONHelper.Convert2Json(o)); }
public static string GetTextFromReader (TextReader file) { string line; StateInfo s = new StateInfo (); while ((line = file.ReadLine ()) != null) ProcessLine (line, s); return s.output.ToString (); }
public void Restore(StateInfo state) { /*State.Time = state.Get<float>("time"); /*var anims = state["animations"] as List<Animation>; foreach (var animation in anims) { State.AddAnimation(animation, false); }/ Skeleton.UpdateWorldTransform();*/ }
public frmState(int stateID, int countryID) { InitializeComponent(); LoadCountry(); State.StateWebService objWebService = new State.StateWebService(); StateInfo objInfo = new StateInfo(); objInfo.StateID = stateID; objInfo.CountryID = countryID; objInfo = objWebService.StateNameGetByID(objInfo.StateID, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens())); cmbCountryName.SelectedValue = objInfo.CountryID; txtStateName.Text = objInfo.StateName; lblCountryID.Text = objInfo.CountryID.ToString(); lblStateID.Text = objInfo.StateID.ToString(); }
internal void copyFrom(StateInfo other) { pawnKey = other.pawnKey; materialKey = other.materialKey; nonPawnMaterial[0] = other.nonPawnMaterial[0]; nonPawnMaterial[1] = other.nonPawnMaterial[1]; castlingRights = other.castlingRights; rule50 = other.rule50; pliesFromNull = other.pliesFromNull; psq = other.psq; epSquare = other.epSquare; key = other.key; checkersBB = other.checkersBB; capturedType = other.capturedType; }
private static void SetOrigin(RateRequest request, Delivery delivery) { request.RequestedShipment.Shipper = new Party(); request.RequestedShipment.Shipper.Address = new Address(); request.RequestedShipment.Shipper.Address.StreetLines = new string[1] { SettingsKeyInfoProvider.GetValue("SourceStreet", "123 Street") }; request.RequestedShipment.Shipper.Address.City = SettingsKeyInfoProvider.GetValue("SourceCity", "Los Angeles"); string[] strCountryState = SettingsKeyInfoProvider.GetValue("SourceCountryState", "US").Split(';'); CountryInfo ci = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetString(strCountryState[0], "USA")); request.RequestedShipment.Shipper.Address.CountryCode = ci.CountryTwoLetterCode; StateInfo si = StateInfoProvider.GetStateInfo(ValidationHelper.GetString(strCountryState[1], "California")); request.RequestedShipment.Shipper.Address.StateOrProvinceCode = si.StateCode; request.RequestedShipment.Shipper.Address.PostalCode = SettingsKeyInfoProvider.GetValue("SourceZip", "90001"); }
void Start() { mInfo = new StateInfo(); mInfo.moveFinish = true; //mInfo.rotateFinish = true; mInfo.rotateTick = 0; mInfo.moveTick = 0; mInfo.state = State.IDLE; mInitPos = this.transform.position; mAnimator = GetComponent <Animator>(); mBody = GetComponent <Rigidbody>(); iLastActionTime = Time.time; mTa = new Vector3(); mTb = new Vector3(); mCurrentPos = new Vector3(); //Debug.Log("Init:" + mInitPos.ToString()); }
public static string GetTextFromStream(Stream stream) { if (stream == null) { return(null); } StreamReader file = new StreamReader(stream); string line; StateInfo s = new StateInfo(); while ((line = file.ReadLine()) != null) { ProcessLine(line, s); } return(s.output.ToString()); }
internal static StateInfo GetObject() { int slotID = System.Threading.Thread.CurrentThread.ManagedThreadId & Constants.BROKER_SLOT_MASK; if (_cnt[slotID] == _pool[slotID].Length) { int poolLength = _pool[slotID].Length; StateInfo[] temp = new StateInfo[poolLength + Constants.BrokerCapacity]; Array.Copy(_pool[slotID], temp, poolLength); for (int i = 0; i < Constants.BrokerCapacity; i++) { temp[poolLength + i] = new StateInfo(); } _pool[slotID] = temp; } return(_pool[slotID][_cnt[slotID]++]); }
public void DisableState(string stateName) { StateInfo state = FindState(stateName); if (state != null) { state.Disable(); } if (needSyncLayers != null) { for (int i = 0; i < needSyncLayers.Count; i++) { needSyncLayers[i].DisableState(stateName); } } }
public void Constructor_ExpectedValues() { // Setup const string name = "Name"; const string symbol = "Symbol"; var fontFamily = new FontFamily(); Func <IProject, object> getRootData = o => new object(); // Call var stateInfo = new StateInfo(name, symbol, fontFamily, getRootData); // Assert Assert.AreEqual(name, stateInfo.Name); Assert.AreEqual(symbol, stateInfo.Symbol); Assert.AreSame(fontFamily, stateInfo.FontFamily); Assert.AreSame(getRootData, stateInfo.GetRootData); }
/* * Main goals: * 1. No copies, ever. States are deposited directly to, and read directly from, one giant ring buffer. * As a consequence, there is no multi-threading because there is nothing to thread. * 2. Support for arbitrary and changeable state sizes. Frequency is calculated dynamically. * 3. No delta compression. Keep it simple. If there are cores that benefit heavily from delta compression, we should * maintain a separate rewinder alongside this one that is customized for those cores. */ public ZwinderBuffer(IRewindSettings settings) { long targetSize = settings.BufferSize * 1024 * 1024; if (settings.TargetFrameLength < 1) { throw new ArgumentOutOfRangeException(nameof(settings.TargetFrameLength)); } Size = 1L << (int)Math.Floor(Math.Log(targetSize, 2)); _sizeMask = Size - 1; _buffer = new MemoryBlock((ulong)Size); _buffer.Protect(_buffer.Start, _buffer.Size, MemoryBlock.Protection.RW); _targetFrameLength = settings.TargetFrameLength; _states = new StateInfo[STATEMASK + 1]; _useCompression = settings.UseCompression; }
/// <summary> /// Creates a new instance of <see cref="StateGraph"/>. /// </summary> /// <param name="machineInfo">An object which exposes the states, transitions, and actions of this machine.</param> public StateGraph(StateMachineInfo machineInfo) { // Add initial state initialState = machineInfo.InitialState; // Start with top-level superstates AddSuperstates(machineInfo); // Now add any states that aren't part of a tree AddSingleStates(machineInfo); // Now grab transitions AddTransitions(machineInfo); // Handle "OnEntryFrom" ProcessOnEntryFrom(machineInfo); }
public void DeleteStateByStateID(StateInfo Stinfo) { try { using (RMSDataContext db = new RMSDataContext()) { var obj = (from a in db.States where a.State_DivisionID == Stinfo.DivitionID select a).First(); db.States.DeleteOnSubmit(obj); db.SubmitChanges(); } } catch (Exception ex) { State St = new State(); } }
public void SetInputWeight(string stateName, float weight) { StateInfo state = FindState(stateName); if (state != null) { state.SetWeight(weight); if (needSyncLayers != null) { for (int i = 0; i < needSyncLayers.Count; i++) { needSyncLayers[i].SetInputWeight(stateName, weight); } } } }
public bool RemoveAtIndex(int index) { StateInfo removed = m_States[index]; if (removed == null) { return(false); } m_States[index] = null; if (removed.playable.IsValid()) { removed.playable.GetGraph().DestroyPlayable(removed.playable); } m_Count = m_States.Count; return(true); }
public void SingleEnqueueSingleDequeueSucceeds() { var stateInfo = new StateInfo { CircularQueue = new CircularQueue <string>(CAPACITY), Count = 1000 * 1000 }; ThreadPool.QueueUserWorkItem(new WaitCallback(DequeueProc), stateInfo); Thread.Sleep(1 * 1000); EnqueueProc(stateInfo); Trace.WriteLine(string.Format("EnqueueOperations '{0}'", stateInfo.EnqueueOperations)); Trace.WriteLine(string.Format("DequeueOperations '{0}'", stateInfo.DequeueOperations)); }
protected override void Start() { _stateInfo = new StateInfo(STATE_NAME, this); base.Start(); if (GCore.IsFreshLaunch) { GStateManager.Instance.EnableLoadingSpinner(true); authenticateBraincloud(); } else { GStateManager.Instance.EnableLoadingSpinner(false); Panel.SetActive(true); } updateViewDisplay(); }
/// <summary> /// Callback from InternalAPIAccess to process a single Animator state. /// </summary> /// <param name="layer">Layer index.</param> /// <param name="layerName">Layer name.</param> /// <param name="item">State name.</param> public void ProcessAnimatorState(StateInfo info) { string layerPrefix = (info.Layer > 0 || config.ForceLayerPrefix ? null : info.LayerName); string name = CodeGenerationUtils.GenerateStateName(config.AnimatorStatePrefix, info.Name, layerPrefix); name = name.FirstCharToUpper(); string fieldName = CodeGenerationUtils.GenerateStateName(config.AnimatorStateHashPrefix, info.Name, layerPrefix); fieldName = fieldName.FirstCharToLower(); // field declaration GenericFieldCodeElement field = new GenericFieldCodeElement(typeof(int), fieldName, "" + info.Id); field.ReadOnly = true; field.Summary.Add("Hash of Animator state " + info.Name); classCodeElement.Fields.Add(field); string methodName = "Is" + name; // IsXXX method () MethodCodeElement <bool> method = new MethodCodeElement <bool> (methodName); method.Origin = "state " + info.Name; method.Code.Add("return " + fieldName + " == animator.GetCurrentAnimatorStateInfo (" + info.Layer + ").nameHash" + ";"); method.Summary.Add("true if the current Animator state of layer " + info.Layer + " is \"" + info.Name + "\"."); classCodeElement.Methods.Add(method); // overloaded IsXXX (int nameHash) MethodCodeElement <bool> methodWithLayerParameter = new MethodCodeElement <bool> (methodName); methodWithLayerParameter.Origin = "state " + info.Name; methodWithLayerParameter.AddParameter(typeof(int), "nameHash"); methodWithLayerParameter.Code.Add("return nameHash == " + fieldName + ";"); methodWithLayerParameter.Summary.Add("true if the given (state) nameHash equals Animator.StringToHash (\"" + info.Name + "\")."); classCodeElement.Methods.Add(methodWithLayerParameter); // state dictionary is filled in overriden method InitialiseEventManager object [] parameters = new object[] { info.Id, info.Layer, info.LayerName, info.Name, info.Tag, info.Speed, info.FootIK, info.Mirror, info.Motion.Name, info.Motion.Duration }; string parameterList = CodeElementUtils.GetCallParameterString(parameters); EventManagerInitialiser.Code.Add(StateInfoDict + ".Add (" + info.Id + ", new StateInfo (" + parameterList + "));"); }
public bool Crossfade(string name, float time) { StateInfo state = m_States.FindState(name); if (state == null) { Debug.LogError(string.Format("Cannot crossfade to state with name {0} because there is no state with that name", name)); return(false); } if (time == 0f) { return(Play(state.index)); } return(Crossfade(state.index, time)); }
/* * Main goals: * 1. No copies, ever. States are deposited directly to, and read directly from, one giant ring buffer. * As a consequence, there is no multi-threading because there is nothing to thread. * 2. Support for arbitrary and changeable state sizes. Frequency is calculated dynamically. * 3. No delta compression. Keep it simple. If there are cores that benefit heavily from delta compression, we should * maintain a separate rewinder alongside this one that is customized for those cores. */ public ZwinderBuffer(IRewindSettings settings) { if (settings == null) { throw new ArgumentException("ZwinderBuffer's settings cannot be null."); } long targetSize = settings.BufferSize * 1024 * 1024; if (settings.TargetFrameLength < 1) { throw new ArgumentOutOfRangeException(nameof(settings.TargetFrameLength)); } Size = 1L << (int)Math.Floor(Math.Log(targetSize, 2)); _sizeMask = Size - 1; _backingStoreType = settings.BackingStore; switch (settings.BackingStore) { case IRewindSettings.BackingStoreType.Memory: { var buffer = new MemoryBlock((ulong)Size); buffer.Protect(buffer.Start, buffer.Size, MemoryBlock.Protection.RW); _disposables.Add(buffer); _backingStore = new MemoryViewStream(true, true, (long)buffer.Start, (long)buffer.Size); _disposables.Add(_backingStore); break; } case IRewindSettings.BackingStoreType.TempFile: { var filename = TempFileManager.GetTempFilename("ZwinderBuffer"); var filestream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose); filestream.SetLength(Size); _backingStore = filestream; _disposables.Add(filestream); break; } default: throw new ArgumentException("Unsupported store type for ZwinderBuffer."); } _targetFrameLength = settings.TargetFrameLength; _states = new StateInfo[STATEMASK + 1]; _useCompression = settings.UseCompression; }
public StateInfo GetCurrentState(int playerNum) { GetCurrentState(playerNum, out VSUserState currentState, out List <VSUserTransition> options); GetPlayerStatus(playerNum, out Vector endTransitionPosition, out Polygon endTransitionArea); int rotationState = _rotationState; int focusState = _playerInFocusState; List <Vector> endPositions = new List <Vector>(); List <Polygon> endAreas = new List <Polygon>(); foreach (VSUserTransition transition in options) { // reset the state after the user centric transition _rotationState = rotationState; _playerInFocusState = focusState; // we need to undo this here // otherwise it's going to f**k up the switched index positions? // no because Assymmetric will never be called here UserCentricTransition(transition, playerNum); // todo this needs to be updated so that ghost areas are adequately transmitted GetPlayerStatus(playerNum, out Vector position, out Polygon area); endPositions.Add(position); endAreas.Add(area); } _rotationState = rotationState; _playerInFocusState = focusState; Logger.Debug($"Creating state info with state id {_stateId}"); StateInfo info = new StateInfo() { YourFinalState = currentState, PossibleTransitions = options, ThisTransitionEndPosition = endTransitionPosition, ThisTransitionEndArea = endTransitionArea, TransitionEndPositions = endPositions, TransitionEndAreas = endAreas, StateId = _stateId }; return(info); }
/// <summary> /// Gets and updates state. Called when the "Get and update state" button is pressed. /// Expects the CreateState method to be run first. /// </summary> private bool GetAndUpdateState() { // Get the state StateInfo updateState = StateInfoProvider.GetStateInfo("MyNewState"); if (updateState != null) { // Update the property updateState.StateDisplayName = updateState.StateDisplayName.ToLower(); // Update the state StateInfoProvider.SetStateInfo(updateState); return(true); } return(false); }
private bool Play(int index) { for (int i = 0; i < m_States.Count; i++) { StateInfo state = m_States[i]; if (state.index == index) { m_States.EnableState(i); m_States.SetInputWeight(i, 1f); } else { DoStop(i); } } return(true); }
public void UpdateStateByStateID(StateInfo stinfo) { try { using (RMSDataContext db = new RMSDataContext()) { var obj = (from a in db.States where a.State_DivisionID == stinfo.DivitionID select a).First(); obj.State_DivisionID = stinfo.DivitionID; obj.State_Division_Name = stinfo.DivisionName; obj.State_Division_Description = stinfo.DivisionDescription; db.SubmitChanges(); } } catch (Exception ex) { State St = new State(); } }
private bool Play(int index) { for (int i = 0; i < m_States.Count; i++) { StateInfo state = m_States[i]; if (state.index == index) { state.Enable(); state.ForceWeight(1.0f); } else { DoStop(i); } } return(true); }
public int Compare(Object x, Object y) { StateInfo xx = (StateInfo)x; StateInfo yy = (StateInfo)y; if (xx.nNextStateCount > yy.nNextStateCount) { return(-1); } else if (xx.nNextStateCount == yy.nNextStateCount) { return(0); } else { return(1); } }
private void RemoveClones(StateInfo state) { var it = m_StateQueue.First; while (it != null) { var next = it.Next; StateInfo queuedState = m_States[it.Value.state.index]; if (queuedState.parentState.index == state.index) { m_StateQueue.Remove(it); DoStop(queuedState.index); } it = next; } }
protected override void ParseData(SqliteDataReader reader) { if (reader == null || !reader.HasRows) { return; } mBattleStateMap = new Dictionary <string, StateInfo>(); StateInfo kInfo; while (reader.Read()) { kInfo = new StateInfo(); kInfo.state = GetReaderString(reader, "state"); kInfo.value = DBTextResource.ParseBT(GetReaderString(reader, "value")); mBattleStateMap.Add(kInfo.state, kInfo); } }
private bool IsClonePlaying(StateInfo state) { for (int i = 0; i < m_States.Count; i++) { StateInfo otherState = m_States[i]; if (otherState == null) { continue; } if (otherState.isClone && otherState.enabled && otherState.parentState.index == state.index) { return(true); } } return(false); }
public void Init(object initState, object inputData = null) { CurrentState = initState; var state = _infos.FirstOrDefault(x => x.StateType == (int)initState); _currentStateInfo = state ?? throw new Exception($"StateMachine Init Error: Can't find state"); if (inputData != null) { try { _currentStateInfo.EventHandler(inputData); } catch (Exception e) { throw new Exception($"StateMachine EnterTrigger Invoke Event in node Error: {e.Message}"); } } }
private void CleanClonedStates() { for (int i = m_States.Count - 1; i >= 0; i--) { StateInfo state = m_States[i]; if (state == null) { continue; } if (state.isReadyForCleanup) { Playable toDestroy = m_Mixer.GetInput(state.index); graph.Disconnect(m_Mixer, state.index); graph.DestroyPlayable(toDestroy); m_States.RemoveState(i); } } }
public bool DeepEquals(DestinyCollectibleDefinition?other) { return(other is not null && (DisplayProperties is not null ? DisplayProperties.DeepEquals(other.DisplayProperties) : other.DisplayProperties is null) && Scope == other.Scope && SourceString == other.SourceString && SourceHash == other.SourceHash && ItemHash == other.ItemHash && (AcquisitionInfo is not null ? AcquisitionInfo.DeepEquals(other.AcquisitionInfo) : other.AcquisitionInfo is null) && (StateInfo is not null ? StateInfo.DeepEquals(other.StateInfo) : other.StateInfo is null) && (PresentationInfo is not null ? PresentationInfo.DeepEquals(other.PresentationInfo) : other.PresentationInfo is null) && PresentationNodeType == other.PresentationNodeType && TraitIds.DeepEqualsListNaive(other.TraitIds) && TraitHashes.DeepEqualsListNaive(other.TraitHashes) && ParentNodeHashes.DeepEqualsListNaive(other.ParentNodeHashes) && Hash == other.Hash && Index == other.Index && Redacted == other.Redacted); }
/// <summary> /// Domain service method to return state info based on input /// </summary> /// <param name="name">State name or abbreviation</param> /// <returns>StateInfo object with state info</returns> public StateInfo GetStateInfo(string name) { // Valid input check if (string.IsNullOrEmpty(name)) { throw new DomainServiceException(Constants.Logging.Message.EmptyInputWarning); } try { var stateInfo = new StateInfo(); // External service call. var restResponse = _gatewayService.GetStatesInfo(); using (Stream responseStream = restResponse.ResponseStream) { StreamReader reader = new StreamReader(responseStream, Encoding.UTF8); var jsonstring = reader.ReadToEnd(); var rootObject = Newtonsoft.Json.JsonConvert.DeserializeObject <RootObject>(jsonstring); var states = rootObject.RestResponse.result; stateInfo = states?.FirstOrDefault(x => x.name.ToUpper() == name.ToUpper() || x.abbr.ToUpper() == name.ToUpper()); } return(stateInfo); } catch (WebException webEx) { LoggingService.Log(webEx.Message); throw new DomainServiceException(webEx, Constants.Logging.Message.IssueWithRESTFulService); } catch (GatewayServiceException gsEx) { LoggingService.Log(gsEx.Message); throw new DomainServiceException(gsEx, Constants.Logging.Message.GatewayServiceError); } catch (Exception ex) { LoggingService.Log(ex.Message); throw new DomainServiceException(ex, Constants.Logging.Message.StatesInfoNotRetrieved); } }
protected override void Start() { _stateInfo = new StateInfo(STATE_NAME, this); base.Start(); StateMachine = StateMachine <eLevels> .Initialize(this); LoadPoint loadPoint = GPlayerManager.Instance.PlayerData.CurrentSavePoint; switch (loadPoint) { case LoadPoint.AreaMRoom1: CurrentSpawnPoint = AreaMRoom1_SpawnPoint; activateLevel(0); break; case LoadPoint.AreaMRoom4: CurrentSpawnPoint = AreaMRoom4_SpawnPoint; activateLevel(0); break; case LoadPoint.Area1Room2: CurrentSpawnPoint = Area1Room2_SpawnPoint; activateLevel(1); break; case LoadPoint.Area1Room8: CurrentSpawnPoint = Area1Room8_SpawnPoint; activateLevel(1); break; case LoadPoint.Area1Room15: CurrentSpawnPoint = Area1Room15_SpawnPoint; activateLevel(1); break; default: break; } SetCurrentSpawnPoint(loadPoint); Player.transform.position = CurrentSpawnPoint.transform.position; }
internal void update(Position pos, List<MoveT> newPv) { Debug.Assert(newPv.Count >= 3); // Keep track of how many times in a row 3rd ply remains stable stableCnt = (newPv[2] == pv[2]) ? stableCnt + 1 : 0; if (pv[0] != newPv[0] || pv[1] != newPv[1] || pv[2] != newPv[2]) { pv[0] = newPv[0]; pv[1] = newPv[1]; pv[2] = newPv[2]; var st = new StateInfo[2]; pos.do_move(newPv[0], st[0], pos.gives_check(newPv[0], new CheckInfo(pos))); pos.do_move(newPv[1], st[1], pos.gives_check(newPv[1], new CheckInfo(pos))); expectedPosKey = pos.key(); pos.undo_move(newPv[1]); pos.undo_move(newPv[0]); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (ValidateForm()) { State.StateWebService objWebService = new State.StateWebService(); StateInfo objInfo = new StateInfo(); objInfo.StateName = txtStateName.Text; lblCountryID.Text = cmbCountryName.SelectedValue.ToString(); int stateID = Convert.ToInt32(lblStateID.Text); int countryID = Convert.ToInt32(lblCountryID.Text); if (stateID == 0 && countryID != 0) { objInfo.CountryID = Convert.ToInt32(cmbCountryName.SelectedValue); objInfo.AddedBy = GetLoginUser.UserName; objWebService.StateNameAdd(objInfo, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens())); MessageBox.Show("Data Saved Successfully"); } else if (stateID != 0 && countryID != 0) { objInfo.StateID = stateID; objInfo.CountryID = countryID; objInfo.EditedBy = GetLoginUser.UserName; objWebService.StateNameUpdate(objInfo, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens())); MessageBox.Show("Data Updated Successfully"); } ClearField(); this.DialogResult = DialogResult.OK; } } catch (Exception ex) { throw ex; } }
/// RootMove::extract_ponder_from_tt() is called in case we have no ponder move before /// exiting the search, for instance in case we stop the search during a fail high at /// root. We try hard to have a ponder move to return to the GUI, otherwise in case of /// 'ponder on' we have nothing to think on. internal bool extract_ponder_from_tt(Position pos) { var st = new StateInfo(); bool ttHit; Debug.Assert(pv.Count == 1); pos.do_move(pv[0], st, pos.gives_check(pv[0], new CheckInfo(pos))); var tte = TranspositionTable.probe(pos.key(), out ttHit); pos.undo_move(pv[0]); if (ttHit) { var m = tte.move(); // Local copy to be SMP safe if (new MoveList(GenType.LEGAL, pos).contains(m)) { pv.Add(m); return true; } } return false; }
internal Position(Position other, Thread thread) { Array.Copy(other.board, board, other.board.Length); Array.Copy(other.byColorBB, byColorBB, other.byColorBB.Length); Array.Copy(other.byTypeBB, byTypeBB, other.byTypeBB.Length); Array.Copy(other.castlingPath, castlingPath, other.castlingPath.Length); Array.Copy(other.castlingRightsMask, castlingRightsMask, other.castlingRightsMask.Length); Array.Copy(other.castlingRookSquare, castlingRookSquare, other.castlingRookSquare.Length); Array.Copy(other.index, index, other.index.Length); Array.Copy(other.pieceCount, pieceCount, other.pieceCount.Length); Array.Copy(other.pieceList, pieceList, other.pieceList.Length); chess960 = other.chess960; gamePly = other.gamePly; sideToMove = other.sideToMove; thisThread = thread; startState = new StateInfo(); startState.copyFrom(other.st); st = startState; nodes = 0; Debug.Assert(pos_is_ok()); }
private void btnSave_Click(object sender, EventArgs e) { try { if (ValidateForm()) { State.StateWebService objWebService = new State.StateWebService(); StateInfo objInfo = new StateInfo(); objInfo.CountryID = Convert.ToInt32(lblCountryID.Text); objInfo.StateName = txtStateName.Text; objInfo.AddedBy = GetLoginUser.UserName; objWebService.StateNameAdd(objInfo, TokenCleintEncrypt.Encrypt(ClientTokenBuilder.BuildTokens())); MessageBox.Show("State Name Added Successfully"); txtStateName.Text = string.Empty; } this.DialogResult = DialogResult.OK; } catch (Exception ex) { throw ex; } }
public void Upload() { StateInfo o = new StateInfo(); HttpRequest request = HttpContext.Current.Request; string str = ""; string str2 = ""; str = request["name"].ToString(); string imgType = request["ImgType"].ToString(); HttpPostedFile file = request.Files[str]; if (str == "FileUpload") { str2 = request.Params["txtOrignalUrl"]; } else { str2 = request.Params["txtOrignalUrl1"]; } if (file == null) { o.State = 0; o.Info = "请选择要上传的文件"; } o = new HttpFileUpload().FileSaveAs(file, false, imgType); if (!string.IsNullOrEmpty(str2)) { try { str2 = "../../" + str2; Utils.FileDelete(HttpContext.Current.Server.MapPath(str2)); } catch { } } JSONHelper.Write(JSONHelper.Convert2Json(o)); }
//遍历词表 private bool Dict_Traversal(StateInfo[] pStateInfo, ref int nStateCount, int n) { //char[] cWordId = new char[MaxWordSize]; String cState = ""; int i ; for ( i= 0; i < m_nDictItemCount; i++)//m_nDictItemCount是指字典里单词的总个数 { AddInfo(m_pcWordArray[i], ref cState, n, m_piWordLenArray[i], ref pStateInfo, ref nStateCount); } //System.Console.Out.WriteLine(i); return true; }
static void ProcessLine (string line, StateInfo s) { string[] parts = SplitLine (line); switch (parts [0]) { case ".\\\"": // comments case ".de": // define macro case ".if": // if case ".ne": // ??? case "..": // end macro // ignore break; case ".I": s.output.Append ("<i>"); Translate (parts, 1, s.output); s.output.Append ("</i>"); break; case ".B": s.output.Append ("<b>"); Translate (parts, 1, s.output); s.output.Append ("</b>"); break; case ".br": Translate (parts, 1, s.output); s.output.Append ("<br />"); break; case ".nf": Expect (s, "</p>"); s.output.Append ("<pre>\n"); s.tags.Push ("</pre>"); break; case ".fi": Expect (s, "</pre>"); break; case ".PP": Expect (s, "</p>", "</dd>", "</dl>"); goto case ".Sp"; case ".Sp": Expect (s, "</p>"); s.output.Append ("<p>"); Translate (parts, 1, s.output); s.tags.Push ("</p>"); break; case ".RS": Expect (s, "</p>"); s.output.Append ("<blockquote>"); s.tags.Push ("</blockquote>"); break; case ".RE": ClearUntil (s, "</blockquote>"); break; case ".SH": ClearAll (s); s.output.Append ("<h2>"); Translate (parts, 1, s.output); s.output.Append ("</h2>") .Append ("<blockquote>"); s.tags.Push ("</blockquote>"); break; case ".SS": s.output.Append ("<h3>"); Translate (parts, 1, s.output); s.output.Append ("</h3>"); break; case ".TH": { ClearAll (s); string name = "", extra = ""; if (parts.Length >= 4 && parts [2].Trim ().Length == 0) { name = parts [1] + "(" + parts [3] + ")"; if (parts.Length > 4) { int start = 4; if (parts [start].Trim ().Length == 0) ++start; extra = string.Join ("", parts, start, parts.Length-start); } } else name = string.Join ("", parts, 1, parts.Length-1); s.output.Append ("<table width=\"100%\" bgcolor=\"#b0c4da\">" + "<tr colspan=\"2\"><td>Manual Pages</td></tr>\n" + "<tr><td><h3>"); Translate (name, s.output); s.output.Append ("</h3></td><td align=\"right\">"); Translate (extra, s.output); s.output.Append ("</td></tr></table>"); break; } case ".TP": Expect (s, "</p>"); if (s.tags.Count > 0 && s.tags.Peek ().ToString () != "</dd>") { s.output.Append ("<dl>"); s.tags.Push ("</dl>"); } else Expect (s, "</dd>"); s.output.Append ("<dt>"); s.tags.Push ("</dt>"); s.ls = ListState.Start; break; default: Translate (line, s.output); break; } if (s.ls == ListState.Start) s.ls = ListState.Title; else if (s.ls == ListState.Title) { Expect (s, "</dt>"); s.output.Append ("<dd>"); s.tags.Push ("</dd>"); s.ls = ListState.None; } s.output.Append ("\n"); }
static void ClearUntil (StateInfo s, string required) { string e; while (s.tags.Count > 0 && (e = s.tags.Peek ().ToString ()) != required) { s.output.Append (s.tags.Pop ().ToString ()); } if (e == required) s.output.Append (s.tags.Pop ().ToString ()); }
static void ClearAll (StateInfo s) { while (s.tags.Count > 0) s.output.Append (s.tags.Pop ().ToString ()); }
/// <summary> /// Creates state. Called when the "Create state" button is pressed. /// </summary> private bool CreateState() { // Get the country CountryInfo country = CountryInfoProvider.GetCountryInfo("MyNewCountry"); if (country != null) { // Create new state object StateInfo newState = new StateInfo(); // Set the properties newState.StateDisplayName = "My new state"; newState.StateName = "MyNewState"; newState.CountryID = country.CountryID; // Create the state StateInfoProvider.SetStateInfo(newState); return true; } return false; }
static void Expect (StateInfo s, params string[] expected) { string e; while (s.tags.Count > 0 && Array.IndexOf (expected, (e = s.tags.Peek ().ToString ())) >= 0) { s.output.Append (s.tags.Pop ().ToString ()); } }
private void Restore(StateInfo state) { Render.Camera.Zoom = state.Get<float>("currentZoom"); Render.Camera.Position = state.Get<Vector2>("currentPosition"); _targetZoom = state.Get<float>("targetZoom"); _previousZoom = state.Get<float>("previousZoom"); _previousPosition = state.Get<Vector2>("previousPosition"); }
/// <summary> /// Gets and bulk updates states. Called when the "Get and bulk update states" button is pressed. /// Expects the CreateState method to be run first. /// </summary> private bool GetAndBulkUpdateStates() { // Get the country CountryInfo country = CountryInfoProvider.GetCountryInfo("MyNewCountry"); if (country != null) { // Get the data DataSet states = StateInfoProvider.GetCountryStates(country.CountryID); if (!DataHelper.DataSourceIsEmpty(states)) { // Loop through the individual items foreach (DataRow stateDr in states.Tables[0].Rows) { // Create object from DataRow StateInfo modifyState = new StateInfo(stateDr); // Update the property modifyState.StateDisplayName = modifyState.StateDisplayName.ToUpper(); // Update the state StateInfoProvider.SetStateInfo(modifyState); } return true; } } return false; }
private void Save(StateInfo state) { state["currentZoom"] = Render.Camera.Zoom; state["currentPosition"] = Render.Camera.Position; state["targetZoom"] = _targetZoom; state["previousZoom"] = _previousZoom; state["previousPosition"] = _previousPosition; }
//添加状态信息到结构数组中 private void AddInfo(String cWord, ref String cState, int n, int nLen, ref StateInfo[] pStateInfo, ref int nStateCount) { //nLen指cWord的长度,n是指当前在处理第几个字,cState表示当前状态,cWord就是当前单词, int nIter = 0; StringBuilder temp = new StringBuilder(); String buff = ""; util.GetChar(cWord, ref nIter, ref buff); temp.Append(buff); for (int i = 1; i < n; i++) //获得cWord的前n个字 { if (nIter == nLen) return; else { util.GetChar(cWord, ref nIter, ref buff); temp.Append(buff); } } String cWordFir = temp.ToString(); //如果当前状态后面还有输入变量 if (nLen > nIter) { String cWordSec = ""; util.GetChar(cWord, ref nIter, ref cWordSec); if (!cState.Equals(cWordFir)) //当前状态与数组中前一状态不同 { //将当前状态的信息加入状态信息数组 pStateInfo[nStateCount].nStateSub = GetStatArraySub(cWordFir); pStateInfo[nStateCount].pNextID = new int[Maxsize]; pStateInfo[nStateCount].pNextID[0] = util.GetInnerCode(cWordSec); pStateInfo[nStateCount].nNextStateCount = 1; nStateCount++; ; cState = cWordFir; } else //相同 { int nCount = pStateInfo[nStateCount - 1].nNextStateCount; if (nCount == 0)//如果当前状态还没有延续字, { pStateInfo[nStateCount - 1].pNextID = new int[Maxsize]; pStateInfo[nStateCount - 1].pNextID[0] = util.GetInnerCode(cWordSec); pStateInfo[nStateCount - 1].nNextStateCount = 1; } else//如果当前状态已经有了延续字,再加下现在这个延续字 { if (pStateInfo[nStateCount - 1].pNextID[nCount - 1] != util.GetInnerCode(cWordSec))//如果现在这个延续字与上一个当前状态的延续字不相同 { pStateInfo[nStateCount - 1].pNextID[nCount] = util.GetInnerCode(cWordSec); pStateInfo[nStateCount - 1].nNextStateCount++; } } } } //如果当前状态已经是一个完整的词条 else { if (!cState.Equals(cWordFir))//当前状态与数组中前一状态不同 { pStateInfo[nStateCount].nStateSub = GetStatArraySub(cWordFir); pStateInfo[nStateCount].pNextID = null; pStateInfo[nStateCount].nNextStateCount = 0; ConsidSize(pStateInfo[nStateCount].nStateSub); m_vBase[pStateInfo[nStateCount].nStateSub] = (-1) * pStateInfo[nStateCount].nStateSub;//代表是一个词语了,下面没有后延了 nStateCount++; cState = cWordFir; } } }
//字典文件->数组文件 //<summary> //构造双数组的核心函数 //构造数组,生成数组文件 //</summary> private bool Construct_Arrays(String pszFileName) { bool bSuccess = true; //是否构造成功 m_vBase = new ArrayList();//双数组 m_vCheck = new ArrayList();//双数组 if (m_vBase == null || m_vCheck == null) { bSuccess = false; return bSuccess; } if (DictLoad(pszFileName) == false)//将字典文本装入数组m_pcWordArray和m_pcLenWordArray return false; if (m_nDictItemCount == 0) //词典为空或读入失败 m_nDictItemCount为字典里单词的总个数 bSuccess = false; else { StateInfo[] pStateInfo; int nStateArrayCount = 0; //int &nStateCount = nStateArrayCount; //initialize the check and base for (int n = 0; n < SINGLE_WORD_INNERCODE + Utility.RESERVE_ITEMS; n++)//单字节内码 { m_vBase.Add(0); m_vCheck.Add(-1); //把前SINGLE_WORD_INNERCODE+RESERVE_ITEMS个位置留给首字 } int i; for (i = 1; i < (m_nWordMaxSize) + 1; i++) //遍历词表 m_nWordMaxSize代表一个单词的最大长度 {//以单词里第i个字为标准,计算以该字为首的下面的字的个数 System.Console.Out.WriteLine("第" + i + "轮"); pStateInfo = new StateInfo[m_nDictItemCount];//建立状态 m_nDictItemCount代表字典里词的个数 nStateArrayCount = 0; /* * struct StateInfo { public int nStateSub; //当前状态的base和check数组下标 public int nNextStateCount; //所有下一状态数 public int[] pNextID; //下一状态ID数组 } ; */ Dict_Traversal(pStateInfo, ref nStateArrayCount, i);//每一轮考虑每个单词的当前第i个字(nStateInfo),以及该字下面是否有延续字,如果有,那么记录下来() Sort(pStateInfo, nStateArrayCount);//按每个字的状态数(就是该字的延续字个数)排序 //然后把该轮(第i轮)的状况直接 int k; System.Console.Out.WriteLine(nStateArrayCount);//第i轮首字(即第i个字为首字,different)的个数 for (k = 0; k < nStateArrayCount; k++) //从下一状态较多的词数开赋值 { bSuccess = FindVal(pStateInfo[k]);//在这里面为m_Base赋值 if (pStateInfo[k].nNextStateCount > 0)//为什么要这样做,是为了以后清零 { pStateInfo[k].pNextID = null; pStateInfo[k].nNextStateCount = 0; } //System.Console.Out.WriteLine(k); } pStateInfo = null; for (int j = 0; j < SINGLE_WORD_INNERCODE + Utility.RESERVE_ITEMS; j++) { m_vCheck[j] = 0; } } } return bSuccess; }
//对状态数组排序 private void Sort(StateInfo[] pStateInfo, int nStateCount) { Array.Sort(pStateInfo,comp); //Array.Reverse(pStateInfo); }
// 确定base值和check值 /* * struct StateInfo { public int nStateSub; //当前状态的base和check数组下标,代表着一个字 public int nNextStateCount; //所有下一状态数 public int[] pNextID; //下一状态ID数组 } ; * */ //<summary> //FindVal函数是对当前状态sInfo找到其对应的base值,并为所有延续字的check附上这个base值 //</summary> private bool FindVal(StateInfo sInfo) { bool bFound = true; if (sInfo.nNextStateCount != 0) //后面还有字 sInfo.nNextStateCount是指当前状态下延续字的个数(不算重复字) { bFound = false; int i = 1;//这里i应该是当前状态的base值的candidate值 while (!bFound) { int k; //下面这个for循环是用来选i值的 for (k = 0; k < sInfo.nNextStateCount; k++)//如果是自动遍历完(中间没有停止),那么说明i值是ok的 { if (i + sInfo.pNextID[k] < SINGLE_WORD_INNERCODE + Utility.RESERVE_ITEMS)//说明sInfo.pNextID[k]合法 break;//i值需要改变 if (ConsidSize(i + sInfo.pNextID[k]))//确定m_vBase和m_vCheck和是否需要扩容 { if (i == sInfo.nStateSub)//如果i为当前的状态值,i值需要改变 break; if ((Convert.ToInt32(m_vBase[i + sInfo.pNextID[k]]) != 0) || (Convert.ToInt32(m_vCheck[i + sInfo.pNextID[k]]) != 0)) break;//意思是base和check有一个不为0(即该位置不空),i值(当前状态的base值)就得改变 } } //当i值使得所有m_vBase和m_vCheck均为0时,便可以取该i为当前state的base值,如果这个i值在没遍历完的情况下九跳出了上面的循环,说明该i值不行,得更换掉 if (k == sInfo.nNextStateCount) //找到i(也就是需要确定的当前的base值的candidate值),确定相应的base和check值 这里意思是把当前状态的所有延续字都遍历了 { if (!ConsidSize(sInfo.nStateSub))//如果当前状态超出了范围 m_vBase[sInfo.nStateSub] = i; else { int nbaseval = Convert.ToInt32(m_vBase[sInfo.nStateSub]); if (nbaseval < 0) //如果本身已经成词 m_vBase[sInfo.nStateSub] = (-1) * i;//这里貌似少了一种状态,就是如果本身已经成词,但是下面还可以有延续字怎么办 else m_vBase[sInfo.nStateSub] = i; } for (k = 0; k < sInfo.nNextStateCount; k++) //确定check值 { m_vCheck[i + sInfo.pNextID[k]] = sInfo.nStateSub;//因为m_vBase[sInfo.nStateSub]=i } bFound = true; } else i++; } } return bFound; }