Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (GBM.GameWin || !Dead)
        {
            HunterDead();
        }

        if (GBM.GamePause)
        {
            nav.speed = 0;
            return;
        }

        if ((GBM.EnemyStop && !isme && isPursuing) || GBM.PlayerSuper)
        {
            nav.SetDestination(transform.position);
            anim.SetBool(StrisRunning, false);
            CanvaAnim.SetBool(StrIncrease, false);
            isPursuing = false;
            anim.SetBool(StrisWalking, true);
            HeadingPosition = EM.NavChanged();
            isPatroling     = true;
        }

        nav.SetDestination(HeadingPosition);
        if (!isPursuing)
        {
            PatrollingFunction();
        }
        else
        {
            PursuingFunction();
        }

        if (Dead)
        {
            timecount += Time.deltaTime;
            if (timecount > 1)
            {
                Destroy(this.gameObject);
            }
        }

        if (GBM.GameLost && !isCatch)
        {
            isPursuing = false;
            //nav.speed = 0.7f;
            anim.SetBool(StrisWalking, true);
            HeadingPosition = EM.NavChanged();
            isPatroling     = true;
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        anim      = GetComponent <Animator>();
        AS        = GetComponent <AudioSource>();
        nav       = GetComponent <NavMeshAgent>();
        CanvaAnim = Canva.GetComponent <Animator>();
        EM        = GetComponentInParent <EnemiesManager>();

        GBM             = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameBooleanManager>();
        SKM             = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SkillManager>();
        GSM             = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameSceneManager>();
        player          = GameObject.FindGameObjectWithTag("Player");
        HeadingPosition = EM.NavChanged();

        //初始化变量
        foundRate   = 0;
        nav.speed   = 0.7f;
        isPatroling = true;
        if (HeadingPosition.Equals(new Vector3(0, 0, 0)))
        {
            standPosition   = true;
            originPosition  = transform.position;
            HeadingPosition = originPosition;
        }
        nav.SetDestination(HeadingPosition);
        foundRateSlider.value = foundRate;
    }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (nav.remainingDistance < 0.1)
     {
         HeadingPosition = EM.NavChanged();
     }
     nav.SetDestination(HeadingPosition);
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     nav             = GetComponentInChildren <NavMeshAgent>();
     EM              = GetComponent <EnemiesManager>();
     anim            = GetComponent <Animator>();
     HeadingPosition = EM.NavChanged();
     nav.speed       = 0;
 }
Exemplo n.º 5
0
    float viewDistance;        //猎人与玩家的距离

    // Use this for initialization
    void Start()
    {
        anim      = GetComponent <Animator>();
        AS        = GetComponent <AudioSource>();
        nav       = GetComponent <NavMeshAgent>();
        CanvaAnim = Canva.GetComponent <Animator>();
        EM        = GetComponentInParent <EnemiesManager>();

        GBM    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameBooleanManager>();
        SKM    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SkillManager>();
        GSM    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameSceneManager>();
        MUM    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MainUIManagerSC>();
        player = GameObject.FindGameObjectWithTag("Player");

        if (EM.NavChanged().Equals(new Vector3(0, 0, 0)))
        {
            isStandPosition = true;
            originPosition  = transform.position;
        }
        else
        {
            nav.SetDestination(EM.NavChanged());
        }
    }
Exemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (GBM.GameWin)
        {
            EnemyDeadFunc();
        }

        if (GBM.GamePause)
        {
            nav.speed = 0;
            return;
        }

        if (beDelay)
        {
            EnemyBeDelay();
            return;
        }
        if (m_EnemyState != EnemyState.isStanding &&
            m_EnemyState != EnemyState.isPatroling &&
            GBM.GameLost && !iCatch)
        {
            if (isStandPosition)
            {
                nav.SetDestination(originPosition);
            }
            else
            {
                nav.SetDestination(EM.NavChanged());
            }
            m_EnemyState = EnemyState.isStanding;
        }
        else if (GBM.GameLost && iCatch)
        {
            return;
        }

        if ((GBM.EnemyStop && !isme &&
             m_EnemyState == EnemyState.isPursuing))
        {
            StandingFunc();
            nav.SetDestination(transform.position);
            return;
            //m_EnemyState = EnemyState.isStanding;
            //if (isStandPosition) nav.SetDestination(originPosition);
            //else nav.SetDestination(EM.NavChanged());
        }

        targetDir    = player.transform.position - transform.position;
        viewAngle    = Vector3.Angle(transform.forward, targetDir);
        viewDistance = Vector3.Distance(player.transform.position, transform.position);

        switch (m_EnemyState)
        {
        case EnemyState.isStanding:
            StandingFunc();
            break;

        case EnemyState.isPatroling:
            PatrolingFunc();
            break;

        case EnemyState.isTracking:
            TrackingFunc();
            break;

        case EnemyState.isPursuing:
            PursuingFunc();
            break;
        }
    }