Пример #1
0
 private void Awake()
 {
     _instance      = this;
     PartDictionary = new Dictionary <string, MonoPart>();
     foreach (MonoPart p in PartPrefabs)
     {
         PartDictionary.Add(p.PrefabID, p);
     }
 }
Пример #2
0
        public static void LoadFromFile()
        {
            //var bundle = Load();
            SerializableWeaponBundle bundle = null;

            if (bundle == null)
            {
                print("Bundle is null");
                if ((Instance.weapons?.Count > 0) ||
                    (Instance.spareParts?.Count > 0))
                {
                    return;
                }

                print("Have a set of default parts.");
                bundle         = new SerializableWeaponBundle();
                bundle.weapons = new PreserializedWeapon[0];
                bundle.partIDs = new string[] {
                    "AK47_R_V1",
                    "AK47_B_V1",
                    "A2_M_V1",
                    "9mm",
                    "AK47_St_V1",
                };
            }

            Instance.weapons.Clear();
            for (int i = 0; i < bundle.weapons.Length; i++)
            {
                var weapon = WeaponPreserializer.DeserializeWeapon(bundle.weapons[i]);
                Instance.weapons.Add(weapon);
                ReturnWeapon(weapon);
            }

            Instance.spareParts.Clear();
            for (int i = 0; i < bundle.partIDs.Length; i++)
            {
                var part = GameObject.Instantiate(WAPrefabStore.GetPartPrefab(bundle.partIDs[i]).gameObject).GetComponent <MonoPart>();
                Instance.spareParts.Add(part);
                ReturnPart(part);
            }
        }