Example #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>();
     }
 }
Example #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);
        }
Example #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>();
            }
        }
Example #4
0
 public override void Destroy()
 {
     base.Destroy();
     m_spacial = null;
 }
Example #5
0
 public CPawnMovementBaseState(string name, GameObject go) : base(name, go)
 {
     m_spacial = go.GetComponent <CUnitSpacialComp>();
 }
 void Start()
 {
     m_spacial = GetComponent <CUnitSpacialComp>();
     m_mover   = GetComponent <CPawnMovementComp>();
 }
Example #7
0
 protected virtual void OnDestroy()
 {
     m_spacial = null;
 }
Example #8
0
 void OnDestroy()
 {
     m_spacial = null;
     m_sm.Destroy();
 }