コード例 #1
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (group.HasAttackEnemy() || group.HasEscapeEnemy())
            {
                return(BehaveResult.Failure);
            }

            if (Time.time - m_Data.m_StartIdleTime > m_Data.m_CurrentIdleTime)
            {
                return(BehaveResult.Success);
            }

            group.PauseMemberBehave(false);
            return(BehaveResult.Running);
        }
コード例 #2
0
        BehaveResult Tick(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (group.HasEscapeEnemy())
            {
                return(BehaveResult.Success);
            }
            else
            {
                return(BehaveResult.Failure);
            }
        }
コード例 #3
0
        BehaveResult Init(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (!group.HasEscapeEnemy())
            {
                return(BehaveResult.Failure);
            }

            //m_StartTime = Time.time;
            m_LastRandomTime = 0.0f;

            group.PauseMemberBehave(true);
            return(BehaveResult.Running);
        }
コード例 #4
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (group.HasAttackEnemy() || group.HasEscapeEnemy())
            {
                return(BehaveResult.Failure);
            }

            if (Time.time - m_Data.m_StartPatrolTime > m_Data.m_Time)
            {
                return(BehaveResult.Success);
            }

            if (Time.time - m_Data.m_LastSwitchTime > m_Data.m_SwitchTime)
            {
                m_Data.m_LastSwitchTime = Time.time;
                m_Data.m_SwitchTime     = Random.Range(5.0f, 10.0f);

                m_Data.m_CurrentPatrolPosition = GetPatrolPosition(sender);
                if (m_Data.m_CurrentPatrolPosition != Vector3.zero)
                {
                    group.MoveToPosition(m_Data.m_CurrentPatrolPosition, SpeedState.Walk);
                }
            }

            //if (m_Data.m_CurrentPatrolPosition != Vector3.zero)
            //{
            //    //group.Patrol(m_Data.m_CurrentPatrolPosition);
            //    foreach (PeEntity skEntity in group.Entities)
            //    {
            //        if (skEntity != null && !skEntity.IsDeath())
            //        {
            //            Motion_Move mover = skEntity.GetComponent<Motion_Move>();
            //            if (mover != null && group.Leader != null)
            //            {
            //                PeTrans tr1 = mover.GetComponent<PeTrans>();
            //                PeTrans tr2 = group.Leader.GetComponent<PeTrans>();
            //                if (tr1 != null && tr2 != null)
            //                {
            //                    if(skEntity == group.Leader)
            //                        mover.MoveTo(m_Data.m_CurrentPatrolPosition);
            //                    else
            //                    {
            //                        if(PEUtil.SqrMagnitudeH(tr1.position, tr2.position) > tr1.radius * tr1.radius * 16)
            //                        {
            //                            mover.MoveTo(m_Data.m_CurrentPatrolPosition + (tr1.position-tr2.position).normalized * tr1.radius * Random.Range(3.0f, 5.0f));
            //                        }
            //                    }
            //                }
            //            }
            //        }
            //    }
            //}

            return(BehaveResult.Running);
        }