public void Reset(ResetCause cause, ReadyCallback readyCallback) { if (!isResetting) { this.cause = cause; isResetting = true; animator.enabled = true; animator.SetTrigger("Open"); allReadyCallback = readyCallback; } }
public void Reset(ResetCause cause) { switch (cause) { case PLACED: //TODO maybe rotate TileToSpawn currentTile = GetRandomTile(); ApplySpriteFromMimickedTile(); break; } gameObject.SetActive(true); }
// Each response from the board includes a status field, which is handled here for most messages. // If an error is indicated in the status field, issues a query for the error code. // If a reset is indicated, issues a query for the reset code. // Only one query issues; command error takes precedence over reset, reset takes // precedence over global error. // Returns False if the rest of the response should be ignored, True otherwise. virtual internal bool OnStatus(Status stat) { ICommand query = null; if (stat.HasCommandError || (stat.HasGlobalError && !stat.HasBeenReset)) { query = new iCommand(_addr + GetError + DefaultChannel(), // Process the ER response's status: if HasCommandError, comm is not working: // so, return false to prevent the callback action from executing. (st) => { return(!st.HasCommandError); }, // Got an error response, raise any actual error in an event. (err) => { // TODO: global errors tend to be persistent; suppress raising them for every message if (err != 0) { ErrorReceived.Raise(this, new ErrEventArgs(TranslateError(err))); } }); } else if (stat.HasBeenReset) { // query the reset parameter to find out why, and to clear it query = new iCommand(_addr + ResetController + DefaultChannel(), (st) => { return(!st.HasCommandError); }, // Got a reset response, save the reported cause for later querying (cause) => { // Report reset as an error only if reset state is already known. // A reset flag present in first communications with device does not result in error. if (_reset_cause != ResetCause.UnknownResetState) { ErrorReceived.Raise(this, new ErrEventArgs(ErrorCode.ControllerReset)); } _reset_cause = ResetCause.IsDefined(typeof(ResetCause), cause) ? (ResetCause)cause : ResetCause.UnrecognizedReset; }); } // no error or reset, it's a good response; do a little housekeeping else if (_reset_cause == ResetCause.UnknownResetState) { _reset_cause = ResetCause.NoResetReported; // State is no longer unknown } if (query != null) { _board.Issue(query, true); // Issue query right away, in front of other messages in queue } return(!stat.HasCommandError); }
public void StartFading(ResetCause cause, ReadyCallback readyCallback) { if (config == null) { config = Configs.main.UI; } textList = new List <string>(); string text = DetermineText(cause); foreach (string line in text.Split('\n')) { textList.Add(line.Trim()); } StartFading(textList, readyCallback); }
private string DetermineText(ResetCause cause) { string text = ""; if (config) { if (cause == ResetCause.Death) { text = config.DeathResetText[Random.Range(0, config.DeathResetText.Count)]; } else if (cause == ResetCause.EnergyLoss) { text = config.EnergyLossRestText[Random.Range(0, config.EnergyLossRestText.Count)]; } } return(text); }
public void OpenResetDialog(ResetCause cause, ReadyCallback callback) { Time.timeScale = 0f; readyCallback = callback; loopResetDialog.Reset(cause, AfterReset); }