コード例 #1
0
ファイル: FormDetails.cs プロジェクト: AlanWills/Mythology
        public static void ReadItemData()
        {
            ItemDataManager = new ItemDataManager();

            string[] fileNames = Directory.GetFiles(Path.Combine(FormMain.itemPath, "Armour"), "*.xml");

            foreach (string s in fileNames)
            {
                ArmourData armourData = XNASerializer.Deserialize <ArmourData>(s);
                ItemDataManager.ArmourData.Add(armourData.Name, armourData);
            }

            fileNames = Directory.GetFiles(Path.Combine(FormMain.itemPath, "Shield"), "*.xml");

            foreach (string s in fileNames)
            {
                ShieldData shieldData = XNASerializer.Deserialize <ShieldData>(s);
                ItemDataManager.ShieldData.Add(shieldData.Name, shieldData);
            }

            fileNames = Directory.GetFiles(Path.Combine(FormMain.itemPath, "Weapon"), "*.xml");

            foreach (string s in fileNames)
            {
                WeaponData weaponData = XNASerializer.Deserialize <WeaponData>(s);
                ItemDataManager.WeaponData.Add(weaponData.Name, weaponData);
            }
        }
コード例 #2
0
 public static void ReadArmorData(ContentManager Content)
 {
     string[] filenames = Directory.GetFiles(@"Content\Game\Items\Armour", "*.xnb");
     foreach (string name in filenames)
     {
         string     filename = @"Game\Items\Armour\" + Path.GetFileNameWithoutExtension(name);
         ArmourData data     = Content.Load <ArmourData>(filename);
         ArmourData.Add(data.Name, data);
     }
 }
コード例 #3
0
    public void DealArmour(Transform spawnTransform, ArmourData data, List <GameObject> objectList) //Deals hero cards at start of game
    {
        ArmourData card     = Instantiate(data);                                                    //instantiates instance of scriptable object
        ArmourCard tempCard = Instantiate(armourCardTemplate);                                      //instantiates an instance of the card prefab

        tempCard.transform.SetParent(spawnTransform, false);                                        //moves card onto board
        tempCard.armourData = card;                                                                 //assigns the instance of the scriptable object to the instance of the prefab
        equippedArmourObj.Add(tempCard.gameObject);                                                 //adds card to live list
        currentArmour = equippedArmourObj[0].GetComponent <ArmourCard>();
    }
コード例 #4
0
    public void DealArmour(Transform armourTransform, List <GameObject> armourObjectList, ArmourData armour) //Deals one card
    {
        ArmourData card     = Instantiate(armour);                                                           //instantiates instance of scriptable object
        ArmourCard tempCard = Instantiate(armourCardTemplate);                                               //instantiates an instance of the card prefab

        tempCard.transform.SetParent(armourInvTransform.transform, false);                                   //moves card onto board
        tempCard.armourData = card;                                                                          //assigns the instance of the scriptable object to the instance of the prefab
        invArmour.Add(tempCard.gameObject);                                                                  //adds card to live list
        tempCard.equipButton.SetActive(true);                                                                //enables the button
        tempCard.name = tempCard.armourData.name.Replace("(Clone)", "").ToString();
    }
コード例 #5
0
    public static void saveArmour(armourStorageList armourList)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/armour.data";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ArmourData armourData = new ArmourData(armourList);

        formatter.Serialize(stream, armourData);
        stream.Close();
    }
コード例 #6
0
    // Start is called before the first frame update
    void Start()
    {
        alertBox.SetActive(false);

        //get the data of what armour the person has
        ArmourData data = SaveSystem.loadArmour();

        if (data != null)
        {
            armourList.playerArmour = data.playerArmour;
        }
    }
コード例 #7
0
    private void StatsArmourInit(ArmourData id)
    {
        baseStats[0].Init(id.resistance.Title, id.resistance.value);
        baseStats[1].Init(id.magicResist.Title, id.magicResist.value);
        baseStats[2].Init(id.weight.Title, id.weight.value);
        baseStats[3].Init(id.quality.Title, id.quality.value);
        ApplyAffinityData(id.affinities.GetAffinities());

        actionButtons[0].Init("Equip", InventoryManager.Instance.ChangeWeapon, ActiveItem, ActionType.Equip);
        actionButtons[1].Init("Discard", InventoryManager.Instance.DiscardItem, ActiveItem, ActionType.Discard);
        actionButtons[2].Hide();
        actionButtons[3].Hide();
    }
コード例 #8
0
        void btnOK_Click(object sender, EventArgs e)
        {
            int   price, defVal, defMod;
            float weight;

            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show("You must enter a name for the item.");
                return;
            }

            if (!int.TryParse(mtbPrice.Text, out price))
            {
                MessageBox.Show("Price must be an integer value.");
                return;
            }

            weight = (float)nudWeight.Value;

            if (!int.TryParse(mtbDefenceValue.Text, out defVal))
            {
                MessageBox.Show("Defence value must be an integer value.");
                return;
            }

            if (!int.TryParse(mtbDefenceModifier.Text, out defMod))
            {
                MessageBox.Show("Defence value must be an integer value.");
                return;
            }

            List <string> allowedClasses = new List <string>();

            foreach (object o in lbAllowedClasses.Items)
            {
                allowedClasses.Add(o.ToString());
            }

            Armour                  = new ArmourData();
            Armour.Name             = tbName.Text;
            Armour.Type             = tbType.Text;
            Armour.Price            = price;
            Armour.Weight           = weight;
            Armour.ArmourLocation   = (ArmourLocation)cboArmourLocation.SelectedIndex;
            Armour.DefenceValue     = defVal;
            Armour.DefenceModifier  = defMod;
            Armour.AllowableClasses = allowedClasses.ToArray();

            this.FormClosing -= FormArmourDetails_FormClosing;
            this.Close();
        }
