public static void populateTable() { probabilities[new PrecStates("Idle", "Walk")] = new NextState[] { new NextState("Idle", 0.5f), new NextState("Walk", 0.3f), new NextState("Meow", 0.1f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Idle", "Idle")] = new NextState[] { new NextState("Idle", 0.3f), new NextState("Walk", 0.5f), new NextState("Meow", 0.0f), new NextState("Ithcing", 0.2f) }; probabilities[new PrecStates("Idle", "Meow")] = new NextState[] { new NextState("Idle", 0.6f), new NextState("Walk", 0.3f), new NextState("Meow", 0.0f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Idle", "Ithcing")] = new NextState[] { new NextState("Idle", 0.5f), new NextState("Walk", 0.25f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.05f) }; probabilities[new PrecStates("Walk", "Walk")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.4f), new NextState("Meow", 0.1f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Walk", "Idle")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.3f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Walk", "Meow")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.5f), new NextState("Meow", 0.0f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Walk", "Ithcing")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.3f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Meow", "Walk")] = new NextState[] { new NextState("Idle", 0.7f), new NextState("Walk", 0.1f), new NextState("Meow", 0.1f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Meow", "Idle")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.3f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Meow", "Meow")] = new NextState[] { new NextState("Idle", 0.8f), new NextState("Walk", 0.1f), new NextState("Meow", 0.0f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Meow", "Ithcing")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.3f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Ithcing", "Walk")] = new NextState[] { new NextState("Idle", 0.7f), new NextState("Walk", 0.1f), new NextState("Meow", 0.1f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Ithcing", "Idle")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.3f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Ithcing", "Meow")] = new NextState[] { new NextState("Idle", 0.8f), new NextState("Walk", 0.1f), new NextState("Meow", 0.0f), new NextState("Ithcing", 0.1f) }; probabilities[new PrecStates("Ithcing", "Ithcing")] = new NextState[] { new NextState("Idle", 0.4f), new NextState("Walk", 0.3f), new NextState("Meow", 0.2f), new NextState("Ithcing", 0.1f) }; }
//--------------------------------------------------------------------- /// <summary> /// Draws the current GameState. /// </summary> /// <param name="_time"></param> public override void Draw(Microsoft.Xna.Framework.GameTime _time) { if (mbExit) { CurrentState.DrawFadeOut(); } else if (NextState != null) { if (CurrentState != null) { CurrentState.DrawFadeOut(); } else { NextState.DrawFadeIn(); } } else { CurrentState.Draw(); } }
public int CompareTo(Transition other) { if (other == null) { return(1); } int result = CurrentState.CompareTo(other.CurrentState); if (result != 0) { return(result); } result = Symbol.CompareTo(other.Symbol); if (result != 0) { return(result); } return(NextState.CompareTo(other.NextState)); }
private void GameStarter_GameStarterCompleted(object sender, GameStarterCompletedEventArgs e) { if (e.Cancelled) { Logger.Debug($"{sender.ToString()} cancelled."); } else if (e.Error != null) { Logger.Error(e.Error); MsgBox.Error(e.Error.Message); } else if (e.NeedsForcePatch) { MsgBox.Notice(StringLoader.GetText("notice_outdated_translation")); ResetTranslation(e.Language); this.CurrentState = State.RTPatch; this._nextState = NextState.Download; this.RTPatcher.Run(e.Language); return; } else { Logger.Debug($"{sender.ToString()} successfuly completed"); this.RestoreFromTray(); } try { RestoreBackup(e.Language); } finally { this.CurrentState = State.Idle; } }
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj) { context.RemoveAllBookmarks(); NextState.Set(context, nextState); NextWorkFlow.Set(context, nextWorkFlow); }
public void Write(NextState nextState) { Write(new VarInt((int)nextState)); }
public void ButtonNo() { _nextState = NextState.Resume; Time.timeScale = 1f; StartTimer(); }
private void Update() { // GUI input if (Input.GetButtonDown("Cancel") && _gameState != GameState.Menu) { if (_timer > 0f) { // Complete any ongoing transitions ChooseAction(); _timer = Time.deltaTime; } StartTimer(); if (_gameState == GameState.Playing) { // Queues up for pause menu transition Time.timeScale = 0f; _gameState = GameState.Paused; _gameManager.Pause(); _nextState = NextState.PauseMenu; } else if (_gameState == GameState.Paused) { // Resumes game Time.timeScale = 1f; _nextState = NextState.Resume; } } // Transition timer handling if (_timer > 0f) { // Transition functionalities switch (_nextState) { // If starting game, fade out main menu background case NextState.Start: { pnl_MM.GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f - _timer / _transitionDuration); break; } // If pausing game, fade in pause menu (for now, just instantly pop up) case NextState.PauseMenu: { pnl_PM.SetActive(true); pnl_PM.GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f); break; } // If resuming game, fade out pause menu case NextState.Resume: { pnl_PM.SetActive(true); pnl_PM.GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f - _timer / _transitionDuration); break; } } _timer += Time.deltaTime; if (_timer >= _transitionDuration) { _timer = 0f; ChooseAction(); } } }
/// <summary> /// Returns a string representation of a <see cref="Transition"/> /// </summary> /// <returns>A human-readable representation of the <see cref="Transition"/></returns> public string ToString() { return "(" + NextState.ToString() + ", " + Direction.ToString() + ", " + WriteSymbol.ToString() + ")"; }
public void ButtonQuit() { _nextState = NextState.QuitToDesktop; Time.timeScale = 1f; _timer = _transitionDuration - Time.deltaTime; }
public override void PlayDomino() { nextState = NextState.Draw; }
private void OpenExistingButton_Click(object sender, RoutedEventArgs e) { Next = NextState.Open; this.Close(); }
private void RTPatcher_Completed(object sender, RTPatcherCompletedEventArgs e) { if (e.Cancelled) { Logger.Debug($"{sender.ToString()} cancelled"); } else if (e.Error != null) { if (e.Error is ResultException ex) { string logFileName = Path.GetFileName(ex.LogPath); switch (ex.Result) { case 4: Logger.Error(ex.Message); MsgBox.Error(StringLoader.GetText("exception_rtpatch_not_exist_directory")); break; case 7: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_error_open_patch_file")); break; case 9: Logger.Error($"error=[{ex.Message}] file=[{Path.Combine(UserSettings.GamePath, ex.FileName)}] version=[{ex.ClientVersion}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_corrupt", $"{Path.Combine(UserSettings.GamePath, ex.FileName)}@Version=[{ex.ClientVersion}]")); break; case 15: Logger.Error($"error=[{ex.Message}] file=[{Path.Combine(UserSettings.GamePath, ex.FileName)}] version=[{ex.ClientVersion}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_missing_file", $"{Path.Combine(UserSettings.GamePath, ex.FileName)}@Version=[{ex.ClientVersion}]")); break; case 18: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_open_patch_file_fail")); break; case 20: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_read_patch_file_fail")); break; case 22: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_rename_fail")); break; case 29: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_insufficient_storage")); break; case 32: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_time_date_fail")); break; case 36: Logger.Error($"error=[{ex.Message}] file=[{Path.Combine(UserSettings.GamePath, ex.FileName)}] version=[{ex.ClientVersion}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_corrupt_file", $"{Path.Combine(UserSettings.GamePath, ex.FileName)}@Version=[{ex.ClientVersion}]")); break; case 49: Logger.Error($"error=[{ex.Message}]@Version=[{ex.ClientVersion.ToString()}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_administrator_required")); break; default: #if !DEBUG string logFileText = File.ReadAllText(ex.LogPath); try { UploadToPasteBin(logFileName, logFileText, PasteBinExpiration.OneWeek, true, "text"); } catch (PasteBinApiException) { } Logger.Error($"See {logFileName} for details. Error Code=[{ex.Result}]"); MsgBox.Error(StringLoader.GetText("exception_rtpatch_result", ex.Result, logFileName)); #endif break; } Methods.RTPatchCleanup(true); } else { Methods.RTPatchCleanup(false); Logger.Error(e.Error); MsgBox.Error(Methods.ExeptionParser(e.Error)); } } else { Methods.RTPatchCleanup(true); Logger.Debug($"{sender.ToString()} successfuly completed"); switch (this._nextState) { case NextState.Download: this.CurrentState = State.Download; this.Downloader.Run(e.Language); break; case NextState.Play: this.GameStarter.Run(e.Language, true); break; case NextState.PlayRaw: this.GameStarter.Run(e.Language, false); break; } this._nextState = 0; return; } this.CurrentState = State.Idle; }
public override int GetHashCode() { return(CurrentState.GetHashCode() ^ NextState.GetHashCode() ^ Symbol.GetHashCode()); }
private void Update() { switch (nextState) { case NextState.Wait: return; case NextState.Draw: if (history.horizontalDominoes.Count > 0) { placesToPlay = PlacesToPlay(); if (placesToPlay.Count == 0) { base.DrawDomino(); placesToPlay = PlacesToPlay(); if (placesToPlay.Count == 0) { nextState = NextState.Wait; gameController.PlayerIsBlocked(this); return; } } } nextState = NextState.Play; break; case NextState.Play: List <ChosenWayToPlay> waysToPlay = new List <ChosenWayToPlay>(); if (history.horizontalDominoes.Count == 0) { foreach (DominoController domino in dominoControllers) { waysToPlay.Add(new ChosenWayToPlay(domino, null)); } } else { foreach (KeyValuePair <DominoController, List <DominoController> > entry in placesToPlay) { List <DominoController> list = entry.Value; foreach (DominoController chosenPlace in list) { ChosenWayToPlay chosenWayToPlay = new ChosenWayToPlay(entry.Key, chosenPlace); waysToPlay.Add(chosenWayToPlay); } } } // From small to large waysToPlay.Sort(delegate(ChosenWayToPlay x, ChosenWayToPlay y) { int xScore = GetScoreOfChosenWay(x); int yScore = GetScoreOfChosenWay(y); return(xScore - yScore); }); ChosenWayToPlay bestWayToPlay = waysToPlay[waysToPlay.Count - 1]; PlaceDomino(bestWayToPlay.chosenDomino, bestWayToPlay.chosenPlace, history); dominoControllers.Remove(bestWayToPlay.chosenDomino); // Debug Debug.Log("Chosen Domino: " + bestWayToPlay.chosenDomino.leftValue + ", " + bestWayToPlay.chosenDomino.rightValue + ", " + bestWayToPlay.chosenDomino.upperValue + ", " + bestWayToPlay.chosenDomino.lowerValue); if (bestWayToPlay.chosenPlace != null) { Debug.Log("Chosen Place: " + bestWayToPlay.chosenPlace.leftValue + ", " + bestWayToPlay.chosenPlace.rightValue + ", " + bestWayToPlay.chosenPlace.upperValue + ", " + bestWayToPlay.chosenPlace.lowerValue); } Debug.Log(Environment.StackTrace); nextState = NextState.Wait; gameController.PlayerPlayDomino(this, bestWayToPlay.chosenDomino, bestWayToPlay.chosenPlace); break; } }
//--------------------------------------------------------------------- /// <summary> /// Updates the current GameState. /// </summary> /// <param name="_time">Provides a snapshot of timing values.</param> public override void Update(Microsoft.Xna.Framework.GameTime _time) { float _fElapsedTime = (float)_time.ElapsedGameTime.TotalSeconds; if (mbExit) { //--------------------------------------------------------- // Fade out current state if (CurrentState.UpdateFadeOut(_fElapsedTime)) { // We're done CurrentState.Stop(); Game.Exit(); } } //----------------------------------------------------------------- // Handle state switching else if (NextState != null) { if (CurrentState != null) { //--------------------------------------------------------- // Fade out current state if (CurrentState.UpdateFadeOut(_fElapsedTime)) { // We're done fading out CurrentState.Stop(); CurrentState = null; // Reset all vibrations when switching active GameState GamePad.SetVibration(PlayerIndex.One, 0f, 0f); GamePad.SetVibration(PlayerIndex.Two, 0f, 0f); GamePad.SetVibration(PlayerIndex.Three, 0f, 0f); GamePad.SetVibration(PlayerIndex.Four, 0f, 0f); NextState.Start(); } } if (CurrentState == null) { //--------------------------------------------------------- // Fade in next state if (NextState.UpdateFadeIn(_fElapsedTime)) { // We're done fading in CurrentState = NextState; NextState = null; CurrentState.Update(_fElapsedTime); } } } //----------------------------------------------------------------- // Update current GameState else { CurrentState.Update(_fElapsedTime); } }
public override string ToString() { return(CurrentState.ToString() + Symbol.ToString() + NextState.ToString()); }
public State GetStateByName(string stateName) { // if ( stateName.Equals(Global.NOW_STATE)) // { // return GetStateByName(machine.GetTempState().GetName()); // } DataRow row = machine.GetMainRow(stateName); State state; if ( isFull(row,Global.TRANS_TO_COLUMN_NAME) ) { state = new TransformState(); state.Init(row, stateName , machine); return state; } else if ( isFull(row,Global.AUTO_NEXT_COLUMN_NAME)) { if ( isFull(row,Global.DELAY_TIME_COLUMN_NAME) ) { state = new NextTimeState(); state.Init(row, stateName , machine); return state; }else { state = new NextState(); state.Init(row,stateName,machine); return state; } } state = new State(); state.Init(row, stateName , machine); return state; }
new Command(NextState, NextCharacter, Direction, CommandString) );
private void Update() { switch (nextState) { case NextState.Wait: return; case NextState.Draw: if (history.horizontalDominoes.Count > 0) { placesToPlay = PlacesToPlay(); if (placesToPlay.Count == 0) { base.DrawDomino(); placesToPlay = PlacesToPlay(); if (placesToPlay.Count == 0) { nextState = NextState.Wait; gameController.PlayerIsBlocked(this); return; } } } nextState = NextState.Play; break; case NextState.Play: List <ChosenWayToPlay> waysToPlay = new List <ChosenWayToPlay>(); if (history.horizontalDominoes.Count == 0) { foreach (DominoController domino in dominoControllers) { waysToPlay.Add(new ChosenWayToPlay(domino, null)); } } else { foreach (KeyValuePair <DominoController, List <DominoController> > entry in placesToPlay) { List <DominoController> list = entry.Value; foreach (DominoController chosenPlace in list) { ChosenWayToPlay chosenWayToPlay = new ChosenWayToPlay(entry.Key, chosenPlace); waysToPlay.Add(chosenWayToPlay); } } } int historyDominoesNum = history.horizontalDominoes.Count + history.verticalDominoes.Count - (history.spinner == null ? 0 : 1); GameStatusModel gameStatus = GetGameStatus(); // From small to large waysToPlay.Sort(delegate(ChosenWayToPlay x, ChosenWayToPlay y) { if (historyDominoesNum <= 18) { int xScore = GetScoreOfChosenWay(x); int yScore = GetScoreOfChosenWay(y); return(xScore - yScore); } ChosenWayToPlayModel xModel = new ChosenWayToPlayModel(Utility.DominoControllerToDominoModel(x.chosenDomino), Utility.DominoControllerToDominoModel(x.chosenPlace)); PlayActionModel xPlayActionModel = new PlayActionModel(gameStatus, xModel); WinLoseStatusModel xWinLoseStatus; if (winLoseDict.ContainsKey(xPlayActionModel)) { xWinLoseStatus = winLoseDict[xPlayActionModel]; } else { xWinLoseStatus = new WinLoseStatusModel(); xWinLoseStatus.wins = 1; xWinLoseStatus.loses = 1; } double xWinRate = (double)xWinLoseStatus.wins / (xWinLoseStatus.wins + xWinLoseStatus.loses); ChosenWayToPlayModel yModel = new ChosenWayToPlayModel(Utility.DominoControllerToDominoModel(y.chosenDomino), Utility.DominoControllerToDominoModel(y.chosenPlace)); PlayActionModel yPlayActionModel = new PlayActionModel(gameStatus, yModel); WinLoseStatusModel yWinLoseStatus; if (winLoseDict.ContainsKey(yPlayActionModel)) { yWinLoseStatus = winLoseDict[xPlayActionModel]; } else { yWinLoseStatus = new WinLoseStatusModel(); yWinLoseStatus.wins = 1; yWinLoseStatus.loses = 1; } double yWinRate = (double)yWinLoseStatus.wins / (yWinLoseStatus.wins + yWinLoseStatus.loses); if (xWinRate < yWinRate) { return(-1); } else if (xWinRate == yWinRate) { return(0); } return(1); }); ChosenWayToPlay bestWayToPlay = waysToPlay[waysToPlay.Count - 1]; PlaceDomino(bestWayToPlay.chosenDomino, bestWayToPlay.chosenPlace, history); dominoControllers.Remove(bestWayToPlay.chosenDomino); if (historyDominoesNum > 18) { ChosenWayToPlayModel bestPlayModel = new ChosenWayToPlayModel(Utility.DominoControllerToDominoModel(bestWayToPlay.chosenDomino), Utility.DominoControllerToDominoModel(bestWayToPlay.chosenPlace)); PlayActionModel bestPlayActionModel = new PlayActionModel(gameStatus, bestPlayModel); if (winLoseDict.ContainsKey(bestPlayActionModel)) { winLoseStatusList.Add(winLoseDict[bestPlayActionModel]); } else { WinLoseStatusModel winLoseStatus = new WinLoseStatusModel(); winLoseStatus.wins = 1; winLoseStatus.loses = 1; winLoseDict.Add(bestPlayActionModel, winLoseStatus); winLoseStatusList.Add(winLoseStatus); } } // Debug Debug.Log("Chosen Domino: " + bestWayToPlay.chosenDomino.leftValue + ", " + bestWayToPlay.chosenDomino.rightValue + ", " + bestWayToPlay.chosenDomino.upperValue + ", " + bestWayToPlay.chosenDomino.lowerValue); if (bestWayToPlay.chosenPlace != null) { Debug.Log("Chosen Place: " + bestWayToPlay.chosenPlace.leftValue + ", " + bestWayToPlay.chosenPlace.rightValue + ", " + bestWayToPlay.chosenPlace.upperValue + ", " + bestWayToPlay.chosenPlace.lowerValue); } Debug.Log(Environment.StackTrace); nextState = NextState.Wait; gameController.PlayerPlayDomino(this, bestWayToPlay.chosenDomino, bestWayToPlay.chosenPlace); break; } }
public override string ToString() { return(Type.ToString() + " [" + Vertical.ToString() + ", " + Horizontal.ToString() + "] " + NextState.ToString()); }
private void SetNewButton_Click(object sender, RoutedEventArgs e) { Next = NextState.New; this.Close(); }
public override int GetHashCode() { //tratativa para valores nullos, usa o max value return(PreviousState?.GetHashCode() ?? 1 >> NextState?.GetHashCode() ?? 1); }