Exemplo n.º 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);
        }
Exemplo n.º 2
0
        BehaveResult Tick(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

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

            if (group.HasAttackEnemy())
            {
                return(BehaveResult.Success);
            }
            else
            {
                return(BehaveResult.Failure);
            }
        }
Exemplo n.º 3
0
        BehaveResult Tick(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

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

            if (group.HasAttackEnemy())
            {
                group.PauseMemberBehave(false);
                return(BehaveResult.Running);
            }
            else
            {
                return(BehaveResult.Failure);
            }
        }
Exemplo n.º 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);
        }