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(); }
//for perk that modify the weapon attack effect public void ChangeAllWeaponEffect(int effectID) { int effectIndex = EffectDB.GetEffectIndex(effectID); for (int i = 0; i < weaponList.Count; i++) { weaponList[i].ChangeEffect(effectID, effectIndex); } }
//for perk that modify the ability attack effect public void ChangeAllAbilityEffect(int effectID) { int effectIndex = EffectDB.GetEffectIndex(effectID); List <Ability> abList = AbilityManager.GetAbilityList(); for (int i = 0; i < abList.Count; i++) { abList[i].ChangeEffect(effectID, effectIndex); } }
public static void CopyFromOldDB() { Init(); if (instance.copiedFromOldDB) { return; } instance.copiedFromOldDB = true; instance.effectList = new List <Effect>(EffectDB.LoadClone1()); }
public void ChangeWeaponEffect(int weaponID, int effectID) { int effectIndex = EffectDB.GetEffectIndex(effectID); for (int i = 0; i < weaponList.Count; i++) { if (weaponList[i].ID == weaponID) { weaponList[i].ChangeEffect(effectID, effectIndex); break; } } }
public static List <Effect> Load() { GameObject obj = Resources.Load("DB_TDSTK/DB_Effect", typeof(GameObject)) as GameObject; #if UNITY_EDITOR if (obj == null) { obj = CreatePrefab(); } #endif EffectDB instance = obj.GetComponent <EffectDB>(); return(instance.effectList); }
public static List <Effect> LoadClone1() { EffectDB instance = LoadDB1(); List <Effect> newList = new List <Effect>(); if (instance != null) { for (int i = 0; i < instance.effectList.Count; i++) { newList.Add(instance.effectList[i].Clone()); } } return(newList); }
public static List <Effect> LoadClone() { GameObject obj = Resources.Load("DB_TDSTK/DB_Effect", typeof(GameObject)) as GameObject; EffectDB instance = obj.GetComponent <EffectDB>(); List <Effect> newList = new List <Effect>(); if (instance != null) { for (int i = 0; i < instance.effectList.Count; i++) { newList.Add(instance.effectList[i].Clone()); } } return(newList); }
public static void LoadEffect() { effectDB = EffectDB.LoadDB(); for (int i = 0; i < effectDB.effectList.Count; i++) { if (effectDB.effectList[i] != null) { //effectDB.effectList[i].ID=i; effectIDList.Add(effectDB.effectList[i].ID); } else { effectDB.effectList.RemoveAt(i); i -= 1; } } UpdateLabel_Effect(); TDSEditorWindow.SetEffectDB(effectDB, effectIDList, effectLabel); TDSEditorInspector.SetEffectDB(effectDB, effectIDList, effectLabel); }
//apply the effect to player void ApplyEffectSelf(UnitPlayer player) { //gain life if (life > 0) { GameControl.GainLife(); } //gain hit-point if (hitPoint > 0) { float hitPointGained = player.GainHitPoint(hitPoint); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+" + hitPointGained.ToString("f0"), new Color(0.3f, 1f, 0.3f, 1)); } //gain energy if (energy > 0) { float energyGained = player.GainEnergy(energy); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+" + energyGained.ToString("f0"), new Color(.3f, .3f, 1f, 1)); } //not in used if (credit > 0) { GameControl.GainCredits(credit); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+$" + credit.ToString("f0"), new Color(.5f, .75f, 1, 1)); } //gain score if (score > 0) { GameControl.GainScore(score); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+" + score.ToString("f0"), new Color(.1f, 1f, 1, 1)); } //gain ammo if (ammo != 0) { player.GainAmmo(ammoID, ammo); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+ammo"); } //gain exp if (exp != 0) { player.GainExp(exp); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+exp", new Color(1f, 1f, 1, 1)); } //gain perk currency if (perkCurrency != 0) { player.GainPerkCurrency(perkCurrency); Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(transform.position + offsetPos, "+perk points", new Color(1f, 1f, 1, 1)); } //effects if (effectIdx >= 0) { player.ApplyEffect(EffectDB.CloneItem(effectIdx)); } //if(effect!=null && effect.duration>0) player.ApplyEffect(effect); //gain weapon if (gainWeapon && weaponList.Count > 0) { int playerWeaponID = player.weaponList[player.weaponID].ID; int rand = randomWeapon ? Random.Range(0, weaponList.Count) : 0; if (randomWeapon && weaponList.Count > 1) { int count = 0; while (weaponList[rand].ID == playerWeaponID) { rand = Random.Range(0, weaponList.Count); count += 1; if (count > 50) { break; } } } bool replaceWeapon = weaponType == _WeaponType.Replacement; bool temporaryWeapon = weaponType == _WeaponType.Temporary; player.AddWeapon(weaponList[rand], replaceWeapon, temporaryWeapon, tempWeapDuration); } }
public static void SetEffectDB(EffectDB db, List <int> IDList, string[] label) { effectDB = db; effectIDList = IDList; effectLabel = label; }
//applies the effect of an attack public void ApplyAttack(AttackInstance attInstance) { //if unit is invincible, do nothing if (IsInvincible()) { Debug.Log("Immuned"); Vector3 osPos = new Vector3(0, Random.value + 0.5f, 0); new TextOverlay(thisT.position + osPos, "Immuned"); return; } AttackStats aStats = attInstance.aStats; //check if the attack is an aoe and modify the damage value is dimishingAOE is enabled float damage = Random.Range(aStats.damageMin, aStats.damageMax); if (attInstance.isAOE && aStats.diminishingAOE) { damage *= Mathf.Clamp(1 - attInstance.aoeDistance / aStats.aoeRadius, 0, 1); } //check for cirtical and modify the damage based on critical multiplier bool critical = Random.value < aStats.critChance; if (critical) { damage *= aStats.critMultiplier; } //modify the damage based on damage and armor type damage *= DamageTable.GetModifier(armorType, aStats.damageType); //if damage is valid, modify the hit point if (damage > 0) { //show the overlay (for UI) Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0); if (!critical) { new TextOverlay(thisT.position + offsetPos, damage.ToString("f0")); } else { new TextOverlay(thisT.position + offsetPos, damage.ToString("f0"), new Color(1f, 0.9f, 0.9f, 1f), 1.5f); } //if the unit is player, fire event to inform UI if (thisObj.layer == TDS.GetLayerPlayer()) { TDS.PlayerDamaged(damage); } //register the stagger hpRegenStaggerCounter = hpRegenStagger; hitPoint -= damage; //damage the hitpoint if (hitPoint <= 0) { Destroyed(attInstance.GetSrcPlayer()); } if (hitPoint > 0 && uAnimation != null) { uAnimation.Hit(); } } //apply effect if there's any //if(aStats.effect!=null) ApplyEffect(aStats.effect); if (aStats.effectIdx >= 0) { ApplyEffect(EffectDB.CloneItem(aStats.effectIdx)); } }
public int effectIdx = -1; //effect'sindex to effectlist in DB during runtime //[HideInInspector] public Effect effect=null; public void Init() { //clone the effect so the original in DB wont get modified //effect=EffectDB.CloneItem(effectID); effectIdx = EffectDB.GetEffectIndex(effectID); }