Ejemplo n.º 1
0
        private void LoadData_Click(object sender, EventArgs e)
        {
            int NewAttack;
            int NewDefense;

            //Loads the saved information for currentHero, currentItem, and currentArmor
            if (Singleton.Instance.currentHero != null)
            {
                Singleton.Instance.currentHero = AssessmentSerialization <Players> .Deserialize("CurrentPlayer"); //If there is no Player chosen, the program will not break

                PlayerSelection.SelectedItem = Singleton.Instance.currentHero.Name;                               //Makes the comboBox currentHero equal the saved currentHero
            }
            if (Singleton.Instance.currentItem != null)
            {
                Singleton.Instance.currentItem = AssessmentSerialization <Items> .Deserialize("CurrentItem");   //If there is no Item chosen, the program will not break

                ItemSelection.SelectedItem = Singleton.Instance.currentItem.Name;                               //Makes the comboBox currentItem equal the saved currentItem
                NewAttack      = Singleton.Instance.currentHero.Attack + Singleton.Instance.currentItem.Attack; //When Loaded, it automatically fixes the combined attack
                ItemCombo.Text = NewAttack.ToString();
            }
            if (Singleton.Instance.currentArmor != null)
            {
                Singleton.Instance.currentArmor = AssessmentSerialization <Armor> .Deserialize("CurrentArmor");     //If there is no Armor chosen, the program will not break

                ArmorSelection.SelectedItem = Singleton.Instance.currentArmor.Name;                                 //Makes the comboBox currentArmor equal the saved currentArmor
                NewDefense      = Singleton.Instance.currentHero.Defense + Singleton.Instance.currentArmor.Defense; //When Loaded, it automatically fixes the combined defense
                ArmorCombo.Text = NewDefense.ToString();
            }
            SaveLoad.AppendText("                    Loaded");
        }
Ejemplo n.º 2
0
        private void ItemSelections(object sender, EventArgs e)
        {
            int NewAttack;

            //When you click an Item in the comboBox, it becomes the currentItem and it's values
            foreach (Items item in Singleton.Instance.mItems)
            {
                if (ItemSelection.SelectedItem.Equals(item.Name))
                {
                    Singleton.Instance.currentItem = item;
                    break;
                }
            }
            if (PlayerSelection.SelectedValue != null)
            {
                //This adds the Players attack and item's value together to get a new attack
                NewAttack      = Singleton.Instance.currentHero.Attack + Singleton.Instance.currentItem.Attack;
                ItemCombo.Text = NewAttack.ToString();
            }
        }
Ejemplo n.º 3
0
        private void UpdateD_Click(object sender, EventArgs e)
        {
            //This was made to update the data whenever you choose a new Player, it updates the attack and defense after clicking the new Player
            int NewAttack;
            int NewDefense;

            if (Singleton.Instance.currentHero != null)//If there is no Player chosen, the program will not break
            {
                PlayerAttack.Text  = Singleton.Instance.currentHero.Attack.ToString();
                PlayerDefense.Text = Singleton.Instance.currentHero.Defense.ToString();
            }
            if (Singleton.Instance.currentItem != null)//If there is no Item chosen, the program will not break
            {
                NewAttack      = Singleton.Instance.currentHero.Attack + Singleton.Instance.currentItem.Attack;
                ItemCombo.Text = NewAttack.ToString();
            }
            if (Singleton.Instance.currentArmor != null)//If there is no Armor chosen, the program will not break
            {
                NewDefense      = Singleton.Instance.currentHero.Defense + Singleton.Instance.currentArmor.Defense;
                ArmorCombo.Text = NewDefense.ToString();
            }
        }