private ComboElement TranslateActionToComboElement(ActionType actionType) { if (currentElement == null) { switch (actionType) { case ActionType.lightMelee: currentElement = FindElementOfThisName("Jab"); break; case ActionType.heavyMelee: currentElement = FindElementOfThisName("Kick"); break; case ActionType.lightRanged: currentElement = FindElementOfThisName("SunBolt"); break; } return(currentElement); } else { foreach (ComboElement nextElement in currentElement.nextElements) { if (nextElement.actionToTrigger == actionType) { return(nextElement); } } } return(null); }
public override void ReduceHealth(ComboElement attackStats) { if (turnCoroutine == null) { turnCoroutine = StartCoroutine(TurnAnimation()); } }
private void ClearCombo() { if (comboTimerCoroutine != null) { StopCoroutine(comboTimerCoroutine); } currentElement = null; comboTimer = 0; }
public override void ReduceHealth(ComboElement attackStats) { base.ReduceHealth(attackStats); if (base.curHP <= 0) { FMODUnity.RuntimeManager.PlayOneShot(sfxBreakingJar, transform.position); Die(); } }
public void Attack(ActionType attackType) { if (health.GetCanAct()) { currentAttack = comboManager.AddToCombo(attackType); currentDamageValue = currentAttack.damage; StartCoroutine(CountAttackCooldown(currentAttack.cooldown)); } }
private bool CheckIfNewElementMatchesNextElements(ComboElement newElement) { for (int i = 0; i < currentElement.nextElements.Length; ++i) { if (currentElement.nextElements[i].Equals(newElement)) { return(true); } } return(false); }
public void HandlSpecialAttackEffect(ComboElement currentAttack, GameObject target) { switch (currentAttack.specialEffect) { case SpecialEffect.knockback: ApplyKnockback(currentAttack, target); break; case SpecialEffect.stun: //stun break; } }
public override void ReduceHealth(ComboElement attackStats) { FMODUnity.RuntimeManager.PlayOneShot(sfxEnemyHitReceivingDamage, transform.position); FMODUnity.RuntimeManager.PlayOneShot(sfxEnemyGrowlReceivingDamage, transform.position); base.ReduceHealth(attackStats); HPView.PlayDamageVisuals(); stateMachine.ChangeState(typeof(FlinchingState), attackStats.hitstunDuration); if (base.curHP <= 0) { Die(); } }
public override void ReduceHealth(ComboElement attackStats) { FMODUnity.RuntimeManager.PlayOneShot(sfxReceiveDamage, transform.position); FMODUnity.RuntimeManager.PlayOneShot(voiceAylaHurt, transform.position); base.ReduceHealth(attackStats); playerHPView.ReactToDamage(base.curHP, base.maxHP); stateMachine.ChangeOtherStateMachineState(typeof(PlayerIdleState)); stateMachine.ChangeState(typeof(FlinchingState), attackStats.hitstunDuration); if (base.curHP <= 0) { Die(); } }
private void ApplyKnockback(ComboElement currentAttack, GameObject target) { float xDirection; if (transform.root.position.x < target.transform.position.x) { xDirection = 1; } else { xDirection = -1; } //xDirection *= 3; target.GetComponentInChildren <EntityMovement>().StopAllMovement(); target.GetComponent <Rigidbody2D>().velocity = new Vector2(xDirection, 0.5f) * currentAttack.specialEffectIntensity; }
private void DoDamage(RaycastHit[] hits, ComboElement element) { bool shield = false; foreach (RaycastHit hit in hits) { if (hit.collider.tag == "Shield") { shield = true; } } if (shield == false) { foreach (RaycastHit hit in hits) { // trocar isso para algo como os alvos terem uma invulnerabilidade temporaria, para evitar ter que ficar mexendo com lista if (!targetsAlreadyHit.Contains(hit.collider)) { HealthPoints hp = hit.collider.GetComponent <HealthPoints>(); if (hp != null) { hp.ReduceHealth(element); } if (element.knockback > 0) { Vector3 direction = hit.collider.transform.position - transform.position; direction.y = 0; if (hit.collider.transform.parent != null && ShouldKnockback(hit)) { Rigidbody rb = hit.collider.transform.parent.GetComponent <Rigidbody>(); if (rb != null) { rb.AddForce(direction * element.knockback, ForceMode.Impulse); StartCoroutine(removeKnockbackForce(rb, element.knockbackTime)); } } } targetsAlreadyHit.Add(hit.collider); } } } }
private IEnumerator AttackRoutine(ComboElement element) { willTriggerNextAttack = false; // TODO: Tocar animacao de ataque meleeAttack.Sweep(element); stateMachine.ChangeOtherStateMachineState(typeof(PlayerIdleState)); stateMachine.canChangeStates = false; isAttacking = true; for (attackTimeElapsed = 0; attackTimeElapsed < element.totalTime; attackTimeElapsed += Time.deltaTime) { yield return(null); } isAttacking = false; stateMachine.canChangeStates = true; stateMachine.ChangeState(typeof(PlayerNotActingState)); }
private bool DoStabDamage(ComboElement stabStats) { bool hitObstacle = false; Collider[] targets = Physics.OverlapBox(attackPoint.position, damageArea, transform.rotation, targetLayer); foreach (Collider target in targets) { if (target.tag == "Obstacle") { hitObstacle = true; } HealthPoints currHP = target.GetComponent <HealthPoints>(); if (currHP != null) { currHP.ReduceHealth(stabStats); } } //sfxAylaSpecialAttack.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); return(hitObstacle); }
public ComboElement AddToCombo(ActionType actionType) { ComboElement newElement = TranslateActionToComboElement(actionType); // Didn't find a possible element to follow up the current action. Will return a basic action if (newElement == null) { ClearCombo(); return(TranslateActionToComboElement(actionType)); } else if (newElement.isFinisher) { StartCoroutine(DelayClearingCombo()); return(newElement); } if (comboTimerCoroutine == null) { StartCoroutine(StartComboResetTimer()); } currentElement = newElement; return(currentElement); }
private IEnumerator SweepRoutine(ComboElement element) { float raysToCast = 0; float totalRaysCast = 0; float raysRemaining = (float)rayCount; float startingAngle = VectorToAngle(transform.forward); float currentAngle; if (element.goesRightToLeft) { currentAngle = startingAngle - fov / 2; } else { currentAngle = startingAngle + fov / 2; } targetsAlreadyHit.Clear(); float lastTotalTime = 0; FMODUnity.RuntimeManager.PlayOneShot(element.sfxAttack, transform.position); FMODUnity.RuntimeManager.PlayOneShot(element.voiceSound, transform.position); for (float time = 0; time <= element.duration; time += Time.deltaTime) { float timeIncrementPercentage = time / element.duration - lastTotalTime; lastTotalTime = time / element.duration; raysToCast += raysRemaining * timeIncrementPercentage; if (raysToCast >= 1) { int i = 0; do { this.DoDamage(this.CastNextRay(currentAngle), element); if (element.goesRightToLeft) { currentAngle += angleIncrease; } else { currentAngle -= angleIncrease; } totalRaysCast++; ++i; } while (i < (int)raysToCast); raysToCast -= i; } else if (time == 0) { this.DoDamage(this.CastNextRay(currentAngle), element); if (element.goesRightToLeft) { currentAngle += angleIncrease; } else { currentAngle -= angleIncrease; } totalRaysCast++; } yield return(null); } }
public virtual void ReduceHealth(ComboElement attackStats) { //TODO: Toca som de dano curHP -= attackStats.damage; }
public void Sweep(ComboElement element) { StartCoroutine(SweepRoutine(element)); }