예제 #1
0
        /// <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();
        }
예제 #2
0
 private void AddLog(string msg)
 {
     Invoke(new Action(() =>
     {
         TextLog.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "]" + msg);
         TextLog.AppendText(Environment.NewLine);
         TextLog.ScrollToCaret();
     }));
 }
예제 #3
0
파일: Main.cs 프로젝트: Br3nda/sfdocsamples
 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();
 }
예제 #4
0
        /// <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();
        }
예제 #5
0
        //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();
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
 /// <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();
 }
예제 #8
0
 private void TextLog_TextChanged(object sender, EventArgs e)
 {
     TextLog.SelectionStart = TextLog.Text.Length;
     TextLog.ScrollToCaret();
 }