Ejemplo n.º 1
0
            public static void MoveTo(this PeEntity entity, Vector3 dst)
            {
                Motion_Move mm = entity.GetCmpt <Motion_Move>();

                if (mm == null)
                {
                    return;
                }

                mm.MoveTo(dst);
            }
Ejemplo n.º 2
0
            public static void MoveTo(this PeEntity entity, Vector3 dest, float stopDistance, float speed)
            {
                Motion_Move mm = entity.GetCmpt <Motion_Move>();

                if (mm == null)
                {
                    return;
                }

                mm.SetSpeed(speed);
                mm.MoveTo(dest);
            }
Ejemplo n.º 3
0
    protected Vector3 GetTargetVeloctiy(Transform target)
    {
        if (target == null)
        {
            return(Vector3.zero);
        }

        Motion_Move mover = target.GetComponentInParent <Motion_Move>();

        if (mover != null)
        {
            return(mover.velocity);
        }
        else
        {
            return(Vector3.zero);
        }
    }
Ejemplo n.º 4
0
 public void MoveToPosition(Vector3 pos, SpeedState speed = SpeedState.Walk)
 {
     foreach (PeEntity skEntity in m_Entities)
     {
         if (skEntity != null && !skEntity.IsDeath())
         {
             Motion_Move mover = skEntity.GetComponent <Motion_Move>();
             if (mover != null && Leader != null)
             {
                 PeTrans tr1 = mover.GetComponent <PeTrans>();
                 PeTrans tr2 = Leader.GetComponent <PeTrans>();
                 if (tr1 != null && tr2 != null)
                 {
                     float r = 3 * Random.value * Mathf.Max(1.0f, Mathf.Max(tr1.radius, tr2.radius));
                     mover.MoveTo(pos + (tr1.position - tr2.position).normalized * r, speed);
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 public void SetHandler(Motion_Move move, ViewCmpt view, Motion_Beat beat)
 {
     m_Beat = beat;
 }
Ejemplo n.º 6
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 (m_Data.fly)
            {
                if (Time.time - m_StartTime < 0.5f)
                {
                    return(BehaveResult.Running);
                }

                group.ActivateGravity(false);
                group.Fly(true);

                return(BehaveResult.Success);
            }
            else
            {
                group.ActivateGravity(true);

                bool running = false;

                for (int i = 0; i < group.Entities.Count; i++)
                {
                    PeEntity e = group.Entities[i];
                    if (e != null)
                    {
                        MonsterCmpt monster = e.GetComponent <MonsterCmpt>();
                        Motion_Move mover   = e.GetComponent <Motion_Move>();
                        BehaveCmpt  behave  = e.GetComponent <BehaveCmpt>();

                        if (monster != null && mover != null && behave != null)
                        {
                            if (mover.grounded)
                            {
                                monster.Fly(false);
                                behave.Pause(false);

                                running = true;
                            }
                        }
                    }
                }

                if (running)
                {
                    return(BehaveResult.Running);
                }
                else
                {
                    return(BehaveResult.Success);
                }
            }
        }