예제 #1
0
        /************************************************************************/
        /* start up                                                             */
        /************************************************************************/
        public override bool Startup(StateManager _mgr)
        {
            // store reference to engine, this state does not need to store the state manager reference
            mEngine = _mgr.Engine;

            if (File.Exists("map.txt"))
            {
                using (TextReader reader = File.OpenText("map.txt"))
                {
                    /*byte[] buffer = new byte[1];
                     * while (fs.Read(buffer, 0, buffer.Length) > 0)
                     * {
                     *  if (byte[0] == '0') {
                     *      SceneNode tile = mEngine.CreateSimpleObject("Droit", "droit.mesh");
                     *      if (tile != null)
                     *      {
                     *          mMapTiles.Add(tile);
                     *          mEngine.AddObjectToScene(tile);
                     *      }
                     *  }
                     * }*/
                }
            }

            // OK
            return(true);
        }
예제 #2
0
        /// <summary>
        /// Start up the state
        /// </summary>
        /// <param name="_mgr">State manager for this state</param>
        /// <returns></returns>
        public override bool Startup(StateManager _mgr)
        {
            // store reference to the state manager
            StateMgr = _mgr;

            // get reference to the ogre manager
            OgreManager engine = StateMgr.Engine;

            //Instantiate everything
            WeatherMgr = new WeatherManager();
            CityManager.SetGameMgr(this);

            //Initialize everythings
            createScene(engine);
            createUI();
            createCommands();
            //Initialize the City Manager (that's everything right?)
            CityManager.Init(0, 0);

            CompositorManager.Singleton.AddCompositor(engine.Window.GetViewport(0), "Bloom");
            CompositorManager.Singleton.AddCompositor(engine.Window.GetViewport(0), "Radial Blur");

            // OK
            return(true);
        }
예제 #3
0
        private void setupCamera(OgreManager engine)
        {
            focalPoint          = engine.SceneMgr.RootSceneNode.CreateChildSceneNode("focalPoint");
            focalPoint.Position = new Vector3(0, 0, 0);

            engine.Camera.NearClipDistance = 5;
            engine.Camera.FarClipDistance  = 2048;
            engine.Camera.AutoAspectRatio  = true;
            engine.Camera.SetAutoTracking(true, focalPoint);
        }
예제 #4
0
        /// <summary>
        /// Provide input handling during the game.
        /// </summary>
        /// <param name="mStateMgr"></param>
        private void HandleInput(StateManager mStateMgr)
        {
            // get reference to the ogre manager
            OgreManager engine = mStateMgr.Engine;
            MoisManager input  = mStateMgr.Input;

            HandleMouseMove(input);
            if (mStateMgr.Input.WasMouseButtonPressed(MouseButtonID.MB_Left))
            {
                HandleLeftMousePressed(input);
            }
            if (mStateMgr.Input.WasMouseButtonPressed(MouseButtonID.MB_Middle))
            {
                HandleMiddleMousePressed(input);
            }
            if (mStateMgr.Input.WasMouseButtonPressed(MouseButtonID.MB_Right))
            {
                HandleRightMousePressed(input);
            }
            if (mStateMgr.Input.IsMouseButtonDown(MouseButtonID.MB_Left))
            {
                HandleLeftMouseHeld(input);
            }
            if (mStateMgr.Input.IsMouseButtonDown(MouseButtonID.MB_Middle))
            {
                HandleMiddleMouseHeld(input);
            }
            if (mStateMgr.Input.IsMouseButtonDown(MouseButtonID.MB_Right))
            {
                HandleRightMouseHeld(input);
            }
            if (mStateMgr.Input.WasMouseButtonReleased(MouseButtonID.MB_Left))
            {
                HandleLeftMouseReleased(input);
            }
            if (mStateMgr.Input.WasMouseButtonReleased(MouseButtonID.MB_Middle))
            {
                HandleMiddleMouseReleased(input);
            }
            if (mStateMgr.Input.WasMouseButtonReleased(MouseButtonID.MB_Right))
            {
                HandleRightMouseReleased(input);
            }
            HandleKeyboard(input);
        }
