예제 #1
0
    /// <summary>
    /// Import simple settings
    /// </summary>
    public static void ImportBaseSettings()
    {
        ImportCache.Clear();
        mNameLookup = new Dictionary <string, ushort>();


        // Add empty item
        ItemDataImporter noneItem = new ItemDataImporter();

        noneItem.mName = "none";
        noneItem.mType = ItemType.None;
        ImportCache.Add(noneItem);
        mNameLookup["none"] = 0;


        ItemDataImporter[] allData = Resources.LoadAll <ItemDataImporter>("Items");

        foreach (ItemDataImporter head in allData)
        {
            foreach (ItemDataImporter settings in head.GetComponents <ItemDataImporter>())
            {
                string key = settings.mName.ToLower();

                if (mNameLookup.ContainsKey(key))
                {
                    Debug.LogError("Multiple items with name '" + key + "' have been discovered");
                    continue;
                }

                settings.mName = key;
                ImportCache.Add(settings);
                mNameLookup[key] = (ushort)(ImportCache.Count - 1);
            }
        }
    }
예제 #2
0
    /// <summary>
    /// Build the desired item object from the settings
    /// </summary>
    private static ItemData Build(ushort ID, ItemDataImporter Settings)
    {
        ItemData item = null;

        switch (Settings.mType)
        {
        case ItemType.None:
            return(new ItemData(ID, Settings));

        case ItemType.Tool:
            item = new ItemData_Tool(ID, Settings);
            break;

        case ItemType.Material:
            item = new ItemData_Material(ID, Settings);
            break;

        default:
            item = new ItemData(ID, Settings);
            break;
        }


        // Fetch icon id
        if (Settings.mIconTexture != null)
        {
            item.mIconID = mIconManager.AddItem(Settings.mIconTexture);
        }
        else
        {
            item.mIconID = ushort.MaxValue;
        }

        return(item);
    }
예제 #3
0
    public ItemData(ushort ID, ItemDataImporter Settings)
    {
        mID   = ID;
        mType = Settings.mType;

        mMaxStackCount = Settings.mMaxStackCount;
        if (mMaxStackCount < 1)
        {
            mMaxStackCount = 1;
        }
    }
예제 #4
0
 public ItemData_Tool(ushort ID, ItemDataImporter Settings) : base(ID, Settings)
 {
 }
예제 #5
0
 void OnEnable()
 {
     mSettings = (ItemDataImporter)target;
 }
예제 #6
0
 public ItemData_Material(ushort ID, ItemDataImporter Settings) : base(ID, Settings)
 {
     mVoxelMaterial = VoxelLibrary.GetID(Settings.mVoxelMaterial);
 }