Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     meshAgent                  = GetComponent <NavMeshAgent> ();
     player                     = PlayerManager.instance;
     enemyInteractable          = GetComponent <EnemyInteractable> ();
     meshAgent.stoppingDistance = enemyInteractable.radius;
     myCombat                   = GetComponent <CharacterCombat>();
 }
    //----------------------------

    private void Awake()
    {
        m_enemyInteractable = GetComponent <EnemyInteractable>();
        audioSource         = GetComponent <AudioSource>();
        playerActor         = GameObject.FindObjectOfType <PlayerActor>();
        wantedLevel         = GameObject.FindObjectOfType <WantedLevel>();

        chaseState          = new ChaseState(this);
        alertState          = new AlertState(this);
        patrolState         = new PatrolState(this);
        m_caughtPlayerState = new CaughtPlayerState(this);

        navMeshAgent       = GetComponent <NavMeshAgent>();
        navMeshAgent.speed = standartSpeed;

        enemyAnimator    = GetComponent <Animator>();
        elephantMovement = playerActor.GetComponent <ElephantMovement>();

        if (wayPoints == null)
        {
            wayPoints = new Waypoints()
            {
                points = new[] { transform.position },
                pairs  = new[] { new Pair() }
            }
        }
        ;
    }

    void OnValidate()
    {
        currentState = patrolState;
    }

    void Start()
    {
        currentState = patrolState;

        viewCone.MainViewRadius = toleratedSightrange;
        viewCone.FullViewRadius = sightRange;
        viewCone.FieldOfView    = fieldOfView;

        OnCaught += StatePatternEnemy_OnCaught;
    }