Exemplo n.º 1
0
    IEnumerator ChangeState(AIstates newState, float t)
    {
        yield return(new WaitForSeconds(t));

        CurrentState = newState;
        isChanging   = false;
    }
Exemplo n.º 2
0
    IEnumerator DelayNextWaypoint(float time, AIstates newstate)
    {
        yield return(new WaitForSeconds(time));

        CurrentState = newstate;
        NextWaypoint();
    }
Exemplo n.º 3
0
    IEnumerator DelayNextWaypoint(float time, AIstates newstate)
    {
        yield return(new WaitForSeconds(time));

        NextWaypoint();
        ChangeState(newstate);
    }
Exemplo n.º 4
0
 public void handleDeath()
 {
     if (States.EnemyHealth.fillAmount <= 0)
     {
         States.RotateToTarget    = false;
         States.AgentAI.isStopped = true;
         _AiStates = AIstates.death;
     }
 }
Exemplo n.º 5
0
 void switchStates()
 {
     Timer -= Time.deltaTime;
     if (Timer < 0)
     {
         myState++;
         if (myState == AIstates.startOver)
         {
             myState = AIstates.wander;
         }
         Timer = StartTimer;
     }
 }
Exemplo n.º 6
0
        public void HandleCloseSight()
        {
            _Close++;
            if (_Close > CloseCOunt)
            {
                _Close = 0;
                if (Dis > Sight || _angle > FOV_Angle)
                {
                    _AiStates = AIstates.far;
                    return;
                }
            }

            RayCastToTarget();
        }
Exemplo n.º 7
0
 public void HandleFarSight()
 {
     if (target == null)
     {
         return;
     }
     _Frame++;
     if (_Frame > frameCount)
     {
         _Frame = 0;
         if (Dis < Sight)
         {
             if (_angle < FOV_Angle)
             {
                 _AiStates = AIstates.close;
             }
         }
     }
 }
Exemplo n.º 8
0
        public void In_Sight()
        {
            States.RotateToTarget = true;
            HandleCoolDown();
            float disToDes = Vector3.Distance(States.TargetDestination, target.position);

            if (disToDes > 2 || Dis > Sight * 0.5)
            {
                GoToTarget();
            }


            if (Dis < 2)
            {
                States.AgentAI.isStopped = true;
            }



            if (_AttackCount > 0)
            {
                _AttackCount--;
                return;
            }
            _AttackCount = AttackCount;


            BossAttacks a = WillAttack();

            if (a != null)
            {
                States.anim.applyRootMotion = true;
                //  States.AgentAI.enabled = false;
                _AiStates = AIstates.Attacking;
                States.anim.Play(a.targetAnim);
                States.CanMove           = false;
                a.cool                   = a.CoolDown;
                States.AgentAI.isStopped = true;
                return;
            }
        }
Exemplo n.º 9
0
        public void RayCastToTarget()
        {
            RaycastHit hit;
            Vector3    Origin = transform.position;

            Origin.y += 0.5f;
            Vector3 dir = DirToTarget;

            dir.y += 0.5f;
            if (Physics.Raycast(Origin, dir, out hit, Sight, States.IgnoreLayers))
            {
                StateManager st = hit.transform.GetComponent <StateManager>();
                if (st != null)
                {
                    States.anim.Play(Standingup);
                    _AiStates             = AIstates.InSight;
                    States.RotateToTarget = true;
                    //   States.SetDestination(target.position);
                }
            }
        }
Exemplo n.º 10
0
        private void Update()
        {
            Delta  = Time.deltaTime;
            Dis    = DistanceFromTarget();
            _angle = AngleTotarget();

            if (target)
            {
                DirToTarget = target.position - transform.position;
            }


            if (Dis > Sight || _angle > FOV_Angle)
            {
                _AiStates = AIstates.far;
                BossHealth.SetActive(false);
                States.anim.Play(Idle);
                States.AgentAI.isStopped = true;
            }

            // checking player pos // updating.
            if (Dis < Sight)
            {
                PLAYERPOS = target.position;
            }

            handleDeath();


            // checking dist is smaller

            if (Vector3.Distance(transform.position, PLAYERPOS) < 1f)
            {
                States.anim.SetFloat(EnemyMove, -1);
            }

            States.DirtoTarget = DirToTarget;

            switch (_AiStates)
            {
            case AIstates.far:
                HandleFarSight();
                break;

            case AIstates.close:
                HandleCloseSight();
                break;

            case AIstates.InSight:
                In_Sight();
                BossHealth.SetActive(true);
                break;

            case AIstates.Attacking:
                if (States.CanMove)
                {
                    _AiStates             = AIstates.InSight;
                    States.RotateToTarget = true;
                    States.anim.SetFloat(EnemyMove, -1);
                }



                break;

            case AIstates.death:
                handleDeath();
                break;

            default:
                break;
            }

            States.Tick(Delta);
        }
Exemplo n.º 11
0
 void ChangeState(AIstates newState)
 {
     CurrentState = newState;
 }