// Use this for initialization void Start() { enemyTrash = transform.gameObject.GetComponentInParent <EnemyTrash>(); if (enemyTrash.anim != null) { switch (enemyTrash.behaviour) { case EnemyBehaviour.EB_DEFAULT: if (enemyTrash.nav != null) { enemyTrash.nav.Stop(); } enemyTrash.anim.SetBool("iddle", true); enemyTrash.anim.SetBool("chase", false); break; case EnemyBehaviour.EB_ARTILLERY: artillery = GameObject.FindGameObjectWithTag("EventTarget").GetComponent <ArtilleryController>(); if (artillery != null) { enemyTrash.ChangeTarget(artillery.transform, TargetType.TT_ARTILLERY); enemyTrash.anim.SetBool("chase", true); enemyTrash.anim.SetBool("iddle", false); } break; } } }
void Update() { if (capsules.Count > 0) { ManageCapsules(); } if (enemies.Count > 0) { if (!isInRound) { round++; isInRound = true; StartRound(round); } for (int i = 0; i < enemies.Count; i++) { EnemyTrash aux = enemies[i]; if (aux != null) { Debug.Log(aux.GetLife()); if (aux.GetLife() <= 0) { DeleteEnemy(aux); } } } } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemyTrash == null) { enemyTrash = animator.transform.gameObject.GetComponent <EnemyTrash>(); } enemyTrash.DisableSwordEmitter(); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemyTrash == null) { enemyTrash = animator.transform.gameObject.GetComponent <EnemyTrash>(); } enemyTrash.nav.speed = 5; enemyTrash.nav.Resume(); }
void DeleteEnemy(EnemyTrash enemy) { if (enemies.Count == 1) { isInRound = false; EndRound(round); } enemies.Remove(enemy); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemyTrash == null) { enemyTrash = animator.transform.gameObject.GetComponent <EnemyTrash>(); enemyTrash.nav.Stop(); } enemyTrash.GetComponent <CapsuleCollider>().enabled = false; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemyTrash == null) { enemyTrash = animator.transform.gameObject.GetComponent <EnemyTrash>(); } enemyTrash.ChangeAttack("Attack"); animator.ResetTrigger("attack"); enemyTrash.nav.Stop(); }
public void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("EnemyAttack") && alive) { EnemyTrash trashScript = other.gameObject.GetComponentInParent <EnemyTrash>(); Attack currentAttackReceived = trashScript.GetAttack(); if (currentAttackReceived != null) { TakeDamage(currentAttackReceived.damage); } } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemyTrash == null) { enemyTrash = animator.transform.gameObject.GetComponent <EnemyTrash>(); } if (playerDetection == null) { playerDetection = animator.transform.gameObject.GetComponentInChildren <PlayerDetection>(); artilleryRadius = playerDetection.artillery.GetComponent <CapsuleCollider>().radius; } animator.ResetTrigger("attackArtillery"); enemyTrash.ChangeAttack("Attack"); enemyTrash.nav.Stop(); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemyTrash == null) { enemyTrash = animator.transform.gameObject.GetComponent <EnemyTrash>(); enemyTrash.nav.Stop(); } int num = Random.Range(0, 2); if (num == 0) { rotationDirection = Vector3.up; } else { rotationDirection = Vector3.down; } moveAroundDuration = Random.Range(1.0f, 3.0f); startTime = Time.time; enemyTrash.transform.RotateAround(enemyTrash.GetTarget().transf.position, rotationDirection, enemyTrash.combatAngularSpeed * Time.deltaTime); }
public void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("Interactable")) { Interactable interactable = other.gameObject.GetComponent <Interactable>(); if (interactable != null && interactable.CanInteract()) { canInteract = true; } } else if (other.gameObject.layer == LayerMask.NameToLayer("EnemyAttack")) { EnemyTrash trashScript = other.gameObject.GetComponentInParent <EnemyTrash>(); Attack currentAttackReceived = trashScript.GetAttack(); if (currentAttackReceived != null) { if (anim.GetCurrentAnimatorStateInfo(0).IsName("Damaged") == false && anim.GetCurrentAnimatorStateInfo(0).IsName("Block") == false && anim.GetCurrentAnimatorStateInfo(0).IsName("Die") == false) { SpawnHitParticles(other.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position)); AudioSources.instance.PlaySound((int)AudiosSoundFX.Enemy_Combat_AttackHit); TakeDamage(currentAttackReceived.damage); anim.SetTrigger("damaged"); } else if (anim.GetCurrentAnimatorStateInfo(0).IsName("Block") == true) { AudioSources.instance.PlaySound((int)AudiosSoundFX.Player_Combat_BlockAttack); } } } else if (other.gameObject.layer == LayerMask.NameToLayer("BossAttack")) { bool canReceiveBossAttack = true; if (anim.GetCurrentAnimatorStateInfo(0).IsName("Damaged") == true || anim.GetCurrentAnimatorStateInfo(0).IsName("Die") == true) { canReceiveBossAttack = false;; } else { if (other.name == "Ray") { Vector3 playerLeftForward = transform.forward - transform.right; if (anim.GetCurrentAnimatorStateInfo(0).IsName("Block") == true && Vector3.Dot(playerLeftForward, other.transform.parent.forward) < 0.2f) { AudioSources.instance.PlaySound((int)AudiosSoundFX.Player_Combat_BlockAttack); canReceiveBossAttack = false; } } if (other.name == "ArmCollider") { //hurts you anyway } } if (canReceiveBossAttack) { blocking = false; SpawnHitParticles(other.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position)); AudioSources.instance.PlaySound((int)AudiosSoundFX.Enemy_Combat_AttackHit); TakeDamage(30); anim.SetTrigger("damaged"); } } }