예제 #5
0
파일: Program.cs 프로젝트: nwrush/Snowflake
        static void Main()
        {
            // create Ogre manager
            mEngine = new OgreManager();

            // create state manager
            mStateMgr = new StateManager(mEngine);

            // create main program
            Program prg = new Program();

            // try to initialize Ogre and the state manager
            if (mEngine.Startup() && mStateMgr.Startup((BOOT_INTO_GAME ? typeof(GameLoopState) : typeof(MenuState))))
            {
                // create objects in scene
                prg.CreateScene();

                // run engine main loop until the window is closed
                while (!mEngine.Window.IsClosed)
                {
                    // update the objects in the scene
                    prg.UpdateScene();

                    // update Ogre and render the current frame
                    mEngine.Update();

                    // check if state manager is in shutting down state
                    if (mStateMgr.ShuttingDown)
                    {
                        // destroy the window to shut down the application
                        mEngine.Window.Destroy();
                    }
                }

                // remove objects from scene
                prg.RemoveScene();
            }

            // shut down state manager
            mStateMgr.Shutdown();

            // shutdown Ogre
            mEngine.Shutdown();
        }
예제 #6
0
        /// <summary>
        /// Set up camera and call other createScene methods
        /// </summary>
        /// <param name="engine"></param>
        public void createScene(OgreManager engine)
        {
            engine.SceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;

            setupCamera(engine);

            //Cursor plane
            cursorPlane    = engine.SceneMgr.RootSceneNode.CreateChildSceneNode("cursorPlane");
            cursorPlaneEnt = engine.SceneMgr.CreateEntity("cursorPlaneEnt", "cursorplane.mesh");
            cursorPlane.AttachObject(cursorPlaneEnt);
            cursorPlane.Scale(new Vector3(SCALEFACTOR, SCALEFACTOR, SCALEFACTOR));
            cursorPlaneEnt.CastShadows = false;

            //Selection box
            selectionBox    = engine.SceneMgr.RootSceneNode.CreateChildSceneNode("selectionBox");
            selectionBoxEnt = engine.SceneMgr.CreateEntity("selectionBoxEnt", "selectionbox.mesh");
            selectionBox.AttachObject(selectionBoxEnt);
            selectionBox.Scale(new Vector3(SCALEFACTOR, SCALEFACTOR / 2.0f, SCALEFACTOR));
            selectionBoxEnt.CastShadows = false;
            selectionBox.SetVisible(false);

            //Scratch zone
            Plane plane = new Plane(Vector3.UNIT_Y, 0);

            MeshManager.Singleton.CreatePlane("scratchZonePlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, Renderable.PlotWidth, Renderable.PlotHeight, 1, 1, true, 1, 1, 1, Vector3.UNIT_Z);
            scratchZoneEnt = engine.SceneMgr.CreateEntity("scratchZoneNode", "scratchZonePlane");

            scratchZone = engine.SceneMgr.RootSceneNode.CreateChildSceneNode();
            scratchZone.AttachObject(scratchZoneEnt);

            scratchZoneEnt.CastShadows = false;
            scratchZone.Translate(new Vector3(0, 1, 0));
            scratchZone.SetVisible(false);


            WeatherMgr.CreateScene(engine.SceneMgr);
            CityManager.CreateScene(engine.SceneMgr);
        }
예제 #7
0
        static void Main()
        {
            // create Ogre manager
            mEngine = new OgreManager();

            // create state manager
            mStateMgr = new StateManager(mEngine);

            // create main program
            Program prg = new Program();

            // try to initialize Ogre and the state manager
            if (mEngine.Startup() && mStateMgr.Startup(typeof(InGame)))
            {
                // create objects in scene
                prg.CreateScene();

                // run engine main loop until the window is closed
                while (!mEngine.Window.IsClosed)
                {
                    // update the objects in the scene
                    prg.UpdateScene();

                    // update Ogre and render the current frame
                    mEngine.Update();
                }

                // remove objects from scene
                prg.RemoveScene();
            }

            // shut down state manager
            mStateMgr.Shutdown();

            // shutdown Ogre
            mEngine.Shutdown();
        }
예제 #8
0
 /************************************************************************/
 /* constructor                                                          */
 /************************************************************************/
 public InGame()
 {
     mEngine = null;
 }