Logic control Processes Messages and other system reactions with regard to the current gamestate. It uses Message events to inform relevant classes.
示例#1
0
文件: Ballz.cs 项目: SpagAachen/Ballz
        private Ballz()
        {
            Teamnames = new List<string>();
            Graphics = new GraphicsDeviceManager(this);
            InitSettings();
            Content.RootDirectory = "Content";
            if(GameSettings.MSAASamples.Value > 1)
            {
                Graphics.PreferMultiSampling = true;
                msaaSettingsHandler = (object sender, PreparingDeviceSettingsEventArgs args) => {
                    args.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = GameSettings.MSAASamples.Value;
                };
                Graphics.PreparingDeviceSettings += msaaSettingsHandler;
            }
            Graphics.IsFullScreen = GameSettings.Fullscreen.Value;
            Graphics.PreferredBackBufferHeight = GameSettings.ScreenResolution.Value.Height;
            Graphics.PreferredBackBufferWidth = GameSettings.ScreenResolution.Value.Width;
            Window.AllowUserResizing = true;
            IsFixedTimeStep = false;

            Camera = new Camera();
            // create the Game Components
            MenuRenderer = new MenuRenderer(this);
            //var physics = new PhysicsControl(this);
            Input = new InputTranslator(this);
            Network = new Network.Network(this);

            Components.Add(Input);
            //Components.Add(physics);
            Components.Add(Network);
            Components.Add(MenuRenderer);
            Components.Add(new PerformanceRenderer(this));

            Logic = new LogicControl(this);

            Services.AddService(Logic);
            Services.AddService(Input);

            Services.AddService(new SoundControl(this));

            //add eventhandlers to events
            Input.Input += Logic.HandleInputMessage;
            //input.Input += physics.HandleMessage;
            Input.Input += Network.HandleMessage;

            //Logic.Message += physics.HandleMessage;
            Logic.Message += Network.HandleMessage;
            //Logic.Message += gameRendering.HandleMessage;
            Logic.Message += MenuRenderer.HandleMessage;

            Network.Message += Logic.HandleNetworkMessage;
        }
示例#2
0
        private Ballz()
        {
            Graphics = new GraphicsDeviceManager(this);
            initSettings();
            Content.RootDirectory = "Content";
            Graphics.IsFullScreen = GameSettings.Fullscreen.Value;
            Graphics.PreferredBackBufferHeight = GameSettings.ScreenResolution.Value.Height;
            Graphics.PreferredBackBufferWidth = GameSettings.ScreenResolution.Value.Width;
            Window.AllowUserResizing = true;
            IsFixedTimeStep = false;

            Camera = new Camera();
            // create the Game Components
            var menuRendering = new MenuRenderer(this, DefaultMenu());
            //var physics = new PhysicsControl(this);
            var input = new InputTranslator(this);
            Network = new Network.Network(this);

            Components.Add(input);
            //Components.Add(physics);
            Components.Add(Network);
            Components.Add(menuRendering);
            Components.Add(new PerformanceRenderer(this));

            MainMenu = DefaultMenu();
            Logic = new LogicControl(this);

            Services.AddService(Logic);
            Services.AddService(input);

            Services.AddService(new SoundControl(this));

            //add eventhandlers to events
            input.Input += Logic.HandleInputMessage;
            //input.Input += physics.HandleMessage;
            input.Input += Network.HandleMessage;

            //Logic.Message += physics.HandleMessage;
            Logic.Message += Network.HandleMessage;
            //Logic.Message += gameRendering.HandleMessage;
            Logic.Message += menuRendering.HandleMessage;

            Network.Message += Logic.HandleNetworkMessage;
        }