Ejemplo n.º 1
0
    //THIS IS THE ONLY WAY AN ENEMY SHOULD BE KILLED
    public void KillEnemy(bool forceDestroy = false)
    {
        if (ArcAngle != 360 && CurrentStatus != EnemyBehaviorStatus.ArcRunner)
        {
            director.ReturnAngle(ArcAngle);
            ArcAngle = 360;
        }
        if (myAction != EnemyActions.None)
        {
            switch (myAction)
            {
            case EnemyActions.NormalAttack:
                director.NormalAttackCompleted();
                break;

            case EnemyActions.Special1:
                director.Special1AttackCompleted();
                break;

            default:
                break;
            }
        }

        timesKilled++;
        if (timesKilled >= finishersToKill) //kill enemy with an animation playing
        {
            if (forceDestroy)
            {
                Destroy(gameObject);
            }
            anim.updateMode = AnimatorUpdateMode.UnscaledTime;
            GetEnemyMovementCtrl.enabled = false;
            CurrentStatus = EnemyBehaviorStatus.Dying;

            GetComponent <CapsuleCollider>().enabled = false;
            anim.Play("Death");
            this.enabled = false;
            StartCoroutine(DestroyEnemy());
        }

        //BossComment specific code
        if (etc.MyEnemyType == EnemyType.Boss && (float)(finishersToKill - GetTimesKilled()) / finishersToKill < .34f)
        {
            etc.EnemySkin.material = GetComponent <Enemyhp>().lowRed;
            GetEnemyMovementCtrl.ResumeMovement();
            GetEnemyMovementCtrl.SetLockToGround(true);
            GetComponent <EnemyMovementController>().EnableNavAgent();
        }
        else if (etc.MyEnemyType == EnemyType.Boss && (float)(finishersToKill - GetTimesKilled()) / finishersToKill < .68f)
        {
            StartCoroutine(PutOnFountain());
        }
    }
Ejemplo n.º 2
0
    //Leap Attack for a knight
    IEnumerator PerformSpecial1Attack()
    {
        MovementCtrl.StopMovement();
        MovementCtrl.SetLockToGround(false);
        AI.ChangeStatus(EnemyBehaviorStatus.Attacking);
        AI.ChangeAction(EnemyActions.Special1);
        sword.damage = PlayerDamageValues.Instance.JumpAttackDamage;
        //set animation
        //attack()
        //Animation
        //AI.anim.applyRootMotion = true;

        AI.anim.Play("JumpAttack");

        //AI.anim.transform.localEulerAngles = new Vector3(0, 0, 0);

        GetComponent <EnemyMovementController>().DisableNavAgent();

        // Calculate distance to target
        float target_Distance = Vector3.Distance(transform.position, playerT.position);

        // Calculate the velocity needed to throw the object to the target at specified angle.
        float projectile_Velocity = target_Distance / (Mathf.Sin(2 * firingAngle * Mathf.Deg2Rad) / gravity);

        // Extract the X  Y componenent of the velocity
        float Vx = Mathf.Sqrt(projectile_Velocity) * Mathf.Cos(firingAngle * Mathf.Deg2Rad);
        float Vy = Mathf.Sqrt(projectile_Velocity) * Mathf.Sin(firingAngle * Mathf.Deg2Rad);

        // Calculate flight time.
        float flightDuration = target_Distance / Vx;

        // Rotate projectile to face the target.
        transform.rotation = Quaternion.LookRotation(playerT.position - transform.position);

        float elapse_time = 0;

        GetComponent <CapsuleCollider>().isTrigger = true;

        bool interupted = false;

        while (elapse_time < flightDuration)
        {
            transform.Translate(0, (Vy - (gravity * elapse_time)) * Time.deltaTime, Vx * .8f * Time.deltaTime);

            elapse_time += Time.deltaTime;

            if (AI.GetDirector().IsInterupted(AI.GetCurrentStatus()))
            {
                interupted = true;
                break;
            }

            yield return(null);
        }

        yield return(new WaitForSeconds(.2f));

        GetComponent <CapsuleCollider>().isTrigger = false;

        GetComponent <EnemyMovementController>().EnableNavAgent();
        AI.GetDirector().Special1AttackCompleted();

        AI.ChangeAction(EnemyActions.None);

        MovementCtrl.SetLockToGround(true);

        if (!interupted)
        {
            AI.anim.Play("Idle");
            AI.ChangeStatus(EnemyBehaviorStatus.Waiting);
        }
    }