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); } }
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); } }
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>(); }
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(); }
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(); }
// 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; } }
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(); }
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(); }
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); } }
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); } }
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); }
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(); }
// 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] + ")"; } }
void btnCancel_Click(object sender, EventArgs e) { Armour = null; this.FormClosing -= FormArmourDetails_FormClosing; this.Close(); }