/// <summary> /// Function that runs a case statement to run a function depending on state /// </summary> private void StateFunctions() { switch (gm.GenFSM.CurrentState.ToUpper()) { case "INIT": HelpText(); gm.turnManager.ToStartUp(); gm.GenFSM.CurrentState = "idle"; break; case "IDLE": gm.turnManager.ToIdle(); gm.GenFSM.CurrentState = "turn"; break; case "TURN": gm.turnManager.ToChoosePlayer(); gm.GenFSM.CurrentState = "atk"; break; case "ATK": gm.turnManager.ToCombat(); gm.GenFSM.CurrentState = "endturn"; break; case "ENDTURN": gm.turnManager.ToEndTurn(); gm.GenFSM.CurrentState = "idle"; break; } TextLog.SelectionStart = TextLog.Text.Length; TextLog.ScrollToCaret(); }
private void AddLog(string msg) { Invoke(new Action(() => { TextLog.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "]" + msg); TextLog.AppendText(Environment.NewLine); TextLog.ScrollToCaret(); })); }
private void ftpc_FTPCommand(object sender, FTPCom.FTPEventArgs e) { TextLog.SelectionColor = Color.Blue; if (e.Message != string.Empty) { TextLog.AppendText(e.Message); } TextLog.AppendText("\n"); TextLog.SelectionStart = TextLog.TextLength; TextLog.ScrollToCaret(); }
/// <summary> /// Saves needed data into an xml format /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveButton_Click(object sender, EventArgs e) { //Saves information on an xml file to be read later to be loaded Debug.WriteLine("Saving current progress..."); DataManager <Player> .Serialize("CurrentPlayer", gm.CurrentPlayer); DataManager <Player> .Serialize("CurrentEnemy", gm.CurrentEnemy); DataManager <int> .Serialize("PotionUse", potionlimit); DataManager <string> .Serialize("TextLog", TextLog.Text); TextLog.SelectionStart = TextLog.Text.Length; TextLog.ScrollToCaret(); }
//Other buttons /// <summary> /// Loads data from saved xml document /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadButton_Click(object sender, EventArgs e) { Debug.WriteLine("Loading previous save..."); //Reloads how many potions have been used and reallows the ability to attack potionlimit = DataManager <int> .Deserialize("PotionUse"); gm.CurrentPlayer = DataManager <Player> .Deserialize("CurrentPlayer"); gm.CurrentEnemy = DataManager <Player> .Deserialize("CurrentEnemy"); EnableButtons(); UpdateUI(); TextLog.AppendText("Previous Save Loaded... \n"); Debug.WriteLine("Previous Save Loaded"); TextLog.SelectionStart = TextLog.Text.Length; TextLog.ScrollToCaret(); }
public void WriteLog(object sender, LogEventArgs e) { if (!ServerRunning) { return; } if (TextLog.InvokeRequired) { var d = new DelegateWriteLog(WriteLog); TextLog.Invoke(d, sender, e); } else { TextLog.SelectionStart = TextLog.TextLength; TextLog.SelectionLength = 0; TextLog.SelectionColor = e.Color; TextLog.AppendText($"{DateTime.Now}: {e.Text}{Environment.NewLine}"); TextLog.ScrollToCaret(); } }
/// <summary> /// Runs a check and if all players or enemies are dead, /// will end the game /// </summary> public void Endlog() { if (gm.turnManager.CheckWin() == true) { AtkButton.Enabled = false; PotionButton.Enabled = false; PassTurn.Enabled = false; if (gm.CurrentPlayer.IsDead) { UpdateLog("Mission Failed. We'll get'em next time..."); UpdateLog("Load a previous save or start over by pressing reset"); } if (gm.CurrentEnemy.IsDead) { UpdateLog("Congratulations!"); UpdateLog("You defeated the Brightest Dungeon! Please play again."); } } TextLog.SelectionStart = TextLog.Text.Length; TextLog.ScrollToCaret(); }
private void TextLog_TextChanged(object sender, EventArgs e) { TextLog.SelectionStart = TextLog.Text.Length; TextLog.ScrollToCaret(); }