Exemple #1
0
    //Function called when the Yes button is clicked
    public void ClickYes()
    {//Disable the save menu
        cSaveMenu.enabled = false;
        //Create a new instance of a party object
        Party party = new Party();

        //Set the list in the party object to the player Party list
        party.ulUnits = ulPlayerParty;
        //Loop through the list
        foreach (Unit u in party.ulUnits)
        {//Reset health
            u.iHealth = u.iMaxHp;
            //Bring life to true
            u.bLife = true;
        }

        //string ppartyfile = EditorUtility.SaveFilePanel("Save File", Application.dataPath + "/GameData/VictoryParty", "Enter a filename here for your party", "xml");
        //Store the file path in this variable
        string ppartyfile = Application.dataPath + "/GameData/VictoryParty/WinningParty.xml";

        //Serialize the data
        File.Serialize(ppartyfile, party);
        //Enable the gameCanvas
        canvasScript.cGameCanvas.enabled = true;
        //Disable the battleCanvas
        canvasScript.cBattleCanvas.enabled = false;
        //Enable the SavedFilePrompt Canvas
        canvasScript.cSavedFilePrompt.enabled = true;
        //Feed the machine
        fsm.Feed("playertostart");
    }
Exemple #2
0
    //Save a game to an xml file
    public void SaveGame()
    {//Create a Party instance
        Party Players = new Party();
        //Create a Party instance
        Party Enemies = new Party();

        //Add playerParty to new Players Party units
        Players.ulUnits = game.ulPlayerParty;
        //Add enemyParty to new Enemies units
        Enemies.ulUnits = game.ulEnemyParty;

        //Open the file Path and store it in this variable
        string currentState = Application.dataPath + "/GameData/State/s.xml";

        //Serialize the data
        File.Serialize(currentState, game.fsm.sCurrentState.eName.ToString());

        //Open the file Path and store it in this variable
        string ppartyfile = Application.dataPath + "/GameData/PlayerParty/p.xml";

        //Serialize the data
        File.Serialize(ppartyfile, Players);

        //Open the file Path and store it in this variable
        string epartyfile = Application.dataPath + "/GameData/EnemyParty/e.xml";

        //Serialize the data
        File.Serialize(epartyfile, Enemies);

        //Open the file Path and store it in this variable
        string currentUnitIndex = Application.dataPath + "/GameData/index.xml";

        //Serialize the data
        File.Serialize(currentUnitIndex, game.iIndex);

        //Enable the game saved cCanvas
        cCanvas.enabled = true;
    }
Exemple #3
0
 //Function called when a key is pressed down while inside the text box
 private void saveFileName_KeyDown(object sender, KeyEventArgs e)
 {     //If the key pressed is th Enter key
     if (e.KeyCode == Keys.Enter)
     { //Create an instance of a new party object
         Party party = new Party();
         //Foreach unit in the BattleReadyParty list
         foreach (Unit i in BattleReadyParty)
         {     //If the current unit is of type Player
             if (i.sType == "Player")
             { //Add the current unit to the list of units in the party object
                 party.ulUnits.Add(i);
             }
         }
         //Serialize the party object and all of its data into a file with the passed in fileName
         _Save.Serialize(fileName, party);
         //Messagebox displays letting the user know the party was saved
         MessageBox.Show("Party Saved!");
         //Set the saveFileName text to "Enter Save File Name Here Then Press Enter:" for the user to see
         saveFileName.Text = "Enter Save File Name Here Then Press Enter:";
         //Set the box to not be visible
         saveFileName.Visible = false;
     }
 }
Exemple #4
0
        //Function activated when the Enemy1Button is clicked - Gives user option of attacking specific unit
        private void Enemy1Button_Click(object sender, EventArgs e)
        {//Set the current unit in the list into a Unit variable to simplify and make it easier to read
            Unit a = refer.u.ulParticipants[iIndex];

            //If the current enemy in the enemyParty is alive
            if (ulEnemyParty[0].bLife == true)
            {//The current unit will attack that enemy
                a.Attack(ulEnemyParty[0]);
                //Set the BattleText text to stufftext data
                BattleText.Text = a.sStuffText;
                //If the index is equal to the count variable
                if (iIndex == iCount)
                {//Set index to 0
                    iIndex = 0;
                }
                //If the index is not equal to the count variable
                else
                {//Increment the index by 1
                    iIndex += 1;
                }
            }
            //If the Checkforvictory function returns true
            if (refer.manager.CheckForVictory(ulPlayerParty, ulEnemyParty) == true)
            {//Set the BattleText text to the winText
                BattleText.Text += refer.manager.winText;
                //Create a new Party object
                Party party = new Party();
                //Set the units list in that party object to the playerParty list
                party.ulUnits = ulPlayerParty;
                //Loop through each unit in the party units list
                foreach (Unit u in party.ulUnits)
                {//Reset health
                    u.iHealth = u.iMaxHp;
                    //Bring life to true
                    u.bLife = true;
                }
                //Set the statsText to ""
                refer.manager.statsText = "";
                //Call this function to print out the Stats of the objects in battle
                refer.manager.StatsOfObjects(refer.u.ulParticipants);
                //Set the StatsBox text to the statsText
                StatsBox.Text = refer.manager.statsText;

                //Disable the Enemy1Button
                Enemy1Button.Enabled = false;
                //Disable the Enemy2Button
                Enemy2Button.Enabled = false;
                //Disable the Enemy3Button
                Enemy3Button.Enabled = false;
                //Set the CurrentStateBox text to the currentStates name
                CurrentStateBox.Text = refer.fsm.sCurrentState.eName.ToString();

                //Message box that prompts the user they have won and asked is they would like to save the current party
                DialogResult = MessageBox.Show("Would you like to save your current party?\n", "You Win!", MessageBoxButtons.YesNo);
                //If yes is clicked
                if (DialogResult == DialogResult.Yes)
                {//Serialize the party object to a file called "Party"
                    _Save.Serialize("Party", party);

                    //Message box prompts user that the Game has been saved
                    MessageBox.Show("Game Has Been Saved!", "Save", MessageBoxButtons.OK);
                }
                //Set isDone variable to true
                bIsDone = true;
                //Changes state to start
                refer.fsm.Feed("start");
            }
            //If isDone is equal to false
            if (bIsDone == false)
            {//Call the process turn function
                processTurn(iIndex);
            }
        }