コード例 #9
0
ファイル: FormArmour.cs プロジェクト: AlanWills/Mythology
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string   detail = lbDetails.SelectedItem.ToString();
                string[] parts  = detail.Split(',');
                string   entity = parts[0].Trim();

                ArmourData data    = ItemDataManager.ArmourData[entity];
                ArmourData newData = null;

                using (FormArmourDetails formArmourDetails = new FormArmourDetails())
                {
                    formArmourDetails.Armour = data;
                    formArmourDetails.ShowDialog();

                    if (formArmourDetails.Armour == null)
                    {
                        return;
                    }

                    if (formArmourDetails.Armour.Name == entity)
                    {
                        ItemDataManager.ArmourData[entity] = formArmourDetails.Armour;
                        FillListBox();
                        return;
                    }

                    newData = formArmourDetails.Armour;
                }

                DialogResult result = MessageBox.Show(
                    "Name has changed.  Do you want to add a new entry?",
                    "New Entry",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }

                if (ItemDataManager.ArmourData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists.  Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                ItemDataManager.ArmourData.Add(newData.Name, newData);
            }
        }
コード例 #10
0
    public static ArmourData loadArmour()
    {
        string path = Application.persistentDataPath + "/armour.data";

        if (File.Exists(path))
        {
            BinaryFormatter formatter  = new BinaryFormatter();
            FileStream      stream     = new FileStream(path, FileMode.Open);
            ArmourData      armourList = formatter.Deserialize(stream) as ArmourData;
            stream.Close();

            return(armourList);
        }
        else
        {
            FileStream stream = new FileStream(path, FileMode.Create);
            stream.Close();
            Debug.LogError("No save file found at " + path);
            return(null);
        }
    }
コード例 #11
0
ファイル: FormArmour.cs プロジェクト: AlanWills/Mythology
        private void AddArmour(ArmourData armourData)
        {
            if (FormDetails.ItemDataManager.ArmourData.ContainsKey(armourData.Name))
            {
                DialogResult result = MessageBox.Show(
                    armourData.Name + " already exists. Overwrite it?",
                    "Existing Armour",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }

                ItemDataManager.ArmourData[armourData.Name] = armourData;
                FillListBox();
                return;
            }
            ItemDataManager.ArmourData.Add(armourData.Name, armourData);
            lbDetails.Items.Add(armourData);
        }
コード例 #12
0
    public void DealArmourLoot(Transform spawnTransform, List <ArmourData> dataList, List <GameObject> objectList) //Deals one weapon card
    {
        if (dataList.Count > 0)
        {
            int rng = UnityEngine.Random.Range(0, dataList.Count); //randomly select a card
            armourTopDeck = dataList[rng];
        }
        else
        {
            armourTopDeck = null;
        }
        ArmourData card     = Instantiate(armourTopDeck);      //instantiates instance of scriptable object
        ArmourCard tempCard = Instantiate(armourCardTemplate); //instantiates an instance of the card prefab

        tempCard.transform.SetParent(spawnTransform, false);   //moves card onto board
        tempCard.armourData = card;                            //assigns the instance of the scriptable object to the instance of the prefab
        armourLoot1.Remove(armourTopDeck);                     //removes from list
        objectList.Add(tempCard.gameObject);                   //adds card to list
        tempCard.equipButton.SetActive(true);                  //enables button
        tempCard.name = tempCard.armourData.name.Replace("(Clone)", "").ToString();
    }
コード例 #13
0
    // Start is called before the first frame update
    void Start()
    {
        //show what current armour level is
        GameObject playerArmour = GameObject.Find("PlayerArmour");

        if (playerArmour == null)
        {
        }

        else
        {
            playerArmour playerArmourScript = playerArmour.GetComponent <playerArmour>();

            //display level is + 1 compared to level it is saved as
            notificationBox.GetComponentInChildren <Text>().text = "Your current armour is level " + (playerArmourScript.GetArmour().level + 1);
        }

        //get the data of what armour the person has
        ArmourData data = SaveSystem.loadArmour();

        if (data != null)
        {
            armourList.playerArmour = data.playerArmour;
        }

        //disable icons as default
        for (int i = 0; i < armourIcons.Length; i++)
        {
            armourIcons[i].SetActive(false);
        }

        //enable icons
        for (int i = 0; i < armourList.playerArmour.Count; i++)
        {
            int armourNum = armourList.playerArmour[i].level;
            armourIcons[armourNum].SetActive(true);
            numberArmourAvailable[armourNum] = numberArmourAvailable[armourNum] + 1;
            armourIcons[armourNum].GetComponentInChildren <Text>().text = "Take Armour (Number Owned: " + numberArmourAvailable[armourNum] + ")";
        }
    }
コード例 #14
0
 void btnCancel_Click(object sender, EventArgs e)
 {
     Armour            = null;
     this.FormClosing -= FormArmourDetails_FormClosing;
     this.Close();
 }