// Start is called before the first frame update void Start() { ctrl_boss = FindObjectOfType <BossScript>(); ctrl_Player = FindObjectOfType <CharacterController2D>(); ctrl_enemy = FindObjectOfType <EnemyMelee>(); ctrl_ShootingEnemy = FindObjectOfType <ShootingEnemy>(); ctrl_flierEnemy = FindObjectOfType <FlierEnemy>(); spriteRenderer = GetComponent <SpriteRenderer>(); }
// Delete this method if you are implementing this script into your own game // It's way too specific public void MultiplyStats(Transform enemy) { enemy.GetComponent <EnemyAI>().speed += enemy.GetComponent <EnemyAI>().speed *multiplier / 10f; EnemyMaster em = enemy.GetComponent <EnemyMaster>(); em.health = (int)(em.health * multiplier); em.moneyReward = (int)(em.moneyReward * multiplier); EnemyMelee melee = enemy.GetComponent <EnemyMelee>(); if (melee != null) { melee.damage = (int)(melee.damage * multiplier); melee.hitRate = (multiplier); } }
//Weapon Prefab //Initialization void Awake() { renderer = GetComponent <SpriteRenderer>(); collider = GetComponent <BoxCollider2D>(); rigidbody = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); controls = GetComponent <EnemyControllerAI>(); status = GetComponent <EnemyStatus>(); melee = GetComponentInChildren <EnemyMelee>(); //camera = GetComponentInChildren<PlayerCamera>(); if (controls != null) { controls.self = this; } if (status != null) { status.self = this; } }
protected override IEnumerator Attacking() { isAttacking = true; agent.updateRotation = true; List <Move> availableAttacks = GetAvailableMoves(); if (availableAttacks.Count > 0) { //choose random attack currentMove = availableAttacks[Random.Range(0, availableAttacks.Count)]; battleManager.CurrentMove = currentMove; Vector3 startPos = transform.position; Quaternion startRot = transform.rotation; EnemyMelee melee = currentMove as EnemyMelee; EnemySelfBuff selfBuff = currentMove as EnemySelfBuff; EnemySpell spell = currentMove as EnemySpell; SpellProjectile projectile = null; if (melee) { hurtbox.enabled = false; agent.SetDestination(player.GetAttackPosition().position); agent.stoppingDistance = attackPositionOffset; yield return(new WaitUntil(() => !agent.pathPending)); yield return(new WaitUntil(() => agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance <= attackPositionOffset)); } animator.SetTrigger(currentMove.animationName); if (melee) { if (melee.hitboxDelay > 0) { StartCoroutine(HandleHitbox(melee)); } else { hitboxes[melee.hitboxID].enabled = true; } } yield return(new WaitUntil(() => animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains(currentMove.animationName))); PayForAttack(); if (spell != null) { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(player.transform.position - transform.position), Time.deltaTime); for (int i = 0; i < spell.projectile.Length; i++) { yield return(new WaitForSeconds(spell.delay[i])); projectile = Instantiate(spell.projectile[i], spellSpawnTransforms[spell.spawnTransformID].position, transform.rotation, transform); projectile.LockOnTarget(player.GetProjectileTarget()); } } if (selfBuff != null) { perks.Add(selfBuff.buff); } yield return(new WaitUntil(() => !animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains(currentMove.animationName))); if (melee != null) { agent.SetDestination(startPos); agent.stoppingDistance = 0f; hitboxes[melee.hitboxID].enabled = false; yield return(new WaitUntil(() => !agent.pathPending)); yield return(new WaitUntil(() => agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance == 0)); hurtbox.enabled = true; while (transform.rotation != startRot) { transform.rotation = Quaternion.RotateTowards(transform.rotation, startRot, 10f); yield return(null); } } yield return(new WaitUntil(() => projectile == null)); } yield return(base.Attacking()); }
private IEnumerator HandleHitbox(EnemyMelee melee) { yield return(new WaitForSeconds(melee.hitboxDelay)); hitboxes[melee.hitboxID].enabled = true; }