void PrepareTeleport() { if (!isCasting && !isRagdolling && player != null) { preparedSpell = EnemySpell.teleport; Vector3 targetPosition = transform.position; float r = 20; float theta = Random.Range(0, Mathf.PI * 2); targetPosition.x += r * Mathf.Cos(theta); targetPosition.z += r * Mathf.Sin(theta); // currentTargetPosition = targetPosition; Vector3 origin = transform.position + Vector3.up * 1.5f; Vector3 direction = targetPosition - origin; RaycastHit hit; if (Physics.Raycast(origin, direction, out hit, Vector3.Distance(targetPosition, origin), sightObstacleMask)) { currentTargetPosition = hit.point; } else { currentTargetPosition = targetPosition; } StartPrepareAnimation("spell line ud"); } }
void PrepareShield() { if (!isCasting && !isRagdolling && player != null && shieldPrefab) { currentTargetPosition = player.transform.position; preparedSpell = EnemySpell.shield; StartPrepareAnimation("spell circle cw"); } }
protected virtual IEnumerator Shoot(Vector2 direction) { attackable = false; EnemySpell spell = Instantiate(spellPrefab, transform.position, transform.rotation) as EnemySpell; spell.MyDirection = direction; spell.MyDamage = damage; yield return(new WaitForSeconds(attackInterval)); attackable = true; }
protected override IEnumerator Shoot() { attack2 = false; EnemySpell spell = Instantiate(spellPrefab, transform.position, transform.rotation) as EnemySpell; spell.MyDirection = Player.MyInstance.transform.position - spell.transform.position; spell.MyDamage = damage; yield return(new WaitForSeconds(0.5f)); spell = Instantiate(spellPrefab, transform.position, transform.rotation) as EnemySpell; spell.MyDirection = Player.MyInstance.transform.position - spell.transform.position; spell.MyDamage = damage; }
void PrepareAttack() { currentTargetPosition = player.transform.position; if (!isCasting && !isRagdolling && player != null && projectilePrefab) { var projStartPos = transform.position + Vector3.up * projectileSpawnHeight; var currentFireAngle = GetAttackAngle(); // Only fire if AI is within range if (!float.IsNaN(currentFireAngle)) { preparedSpell = EnemySpell.attack; StartPrepareAnimation("spell fish r"); } } }
protected virtual IEnumerator Shoot(float x, float y) { attackable = false; EnemySpell spell = Instantiate(spellPrefab, transform.position, transform.rotation) as EnemySpell; Vector2 tDirection; tDirection = Player.MyInstance.transform.position - spell.transform.position; tDirection.x += x; tDirection.y += y; spell.MyDirection = tDirection; spell.MyDamage = damage; yield return(new WaitForSeconds(attackInterval)); attackable = true; }
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()); }