Beispiel #1
0
    public Dictionary <string, int> GetZeroState()
    {
        Dictionary <string, int> zeroState = new Dictionary <string, int>();

        // Reflection trick to get fields
        FieldInfo[] fields = typeof(Resources).GetFields();
        foreach (FieldInfo field in fields)
        {
            WorldItemDefinition itemDefinition = (WorldItemDefinition)field.GetValue(this.resources);
            zeroState.Add(itemDefinition.itemName, 0);
        }

        fields = typeof(Stats).GetFields();
        foreach (FieldInfo field in fields)
        {
            WorldItemDefinition itemDefinition = (WorldItemDefinition)field.GetValue(this.stats);
            zeroState.Add(itemDefinition.itemName, 0);
        }

        fields = typeof(Tools).GetFields();
        foreach (FieldInfo field in fields)
        {
            WorldItemDefinition itemDefinition = (WorldItemDefinition)field.GetValue(this.tools);
            zeroState.Add(itemDefinition.itemName, 0);
        }

        return(zeroState);
    }
Beispiel #2
0
 public WorldItem(WorldItemDefinition _itemDefinition, int _amount)
 {
     itemDefinition = _itemDefinition;
     amount         = _amount;
 }