Пример #1
0
    //Perseguir al jugador.
    public IEnumerator AIChase()
    {
        while (currentState == ENEMY_STATE.CHASE)
        {
            if (player != null)
            {
                nav.isStopped = false;
                if (distanceToPlayer <= attackDistance)
                {
                    nav.isStopped = true;
                    currentState  = ENEMY_STATE.ATTACK;
                    yield break;
                }


                nav.isStopped = false;
                nav.SetDestination(player.transform.position);

                //Mientras no ha cargado la ruta (Puede que no sea necesario, la ruta es muy simple)
                while (nav.pathPending)
                {
                    yield return(null);
                }
            }
            else
            {
                player = closestObject("PlayerRoot");
            }
            yield return(null);
        }
    }
Пример #2
0
    //------------------------------------------------
    //Change AI State
    public void ChangeState(ENEMY_STATE State)
    {
        //Stops all AI Processing
        StopAllCoroutines();

        //Set new state
        ActiveState = State;

        //Activates new state
        switch(ActiveState)
        {
            case ENEMY_STATE.ATTACK:
                StartCoroutine(AI_Attack());
                SendMessage("Attack", SendMessageOptions.DontRequireReceiver); //Notify Game Object
            return;

            case ENEMY_STATE.CHASE:
                StartCoroutine(AI_Chase());
                SendMessage("Chase", SendMessageOptions.DontRequireReceiver); //Notify Game Object
            return;

            case ENEMY_STATE.PATROL:
                StartCoroutine(AI_Patrol());
                SendMessage("Patrol", SendMessageOptions.DontRequireReceiver); //Notify Game Object
            return;
        }
    }
Пример #3
0
    public IEnumerator EnemyWalk()
    {
        while (currentState == ENEMY_STATE.WALK)
        {
            checkMyVision.sensitity = CheckMyVision.enmSensitivity.HIGH;
            agent.isStopped         = false;
            agent.SetDestination(GetComponent <FollowDestination>().destination.position);
            if (isJumping && !isWalking)
            {
                CurrentState = ENEMY_STATE.Invincible;
            }
            if (isCollidedWithPlayer)
            {
                Debug.Log("Enemy died");
                CurrentState = ENEMY_STATE.Die;
            }

            if (checkMyVision.targetInSight)
            {
                agent.isStopped = true;
                Debug.Log("Enemy in super state");

                CurrentState = ENEMY_STATE.Super;
                yield break;
            }
            yield return(null);
        }
    }
Пример #4
0
    public IEnumerator EnemySuper()
    {
        while (currentState == ENEMY_STATE.Super)
        {
            particles.SetActive(true);
            checkMyVision.sensitity = CheckMyVision.enmSensitivity.LOW;
            agent.isStopped         = false;
            agent.SetDestination(checkMyVision.lastknownSighting);
            while (agent.pathPending)
            {
                yield return(null);
            }

            if (agent.remainingDistance <= agent.stoppingDistance)
            {
                agent.isStopped = true;
                if (!checkMyVision.targetInSight)
                {
                    Debug.Log("Enemy died");

                    CurrentState = ENEMY_STATE.Die;
                }
                else
                {
                    Debug.Log("Enemy in walk state");

                    CurrentState = ENEMY_STATE.WALK;
                }
                yield break;
            }
            yield return(null);
        }
        yield break;
    }
