private IEnumerator attack() { chargeParticles.SetActive(true); originalSpeed = parent.GetComponent <CharacterController> ().speed; parent.GetComponent <CharacterController> ().speed = chargeSpeed; iaAnimator.SetTrigger("isChargingChargeAttack"); float timer = 0f; while (timer < timeBeforeCharge && !interrupted && !parent.GetComponent <IAController>().isDead) { timer += Time.deltaTime; float ratio = timer / timeBeforeCharge; Color newColor = Color.Lerp(Color.black, Color.red, ratio); outlineChanger.setOutlineColor(newColor); yield return(null); } //yield return new WaitForSeconds (timeBeforeCharge); chargeParticles.SetActive(false); iaAnimator.SetBool("isDoingChargeAttack", true); yield return(null); GetComponent <Collider> ().enabled = true; whileChargingParticles.GetComponent <ParticleSystem> ().Play(); timer = 0f; parent.layer = LayerMask.NameToLayer("Dashing"); while (timer <= timeItLastsCharge && !interrupted && !parent.GetComponent <IAController>().isDead) { timer += Time.deltaTime; parent.GetComponent <IAController> ().Move(direction); yield return(null); } parent.layer = LayerMask.NameToLayer("Enemy"); interrupted = false; outlineChanger.setOutlineColor(Color.black); //whileChargingParticles.SetActive (false); whileChargingParticles.GetComponent <ParticleSystem> ().Stop(); iaAnimator.SetBool("isDoingChargeAttack", false); isFinished = true; parent.GetComponent <CharacterController> ().speed = originalSpeed; GetComponent <Collider> ().enabled = false; yield return(null); }
public void onHitGround() { if (parent != null) { parent.GetComponent <IAControllerCrane> ().resetActionToCallOnTouchGround(); outlineChanger.setOutlineColor(Color.black); iaAnimator.SetBool("isFlyingAttacking", false); isFinished = true; doDamage = false; parent.GetComponent <IAControllerCrane> ().resetOriginalPreferredHeight(); parent.GetComponent <IAControllerCrane> ().resetOriginalUpSpeed(); particles.Stop(); interrupted = false; } }
private void chargeAttack() { isInterruptable = true; chargeAttackTimer += Time.deltaTime; float ratio = chargeAttackTimer / timeToCharge; Color newColor = Color.Lerp(Color.black, Color.red, ratio); outlineChanger.setOutlineColor(newColor); if (chargeAttackTimer >= timeToCharge || interrupted) { outlineChanger.setOutlineColor(Color.black); isChargingAttack = false; isDoingAttack = true; } }
IEnumerator doAttack() { iaAnimator.SetTrigger("isChargingSlide"); float timer = 0f; //Charges the move while (timer < timeToCharge && !interrupted) { timer += Time.deltaTime; float ratio = timer / timeToCharge; outlineChanger.setOutlineColor(Color.Lerp(Color.black, Color.white, ratio)); yield return(null); } iaAnimator.SetBool("isSliding", true); timer = 0f; direction = parent.GetComponent <IAController> ().getPlayerDirection(); parent.layer = LayerMask.NameToLayer("OnlyFloor"); //The penguin slides until it reaches the back of the player while (timer < timeItLasts && !isInOtherSideOfEnemy() && !interrupted) { timer += Time.deltaTime; float ratio = timer / timeItLasts; parent.GetComponent <CharacterController>().Move(direction * speedMultiplyier); yield return(null); } yield return(null); iaAnimator.SetBool("isSliding", false); timer = 0f; while (timer < timeToStand && !interrupted) { timer += Time.deltaTime; float ratio = (timer / timeToStand); outlineChanger.setOutlineColor(Color.Lerp(Color.white, Color.black, ratio)); yield return(null); } parent.GetComponent <CharacterController> ().StopMoving(); outlineChanger.setOutlineColor(Color.black); interrupted = false; isFinished = true; parent.layer = LayerMask.NameToLayer("Enemy"); }
private IEnumerator doAttack() { interrupted = false; iaAnimator.SetTrigger("isDoingMeleeAttack"); float timer = 0f; while (timer < timeToChargeAttack && !interrupted) { timer += Time.deltaTime; float ratio = timer / timeToChargeAttack; outlineChanger.setOutlineColor(Color.Lerp(Color.black, Color.red, ratio)); yield return(null); } if (isPlayerInRange && !interrupted) { doDamage(); } outlineChanger.setOutlineColor(Color.black); isFinished = true; }
private void chargeAttack() { isInterruptable = true; chargeAttackTimer += Time.deltaTime; float ratio = chargeAttackTimer / timeToChargeAttack; Color newColor = Color.Lerp(Color.black, Color.red, ratio); outlineChanger.setOutlineColor(newColor); if (chargeAttackTimer >= timeToChargeAttack || interrupted) { outlineChanger.setOutlineColor(Color.black); isChargingAttack = false; isDoingAttack = true; iaAnimator.SetTrigger("isDoingHeadbutt"); if (!interrupted) { particlesAttack.GetComponent <ParticleSystem>().Play(); } } }
IEnumerator doAttack() { hasHurtPlayer = false; setOriginalParticlesPosition(); setParticles(true); float timer = 0f; iaAnimator.SetBool("isChargingBaseAttack", true); while (timer < timeToCharge) { timer += Time.deltaTime; float ratio = timer / timeToCharge; outlineChanger.setOutlineColor(Color.Lerp(Color.black, Color.red, ratio)); setOriginalParticlesPosition(); yield return(null); } playerDirectionRight = GameManager.player.GetComponent <Rigidbody>().worldCenterOfMass - rightClawParticles.transform.position; playerDirectionLeft = GameManager.player.GetComponent <Rigidbody>().worldCenterOfMass - leftClawParticles.transform.position; Vector3 particlesMovementRight = playerDirectionRight.normalized * speed; Vector3 particlesMovementLeft = playerDirectionLeft.normalized * speed; iaAnimator.SetBool("isChargingBaseAttack", false); timer = 0f; while (timer < timeItLasts) { timer += Time.deltaTime; leftClawParticles.transform.position += particlesMovementLeft * Time.deltaTime; rightClawParticles.transform.position += particlesMovementRight * Time.deltaTime; yield return(null); } setParticles(false); outlineChanger.setOutlineColor(Color.black); isFinished = true; interrupted = false; }
private IEnumerator doAttack() { //Charge attack playerOriginalPosition = GameManager.player.GetComponent <Rigidbody> ().worldCenterOfMass; float timer = 0f; while (timer <= timeToChargeAttack) { timer += Time.deltaTime; float ratio = timer / timeToChargeAttack; outlineChanger.setOutlineColor(Color.Lerp(Color.black, Color.red, ratio)); yield return(null); } //Throw banana outlineChanger.setOutlineColor(Color.black); GameObject banana = GameObject.Instantiate(bananaPrefab); //Finishs banana.transform.position = parent.GetComponent <Rigidbody>().worldCenterOfMass; Vector3 direction = playerOriginalPosition - transform.position; float forwardSpeed = (Random.value * (maxBananaSpeed - minBananaSpeed)) + minBananaSpeed; float distance = Vector3.Distance(banana.transform.position, playerOriginalPosition); float timeToImpact = distance / forwardSpeed; float upSpeed = (bananaGravity * timeToImpact) / 2f; //Minimo 45 grados if (upSpeed < forwardSpeed) { upSpeed = forwardSpeed; } Vector3 throwDirection = (direction.normalized * forwardSpeed) + (parent.transform.up * upSpeed); banana.GetComponent <Banana> ().setParameters(throwDirection, parent.transform.up * -bananaGravity, this); isFinished = true; yield return(null); }
public override void interruptAttack() { interrupted = true; outlineChanger.setOutlineColor(Color.black); }
IEnumerator doAttack() { float timer = 0f; iaAnimator.SetBool("isChargingBallAttack", true); while (timer < timeToCharge) { timer += Time.deltaTime; float ratio = timer / timeToCharge; outlineChanger.setOutlineColor(Color.Lerp(Color.black, Color.red, ratio)); yield return(null); } iaAnimator.SetBool("isChargingBallAttack", false); for (int i = 0; i < numBalls; i++) { Vector3 ballPosition; float direction = 0f; if (i % 2 == 0) { ballPosition = transform.position; direction = 1f; } else { ballPosition = backSpawningGO.transform.position; direction = -1f; } particlesSpawnBallOfDeath.transform.localScale = new Vector3(0f, 0f, 0f); particlesSpawnBallOfDeath.SetActive(true); particlesSpawnBallOfDeath.transform.position = ballPosition; timer = 0f; while (timer < timeToCharge) { timer += Time.deltaTime; float ratio = timer / timeToCharge; float proportionScale = ratio * maxScaleSummoningParticles; particlesSpawnBallOfDeath.transform.localScale = new Vector3(proportionScale, proportionScale, proportionScale); yield return(null); } //We create a new instance because there can be multiple ocurrences at the same time GameObject ballOfDeathInstance = GameObject.Instantiate(ballOfDeath) as GameObject; ballOfDeathInstance.transform.position = ballPosition; ballOfDeathInstance.GetComponent <BallOfDeath> ().setDirectionAndDamage(direction, damage, particlesSpawnBallOfDeath); particlesSpawnBallOfDeath.SetActive(false); timer = 0f; while (timer < timeToSummonBall) { timer += Time.deltaTime; yield return(null); } } iaAnimator.SetTrigger("isBallOfDeathAttackFinished"); outlineChanger.setOutlineColor(Color.black); isFinished = true; interrupted = false; }