예제 #1
0
        private void InitStates()
        {
            PatrolState       patrol       = new PatrolState(this, _path, direction, _arriveDistance);
            FollowTargetState followTarget = new FollowTargetState(this);
            ShootState        shoot        = new ShootState(this);

            _states.Add(patrol);
            _states.Add(followTarget);
            _states.Add(shoot);
            CurrentState = patrol;
            CurrentState.StateActivated();
        }
예제 #2
0
    void SwitchState(FollowTargetState newState)
    {
        switch (newState)
        {
        case FollowTargetState.FTS_SEARCH:
        {
//				if(!boolbool)
//				{
//					this.GetComponentInParent<MonsterManager> ().SetAction(MonsterManager.Action.NOTHING);
//					boolbool = true;
//				}
            chasingThePlayer = false;

            m_fStateTimer = LineOfSightCheckFrequency;
            //if you're searching, go about your normal behavior
            if (m_randomWalkComponent != null)
            {
                m_randomWalkComponent.enabled = true;
//					if(this.gameObject.tag != "dog")				{
//						this.GetComponentInParent<MonsterManager> ().SetAction(MonsterManager.Action.NOTHING);
//					}
            }
        }
        break;

        case FollowTargetState.FTS_GO_TO_TARGET:
        {
//				if(boolbool)
//				{
//					this.GetComponentInParent<MonsterManager> ().SetAction(MonsterManager.Action.ATTACK);
//					boolbool = false;
//				}
            chasingThePlayer = true;

            m_fStateTimer = LineOfSightCheckFrequencyDuringFollow;
            //if we've found a target we are no longer
            //interested in our previous behavior
            if (m_randomWalkComponent != null)
            {
                m_randomWalkComponent.enabled = false;
            }
//				if(this.gameObject.tag != "dog")			{
//					this.GetComponentInParent<MonsterManager> ().SetAction(MonsterManager.Action.ATTACK);
//				}

            m_agent.destination = targetGameObject.transform.position;
        }
        break;
        }
        m_followTargetState = newState;
    }
예제 #3
0
    // Inicializace a nastaví počáteční stav
    void Start()
    {
        EnemyController controller = GetComponent <EnemyController>();

        _followPathToTargetState  = new FollowPathToTargetState(controller, this);
        _waitForNextActionState   = new WaitForNextActionState(controller, this);
        _attackTargetState        = new AttackTargetState(controller, this);
        _followTargetState        = new FollowTargetState(controller, this);
        _walkToRandomPlaceState   = new WalkToRandomPlaceState(controller, this);
        _faceRandomDirectionState = new FaceRandomDirectionState(controller, this);

        SetState(EnemyStateType.WaitForNextAction);
        _currentState.OnEntered();
    }
예제 #4
0
        /// <summary>
        /// Initializes the state system.
        /// </summary>
        private void InitStates()
        {
            PatrolState patrol = new PatrolState(
                this, path, direction, arriveDistance);
            FollowTargetState followTarget = new FollowTargetState(this);
            ShootState        shoot        = new ShootState(this);

            states.Add(patrol);
            states.Add(followTarget);
            states.Add(shoot);

            // Starts with the patrol state
            CurrentState = patrol;
            CurrentState.Activate();
        }
        private void InitStates()
        {
            PatrolState patrol = new PatrolState(this, _path, _direction, _waypointArriveDistance);

            _states.Add(patrol);

            FollowTargetState followTarget = new FollowTargetState(this);

            _states.Add(followTarget);

            // Initiating the ShootState and adding it to the state system.
            ShootState shoot = new ShootState(this);

            _states.Add(shoot);

            CurrentState = patrol;
            CurrentState.StateActivated();
        }