Пример #5
0
    IEnumerator CoroutineAttckidle()
    {
        anim.SetBool("attack_idle", true);


        int rand = Random.Range(0, 4);

        if (bulletCount < 5 && rand == 2)
        {
            NextState = ENEMY_STATE.ATTACK_IDLE;
        }
        else
        {
            switch (rand)
            {
            case 0: NextState = ENEMY_STATE.ATTACK1; break;

            case 1: NextState = ENEMY_STATE.ATTACK2; break;

            case 2: NextState = ENEMY_STATE.ATTACK1; break;

            case 3: NextState = ENEMY_STATE.IDLE; break;
            }

            yield return(new WaitForSeconds(4.0f));
        }


        changeCoroutine(NextState);
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (bullet.intbar() == mybossindex)
        {
            hpAtt(HP / MaxHP);
        }

        if (HP < 1)
        {
            if (currState != ENEMY_STATE.Death)
            {
                StopAllCoroutines();
                currState = ENEMY_STATE.Death;
                anim.SetBool("attack_idle", false);
                anim.SetBool("fly", false);
                anim.SetBool("attack_3", false);
                anim.SetBool("attack_2", false);
                anim.SetBool("attack_1", false);
                anim.SetBool("death", true);
                groundpos = transform.position - new Vector3(0, transform.position.y, 0);
                deathpos  = transform.position;
            }
            else
            {
                DeathTime         += Time.deltaTime * 1.1f;
                transform.position = Vector3.Lerp(deathpos, groundpos, DeathTime);
                if (DeathTime > 11)
                {
                    this.gameObject.SetActive(false);
                }
            }
        }
    }
Пример #7
0
    public IEnumerator AIPatrol()
    {
        while (currentState == ENEMY_STATE.PATROL)
        {
            ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;

            ThisAgent.Resume();

            ThisAgent.SetDestination(PatrolDestination.position);

            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            if (ThisLineSight.CanSeeTarget)
            {
                ThisAgent.Stop();

                CurrentState = ENEMY_STATE.CHASE;

                yield break;
            }

            yield return(null);
        }
    }
Пример #8
0
    public IEnumerator EnemyAttack()
    {
        //Like the others start with the loop
        while (currentState == ENEMY_STATE.Levelup)
        {
            Debug.Log("I am attacking");
            agent.isStopped = false;
            agent.SetDestination(playerTransform.position);

            while (agent.pathPending)
            {
                yield return(null);
            }

            if (agent.remainingDistance > agent.stoppingDistance)
            {
                CurrentState = ENEMY_STATE.Movestart;
                yield break;
            }
            else
            {
                //attack
                //Do something here later on about player health
                playerHealth.HealthPoints -= maxDamage * Time.deltaTime;
            }

            yield return(null);
        }
        yield break;
    }
Пример #9
0
    public IEnumerator AIAttack()
    {
        while (currentState == ENEMY_STATE.ATTACK)
        {
            ThisAgent.Resume();

            ThisAgent.SetDestination(SnekTransform.position);

            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            if (ThisAgent.remainingDistance > ThisAgent.stoppingDistance + 0.3)
            {
                CurrentState = ENEMY_STATE.CHASE;
            }

            else
            {
                SnekHealth.healthpoints -= MaxDamage;

                Debug.Log(ThisAgent.remainingDistance);
            }

            yield return(new WaitForSeconds(1));
        }
    }
Пример #10
0
    //------------------------------------------
    public IEnumerator AILook_Around()
    {
        // specifiy local variables
        ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;
        float   angle = 360.0f;     // Degree per time unit
        float   time  = 5.0f;       // Time unit in sec
        Vector3 axis  = Vector3.up; // Rotation axis, here it the yaw axis
        float   timer = 0;

        // look around
        while (timer < time)
        {
            transform.RotateAround(transform.position, axis, angle * Time.deltaTime / time);
            timer += Time.deltaTime;
            if (ThisLineSight.CanSeeTarget)
            {
                CurrentState = ENEMY_STATE.CHASE;
                yield break;
            }
            yield return(null);
        }

        // still could not locate player, return to idle/patrol state
        if (!useWaypoints)
        {
            CurrentState = ENEMY_STATE.IDLE;
        }
        else
        {
            CurrentState = ENEMY_STATE.PATROL;
        }

        yield break;
    }
