コード例 #1
0
    protected override void Update()
    {
        base.Update();

        float deltatime = Time.deltaTime;

        if (m_AttackDelayTimer > 0.0f)
        {
            m_AttackDelayTimer -= deltatime;
            if (m_AttackDelayTimer <= 0.0f)
            {
                m_AttackDelayTimer = 0.0f;
            }
        }

        if (m_FreezeTimer > 0.0f)
        {
            m_FreezeTimer -= deltatime;
            if (m_FreezeTimer <= 0.0f)
            {
                m_FreezeTimer = 0.0f;
            }
        }

        if (m_AttackLevelConnetTimer > 0.0f)
        {
            m_AttackLevelConnetTimer -= deltatime;
            if (m_AttackLevelConnetTimer <= 0.0f)
            {
                m_AttackLevelConnetTimer = 0.0f;
                m_AttackAniNumber        = 0;
            }
        }

        if (PhotonNetwork.InRoom && !m_PhotonView.IsMine)
        {
            return;
        }

        if (m_IsAutoPlay)
        {
            if (m_AttackTarget != null)
            {
                if (m_AttackTarget.m_Character == null || m_AttackTarget.m_Character.m_Live == E_LIVE.DEAD)
                {
                    m_AttackTarget = null;
                    m_NavMeshController.ClearPath();
                }
            }

            if (m_DicHateTarget.Count > 0)
            {
                foreach (HateTarget h in m_DicHateTarget.Values)
                {
                    h.m_Hate -= deltatime * (1.0f + h.m_Hate * 0.1f);
                }
            }

            if (m_DicHateTarget.Count > 0)
            {
                List <int> deletekeys = new List <int>();
                foreach (HateTarget h in m_DicHateTarget.Values)
                {
                    if (h.m_Hate <= 0.0f || h.m_Character == null || h.m_Character.m_Live == E_LIVE.DEAD)
                    {
                        deletekeys.Add(h.m_Key);
                        continue;
                    }

                    if (m_AttackTarget == null)
                    {
                        m_AttackTarget = h;
                        break;
                    }
                    else if (h.m_Hate > m_AttackTarget.m_Hate)
                    {
                        m_AttackTarget = h;
                    }
                }

                if (deletekeys.Count > 0)
                {
                    for (int i = 0; i < deletekeys.Count; ++i)
                    {
                        m_DicHateTarget.Remove(deletekeys[i]);
                    }
                }
            }
        }

        if (m_Live == E_LIVE.DEAD)
        {
            return;
        }
        if (m_IsCharging)
        {
            return;
        }
        if (m_FreezeTimer > 0.0f)
        {
            return;
        }

        if (m_IsAutoPlay)
        {
            bool useskill = false;
            if (m_ListActiveSkill.Count > 0)
            {
                for (int i = 0; i < m_ListActiveSkill.Count; ++i)
                {
                    if (m_ListActiveSkill[i].AutoPlayLogic())
                    {
                        useskill = true;
                        break;
                    }
                }
            }
            if (useskill)
            {
                return;
            }

            m_AutoPlayLogic?.Invoke();
        }

        if (m_State != E_STATE.IDLE)
        {
            if (m_AttackDelayTimer <= 0.0f && !m_NavMeshController.IsUpdate())
            {
                m_State = E_STATE.IDLE;
                SetStateAndAnimationNetwork(E_ANIMATION.IDLE, 0.25f, 1.0f, 0.0f);
            }
        }

        m_NavMeshController.UpdateTransform(transform, m_MovePerSpeed, m_RotatePerSpeed);
    }