private void Play_Click(object sender, RoutedEventArgs e)
        {
            Object     boi           = null;
            MethodInfo NWConstructor = GameType.GetMethod($"Init", new Type[] { typeof(int) });
            Object     nextWindow    = NWConstructor.Invoke(boi, new Object[] { BoundNumber });
            MethodInfo NWShow        = GameType.GetMethod($"Show", new Type[] { });

            NWShow.Invoke(nextWindow, null);
            this.Close();
        }
示例#2
0
        public GLScene CreateObject(bool newGame)
        {
            GameObject = Activator.CreateInstance(GameType);
            MethodInfo initMethod = GameType.GetMethod("InitEngine");

            try
            {
                initMethod.Invoke(GameObject, new object[] { gameData, game });
            }
            catch (TargetInvocationException e)
            {
                game.sc.Error = e.InnerException.InnerException.Message;
                return(game);
            }
            MethodInfo methodInfo  = GameType.GetMethod("GetView");
            MethodInfo setupGame   = GameType.GetMethod("SetupGame");
            MethodInfo preActions  = GameType.GetMethod("PreActions");
            MethodInfo postActions = GameType.GetMethod("PostActions");

            try
            {
                if (newGame)
                {
                    setupGame.Invoke(GameObject, null);
                }
                preActions.Invoke(GameObject, null);
                methodInfo.Invoke(GameObject, null);
                postActions.Invoke(GameObject, null);
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException.GetType() == typeof(RediredctException))
                {
                    game.sc.Redirect = e.InnerException.Message;
                    if (e.InnerException.InnerException != null && e.InnerException.InnerException.Message != null)
                    {
                        game.sc.Error = e.InnerException.InnerException.Message;
                    }
                }
                else if (e.InnerException.GetType() == typeof(MessageException))
                {
                    game.sc.Redirect = e.InnerException.Message;
                    if (e.InnerException.InnerException != null && e.InnerException.InnerException.Message != null)
                    {
                        game.sc.Message = e.InnerException.InnerException.Message;
                    }
                }
                else
                {
                    throw new Exception(e.Message, e);
                }
            }
            return(game);
        }