private void SpawnMeleeHitBox(MeleeEffect effect) { HitBox newHitBox; // Spawn hit box as child of fire point if (effect.hitBoxAsChild) { newHitBox = Instantiate(effect.hitBox, effect.firePoint.position, effect.firePoint.rotation, effect.firePoint).GetComponent <HitBox>(); } // Spawn hit box not as child else { newHitBox = Instantiate(effect.hitBox, effect.firePoint.position, effect.firePoint.rotation).GetComponent <HitBox>(); } if (!newHitBox) { return; } newHitBox.SetPower(effect.power); newHitBox.SetLifeTime(effect.lifeTime); newHitBox.SetAttacker(gameObject); newHitBox.SetIgnoreLayers(effect.ignoreLayers); }
private void PerformMeleeEffect(MeleeEffect effect, KeyType type, int keyEffect, int meleeEffect) { // Don't do anything if on cool down if (effect.onCoolDown) { return; } // Use energy if (partUsesEnergy) { energy.UseEnergy(effect.energyUsage); } // Perform cool down if (effect.coolDown > 0f && !effect.onCoolDown) { StartCoroutine(MeleeEffectCoolDownTime(type, keyEffect, meleeEffect)); } // Play fire animation for (int i = 0; i < effect.animationParameters.Length; i++) { StartCoroutine(PlayAnimation(effect.animationParameters[i])); } // Delay effect for specified amount of time if (effect.effectDelay > 0) { StartCoroutine(WaitForMeleeDelay(effect)); return; } SpawnMeleeHitBox(effect); }
IEnumerator WaitForMeleeDelay(MeleeEffect effect) { yield return(new WaitForSeconds(effect.effectDelay)); SpawnMeleeHitBox(effect); }