void Awake() { gameObject.GetComponent <Collider>().isTrigger = true; gameObject.layer = TDS.GetLayerCollectible(); if (type == _CollectType.Self) { //initiate the weapon list to contain all weapon if the condition is checked if (gainWeapon && randomWeapon && enableAllWeapon) { weaponList = new List <Weapon>(WeaponDB.Load()); } //make sure none of the element in weaponList is null for (int i = 0; i < weaponList.Count; i++) { if (weaponList[i] == null) { weaponList.RemoveAt(i); i -= 1; } } } //effect=EffectDB.CloneItem(effectID); effectIdx = EffectDB.GetEffectIndex(effectID); if (triggerEffectObj != null) { ObjectPoolManager.New(triggerEffectObj, 1); } }
public static void Init() { if (instance != null) { return; } instance = LoadDB1(); }
public static void CopyFromOldDB() { Init(); if (instance.copiedFromOldDB) { return; } instance.copiedFromOldDB = true; instance.weaponList = new List <Weapon>(WeaponDB.Load1()); }
public static List <Weapon> Load() { GameObject obj = Resources.Load("DB_TDSTK/DB_Weapon", typeof(GameObject)) as GameObject; #if UNITY_EDITOR if (obj == null) { obj = CreatePrefab(); } #endif WeaponDB instance = obj.GetComponent <WeaponDB>(); return(instance.weaponList); }
// Use this for initialization public override void Awake() { base.Awake(); thisObj.layer = TDS.GetLayerPlayer(); isPlayer = true; SetDestroyCallback(this.PlayerDestroyCallback); if (enableAllWeapons) { weaponList = new List <Weapon>(WeaponDB.Load()); } if (weaponMountPoint == null) { weaponMountPoint = thisT; } if (turretObj != null) { turretObjParent = turretObj.parent; } else { turretObj = thisT; faceTravelDirection = false; } hitPointBase = hitPointFull; energyBase = energyFull; progress = thisObj.GetComponent <PlayerProgression>(); if (progress != null) { progress.SetPlayer(this); } perk = thisObj.GetComponent <PlayerPerk>(); if (perk != null) { perk.SetPlayer(this); } Load(); }
public static void LoadWeapon() { weaponDB = WeaponDB.LoadDB(); for (int i = 0; i < weaponDB.weaponList.Count; i++) { if (weaponDB.weaponList[i] != null) { //weaponDB.weaponList[i].ID=i; weaponIDList.Add(weaponDB.weaponList[i].ID); } else { weaponDB.weaponList.RemoveAt(i); i -= 1; } } UpdateLabel_Weapon(); TDSEditorWindow.SetWeaponDB(weaponDB, weaponIDList, weaponLabel); TDSEditorInspector.SetWeaponDB(weaponDB, weaponIDList, weaponLabel); }
public static void SetWeaponDB(WeaponDB db, List <int> IDList, string[] label) { weaponDB = db; weaponIDList = IDList; weaponLabel = label; }
//public static string PurchasePerk(Perk perk, bool useCurrency=true){ return instance._PurchasePerk(perk, useCurrency); } public string PurchasePerk(Perk perk, bool useCurrency = true, bool saving = true) { string text = perk.Purchase(this, useCurrency); if (text != "") { Debug.Log(text); return(text); } for (int i = 0; i < perkList.Count; i++) { Perk perkTemp = perkList[i]; if (perkTemp.purchased > 0 || perkTemp.prereq.Count == 0) { continue; } perkTemp.prereq.Remove(perk.ID); } TDS.PerkPurchased(perk); if (player.SaveUponChange()) { Save(); } if (perk.type == _PerkType.ModifyGeneralStats) { hitPointCap += perk.hitPointCap; energyCap += perk.energyCap; hitPointRegen += perk.hitPointRegen; energyRegen += perk.energyRegen; player.GainHitPoint(perk.hitPoint); player.GainEnergy(perk.energy); moveSpeedMul += perk.moveSpeedMul; damageMul += perk.dmgMul; critMul += perk.critChanceMul; critMulMul += perk.CritMultiplierMul; expGainMul += perk.expGainMul; creditGainMul += perk.creditGainMul; scoreGainMul += perk.scoreGainMul; hitPointGainMul += perk.hitPointGainMul; energyGainMul += perk.energyGainMul; } else if (perk.type == _PerkType.AddWeapon && perk.newWeaponID >= 0) { Weapon newWeapon = WeaponDB.GetPrefab(perk.newWeaponID); if (newWeapon != null) { if (perk.replaceExisting) { player.AddWeapon(newWeapon, true); } else if (perk.replaceWeaponID >= 0) { int replaceIndex = -1; for (int i = 0; i < player.weaponList.Count; i++) { if (perk.replaceWeaponID == player.weaponList[i].ID) { replaceIndex = i; break; } } if (replaceIndex >= 0) { player.SwitchWeapon(replaceIndex); player.AddWeapon(newWeapon, true); } else { player.AddWeapon(newWeapon); } } else { player.AddWeapon(newWeapon); } } for (int i = 0; i < perkList.Count; i++) { if (perkList[i].purchased > 0 && perkList[i].type == _PerkType.ModifyWeapon) { if (perkList[i].appliedToAllWeapon || perkList[i].weaponIDList.Contains(perk.newWeaponID)) { if (perkList[i].weapEffectID >= 0) { player.ChangeWeaponEffect(perk.newWeaponID, perkList[i].weapEffectID); } if (perkList[i].weapAbilityID >= 0) { player.ChangeWeaponAbility(perk.newWeaponID, perkList[i].weapAbilityID); } } } } } else if (perk.type == _PerkType.AddAbility && perk.newAbilityID >= 0) { AbilityManager.AddAbility(perk.newAbilityID, perk.replaceAbilityID); for (int i = 0; i < perkList.Count; i++) { if (perkList[i].purchased > 0 && perkList[i].type == _PerkType.ModifyAbility) { if (perkList[i].appliedToAllAbility || perkList[i].abilityIDList.Contains(perk.newAbilityID)) { if (perkList[i].abEffectID >= 0) { player.ChangeAbilityEffect(perk.newAbilityID, perkList[i].abEffectID); } } } } } else if (perk.type == _PerkType.ModifyWeapon) { if (perk.appliedToAllWeapon) { weapStatG.ModifyWithPerk(perk); if (perk.weapEffectID >= 0) { player.ChangeAllWeaponEffect(perk.weapEffectID); } if (perk.weapAbilityID >= 0) { player.ChangeAllWeaponAbility(perk.weapAbilityID); } } else { for (int i = 0; i < perk.weaponIDList.Count; i++) { WeaponStatMultiplier item = GetWeaponStatMul(perk.weaponIDList[i]); if (item == null) { item = new WeaponStatMultiplier(); item.prefabID = perk.weaponIDList[i]; weapStatList.Add(item); } item.ModifyWithPerk(perk); if (perk.weapEffectID >= 0) { player.ChangeWeaponEffect(perk.weaponIDList[i], perk.weapEffectID); } if (perk.weapAbilityID >= 0) { player.ChangeWeaponAbility(perk.weaponIDList[i], perk.weapAbilityID); } } } } else if (perk.type == _PerkType.ModifyAbility) { if (perk.appliedToAllAbility) { abilityStatG.ModifyWithPerk(perk); if (perk.weapEffectID >= 0) { player.ChangeAllAbilityEffect(perk.weapEffectID); } } else { for (int i = 0; i < perk.abilityIDList.Count; i++) { AbilityStatMultiplier item = GetAbilityStatMul(perk.abilityIDList[i]); if (item == null) { item = new AbilityStatMultiplier(); item.prefabID = perk.abilityIDList[i]; abilityStatList.Add(item); } item.ModifyWithPerk(perk); if (perk.abEffectID >= 0) { player.ChangeAbilityEffect(perk.abilityIDList[i], perk.abEffectID); } } } } else if (perk.type == _PerkType.Custom) { GameObject obj = (GameObject)Instantiate(perk.customObject); obj.name = perk.name + "_CustomObject"; obj.transform.parent = transform; obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; } return(""); }