Ejemplo n.º 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();
        }
Ejemplo n.º 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;
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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();
        }
Ejemplo n.º 5
0
        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();
        }