Пример #11
0
    public override void Update()
    {
        //Update attack cooldown
        attack_timer += Time.deltaTime;

        if (GetCurrentHP() <= 0 && state != AI_STATE.AI_DEAD)
        {
            Debug.Log("DEAD", Department.IA);
            //GetComponent<CompAnimation>().SetClipsSpeed(anim_speed);
            state      = AI_STATE.AI_DEAD;
            life_state = ENEMY_STATE.ENEMY_DEAD;


            next_action = GetComponent <Die_Action>();
            current_action.Interupt();
            if (GetComponent <EnemySword_BT>() != null)
            {
                enemies_manager.GetComponent <EnemiesManager>().DeleteSwordEnemy(GetComponent <EnemySword_BT>().gameObject);
            }
            else if (GetComponent <EnemyShield_BT>() != null)
            {
                enemies_manager.GetComponent <EnemiesManager>().DeleteShieldEnemy(GetComponent <EnemyShield_BT>().gameObject);
            }
            else if (GetComponent <EnemySpear_BT>() != null)
            {
                enemies_manager.GetComponent <EnemiesManager>().DeleteLanceEnemy(GetComponent <EnemySpear_BT>().gameObject);
            }
        }

        base.Update();
    }
Пример #12
0
    override protected void EnterState(ENEMY_STATE _state)
    {
        switch (_state)
        {
        case ENEMY_STATE.APPEAR:
            WorkAppear = new Work(Appear(), true);
            break;

        case ENEMY_STATE.IDLE:
            WorkIdle = new Work(Idle(), true);
            break;

        case ENEMY_STATE.ATTACK:
            WorkAttack = new Work(Attack(), true);
            break;

        case ENEMY_STATE.MOVE:
            WorkMove = new Work(Move(), true);
            break;

        case ENEMY_STATE.DIE:
            WorkDie = new Work(Die(), true);
            break;

        case ENEMY_STATE.HIT:
            WorkHit = new Work(Hit(), true);
            break;

        case ENEMY_STATE.STUN:
            WorkStun = new Work(Stun(), true);
            break;
        }
    }
