public void DamagePlatform() { if (targetPlatform != null) { targetPlatform.TakeDamage(); targetPlatform = null; } }
private void UpdatePhase2() { if (roarHatchlingsTimer > roarHatchlingsCooldown && globalTimer > globalCooldown) { roarHatchlingsTimer = Random.Range(0.0f, 10.0f); attacking = true; animator.SetTrigger("RoarHatchlings"); audioPlayer.clip = roarSound; audioPlayer.Play(); Invoke("ResetAttack", roarHatchlingsClip.length); } else if (breathTimer > breathCooldown && globalTimer > globalCooldown) { playerHit = true; breathTimer = Random.Range(0.0f, 5.0f); CavePlatformController platform = GetClosestPlatformToPlayer(); if (platform != null) { attacking = true; audioPlayer.clip = breathSound; audioPlayer.PlayDelayed(1.0f); if (platform.GetCaveSide() == CaveSide.Left || (platform.GetCaveSide() == CaveSide.Middle && Random.Range(0, 2) == 0)) { animator.SetTrigger("BreathLeft"); Invoke("ResetAttack", breathLeftClip.length / breathSpeedMultiplier); } else { animator.SetTrigger("BreathRight"); Invoke("ResetAttack", breathRightClip.length / breathSpeedMultiplier); } } } else if (roarRocksTimer > roarRocksCooldown && globalTimer > globalCooldown) { roarRocksTimer = Random.Range(0.0f, 2.5f); attacking = true; animator.SetTrigger("RoarRocks"); audioPlayer.clip = roarSound; audioPlayer.Play(); Invoke("ResetAttack", roarBouldersClip.length); } else if (smashTimer > smashCooldown && globalTimer > globalCooldown) { SmashAttack(false); } else { TurnTowardsPlayer(60.0f); } }
private void SmashAttack(bool chainAttack) { smashTimer = 0.0f; targetPlatform = GetClosestPlatformToPlayer(); if (targetPlatform != null) { smashCounter++; playerHit = false; attacking = true; smashing = true; if (chainAttack && lastSmashLeft) { lastSmashLeft = false; caveAbilities.SetTargetPlatform(targetPlatform); animator.SetTrigger("SmashRight"); Invoke("ResetAttack", smashRightClip.length / smashSpeedMultiplier); } else if (chainAttack && !lastSmashLeft) { lastSmashLeft = true; caveAbilities.SetTargetPlatform(targetPlatform); animator.SetTrigger("SmashLeft"); Invoke("ResetAttack", smashLeftClip.length / smashSpeedMultiplier); } else { if (Random.Range(0, 2) == 0) { lastSmashLeft = true; caveAbilities.SetTargetPlatform(targetPlatform); animator.SetTrigger("SmashLeft"); Invoke("ResetAttack", smashLeftClip.length / smashSpeedMultiplier); } else { lastSmashLeft = false; caveAbilities.SetTargetPlatform(targetPlatform); animator.SetTrigger("SmashRight"); Invoke("ResetAttack", smashRightClip.length / smashSpeedMultiplier); } } if (smashCounter < maxConsecutiveSmashes && Random.Range(0.0f, 1.0f) < 0.6f) { repeatSmash = true; } else { repeatSmash = false; smashCounter = 0; } } }
private CavePlatformController GetClosestPlatformToPlayer() { float shortestDistance = float.MaxValue; CavePlatformController result = null; foreach (CavePlatformController platform in cavePlatforms) { if (!platform.IsActive()) { continue; } Vector3 platformCenter = platform.GetCenterPoint(); float currentDistance = Vector3.Distance(player.position, platformCenter); if (currentDistance < shortestDistance) { shortestDistance = currentDistance; result = platform; } } return(result); }
public void SetTargetPlatform(CavePlatformController platform) { targetPlatform = platform; }