コード例 #1
0
 public void PauseMemberBehave(bool value)
 {
     foreach (PeEntity skEntity in m_Entities)
     {
         if (skEntity != null)
         {
             BehaveCmpt behave = skEntity.GetComponent <BehaveCmpt>();
             if (behave != null)
             {
                 behave.Pause(value);
             }
         }
     }
 }
コード例 #2
0
ファイル: PETower.cs プロジェクト: shrubba/planetexplorers
    void Start()
    {
        m_Entity = GetComponentInParent <PeEntity>();

        if (m_Entity != null)
        {
            m_Entity.SetAttribute(AttribType.CampID, campid);
            m_Entity.SetAttribute(AttribType.DamageID, damageid);

            TowerCmpt tower = m_Entity.gameObject.AddComponent <TowerCmpt>();
            tower.SkillID   = skillid;
            tower.NeedVoxel = false;
            tower.OnMsg(EMsg.View_Prefab_Build, null, transform.parent.GetComponent <BiologyViewRoot>());
            m_Entity.Tower = tower;

            BehaveCmpt behaveCmpt = m_Entity.gameObject.AddComponent <BehaveCmpt>();
            behaveCmpt.SetAssetPath(behavePath);
            behaveCmpt.OnMsg(EMsg.View_Model_Build);

            if (m_Entity.netCmpt != null)
            {
                m_Entity.netCmpt.OnMsg(EMsg.Net_Instantiate, campid, damageid);

                if (m_Entity.netCmpt.IsController)
                {
                    behaveCmpt.OnMsg(EMsg.Net_Controller);
                }
                else
                {
                    behaveCmpt.OnMsg(EMsg.Net_Proxy);
                }
            }

            m_Entity.BehaveCmpt = behaveCmpt;

            TargetCmpt targetCmpt = m_Entity.gameObject.AddComponent <TargetCmpt>();
            targetCmpt.OnMsg(EMsg.View_Model_Build, null, transform.parent.GetComponent <BiologyViewRoot>());
            m_Entity.target = targetCmpt;
        }
    }
コード例 #3
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);
                }
            }
        }