Пример #13
0
    public IEnumerator AIPatrol()
    {
        //Loop while patrolling
        while (currentstate == ENEMY_STATE.PATROL)
        {
            //Set strict search
            ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;

            //Chase to patrol position
            ThisAgent.Resume();
            ThisAgent.SetDestination(PatrolDestination.position);

            //Wait until path is computed
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            //If we can see the target then start chasing
            if (ThisLineSight.CanSeeTarget)
            {
                ThisAgent.Stop();
                CurrentState = ENEMY_STATE.CHASE;
                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
Пример #14
0
    //------------------------------------------------
    //Change AI State
    public void ChangeState(ENEMY_STATE State)
    {
        //Stops all AI Processing
        StopAllCoroutines();

        //Set new state
        ActiveState = State;

        //Activates new state
        switch (ActiveState)
        {
        case ENEMY_STATE.ATTACK:
            StartCoroutine(AI_Attack());
            SendMessage("Attack", SendMessageOptions.DontRequireReceiver);                     //Notify Game Object
            return;

        case ENEMY_STATE.CHASE:
            StartCoroutine(AI_Chase());
            SendMessage("Chase", SendMessageOptions.DontRequireReceiver);                     //Notify Game Object
            return;

        case ENEMY_STATE.PATROL:
            StartCoroutine(AI_Patrol());
            SendMessage("Patrol", SendMessageOptions.DontRequireReceiver);                     //Notify Game Object
            return;
        }
    }
        //Constructor
        public EnemyGameObject(Vector2 position, GameObjectIndex objectIndex, Random randomNumbers) : base(position, new BoxCollider(position, ENEMY_SIZE), objectIndex)
        {
            //Set the random number generator
            this.randomNumbers = randomNumbers;

            //Initialize animation frames
            List <CanvasBitmap> upAnimationFrames = new List <CanvasBitmap>()
            {
                ImageManager.getImageByName("small_pacman_closed"),
                ImageManager.getImageByName("small_pacman_halfopen_up"),
                ImageManager.getImageByName("small_pacman_open_up"),
                ImageManager.getImageByName("small_pacman_halfopen_up")
            };
            List <CanvasBitmap> rightAnimationFrames = new List <CanvasBitmap>()
            {
                ImageManager.getImageByName("small_pacman_closed"),
                ImageManager.getImageByName("small_pacman_halfopen_right"),
                ImageManager.getImageByName("small_pacman_open_right"),
                ImageManager.getImageByName("small_pacman_halfopen_right")
            };
            List <CanvasBitmap> downAnimationFrames = new List <CanvasBitmap>()
            {
                ImageManager.getImageByName("small_pacman_closed"),
                ImageManager.getImageByName("small_pacman_halfopen_down"),
                ImageManager.getImageByName("small_pacman_open_down"),
                ImageManager.getImageByName("small_pacman_halfopen_down")
            };
            List <CanvasBitmap> leftAnimationFrames = new List <CanvasBitmap>()
            {
                ImageManager.getImageByName("small_pacman_closed"),
                ImageManager.getImageByName("small_pacman_halfopen_left"),
                ImageManager.getImageByName("small_pacman_open_left"),
                ImageManager.getImageByName("small_pacman_halfopen_left")
            };

            //Initialize animations
            upAnimation    = new Animation(upAnimationFrames, ANIMATION_LENGTH);
            rightAnimation = new Animation(rightAnimationFrames, ANIMATION_LENGTH);
            downAnimation  = new Animation(downAnimationFrames, ANIMATION_LENGTH);
            leftAnimation  = new Animation(leftAnimationFrames, ANIMATION_LENGTH);
            PlayAnimations();


            //Setup animations array
            animations = new Animation[4] {
                upAnimation, rightAnimation, downAnimation, leftAnimation
            };

            //Initialize to a random direction
            direction = new CardinalDirection(randomNumbers.Next(0, 4));

            //Pick the matching animation
            OnDirectionChange();

            //Initialize state
            state = ENEMY_STATE.IDLE;

            //Set the action timer
            ResetActionTimer();
        }
Пример #16
0
    //------------------------------------------
    public IEnumerator AIIdle()
    {
        //Loop while patrolling
        while (currentstate == ENEMY_STATE.IDLE)
        {
            //Set loose search
            ThisLineSight.Sensitity = LineSight.SightSensitivity.LOOSE;

            //anim params
            ThisAnim.SetBool("Idle", true);
            ThisAnim.SetBool("Move", false);
            ThisAnim.SetBool("Attack", false);
            ThisAnim.SetBool("Defend", false);

            //Look at player position
            var direction = PlayerTransform.position - this.transform.position;
            ThisAgent.isStopped = true;
            ThisAgent.transform.rotation.SetLookRotation(direction);

            //If we can see the target then start chasing
            if (ThisLineSight.CanSeeTarget && range > 0.1f)
            {
                Debug.Log("Chase now");
                ThisAgent.isStopped = false;
                CurrentState        = ENEMY_STATE.CHASE;
                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
Пример #17
0
    //------------------------------------------
    public IEnumerator AIAttack()
    {
        animator.SetBool("Attacking", true);
        //Loop while chasing and attacking
        while (currentstate == ENEMY_STATE.ATTACK)
        {
            //Chase to player position
            ThisAgent.isStopped = false;
            ThisAgent.SetDestination(PlayerTransform.position);

            //Wait until path is computed
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            //Has player run away?
            if (ThisAgent.remainingDistance > ThisAgent.stoppingDistance)
            {
                animator.SetBool("Attacking", false);
                while (animator.GetCurrentAnimatorStateInfo(0).IsTag("Attacking"))
                {
                    yield return(null);
                }
                //Change back to chase
                CurrentState = ENEMY_STATE.CHASE;
                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
Пример #18
0
    public IEnumerator AIChase()
    {
        while (CurrentState == ENEMY_STATE.CHASE)
        {
            theLineSight.sensitivity = LineSight.SightSensitivity.LOOSE;

            theAgent.Resume();
            theAgent.SetDestination(theLineSight.lastKnownSight);

            while (theAgent.pathPending)
            {
                yield return(null);
            }

            if (theAgent.remainingDistance <= theAgent.stoppingDistance)
            {
                theAgent.Stop();
                if (!theLineSight.canSeeTarget)
                {
                    CurrentState = ENEMY_STATE.PATROL;
                }
                else
                {
                    CurrentState = ENEMY_STATE.ATTACK;
                }
                yield break;
            }


            yield return(null);
        }
    }
Пример #19
0
    //------------------------------------------
    public IEnumerator AIAttack()
    {
        //Loop while chasing and attacking
        while (currentstate == ENEMY_STATE.ATTACK)
        {
            ThisAgent.isStopped = true;

            //Rotate to player
            Vector3 lookRotation = PlayerTransform.position - this.transform.position;
            transform.LookAt(lookRotation);

            if (ThisAgent.remainingDistance >= ThisAgent.stoppingDistance)
            {
                CurrentState = ENEMY_STATE.CHASE;
                yield break;
            }
            else
            {
                ThisAnim.SetBool("Idle", false);
                ThisAnim.SetBool("Move", false);
                ThisAnim.SetBool("Defend", false);
                ThisAnim.SetBool("Attack", true);
            }

            yield return(null);
        }
    }
Пример #20
0
    public IEnumerator AIAttack()
    {
        //Loop while chasing and attacking
        while (currentstate == ENEMY_STATE.ATTACK)
        {
            //Chase to player position
            ThisAgent.Resume();
            ThisAgent.SetDestination(PlayerTransform.position);

            //Wait until path is computed
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            //Has player run away?
            if (ThisAgent.remainingDistance > ThisAgent.stoppingDistance)
            {
                //Change back to chase
                CurrentState = ENEMY_STATE.CHASE;
                yield break;
            }
            else
            {
                //Attack
                PlayerHealth.HealthPoints -= MaxDamage * Time.deltaTime;
            }

            //Wait until next frame
            yield return(null);
        }

        yield break;
    }
Пример #21
0
    // Use this for initialization
    void Start()
    {
        GameObject[] randomDestinations = GameObject.FindGameObjectsWithTag("Destination");
        destination = randomDestinations [Random.Range(0, randomDestinations.Length)].GetComponent <Transform> ();

        CurrentState = ENEMY_STATE.PATROL;
    }
Пример #22
0
    // Update is called once per frame
    void Update()
    {
        if (m_eCurState == ENEMY_STATE.STATE_DIE)
        {
            m_fCurDeathTime += Time.deltaTime;
            if (m_fCurDeathTime >= m_fDeathTime)
            {
                m_HpSlider.gameObject.SetActive(false);
                m_eCurState = ENEMY_STATE.STATE_NONE;
                gameObject.SetActive(false);

                int RNum = Random.Range(0, 10);

                if (RNum >= 0 && RNum <= 2)
                {
                    //hp드랍
                    DropItem(POOL_INDEX.POOL_HP_ITEM);
                }
                else if (RNum >= 3 && RNum <= 5)
                {
                    //sp드랍
                    DropItem(POOL_INDEX.POOL_SP_ITEM);
                }
                else if (RNum >= 6 && RNum <= 8)
                {
                    //둘다 드랍
                    DropItem(POOL_INDEX.POOL_HP_ITEM);
                    DropItem(POOL_INDEX.POOL_SP_ITEM);
                }
            }

            //죽었다.
        }
    }
Пример #23
0
    //------------------------------------------
    public IEnumerator AIChase()
    {
        //Loop while chasing
        while (currentstate == ENEMY_STATE.CHASE)
        {
            //Set loose search
            ThisLineSight.Sensitity = LineSight.SightSensitivity.LOOSE;

            //Chase to last known position
            ThisAgent.isStopped = false;
            ThisAgent.SetDestination(ThisLineSight.LastKnowSighting);

            //Wait until path is computed
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            //Have we reached destination?
            if (ThisAgent.remainingDistance <= ThisAgent.stoppingDistance)
            {
                //Stop agent
                ThisAgent.isStopped = true;

                //Reached destination but cannot see player
                CurrentState = !ThisLineSight.CanSeeTarget ? ENEMY_STATE.PATROL : ENEMY_STATE.ATTACK;

                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
Пример #24
0
    IEnumerator StateAction()
    {
        while (m_eCurState != ENEMY_STATE.STATE_DIE)
        {
            switch (m_eCurState)
            {
            case ENEMY_STATE.STATE_WAIT:        //대기 상태
                m_Animator.SetBool("Attack", false);
                m_Animator.SetBool("Moving", false);
                m_NavMeshAgent.isStopped = true;
                break;

            case ENEMY_STATE.STATE_ATTACK:
                m_Animator.SetBool("Attack", true);
                m_Animator.SetBool("Moving", false);
                transform.LookAt(m_PlayerTR);
                m_NavMeshAgent.isStopped = true;
                m_eCurState = ENEMY_STATE.STATE_WAIT;
                break;

            case ENEMY_STATE.STATE_TRACE:
                m_Animator.SetBool("Attack", false);
                m_Animator.SetBool("Moving", true);
                m_NavMeshAgent.SetDestination(m_PlayerTR.position);
                m_NavMeshAgent.isStopped = false;
                break;
            }
            yield return(null);
        }
    }
Пример #25
0
    public void Damege(float fATK, float fCRI)
    {
        //적이 죽으면 일정확률로 체력 회복 아이템과 SP 회복 아이템을 드랍한다.
        if (m_eCurState != ENEMY_STATE.STATE_DIE)
        {
            m_HpSlider.gameObject.SetActive(true);
            //부딪힌 것의 HP바를 보여준다.
            int iCri = Random.Range(0, 100);
            int iAtk = (int)fATK;

            if (iCri == (int)fCRI)
            {
                iAtk += (iCri * 10);    //크리티컬!
            }

            m_fCurHP -= (float)iAtk;

            if (m_fCurHP <= 0.0f)   //모든 HP가 다 떨어지면
            {
                m_fCurHP    = 0.0f;
                m_eCurState = ENEMY_STATE.STATE_DIE;
                m_Animator.SetBool("Attack", false);
                m_Animator.SetBool("Moving", false);
                m_Animator.SetTrigger("Death");
                m_NavMeshAgent.isStopped = true;
                StopAllCoroutines();
            }

            float fHP = ((float)m_fCurHP / (float)m_fMaxHP);
            m_HpSlider.value = fHP;

            m_HpSlider.GetComponentInChildren <UILabel>().text = Util.ConvertToString(m_CharData.GetEnemyData(CHAR_DATA.CHAR_NAME));//에너미 이름
        }
    }
Пример #26
0
    public IEnumerator AIPatrol()
    {
        while (CurrentState == ENEMY_STATE.PATROL)
        {
            theLineSight.sensitivity = LineSight.SightSensitivity.STRICT;

            theAgent.isStopped = false;

            theAgent.SetDestination(destination.position);


            while (theAgent.pathPending)
            {
                yield return(null);
            }

            if (theLineSight.canSeeTarget)
            {
                theAgent.isStopped = true;
                CurrentState       = ENEMY_STATE.CHASE;
                yield break;
            }

            yield return(null);
        }
    }
Пример #27
0
    public void ChangeState(ENEMY_STATE e)
    {
        if (EnemyState != e)
        {
            EnemyState = e;

            switch (e)
            {
            case ENEMY_STATE.Alive:
                enemyMat.sharedMaterial = AliveMat;
                break;

            case ENEMY_STATE.Vulnerable:
                enemyMat.sharedMaterial = VulnerableMat;
                break;

            case ENEMY_STATE.Floored:
                enemyMat.sharedMaterial = FlooredMat;
                break;

            case ENEMY_STATE.Dead:
                enemyMat.sharedMaterial = DeadMat;
                break;
            }
        }

        /*if(e == ENEMY_STATE.Dead)
         *  StartCoroutine(ChangeStateAfterTime(7.0f));*/
    }
Пример #28
0
    // Update is called once per frame
    void Update()
    {
        switch (EnemyState)
        {
        case ENEMY_STATE.FALL:
            if (isGrounded)
            {
                EnemyState = ENEMY_STATE.IDLE;
                animator.SetTrigger("fallEnd");
            }
            break;

        case ENEMY_STATE.IDLE:
            timeCount += Time.deltaTime;
            if (timeCount >= idleTime)
            {
                EnemyState = ENEMY_STATE.MOVING;
                timeCount  = 0;
            }
            break;

        case ENEMY_STATE.MOVING:
            Moving();
            break;

        default:
            break;
        }
    }
Пример #29
0
 public IEnumerator EnemyChase()
 {
     while (currentState == ENEMY_STATE.CHASE)
     {
         checkMyVision.sensitivity = CheckMyVision.enmSensitivity.LOW;
         agent.isStopped           = false;
         agent.SetDestination(checkMyVision.lastKnownSighting);
         while (agent.pathPending)
         {
             yield return(null);
         }
         Debug.Log(agent.stoppingDistance);
         if (agent.remainingDistance <= agent.stoppingDistance)
         {
             agent.isStopped = true;
             if (!checkMyVision.targetInSight)
             {
                 CurrentState = ENEMY_STATE.PATROL;
             }
             else
             {
                 CurrentState = ENEMY_STATE.ATTACK;
             }
             yield break;
         }
         yield return(null);
     }
     yield break;
 }
Пример #30
0
    public IEnumerator AIAttack()
    {
        while (CurrentState == ENEMY_STATE.ATTACK)
        {
            theAgent.Resume();
            theAgent.SetDestination(playerTransform.position);


            while (theAgent.pathPending)
            {
                yield return(null);
            }


            if (theAgent.remainingDistance > theAgent.stoppingDistance)
            {
                CurrentState = ENEMY_STATE.CHASE;
                yield break;
            }
            else
            {
                playerHealth.HealthPoints -= maxDamage * Time.deltaTime;
            }

            yield return(null);
        }
    }
Пример #31
0
    public IEnumerator EnemyAttack()
    {
        while (curentState == ENEMY_STATE.ATTACK)
        {
            agent.isStopped = false;
            agent.SetDestination(playerTransform.position);

            while (agent.pathPending)
            {
                yield return(null);
            }

            if (agent.remainingDistance > agent.stoppingDistance)
            {
                CurrentState = ENEMY_STATE.CHASE;
            }

            else
            {
                playerHealth.HealthPoints -= maxDamage * Time.deltaTime;
            }
            if (playerHealth.HealthPoints < 0)
            {
                currentpersonState = PersonState.DEAD;
            }


            yield return(null);
        }
        yield break;
    }
Пример #32
0
	// Use this for initialization
	void Start () 
    {
        enemyState = ENEMY_STATE.PATROL;
        puppet = GetComponent<PuppetScript>();
        player = GameObject.FindGameObjectWithTag("Player");
        noticeArea = gameObject.GetComponent<SphereCollider>();
        behaviourTree = gameObject.GetComponent<BehaviourTree>();
        behaviourTree.FuckYouUnity(); 
        foreach (GameObject patrolPoint in patrolPoints)
        {
            behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.PATROL, patrolPoint.transform.position, 0.0f));    
        }
        if(patrolPoints.Length == 0)
        {
            behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.PATROL, gameObject.transform.position, 0.0f));
        }
    }