public void PlayEffect(EffectName effectName, Vector3 pos, float lifetime = 1f) { GameObject clone = (GameObject)Instantiate(effectPrefabArray[(int)effectName], pos + adjust[effectName], Quaternion.identity); lastPlayEffect = clone; Destroy(clone, lifetime); Debugger.Log(effectName.ToString()); //Play effect's sound if (AudioManager.HaveAudio(effectName.ToString())) { AudioManager.AudioName effectAudio = (AudioManager.AudioName)System.Enum.Parse(typeof(AudioManager.AudioName), effectName.ToString()); AudioManager.PlaySound(effectAudio); } }
public void CheckSpawnIcon(EffectType type) { //TODO add traits icons foreach (StatusIcon si in icons) { if (si.type == type)//if icon exists, no need to spawn { //TODO add animation for updating status return; } } StatusIcon icon = Instantiate <StatusIcon>(prefab, transform); icon.manager = this; icon.type = type; if (type == EffectType.baseClass) { icon.SetImage(SpriteLibrary.GetStatusSprite(unit.stats.GetClassName())); } else { icon.SetImage(SpriteLibrary.GetStatusSprite(EffectName.ToString(type))); } icon.SetPosition(icons.Count); icons.Add(icon); }
public void BuffItemEffect(EffectName newFX) { fxID = newFX.ToString(); fxName = newFX; BuffStat(); float fxDuration = float.Parse(effectDB.GetEffectStat(EffectStat.Duration, fxName)); float fillPercent = buffList[fxID][1] / fxDuration; float timeRemaining = fxDuration - buffList[fxID][1]; fxIconSpawner.UpdateIconFill(fxID, fillPercent, timeRemaining); }
protected virtual IEnumerator BuffOverTime(float buffDuration) { float tickRate = float.Parse(effectDB.GetEffectStat(EffectStat.TickRate, fxName)); string[] stat = effectDB.GetEffectStat(EffectStat.StatsAffected, fxName).Split(new char[] { ',' }); string[] fxAdditiveData = effectDB.GetEffectStat(EffectStat.Additive, fxName).Split(new char[] { ',' }); string[] fxValueData = effectDB.GetEffectStat(EffectStat.EffectValues, fxName).Split(new char[] { ',' }); string fxNameOverTime = fxName.ToString(); do { for (int i = 0; i < fxAdditiveData.Length; i++) { bool isPercent = int.Parse(fxAdditiveData[i]) == 0; float fxValue = float.Parse(fxValueData[i]); // Effect strength times stack count float fxValResult = fxValue * buffList[fxNameOverTime][0]; if (isPercent) { fxValResult = (fxValue / 100) * selfHealth.GetMaxAttributeValue(); } if (fxValResult >= 0) { selfHealth.GainAttribute(fxValResult); } else { selfHealth.TakeDamage(Mathf.Abs(fxValResult), false, false); } } yield return(new WaitForSeconds(tickRate)); } while(buffList[fxNameOverTime][1] <= buffDuration && isBattleActive); removeIDs.Add(fxNameOverTime); yield return(null); }