- Home /
Item Issues
Continuing the BergZerg tutorials. This script initially compiled just fine, but then all of a sudden it went crazy and had a problem with everything. The sticky point seems to be the enum list and the class derived from it. Someone please help me understand how to fix it. Thanks! 1. Did I miss a type declaration?(Has to do with the Rarity of the item. 2. Am I missing a cast somewhere(it was complaining about that too). Tried using a ToString() in several places, but it gave more errors.
using UnityEngine; using System; public class Item { private string _itemName; private int _itemValue; private RarityType _rarity; private int _maxDurability; private int _currentDurability; public Item(){ _itemName=""; _itemValue=0; _rarity=RarityType; _maxDurability=50; _currentDurability=_maxDurability; } public Item(string name , int value, RarityType rarity, int CurrentDurability, int MaxDurability){ _itemName=""; _itemValue=0; _rarity=RarityType.Common; _maxDurability=50; _currentDurability=_maxDurability; } public string ItemName{ get{return _itemName;} set{_itemName=value;} } public int ItemValue { get{return _itemValue;} set{_itemValue=value;} } public string Rarity { get{return _rarity;} set{_rarity=value;} } public int MaxDurability{ get{return _maxDurability;} set{_maxDurability=value;} } public int CurrentDurability{ get{return _currentDurability;} set{_currentDurability=value;} } } public enum RarityType{ Common, Uncommon, Rare, Epic }
Answer by Gilead7 · Apr 18, 2012 at 04:58 PM
I may have figured it out, but I need some confirmation: Changed the declaration in three places, but I'm not sure if this is the best way to do it; i only know that it complied.
private RarityType _rarity;
_rarity=new RarityType();
public Item(string name , int value, RarityType rarity, int ItemWeight, int CurrentDurability, int MaxDurability){ _itemName=""; _itemValue=0; _rarity=RarityType.Common; _maxDurability=50; _itemWeight=1; _currentDurability=_maxDurability;
}
Thanks!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Changing the direction of a prefab when colliding with an object 0 Answers
Editor Enum 0 Answers