コード例 #1
0
        /* ENGINE EVENT HANDLERS */
        /// <summary>
        /// Stores reference to the camera, game window, and adds callback functions to keyboard/mouse events in the game window.
        /// <para>This function is called once the game's initialization procedure is complete to ensure that the needed resources exist.</para>
        /// </summary>
        /// <param name="gameEngine">An instance of the <see cref="Tesseract"/> game engine.</param>
        private void PostInitialize(Tesseract gameEngine)
        {
            // Store references to other engine objects
            Camera = gameEngine.Camera;
            MapManager = gameEngine.MapManager;
            Window = gameEngine.WindowManager.Window;

            // Register handlers for window events
            Window.KeyDown += KeyDownHandler;
            Window.KeyUp += KeyUpHandler;
            Window.MouseClick += MouseClickRouter;
            Window.MouseMove += MouseMoveHandler;

            // Initialize the mouse click handler
            OnLeftClick += DestroyTerrain;
        }
コード例 #2
0
ファイル: Tesseract.cs プロジェクト: JoshGrooms/Tesseract
        /* CONSTRUCTOR METHOD */
        /// <summary>
        /// Instantiates various manager classes, the camera, and debugging tools, and performs pre-initialization tasks.
        /// </summary>
        /// <param name="window">The window to display the game in.</param>
        public Tesseract(Form window)
        {
            // Instantiate the various game content managers
            DeviceManager = ToDispose(new DeviceManager(this));
            WindowManager = ToDispose(new WindowManager(window));
            BufferManager = ToDispose(new BufferManager(this));
            ShaderManager = ToDispose(new ShaderManager(this));
            ThreadManager = new ThreadManager(this);
            ControlManager = new ControlManager(this);
            MapManager = new MapManager(this);

            // Instantiate some core classes needed for basic operation
            Clock = Stopwatch.StartNew();
            Camera = new Camera(this);
            DebugPanel = ToDispose(new DebugPanel(this));

            // InterfaceManager = new InterfaceManager(this);	// Manages UIs
            // LightManager = new LightManager(this);			// Manages lighting effects (might not be needed...)
            // SoundManager = new SoundManager(this);			// Manages a library of sounds & music
            // TextureManager = new TextureManager(this);		// Manages a library of textures
            // CommandManager = new CommandManager(this);		// Manages & executes console commands
        }
コード例 #3
0
ファイル: Camera.cs プロジェクト: JoshGrooms/Tesseract
        /// <summary>
        /// Stores a reference to the map manager and initializes the projection matrix.
        /// </summary>
        /// <param name="gameEngine">An instance of the <see cref="Tesseract"/> game engine.</param>
        public void PostInitialize(Tesseract gameEngine)
        {
            // Initialize some data fields
            MapManager = gameEngine.MapManager;
            Clock = gameEngine.Clock;
            LastTime = (float)Clock.Elapsed.TotalSeconds;

            // Initialize the chunk position & start constructing chunks around the starting position
            ChunkPosition = Vector3.Zero;
            ThreadManager.NewMapTask(MapManager.TransitionChunk, ChunkPosition);

            // Setup the initial camera position & target parameters
            Position.X = SettingsManager.ChunkSize[1] / 2;
            Position.Z = -SettingsManager.ChunkSize[0] / 2;
            Position.Y = MapManager.GetHeight(Position.X, Position.Z) + 3;
            Target = new Vector3(Position.X, Position.Y, Position.Z - 1);

            // Create the projection matrix
            CreateProjection(gameEngine);
        }