public void TryAttack() { if (!isBattleActive) { return; } timeSinceLastAttack += Time.deltaTime; MonAtkName triggerAtkName = attackManager.CheckHPTrigger(health.GetPercentage()); if (triggerAtkName != MonAtkName.None) { atkQueue.Clear(); atkQueue.Enqueue(triggerAtkName); } if (timeSinceLastAttack >= idleTimeBetweenHits && enemy.CanAttack()) { if (atkQueue.Count == 0) { atkQueue = attackManager.GetAttackPattern(); } else { StartNewAttack(); } } }
public float GetAttackStat(MonAtkStat stat, MonAtkName atkName, int i) { string[] s = GetBaseAttackStat(stat, atkName); float total = 0; float[] atkStatModifiers = GetAtkStatModifiers(stat, atkName); total = (float.Parse(s[i]) + atkStatModifiers[1]) * (1 + atkStatModifiers[0] / 100); // print(atkName.ToString() + " " + stat.ToString() + " has a value of " + total); return(total); }
public float[] GetAttackStatArray(MonAtkStat stat, MonAtkName atkName) { string[] s = GetBaseAttackStat(stat, atkName); float[] total = new float[s.Length]; for (int i = 0; i < s.Length; i++) { float[] atkStatModifiers = GetAtkStatModifiers(stat, atkName); total[i] = (float.Parse(s[i]) + atkStatModifiers[1]) * (1 + atkStatModifiers[0] / 100); } return(total); }
private float[] GetAtkStatModifiers(MonAtkStat stat, MonAtkName atkName) { float[] total = new float[] { 0, 0 }; foreach (IMonAtkEffectProvider fxProvider in GetComponents <IMonAtkEffectProvider>()) { foreach (float[] modifier in fxProvider.GetMonAtkStatModifiers(atkName, stat)) { total[0] += modifier[0]; total[1] += modifier[1]; } } return(total); }
public IEnumerable <bool> GetMonAtkBooleanModifiers(MonAtkName atkName, MonAtkStat attackStat) { if (buffList.Count == 0) { yield return(false); } bool result = false; //Run through each active buff foreach (string id in buffList.Keys) { EffectName effect = (EffectName)Enum.Parse(typeof(EffectName), id); // Check if effect type boosts Attack, otherwise desired EffectStats aren't assigned if (effectDB.GetEffectStat(EffectStat.EffectType, effect) == "Atk Boost") { // Skip if not a boolean buff value if (int.Parse(effectDB.GetEffectStat(EffectStat.Additive, effect)) != 2) { continue; } // Get affected skill list and compare with the provided AtkType string fxAttackTypes = effectDB.GetEffectStat(EffectStat.AtkTypesAffected, effect); if (fxAttackTypes == "All" || fxAttackTypes.Contains(atkName.ToString())) { string fxAttackStats = effectDB.GetEffectStat(EffectStat.AtkStatsAffected, effect); // Compare the Effect stat to the provided stat if (fxAttackStats.Contains(attackStat.ToString())) { // Check and assign value, then check if buff is consumed on activation if (effectDB.GetEffectStat(EffectStat.AtkEffectValues, effect).ToLower() == "true") { result = true; } if (int.Parse(effectDB.GetEffectStat(EffectStat.Consumed, effect)) == 1) { removeIDs.Add(id); } } } } } yield return(result); }
public IEnumerable <float[]> GetMonAtkStatModifiers(MonAtkName atkName, MonAtkStat attackStat) { if (buffList.Count == 0) { yield return new float[] { 0, 0 } } ; float[] result = new float[] { 0, 0 }; //Run through each active buff foreach (string id in buffList.Keys) { EffectName effect = (EffectName)Enum.Parse(typeof(EffectName), id); // Check if effect type boosts Attack, otherwise desired EffectStats aren't assigned if (effectDB.GetEffectStat(EffectStat.EffectType, effect) == "Atk Boost") { // Skip if buff value is a bool int modType = int.Parse(effectDB.GetEffectStat(EffectStat.Additive, effect)); if (modType == 2) { continue; } // Get affected skill list and compare with the provided AtkType string fxAttackTypes = effectDB.GetEffectStat(EffectStat.AtkTypesAffected, effect); if (fxAttackTypes == "All" || fxAttackTypes.Contains(atkName.ToString())) { string fxAttackStats = effectDB.GetEffectStat(EffectStat.AtkStatsAffected, effect); // Compare the Effect stat to the provided stat if (fxAttackStats.Contains(attackStat.ToString())) { // Check and assign value, then check if buff is consumed on activation result[modType] += float.Parse(effectDB.GetEffectStat(EffectStat.AtkEffectValues, effect)); if (int.Parse(effectDB.GetEffectStat(EffectStat.Consumed, effect)) == 1 && !removeIDs.Contains(id)) { removeIDs.Add(id); } } } } } yield return(result); }
private void StartNewAttack() { curAtk = atkQueue.Dequeue(); timeSinceAttackStarted = 0; float atkSpeed = fighter.GetStat(Stat.AttackSpeed); atkSpeed = 1 / atkSpeed * 100; totalAtkTime = GetAttackStat(MonAtkStat.TotalTime, 0) * atkSpeed; atkLeadTime = GetAttackStat(MonAtkStat.LeadTime, 0) * atkSpeed; maxHitCount = GetAttackStat(MonAtkStat.HitCount, 0); Sprite[] sprites = monAtkIconDB.GetSprite(curAtk); GetComponentInParent <ActionScheduler>().StartAction(this); if (maxHitCount >= 1) { int maxEffectCount = monAtkDB.GetAttackStat(MonAtkStat.EffectID, curAtk).Length; isEffectOnHit = new bool[maxEffectCount]; for (int i = 0; i < maxEffectCount; i++) { string[] fxApply = monAtkDB.GetAttackStat(MonAtkStat.ApplyEffect, curAtk); isEffectOnHit[i] = fxApply[i] == "OnHit"; } for (int i = 0; i < maxHitCount; i++) { float newPosX = (i * 80); HitTimer instance = hitTimerSpawner.SpawnHitTimer(newPosX); hitTimers.Add(instance); instance.SetSprite(sprites[i]); Color32 atkColor = new Color32(254, 195, 30, 255); StartCoroutine(instance.EnemyBorderFill(atkLeadTime, atkColor)); } } // Set attack stats and start attack action enemy.startAttack(totalAtkTime); enemy.SetNewStatus(myName + GetAttackString(MonAtkStat.LeadText), atkLeadTime); enemy.enemyAttack -= TryAttack; enemy.enemyAttack += AttackLeadTime; }
public Sprite[] GetSprite(MonAtkName atkName) { BuildLookup(); return(lookupTable[atkName]); }
public string[] GetAttackStat(MonAtkStat stat, MonAtkName monAtkName) { BuildLookup(); return(lookupTable[monAtkName][stat]); }
private string[] GetBaseAttackStat(MonAtkStat stat, MonAtkName atkName) { return(monAtkDB.GetAttackStat(stat, atkName)); }