Exemplo n.º 1
0
    protected override void Update()
    {
        //Enemyの更新
        base.Update();

        if (m_navAgent.speed == m_profile.RunSpeed)
        {
            int anim = m_animator.CurrentStateHash;
            //走行アニメーションになっていなければ
            if (anim != m_animator.GetStateHash(MercenaryAnimator.StateName.Run))
            {
                //走行アニメーション
                m_animator.SetDoRun();
            }
        }

        //シンデレラとの距離が近ければ探す
        if (m_distance < 20.0f)
        {
            SearchPlayer();
        }

        //目的地に移動完了したら立ち止まる
        if (m_transform.position.x.SafeEquals(m_navAgent.destination.x) &&
            m_transform.position.z.SafeEquals(m_navAgent.destination.z))
        {
            //待機アニメーション
            if (m_elapsedTime == 0)
            {
                m_animator.SetDoStop();
            }
            m_elapsedTime   += Time.deltaTime;
            m_navAgent.speed = 0;
        }

        //次の目的地を決める
        if (m_elapsedTime > m_profile.MoveWaitTime)
        {
            m_arrivedCount++;
            //進行パターンによって変化

            //一巡したら初期化
            if (m_arrivedCount >= m_movePosList.Count)
            {
                m_arrivedCount = 0;
            }
            m_navAgent.SetDestination(m_movePosList[m_arrivedCount]);
            //歩行アニメーション
            m_animator.SetDoWalk();
            m_elapsedTime = 0;
            if (isChase)
            {
                isChase = false;
            }
        }
    }
Exemplo n.º 2
0
    protected override void Update()
    {
        base.Update();

        int anim = m_animator.Component.GetCurrentAnimatorStateInfo(0).fullPathHash;

        if (m_navAgent.speed == m_profile.RunSpeed)
        {
            //走行アニメーションになっていなければ
            if (anim != m_animator.GetStateHash(MercenaryAnimator.StateName.Run))
            {
                //走行アニメーション
                m_animator.SetDoRun();
            }
        }

        //シンデレラとの距離が近ければ探す
        if (m_distance < 20.0f)
        {
            SearchPlayer();
        }

        //目的地に移動完了したら立ち止まる
        if (m_transform.position.x.SafeEquals(m_navAgent.destination.x) &&
            m_transform.position.z.SafeEquals(m_navAgent.destination.z))
        {
            //待機アニメーション
            if (m_elapsedTime == 0 && !m_mouseDiscover)
            {
                m_animator.SetDoStop();
            }
            m_elapsedTime   += Time.deltaTime;
            m_navAgent.speed = 0;
        }

        //次の目的地を決める
        if (m_elapsedTime > m_profile.MoveWaitTime)
        {
            m_arrivedCount++;
            //進行パターンによって変化
            //一巡したら初期化
            if (m_arrivedCount >= m_movePosList.Count)
            {
                m_arrivedCount = 0;
            }
            m_navAgent.SetDestination(m_movePosList[m_arrivedCount]);
            //歩行アニメーション
            m_animator.SetDoWalk();
            m_elapsedTime = 0;
            if (isChase)
            {
                isChase = false;
            }
        }

        if (m_mouseDiscover)
        {
            //ネズミを見失った
            if (!m_mouse.activeSelf)
            {
                m_mouseDiscover = false;
                StartCoroutine(MouseLostAnim());
            }
            //ネズミを追いかける
            else
            {
                m_navAgent.destination = m_mouse.transform.position;
            }
        }
    }
Exemplo n.º 3
0
    protected override void Update()
    {
        base.Update();

        if (m_navAgent.speed == m_profile.RunSpeed)
        {
            int anim = m_animator.CurrentStateHash;
            //走行アニメーションになっていなければ
            if (anim != m_animator.GetStateHash(MercenaryAnimator.StateName.Run))
            {
                //走行アニメーション
                m_animator.SetDoRun();
            }
        }

        //シンデレラとの距離が近ければ探す
        if (m_distance < m_profile.SensingRange)
        {
            SearchPlayer();
        }

        //初期位置にいるとき
        if (m_transform.position.x.SafeEquals(basePos.x) &&
            m_transform.position.z.SafeEquals(basePos.z))
        {
            int anim = m_animator.CurrentStateHash;
            if (!m_pumpkin)
            {
                //待機アニメーションになっていなければ
                if (anim != m_animator.GetStateHash(MercenaryAnimator.StateName.Idle))
                {
                    //待機アニメーション
                    m_animator.SetDoStop();
                    isChase = false;
                }
            }
            if (m_elapsedTime > m_profile.MoveWaitTime)
            {
                //回転角度の更新
                m_nextDir -= new Vector3(0, 90, 0);
                //更新角度が見ない方向だったらさらに更新
                for (int i = 0; i < notDirection.Length; i++)
                {
                    if ((Mathf.Abs((m_nextDir.y / 90.0f)) % 4).SafeEquals(notDirection[i]))
                    {
                        m_nextDir -= new Vector3(0, 90, 0);
                    }
                }

                m_elapsedTime = 0;
            }
            //回転中
            if (Mathf.DeltaAngle(m_transform.eulerAngles.y, m_nextDir.y) < -3.0f ||
                Mathf.DeltaAngle(m_transform.eulerAngles.y, m_nextDir.y) > 3.0f)
            {
                m_transform.Rotate(new Vector3(0f, -5.0f, 0f));
            }
            //回転終了
            else
            {
                m_elapsedTime += Time.deltaTime;
            }
        }
        else
        {
            //目的地到着後
            if (m_transform.position.x.SafeEquals(m_navAgent.destination.x) &&
                m_transform.position.z.SafeEquals(m_navAgent.destination.z))
            {
                m_elapsedTime += Time.deltaTime;
                if (isChase)
                {
                    isChase = false;
                }
            }

            if (m_elapsedTime > m_profile.MoveWaitTime)
            {
                m_elapsedTime = 0;
                //初期位置に戻る
                m_navAgent.destination = basePos;
                m_animator.SetDoWalk();
            }
        }
    }