예제 #1
0
 public static void PopSence()
 {
     //通知原Sence将要消失
     if (sencesList.Count > 0)
     {
         ConsoleSence originalSence = sencesList[sencesList.Count - 1];
         originalSence.SenceWillDisappear();
         sencesList.RemoveAt(sencesList.Count - 1);
     }
     Console.Clear();
     //如果有上一个Sence的话,显示
     if (sencesList.Count > 0)
     {
         ConsoleSence previousSence = sencesList[sencesList.Count - 1];
         previousSence.SenceDidLoad();
         previousSence.DrawSence();
     }
 }
예제 #2
0
        /// <summary>
        /// 切换Sence,清屏,绘制目标Sence,目标Sence开始接收用户输入
        /// </summary>
        /// <param name="destinationSence">切换到的 sence.</param>
        public static void PresentSence(ConsoleSence destinationSence)
        {
            if (destinationSence == null)
            {
                throw new Exception("参数destinationSence不能为空");
            }

            //通知原Sence将要消失
            if (sencesList.Count > 0)
            {
                ConsoleSence originalSence = sencesList[sencesList.Count - 1];
                originalSence.SenceWillDisappear();
            }
            //显示目标Sence
            sencesList.Add(destinationSence);
            Console.Clear();
            destinationSence.SenceDidLoad();
            destinationSence.DrawSence();
        }