//单利
 public static SingletonPattern GetInstace()
 {
     if (Instance == null)
     {
         Instance = new SingletonPattern();
     }
     return(Instance);
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            SingletonPattern.GetInstace().Init();//注册

            SingletonPattern.GetInstace().SwithcStateMachine(0);
            SingletonPattern.GetInstace().SwithcStateMachine((GameState)1);

            try
            {
                object temp2 = null;
                string temp1 = temp2.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine("错误原因" + e.Message);
                SingletonPattern.GetInstace().SwithcStateMachine((GameState)2);
            }

            Console.ReadKey();
        }
Esempio n. 3
0
 public void ComeEvent(State state)
 {
     Console.WriteLine("进入ERROR状态   开始切换End状态");
     SingletonPattern.GetInstace().SwithcStateMachine(GameState.GAME_CONNECT_END);//切换状态结束
 }