Esempio n. 1
0
 /// <summary>
 /// 注册所有依赖的component, 在父类的awake中被调用
 /// </summary>
 protected virtual void RegisterAllComponents()
 {
     //初始化CUnitSpacialComp, 在awake中实现是为了防止时序问题
     //给别的类在start中做一些事情留有机会
     m_spacial = GetComponent <CUnitSpacialComp>();
     if (m_spacial == null)
     {
         m_spacial = gameObject.AddComponent <CUnitSpacialComp>();
     }
 }
Esempio n. 2
0
        void Awake()
        {
            m_spacial = GetComponent <CUnitSpacialComp>();
            if (m_spacial == null)
            {
                m_spacial = gameObject.AddComponent <CUnitSpacialComp>();
            }

            //默认我们用外部的移动器
            m_sm = new CStateMachine();
            m_sm.RegisterState(new CPawnMovementUnknow(gameObject));
            m_sm.RegisterState(new CPawnMovementDirectly(gameObject));
            m_sm.ChangeState(CPawnMovementUnknow.STATE);
        }
Esempio n. 3
0
        void Awake()
        {
            m_spacial = gameObject.GetComponent <CUnitSpacialComp>();
            if (m_spacial == null)
            {
                m_spacial = gameObject.AddComponent <CUnitSpacialComp>();
            }

            m_mover = gameObject.GetComponent <CPawnMovementComp>();
            if (m_mover == null)
            {
                m_mover = gameObject.AddComponent <CPawnMovementComp>();
            }

            m_pathFollower = gameObject.GetComponent <CPawnPathFollowingComp>();
            if (m_pathFollower == null)
            {
                m_pathFollower = gameObject.AddComponent <CPawnPathFollowingComp>();
            }
        }
Esempio n. 4
0
 public override void Destroy()
 {
     base.Destroy();
     m_spacial = null;
 }
Esempio n. 5
0
 public CPawnMovementBaseState(string name, GameObject go) : base(name, go)
 {
     m_spacial = go.GetComponent <CUnitSpacialComp>();
 }
Esempio n. 6
0
 void Start()
 {
     m_spacial = GetComponent <CUnitSpacialComp>();
     m_mover   = GetComponent <CPawnMovementComp>();
 }
Esempio n. 7
0
 protected virtual void OnDestroy()
 {
     m_spacial = null;
 }
Esempio n. 8
0
 void OnDestroy()
 {
     m_spacial = null;
     m_sm.Destroy();
 }