/// <summary> /// This is the function that enacts the actual heavy attack. /// </summary> /// <returns></returns> IEnumerator heavy() { animator.SetBool("attacking", true); animator.SetTrigger("heavy"); StartCoroutine(delayedCycle(heavy_time.x + heavy_time.y)); LockAttack(heavy_time.x + heavy_time.y + 0.01f, false, false); yield return(new WaitForSeconds(heavy_time.x)); // Wait specified time before starting the attack if (hitboxDamage != null) { Destroy(hitboxDamage.gameObject); //Destroy any pre-existing damage hitbox to start this attack. } if (hitboxDeflect != null) { Destroy(hitboxDeflect.gameObject); //Destroy any pre-existing deflection hitbox to start this attack. } List <Enemy> collidedCreatures; List <Projectile> collidedBullets; hitboxDamage = Instantiate(prefabsDamage[2]).GetComponent <Hitbox>(); hitboxDeflect = Instantiate(prefabsDeflect[2]).GetComponent <Hitbox>(); hitboxDamage.transform.parent = transform; hitboxDeflect.transform.parent = transform; hitboxDamage.setPosAuto(true); hitboxDeflect.setPosAuto(true); float totalTime = 0; int combo = comboCounter.getComboCount(); comboCounter.updateComboCount(true, true); float finalDamage = combo; //Calculate final damage here float finalHealing = combo; //Calculate final healing here collidedCreatures = getEnemies(hitboxDamage.collidedObjects(enemyLayerMask)); collidedBullets = getProjectiles(hitboxDeflect.collidedObjects(projectileLayerMask)); foreach (Enemy enemy in collidedCreatures) { Debug.Log(enemy.gameObject); enemy.Damage(attackDamages[1]); player.Hover(floatTime); player.Damage(-10); } foreach (Projectile projectile in collidedBullets) { Debug.Log(projectile.gameObject); projectile.Deflect(); player.Hover(floatTime); } comboCounter.updateComboCount(collidedCreatures.Count + collidedBullets.Count); yield return(new WaitForEndOfFrame()); while (totalTime <= heavy_time.y) //Check how long has passed { totalTime += Time.deltaTime; //Increase the time for the while loop. //Debug.Log(Time.deltaTime + ":" + totalTime + ":" + light_time.y); List <Enemy> tempEnemies = newEnemies(collidedCreatures, getEnemies(hitboxDamage.collidedObjects(enemyLayerMask))); //Temparory list of the new un-checked enemies List <Projectile> tempProjectiles = newProjectiles(collidedBullets, getProjectiles(hitboxDamage.collidedObjects(projectileLayerMask))); //Temparory list of the new un-checked projectiles collidedCreatures.AddRange(tempEnemies); //Adding the new enemies to the total list to make sure no enemy is damaged twice. collidedBullets.AddRange(tempProjectiles); //Adding the new projectile to the total list to make sure no projectile is deflected twice. foreach (Enemy enemy in tempEnemies) { Debug.Log(enemy.gameObject); enemy.Damage(attackDamages[1]); player.Hover(floatTime); } foreach (Projectile projectile in tempProjectiles) { projectile.Deflect(); player.Hover(floatTime); } yield return(new WaitForEndOfFrame()); //Wait for the end of the frame to act again. } queCycle(); Destroy(hitboxDamage.gameObject); Destroy(hitboxDeflect.gameObject); activeAttack = null; animator.SetBool("attacking", false); }