示例#1
0
        /// <summary>
        /// 加载所有的流程
        /// </summary>
        /// <param name="msgs"></param>
        public void LoadProceduces(List <Msg> msgs)
        {
            for (int i = 0; i < msgs.Count; i++)
            {
                BaseProcedure baseProcedure = LoadProcedure(msgs[i]);

                baseProcedure.OnLoad();

                procedureDic.Add(msgs[i].stringValue, baseProcedure);
            }
        }
示例#2
0
        /// <summary>
        /// 加载流程
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        private BaseProcedure LoadProcedure(Msg msg)
        {
            BaseProcedure baseProcedure = null;

            if (String.IsNullOrEmpty(msg.stringValue))
            {
                throw new SystemException("Argument cannot be null.");
            }

            baseProcedure = Activator.CreateInstance(Type.GetType(msg.stringValue)) as BaseProcedure;

            return(baseProcedure);
        }
示例#3
0
        public void ChangeProcedure(Msg msg)
        {
            string msgStringValue = msg.stringValue;

            if (procedureDic.ContainsKey(msgStringValue))
            {
                OnProceduceEvent(procedureDic[msgStringValue], msg);
            }
            else
            {
                BaseProcedure baseProcedure = LoadProcedure(msg);

                OnProceduceEvent(baseProcedure, msg);

                procedureDic.Add(msgStringValue, baseProcedure);
            }
        }
示例#4
0
        private void OnProceduceEvent(BaseProcedure baseProcedure, Msg msg)
        {
            if (!awakeProcedures.Contains(baseProcedure))
            {
                awakeProcedures.Add(baseProcedure);

                baseProcedure.OnAwake();
            }
            switch (msg.intValue)
            {
            case 0:
                baseProcedure.OnEnter(msg);
                break;

            case 1:
                baseProcedure.OnLeave(msg);
                break;

            case 2:
                baseProcedure.OnUnload();
                awakeProcedures.Remove(baseProcedure);
                break;
            }
        }