Esempio n. 1
0
        /// <summary>
        /// 创建游戏状态的环境
        /// </summary>
        /// <param name="assembly">重写游戏状态所在的程序集</param>
        public void CreateContext(Assembly assembly)
        {
            if (_stateContext != null)
            {
                return;
            }

            PEIState_Context stateContext = new PEIState_Context();
            List <PEIState>  listState    = new List <PEIState>();

            Type[] types = assembly.GetTypes();
            foreach (var item in types)
            {
                object[] attribute = item.GetCustomAttributes(typeof(PEIStateAttribute), false);
                if (attribute.Length <= 0 || item.IsAbstract)
                {
                    continue;
                }
                PEIStateAttribute stateAttribute = (PEIStateAttribute)attribute[0];
                if (stateAttribute.StateType == PEIState_Type.Ignore)
                {
                    continue;
                }
                object   obj = Activator.CreateInstance(item);
                PEIState gs  = obj as PEIState;
                if (gs != null)
                {
                    listState.Add(gs);
                    if (stateAttribute.StateType == PEIState_Type.Start)
                    {
                        _startState = gs;
                    }
                }
            }
            stateContext.SetAllState(listState.ToArray());
            _stateContext = stateContext;
        }
Esempio n. 2
0
 /// <summary>
 /// 关闭
 /// </summary>
 public override void OnClose()
 {
     _stateContext.Close();
     _stateContext = null;
 }
Esempio n. 3
0
 internal void SetStateContext(PEIState_Context context)
 {
     _context = context;
 }