Пример #1
0
 public void Fly(bool value)
 {
     foreach (PeEntity entity in m_Entities)
     {
         if (entity != null && !entity.IsDeath())
         {
             MonsterCmpt cmpt = entity.GetComponent <MonsterCmpt>();
             if (cmpt != null)
             {
                 cmpt.Fly(value);
             }
         }
     }
 }
Пример #2
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);
                }
            }
        }