示例#1
0
    void Start()
    {
        instance = this;

        var fileParts = LoadPartsFromFile();

        if (fileParts == null)
        {
            Debug.Log("Using default parts");
            weaponParts = new List <WeaponPart>();

            for (int i = 0; i < defaultWeaponParts.Count; i++)
            {
                weaponParts.Add(WeaponParts.GetPart(defaultWeaponParts[i].partShortCode));
                weaponParts[i].level   = defaultWeaponParts[i].level;
                weaponParts[i].quality = Qualities.GetQuality(defaultWeaponParts[i].quality);
            }
        }
        else
        {
            weaponParts = fileParts.ToList();
        }

        var fileWeapons = LoadWeaponsFromFile();

        if (fileWeapons == null)
        {
            Debug.Log("Using default weapons");
            weapons = defaultWeapons;
        }
        else
        {
            weapons = fileWeapons.ToList();
        }
    }
示例#2
0
    public WeaponPart[] LoadPartsFromFile()
    {
        var partData = LoadFromFile <WeaponPartData[]>("parts");

        if (partData == null)
        {
            return(null);
        }

        var parts = new WeaponPart[partData.Length];

        for (int i = 0; i < partData.Length; i++)
        {
            parts[i]         = WeaponParts.GetPart(partData[i].partShortCode);
            parts[i].level   = partData[i].level;
            parts[i].quality = Qualities.GetQuality(partData[i].quality);
        }

        return(parts);
    }
示例#3
0
    void LoadPart(ref WeaponPartSlot slot, WeaponPartData wpd)
    {
        if (wpd.partShortCode == "")
        {
            return;
        }

        var loadedPart = WeaponParts.GetPart(wpd.partShortCode);

        loadedPart.level   = wpd.level;
        loadedPart.quality = Qualities.GetQuality(wpd.quality);

        slot.SetPart(loadedPart);

        for (int i = 0; i < wpd.dataParts.Length; i++)
        {
            var childSlot = loadedPart.slots[i];
            var childData = wpd.dataParts[i];
            LoadPart(ref childSlot, childData);
        }
    }