示例#1
0
    void DashToPlayer(bool isStateMachine = false)
    {
        Vector3 _dir = (Player.position - transform.position).normalized;

        _dir.y = 0;
        Quaternion endRot = Quaternion.LookRotation(_dir);

        if (isStateMachine)
        {
            _dir   = (lastPos + transform.forward - transform.position);
            _dir.y = 0;
            endRot = Quaternion.LookRotation(_dir);

            transform.rotation  = endRot;
            transform.position += transform.forward * Time.deltaTime * 15;
            if (Vector3.Distance(transform.position, lastPos + transform.forward) < 0.5f || Vector3.Distance(transform.position, Player.position) < 0.5f)
            {
                States = DeshStates.SHAKE;
            }
        }
        if (!isStateMachine && Vector3.Distance(transform.position, Player.position) > rangeOffset)
        {
            //if the player is not so close to the AI, move the AI to the player
            transform.rotation  = endRot;
            transform.position += transform.forward * Time.deltaTime * 2;
        }
        else if (!hasRolled)
        {
            Time.timeScale = 0;
        }
    }
示例#2
0
 void ChangeState(float timeBeforeStateChange, DeshStates nextState)
 {
     if (gameTime > timeBeforeStateChange)
     {
         States = nextState;
         gameTime = 0;
     }
 }
示例#3
0
 void ChangeState(float timeBeforeStateChange, DeshStates nextState)
 {
     if (gameTime > timeBeforeStateChange)
     {
         States   = nextState;
         gameTime = 0;
     }
 }
示例#4
0
 void OnCollisionEnter(Collision col)
 {
     if (col.collider.CompareTag("dagger"))
     {
         States = DeshStates.HIT;
         healthAI--;
     }
 }
示例#5
0
    void DashToPlayer()
    {
        Vector3 _dir = (player.position - transform.position).normalized;

        _dir.y = 0;
        Quaternion endRot = Quaternion.LookRotation(_dir);

        _dir   = (lastPos + transform.forward - transform.position);
        _dir.y = 0;
        endRot = Quaternion.LookRotation(_dir);

        transform.rotation  = endRot;
        transform.position += transform.forward * Time.deltaTime * speedAI * 5;
        if (Vector3.Distance(transform.position, lastPos + transform.forward) < 0.5f || Vector3.Distance(transform.position, player.position) < 0.5f)
        {
            States = DeshStates.SHAKE;
        }
    }
示例#6
0
    protected override void ActivateAbility()
    {
        //triggers when the player is within range of the AI
        Debug.Log("Desh health = " + healthAI);
        ExclamationUI.enabled = true;
        gameTime += Time.deltaTime;
        switch (States)
        {
        case DeshStates.SHAKE:
            _deshAnim.Play("DeshTallSHAKE");
            lastPos = player.position;
            ChangeState(3f, DeshStates.DESH);
            break;

        case DeshStates.DESH:
            _deshAnim.Play("DeshTallWALK");
            DashToPlayer();
            ChangeState(2f, DeshStates.SHAKE);
            break;

        case DeshStates.HIT:
            _deshAnim.Play("DeshTallHIT");
            ChangeState(1f, DeshStates.SHAKE);
            break;

        case DeshStates.DEATH:
            //kill the desh
            if (!gameObject.GetComponent <Collider>().isTrigger)
            {
                deshSound.Play();
                gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
                gameObject.GetComponent <Collider>().isTrigger    = true;
            }
            break;
        }
        if (healthAI < 1)
        {
            States = DeshStates.DEATH;
            ExclamationUI.enabled = false;
        }
    }
示例#7
0
    protected override void ActivateAbility()
    {
        //triggers when the player is within range of the AI
        Debug.Log("Desh health = " + healthAI);
        ExclamationUI.enabled = true;
        gameTime += Time.deltaTime;
        switch(States)
        {
            case DeshStates.SHAKE:
                _deshAnim.Play("DeshTallSHAKE");
                lastPos = player.position;
                ChangeState(3f, DeshStates.DESH);
                break;
            case DeshStates.DESH:
                _deshAnim.Play("DeshTallWALK");
                DashToPlayer();
                ChangeState(2f, DeshStates.SHAKE);
                break;
            case DeshStates.HIT:
                _deshAnim.Play("DeshTallHIT");
                ChangeState(1f, DeshStates.SHAKE);
                break;
            case DeshStates.DEATH:
                //kill the desh
                if(!gameObject.GetComponent<Collider>().isTrigger)
                {
                    deshSound.Play();
                    gameObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
                    gameObject.GetComponent<Collider>().isTrigger = true;
                }
                break;

        }
        if(healthAI <1)
        {
            States = DeshStates.DEATH;
            ExclamationUI.enabled = false;
        }
    }
示例#8
0
 void DashToPlayer(bool isStateMachine = false)
 {
     Vector3 _dir = (Player.position - transform.position).normalized;
     _dir.y = 0;
     Quaternion endRot = Quaternion.LookRotation(_dir);
     if(isStateMachine)
     {
         _dir = (lastPos+transform.forward - transform.position);
         _dir.y = 0;
         endRot = Quaternion.LookRotation(_dir);
       
         transform.rotation = endRot;
         transform.position += transform.forward * Time.deltaTime * 15;
         if (Vector3.Distance(transform.position,lastPos + transform.forward) < 0.5f || Vector3.Distance(transform.position,Player.position) < 0.5f)
         {
             States = DeshStates.SHAKE;
         }
     }
     if (!isStateMachine && Vector3.Distance(transform.position, Player.position) > rangeOffset)
     {
         //if the player is not so close to the AI, move the AI to the player
         transform.rotation = endRot;
         transform.position += transform.forward * Time.deltaTime * 2;
     }
     else if (!hasRolled)
     {
         Time.timeScale = 0;
     }
   
 }
示例#9
0
    void DashToPlayer()
    {
        Vector3 _dir = (player.position - transform.position).normalized;
        _dir.y = 0;
        Quaternion endRot = Quaternion.LookRotation(_dir);
        _dir = (lastPos + transform.forward - transform.position);
        _dir.y = 0;
        endRot = Quaternion.LookRotation(_dir);

        transform.rotation = endRot;
        transform.position += transform.forward * Time.deltaTime * speedAI*5;
        if (Vector3.Distance(transform.position, lastPos + transform.forward) < 0.5f || Vector3.Distance(transform.position, player.position) < 0.5f)
        {
            States = DeshStates.SHAKE;
        }

    }
示例#10
0
 void OnCollisionEnter(Collision col)
 {
     if(col.collider.CompareTag("dagger"))
     {
         States = DeshStates.HIT;
         healthAI--;
     }
 }