コード例 #1
0
        public override bool Update()
        {
            if (null == trans || null == m_TargetAction || null == m_TargetMotion)
            {
                return(true);
            }

            Vector3 targetPos = m_TargetTrans.position + m_TargetTrans.rotation * offset;
            float   angle     = Vector3.Angle(m_TargetTrans.forward, trans.forward);

            if (m_AnimMatch)
            {
                if (Vector3.SqrMagnitude(trans.position - targetPos) > maxDis * maxDis)
                {
                    EndAction();
                    return(true);
                }
            }
            else
            {
                if (Vector3.SqrMagnitude(trans.position - targetPos) > startDis * startDis)
                {
                    move.MoveTo(targetPos, SpeedState.Walk);
                }
                else if (angle > startAngle)
                {
                    move.RotateTo(m_TargetTrans.forward);
                }
                else
                {
                    m_AnimMatch = true;
                    m_TargetAction.OnHand();
                    m_Interaction = new Interaction_Hand();
                    m_Interaction.Init(motionMgr.Entity.transform, m_TargetMotion.Entity.transform);
                    m_Interaction.StartInteraction();
                    if (null != m_MoveAction)
                    {
                        m_MoveAction.rotateSpeedScale = rotateScale;
                    }
                }

                if (Time.time - m_StartTime > tryHandTime)
                {
                    if (m_CurTryCount > tryHandCount)
                    {
                        EndAction();
                    }
                    else
                    {
                        m_StartTime = Time.time;
                        m_CurTryCount++;
                        m_TargetMotion.Entity.motionMove.RotateTo(Quaternion.AngleAxis(tryRotateAngle, m_TargetTrans.existent.up) * m_TargetTrans.forward);
                    }
                }
            }
            return(m_EndAction);
        }
コード例 #2
0
        void OnEndAction(bool immediately)
        {
            motionMgr.SetMaskState(PEActionMask.Hand, false);

            if (null != m_Interaction)
            {
                m_Interaction.EndInteraction(immediately);
                m_Interaction = null;
            }

            if (null != m_TargetMotion)
            {
                m_TargetMotion.EndAction(PEActionType.Handed);
            }

            if (null != m_MoveAction)
            {
                m_MoveAction.rotateSpeedScale = 1f;
            }
        }