//Changes the behaviour of the enemy depending on the state of it's surroundings private void changeBehaviour() { if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and charging attack timers if (isDoingMeleeAttack) { meleeAttackTimer = 0f; isDoingMeleeAttack = false; } if (isSliding) { slideTimer = 0f; isSliding = false; } if (getPlayerDistance() > maxDistancePlayer) { actualBehaviour = ActualBehaviour.Idle; } else { //If it's far away it slides, if it's close it does the whirlwind attack if (getPlayerDistance() > minDistanceMeleeAttack) { if (slideTimer > slideCooldown) { slideTimer = 0f; if (Random.value <= chanceToSlide) { actualBehaviour = ActualBehaviour.Sliding; } else { actualBehaviour = ActualBehaviour.Idle; } } else { actualBehaviour = ActualBehaviour.Idle; } } else if (meleeAttackTimer > meleeAttackCooldown) { meleeAttackTimer = 0f; if (Random.value <= chanceToMeleeAttack) { actualBehaviour = ActualBehaviour.WhirlwindAttack; } else { actualBehaviour = ActualBehaviour.Idle; } } else { actualBehaviour = ActualBehaviour.Idle; } } } }
IEnumerator standUpWithDelay() { yield return(new WaitForSeconds(1f)); isFlying = false; actualBehaviour = ActualBehaviour.GroundStartFlying; GetComponent <CharacterController>().StopMoving(); }
private void doActualBehaviour() { //Does the action that corresponds to the actual behaviour unless it is dead if (!isDead) { if (!attackController.isDoingAnyAttack() && getIsTouchingPlanet()) { if (actualBehaviour.Equals(ActualBehaviour.MeleeAttack)) { if (!attackController.isDoingAnyAttack()) { StopMoving(); lookAtDirection(getPlayerDirection()); if (!attackController.doAttack(frontAttack, false)) { IdleInFrontOfPlayer(); } else { isDoingMeleeAttack = true; } } } else if (actualBehaviour.Equals(ActualBehaviour.ChargeAttack)) { if (!attackController.isDoingAnyAttack()) { StopMoving(); lookAtDirection(getPlayerDirection()); if (!attackController.doAttack(chargeAttack, false)) { actualBehaviour = ActualBehaviour.ChasePlayer; } else { isCharging = true; } } } else if (actualBehaviour.Equals(ActualBehaviour.ChasePlayer)) { if (closestThingInFrontDistance() >= minimumDistanceAttackPlayer) { Move(getPlayerDirection()); } else { StopMoving(); } } else if (actualBehaviour.Equals(ActualBehaviour.Stunned)) { //Do Nothing. StopMoving(); } } } }
protected override bool virtualGetHurt() { GameManager.audioManager.PlayStableSound(10); attackController.interruptActualAttacks(); actualBehaviour = ActualBehaviour.FlyingFalling; iaAnimator.SetBool("isFlying", false); GetComponent <GravityBody> ().setHasToApplyForce(true); preferredHeight = 0f; GameManager.audioManager.PlaySoundDontRepeat(15, 1.0f); return(true); }
private void changeBehaviour() { //Changes the behaviour depending on the conditions of the AI //actualBehaviour = ActualBehaviour.ChargeAttack; if (phase1) { if (getPlayerDistance() >= maxDistanceMeleeAttack) { actualBehaviour = ActualBehaviour.ChasePlayer; } else { actualBehaviour = ActualBehaviour.MeleeAttack; } timeInPhase1 += Time.deltaTime; if (timeInPhase1 >= phase1Duration) { timeInPhase1 = 0; phase1 = false; stunned = false; phase2 = true; } } else if (phase2) { actualBehaviour = ActualBehaviour.ChargeAttack; timeInPhase2 += Time.deltaTime; //Debug.Log (timeInPhase2); if (timeInPhase2 >= 6.5f) { timeInPhase2 = 0; phase1 = false; stunned = true; phase2 = false; } } else if (stunned) { actualBehaviour = ActualBehaviour.Stunned; timeStunned += Time.deltaTime; //Debug.Log (timeStunned); if (timeStunned >= stunDuration) { timeStunned = 0; phase1 = true; phase2 = false; stunned = false; } } }
private void changeBehaviour() { //Changes the behaviour depending on the conditions of the AI if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and charging attack timers if(isDoingMeleeAttack){meleeAttackTimer = 0f; isDoingMeleeAttack=false;} if(isCharging){chargeAttackTimer = 0f; isCharging = false;} } if(!canSeePlayer()){ actualBehaviour = ActualBehaviour.ChasePlayer; }else{ if(getPlayerDistance()>=maxDistancePlayer){ actualBehaviour = ActualBehaviour.ChasePlayer; } if(getPlayerDistance()<=maxDistanceMeleeAttack){ //Is at melee range if(meleeAttackTimer>meleeAttackCooldown){ meleeAttackTimer = 0f; if(Random.value<=chanceToAttackMelee){ actualBehaviour = ActualBehaviour.MeleeAttack; }else{ actualBehaviour = ActualBehaviour.OffensiveIdle; } }else{ actualBehaviour = ActualBehaviour.OffensiveIdle; } }else if(getPlayerDistance()<=maxDistanceCharge){ //Is farther away if(chargeAttackTimer>chargeAttackCooldown){ chargeAttackTimer = 0f; if(Random.value<=chanceToCharge){ actualBehaviour = ActualBehaviour.ChargeAttack; }else{ actualBehaviour = ActualBehaviour.ChasePlayer; } }else{ actualBehaviour = ActualBehaviour.ChasePlayer; } }else{ actualBehaviour = ActualBehaviour.ChasePlayer; } } }
protected override void initialize() { collider = GetComponent<Collider> (); Attack rangedAttackA = attackController.getAttack(rangedAttack); rangedAttackA.informParent(gameObject); Attack meleeAttackA = attackController.getAttack(meleeAttack); meleeAttackA.informParent(gameObject); Attack appearAttackA = attackController.getAttack(appearAttack); appearAttackA.informParent(gameObject); actualBehaviour = ActualBehaviour.Appear; if(attackController.doAttack(appearAttack,false)){ isDoingAppearAttack = true; } }
//Changes the behaviour of the enemy depending on the state of it's surroundings private void changeBehaviour() { if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and charging attack timers if (isDoingRangedAttack) { rangedAttackTimer = 0f; isDoingRangedAttack = false; } if (isCharging) { rangedAttackTimer = 0f; isCharging = false; } } //Changes the behaviour depending on the conditions of the AI if (getPlayerDistance() < minimumPlayerDistanceForRangedAttack) { actualBehaviour = ActualBehaviour.Escape; } else if (getPlayerDistance() > maximumPlayerDistanceForRangedAttack && canSeePlayer()) { actualBehaviour = ActualBehaviour.ChasePlayer; } else if (canSeePlayer()) { if (rangedAttackTimer > rangedAttackCooldown) { rangedAttackTimer = 0f; if (Random.value <= chanceToRangedAttack) { actualBehaviour = ActualBehaviour.RangedAttack; } else { actualBehaviour = ActualBehaviour.JumpingAround; } } } else { actualBehaviour = ActualBehaviour.Patroling; } }
//Changes the behaviour of the enemy depending on the state of it's surroundings private void changeBehaviour() { if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and charging attack timers if(isDoingMeleeAttack){meleeAttackTimer = 0f; isDoingMeleeAttack=false;} if(isSliding){slideTimer = 0f; isSliding = false;} if(getPlayerDistance()>maxDistancePlayer){ actualBehaviour = ActualBehaviour.Idle; }else{ //If it's far away it slides, if it's close it does the whirlwind attack if(getPlayerDistance()>minDistanceMeleeAttack){ actualBehaviour = ActualBehaviour.Sliding; }else if(meleeAttackTimer>meleeAttackCooldown){ meleeAttackTimer = 0f; actualBehaviour = ActualBehaviour.WhirlwindAttack; }else{ actualBehaviour = ActualBehaviour.Sliding; } } } }
private void changeBehaviour() { //Changes the behaviour depending on the conditions of the AI //actualBehaviour = ActualBehaviour.ChargeAttack; if (phase1) { if (getPlayerDistance () >= maxDistanceMeleeAttack) { actualBehaviour = ActualBehaviour.ChasePlayer; } else { actualBehaviour = ActualBehaviour.MeleeAttack; } timeInPhase1 += Time.deltaTime; if (timeInPhase1 >= phase1Duration) { timeInPhase1 = 0; phase1 = false; stunned = false; phase2 = true; } }else if (phase2) { actualBehaviour = ActualBehaviour.ChargeAttack; timeInPhase2 += Time.deltaTime; //Debug.Log (timeInPhase2); if (timeInPhase2 >= 6.5f){ timeInPhase2 = 0; phase1 = false; stunned = true; phase2 = false; } } else if(stunned) { actualBehaviour = ActualBehaviour.Stunned; timeStunned += Time.deltaTime; //Debug.Log (timeStunned); if (timeStunned >= stunDuration ) { timeStunned = 0; phase1 = true; phase2 = false; stunned = false; } } }
private void changeBehaviour() { if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and flying attack timers if (isDoingMeleeAttack) { meleeAttackTimer = 0f; isDoingMeleeAttack = false; } if (isDoingFlyingAttack) { flyingAttackTimer = 0f; isDoingFlyingAttack = false; } } if (!actualBehaviour.Equals(ActualBehaviour.FlyingFalling)) { if (isFlying) { float playerDistance = getPlayerDistance(); if (playerDistance > closestDistanceAttack && playerDistance < farthestDistanceAttack && (getLookingDirection() == getPlayerDirection()) && missingDistancePreferredHeight < 0.3f) { actualBehaviour = ActualBehaviour.FlyingAttack; if (flyingAttackTimer > flyingAttackCooldown) { flyingAttackTimer = 0f; if (UnityEngine.Random.value <= flyingAttackChance) { actualBehaviour = ActualBehaviour.FlyingAttack; } } } else if (playerDistance > maxDistanceChangeDirection) { actualBehaviour = ActualBehaviour.FlyingChasing; } else { actualBehaviour = ActualBehaviour.FlyingPatroling; } } else { if (getPlayerDistance() <= minDistanceMeleeAttack) { if (meleeAttackTimer > meleeAttackCooldown) { meleeAttackTimer = 0f; if (UnityEngine.Random.value <= meleeAttackChance) { actualBehaviour = ActualBehaviour.GroundAttack; } } else { actualBehaviour = ActualBehaviour.GroundStartFlying; } } else { actualBehaviour = ActualBehaviour.GroundStartFlying; } } } }
private void doActualBehaviour() { //Does the action that corresponds to the actual behaviour unless it is dead if(!isDead){ if(!attackController.isDoingAnyAttack() && getIsTouchingPlanet()){ if(actualBehaviour.Equals(ActualBehaviour.MeleeAttack)){ if(!attackController.isDoingAnyAttack()){ StopMoving(); lookAtDirection(getPlayerDirection()); if(!attackController.doAttack(frontAttack,false)){ IdleInFrontOfPlayer(); }else{ isDoingMeleeAttack = true; } } }else if(actualBehaviour.Equals(ActualBehaviour.ChargeAttack)){ if(!attackController.isDoingAnyAttack()){ StopMoving(); lookAtDirection(getPlayerDirection()); if(!attackController.doAttack(chargeAttack,false)){ actualBehaviour = ActualBehaviour.ChasePlayer; }else{ isCharging = true; } } }else if(actualBehaviour.Equals(ActualBehaviour.ChasePlayer)){ if(closestThingInFrontDistance()>=minimumDistanceAttackPlayer){ Move(getPlayerDirection()); }else{ StopMoving(); } } else if (actualBehaviour.Equals (ActualBehaviour.Stunned)) { //Do Nothing. StopMoving(); } } } }
private void changeBehaviour() { //Changes the behaviour depending on the conditions of the AI if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and charging attack timers if (isDoingMeleeAttack) { meleeAttackTimer = 0f; isDoingMeleeAttack = false; } if (isCharging) { chargeAttackTimer = 0f; isCharging = false; } } if (!canSeePlayer()) { actualBehaviour = ActualBehaviour.ChasePlayer; } else { if (getPlayerDistance() >= maxDistancePlayer) { actualBehaviour = ActualBehaviour.ChasePlayer; } if (getPlayerDistance() <= maxDistanceMeleeAttack) { //Is at melee range if (meleeAttackTimer > meleeAttackCooldown) { meleeAttackTimer = 0f; if (Random.value <= chanceToAttackMelee) { actualBehaviour = ActualBehaviour.MeleeAttack; } else { actualBehaviour = ActualBehaviour.OffensiveIdle; } } else { actualBehaviour = ActualBehaviour.OffensiveIdle; } } else if (getPlayerDistance() <= maxDistanceCharge) { //Is farther away if (chargeAttackTimer > chargeAttackCooldown) { chargeAttackTimer = 0f; if (Random.value <= chanceToCharge) { actualBehaviour = ActualBehaviour.ChargeAttack; } else { actualBehaviour = ActualBehaviour.ChasePlayer; } } else { actualBehaviour = ActualBehaviour.ChasePlayer; } } else { actualBehaviour = ActualBehaviour.ChasePlayer; } } }
private void changeBehaviour() { if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and flying attack timers if(isDoingMeleeAttack){meleeAttackTimer = 0f; isDoingMeleeAttack =false;} if(isDoingFlyingAttack){flyingAttackTimer = 0f; isDoingFlyingAttack = false;} } if(!actualBehaviour.Equals(ActualBehaviour.FlyingFalling)){ if(isFlying){ float playerDistance = getPlayerDistance(); if(playerDistance>closestDistanceAttack && playerDistance<farthestDistanceAttack && (getLookingDirection() == getPlayerDirection()) && missingDistancePreferredHeight<0.3f){ actualBehaviour = ActualBehaviour.FlyingAttack; if(flyingAttackTimer>flyingAttackCooldown){ flyingAttackTimer = 0f; if(UnityEngine.Random.value<=flyingAttackChance){ actualBehaviour = ActualBehaviour.FlyingAttack; } } }else if(playerDistance>maxDistanceChangeDirection){ actualBehaviour = ActualBehaviour.FlyingChasing; }else{ actualBehaviour = ActualBehaviour.FlyingPatroling; } }else{ if(getPlayerDistance()<=minDistanceMeleeAttack){ if(meleeAttackTimer>meleeAttackCooldown){ meleeAttackTimer = 0f; if(UnityEngine.Random.value<=meleeAttackChance){ actualBehaviour = ActualBehaviour.GroundAttack; } }else{ actualBehaviour = ActualBehaviour.GroundStartFlying; } }else{ actualBehaviour = ActualBehaviour.GroundStartFlying; } } } }
private void changeBehaviour() { if (!attackController.isDoingAnyAttack()) { //We check if we have to reset the melee and flying attack timers if(isDoingMeleeAttack){meleeAttackTimer = 0f; isDoingMeleeAttack =false;} if(isDoingRangedAttack){rangedAttackTimer = 0f; isDoingRangedAttack = false;} if(isDoingAppearAttack){appearAttackTimer = 0f; isDoingAppearAttack = false; isFinishedUnhidding = true;} } if (!attackController.isDoingAnyAttack() && isFinishedHidding && isFinishedUnhidding) { if(actualBehaviour.Equals(ActualBehaviour.Hide) && isFinishedHidding){ actualBehaviour = ActualBehaviour.Appear; }else if(getPlayerDistance()>minPlayerDistanceToAttack){ actualBehaviour = ActualBehaviour.Hide; }else{ if(Random.value>0.5f){ actualBehaviour = ActualBehaviour.MeleeAttack; }else{ actualBehaviour = ActualBehaviour.RangedAttack; } } } }
IEnumerator standUpWithDelay() { yield return new WaitForSeconds(1f); isFlying = false; actualBehaviour = ActualBehaviour.GroundStartFlying; GetComponent<CharacterController>().StopMoving(); }
protected override bool virtualGetHurt() { GameManager.audioManager.PlaySound (SoundIDs.E_GENERICHIT,AudioManager.STABLE,AudioManager.ENEMY); attackController.interruptActualAttacks (); actualBehaviour = ActualBehaviour.FlyingFalling; iaAnimator.SetBool ("isFlying",false); GetComponent<GravityBody> ().setHasToApplyForce (true); preferredHeight = 0f; GameManager.audioManager.PlaySound(SoundIDs.E_CRANEHURT,AudioManager.COOLDOWN,AudioManager.ENEMY); return true; }