Exemplo n.º 1
0
 private void Start()
 {
     walkSet      = false;
     runSet       = false;
     target       = GameObject.FindGameObjectWithTag("Player");
     man          = target.GetComponent <Manager>();
     currentState = ZStates.IDLE;
     inAnimation  = false;
     hitbox.SetActive(false);
     notstartedDie = true;
     man           = target.GetComponent <Manager>();
 }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (!inAnimation)
     {
         currentState = setState();
     }
     if (health <= 0 && notstartedDie)
     {
         ResetBools();
         currentState = ZStates.DIE;
         inAnimation  = true;
         StartCoroutine("die");
     }
     else
     {
         if (currentState == ZStates.IDLE)
         {
             ResetBools();
             agent.ResetPath();
             ani.SetTrigger("ReturnToIdle");
         }
         else if (currentState == ZStates.ATTACK && !inAnimation)
         {
             ResetBools();
             inAnimation = true;
             StartCoroutine("attack");
         }
         else
         {
             agent.SetDestination(target.transform.position);
             if (currentState == ZStates.WALK)
             {
                 if (!walkSet)
                 {
                     ani.SetBool("IsWalking", true);
                     walkSet = true;
                 }
             }
             else if (currentState == ZStates.RUN)
             {
                 if (!runSet)
                 {
                     ani.SetBool("IsRunning", true);
                     runSet = true;
                 }
             }
         }
     }
 }
    public void run()
    {
        if (current_state == ZStates.q0)
        {
            if (str[position] == '0')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '0';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '1')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '1';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '2')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '2';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '3')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '3';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '4')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '4';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '5')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '5';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '6')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '6';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '7')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '7';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '8')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '8';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '9')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '9';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '+')
            {
                current_state   = ZStates.q0;
                moveCurrent     = zMovement.R;
                replaceChar     = '+';
                positionCurrent = position;
                position        = position + 1;
            }

            else if (str[position] == 'Δ')
            {
                current_state   = ZStates.q1;
                moveCurrent     = zMovement.L;
                replaceChar     = 'Δ';
                positionCurrent = position;
                position        = position - 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q1)
        {
            if (str[position] == '0')
            {
                current_state   = ZStates.q1;
                moveCurrent     = zMovement.L;
                replaceChar     = '0';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == 'x')
            {
                current_state   = ZStates.q1;
                moveCurrent     = zMovement.L;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == '+')
            {
                current_state   = ZStates.q1;
                moveCurrent     = zMovement.L;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position - 1;
            }

            else if (str[position] == '1')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '0';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '2')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '1';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '3')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '2';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '4')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '3';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '5')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '4';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '6')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '5';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '7')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '6';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '8')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '7';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '9')
            {
                current_state   = ZStates.q2;
                moveCurrent     = zMovement.R;
                replaceChar     = '8';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'Δ')
            {
                current_state   = ZStates.q5;
                moveCurrent     = zMovement.R;
                replaceChar     = 'Δ';
                positionCurrent = position;
                position        = position + 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q2)
        {
            if (str[position] == 'x')
            {
                current_state   = ZStates.q3;
                moveCurrent     = zMovement.R;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'Δ')
            {
                current_state   = ZStates.q3;
                moveCurrent     = zMovement.R;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position + 1;
            }

            else if (str[position] == '0')
            {
                current_state   = ZStates.q1;
                moveCurrent     = zMovement.R;
                replaceChar     = '9';
                positionCurrent = position;
                position        = position + 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q3)
        {
            if (str[position] == 'x')
            {
                current_state   = ZStates.q3;
                moveCurrent     = zMovement.R;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'y')
            {
                current_state   = ZStates.q3;
                moveCurrent     = zMovement.R;
                replaceChar     = 'y';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '0')
            {
                current_state   = ZStates.q3;
                moveCurrent     = zMovement.R;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'Δ')
            {
                current_state   = ZStates.q4;
                moveCurrent     = zMovement.L;
                replaceChar     = 'y';
                positionCurrent = position;
                position        = position - 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q4)
        {
            if (str[position] == 'y')
            {
                current_state   = ZStates.q4;
                moveCurrent     = zMovement.L;
                replaceChar     = 'y';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == 'x')
            {
                current_state   = ZStates.q1;
                moveCurrent     = zMovement.L;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position - 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q5)
        {
            if (str[position] == '0')
            {
                current_state   = ZStates.q5;
                moveCurrent     = zMovement.R;
                replaceChar     = 'Δ';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'x')
            {
                current_state   = ZStates.q5;
                moveCurrent     = zMovement.R;
                replaceChar     = 'Δ';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'y')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.S;
                replaceChar     = 'y';
                positionCurrent = position;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q6)
        {
            if (str[position] == '0')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '0';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '1')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '1';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '2')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '2';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '3')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '3';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '4')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '4';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '5')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '5';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '6')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '6';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '7')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '7';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '8')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '8';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '9')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '9';
                positionCurrent = position;
                position        = position + 1;
            }

            else if (str[position] == 'Δ')
            {
                current_state   = ZStates.q8;
                moveCurrent     = zMovement.L;
                replaceChar     = 'Δ';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == 'y')
            {
                current_state   = ZStates.q7;
                moveCurrent     = zMovement.L;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == 'x')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position + 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        else if (current_state == ZStates.q7)
        {
            if (str[position] == 'x')
            {
                current_state   = ZStates.q7;
                moveCurrent     = zMovement.L;
                replaceChar     = 'x';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == '9')
            {
                current_state   = ZStates.q7;
                moveCurrent     = zMovement.L;
                replaceChar     = '0';
                positionCurrent = position;
                position        = position - 1;
            }

            else if (str[position] == '0')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '1';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '1')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '2';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '2')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '3';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '3')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '4';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '4')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '5';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '5')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '6';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '6')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '7';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '7')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '8';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == '8')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '9';
                positionCurrent = position;
                position        = position + 1;
            }
            else if (str[position] == 'Δ')
            {
                current_state   = ZStates.q6;
                moveCurrent     = zMovement.R;
                replaceChar     = '1';
                positionCurrent = position;
                position        = position + 1;
            }
            else
            {
                current_state = ZStates.ha;
                moveCurrent   = zMovement.H;
            }
        }
        if (current_state == ZStates.q8)
        {
            if (str[position] == 'x')
            {
                current_state   = ZStates.q8;
                moveCurrent     = zMovement.L;
                replaceChar     = 'Δ';
                positionCurrent = position;
                position        = position - 1;
            }
            else if (str[position] == '0')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '0';
                positionCurrent = position;
            }
            else if (str[position] == '1')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '1';
                positionCurrent = position;
            }
            else if (str[position] == '2')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '2';
                positionCurrent = position;
            }
            else if (str[position] == '3')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '3';
                positionCurrent = position;
            }
            else if (str[position] == '4')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '4';
                positionCurrent = position;
            }
            else if (str[position] == '5')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '5';
                positionCurrent = position;
            }
            else if (str[position] == '6')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '6';
                positionCurrent = position;
            }
            else if (str[position] == '7')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '7';
                positionCurrent = position;
            }
            else if (str[position] == '8')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '8';
                positionCurrent = position;
            }
            else if (str[position] == '9')
            {
                current_state   = ZStates.q9;
                moveCurrent     = zMovement.H;
                replaceChar     = '9';
                positionCurrent = position;
            }
        }
        else if (current_state == ZStates.q9)
        {
            current_state = ZStates.q9;
            moveCurrent   = zMovement.H;
        }
    }
Exemplo n.º 4
0
 public void ChangeState(ZStates newState) //Changes state from current state to newState
 {
     currentState = newState;
 }