コード例 #1
0
        public override ActionState update(AbstractAI ai, float delta)
        {
            //... DEAD ...///* Play Dead Animation  Despawn after x second*/
            _timer -= delta;
            if (_timer <= 0f)
            {
                //ai.PlayDeathSound();
                AbstractAI.Destroy(ai.gameObject);
            }

            return(this);
        }
コード例 #2
0
ファイル: Chase.cs プロジェクト: Sonatai/Optimization-DoF-VR
        public override ActionState update(AbstractAI ai, float delta)
        {
            ai.navMeshAgent.speed = 1.25f * (ai.movementSpeed / 10f);
            ActionState state = this;
            /* Check if player is in range... Check if player is...  */
            //Debug.Log("CHASE");
            //... calculate the distance to the player

            ActionState newState = ai.IsChasing(ai.Player.transform.position);

            if (newState != null)
            {
                return(newState);
            }

            Vector3 direction = ai.Player.transform.position - ai.transform.position;

            direction = new Vector3(direction.x, direction.y * 0.5f, direction.z);

            if (direction.magnitude > ai.GetAttackDistance())
            {
                //Debug.Log(direction.magnitude);
                ai.navMeshAgent.isStopped = false;
                ai.navMeshAgent.SetDestination(ai.Player.transform.position);
            }
            else
            {
                ai.navMeshAgent.isStopped = true;
                //enemy.playerFocusTimer = _lifetime;//patience;
                state = new Attack(20f);
            }

            if (_timer > 0f) //playerSpotted)//playerSpotted
            {
                _timer -= Time.deltaTime;
            }
            else if (_timer <= 0f
                     ) // && currentSenseState!=SenseStates.playerSpotted)// && currentSenseState==SenseStates.alarmedplayerSpotted)
            {
                //enemy.playerFocusTimer = _lifetime;//patience;
                ai.currentSenseState = AbstractAI.SenseStates.alarmed;
                state = new Search(0f);
            }

            if (state != this)
            {
                ai.navMeshAgent.speed = ai.movementSpeed / 10f;
            }

            return(state);
        }
コード例 #3
0
        public override ActionState update(AbstractAI ai, float delta)
        {
            //Debug.Log("ATTACK");
            Vector3 direction = ai.Player.transform.position - ai.transform.position;

            direction             = new Vector3(direction.x, direction.y * 0.5f, direction.z);
            ai.transform.rotation = Quaternion.Slerp(ai.transform.rotation, Quaternion.LookRotation(direction), 0.1f);

            ActionState state = null;

            state = ai.IsAttacking(direction.magnitude <= ai.GetAttackDistance());
            if (state != null)
            {
                return(state);
            }

            return(this);
        }
コード例 #4
0
ファイル: Search.cs プロジェクト: Sonatai/Optimization-DoF-VR
        public override ActionState update(AbstractAI ai, float delta)
        {
            ActionState state = this;

            if (_timer > 0f) //... SEARCH ...//
            {
                /*
                 * Check if player is seen -> currentActionState == WALK
                 * Check if Entity got hitted -> currentActionState = SEARCH, spottedPlayer = 3
                 * Check if playerSpotted == 0 -> currentActionState == IDLE
                 * Check if playerSpotted > 0 -> currentActionState == WALK
                 */
                _timer -= delta; //... lookAroundTimer -> wie lang herumdrehen, lookAround, soll sich herum drehen
                ai.navMeshAgent.isStopped = true;
                //enemy.walkingTimer = _lifetime;//patience;//Transition!
                ai.IsLooking();
            }
            else
            {
                if (ai.hasAlzheimer && ai.currentSenseState != AbstractAI.SenseStates.neverSeenPlayer &&
                    ai.alzheimerTimer < 0f)
                {
                    state = new Idle(20f); //Forgetful I guess
                }
                else
                {
                    ai.IsRoaming();
                    //enemy.walkingTimer = _lifetime;//patience;//Transition!
                    state = new Walk(20f);
                    ai.currentSenseState = (ai.currentSenseState == AbstractAI.SenseStates.neverSeenPlayer)
                        ? AbstractAI.SenseStates.neverSeenPlayer
                        : AbstractAI.SenseStates.alarmed;
                }
            }

            return(state);
        }
コード例 #5
0
 public abstract ActionState update(AbstractAI ai, float delta);