/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //_mViewMgr _mViewMgr = new ViewportMgr(); //_mInputMgr _mInputMgr = new InputMgr(); //Add Dedicated listeners IDedicatedListener temporaryMgr = (IDedicatedListener)_mViewMgr; _mInputMgr.AddDedicatedListener(temporaryMgr); IDedicatedListener tempGame = (IDedicatedListener)this; _mInputMgr.AddDedicatedListener(tempGame); _mEntArray = _mLevel.Populate(_mEntityMgr); foreach (IEntity tempEnt in _mEntArray) { _mSceneMgr.Add(tempEnt); _mCollisionMgr.AddCollider(tempEnt); _mMindBuilder.BuildMind(tempEnt); _mInputMgr.AddInputListener(tempEnt); _mViewMgr.AddTarget(tempEnt); } }
public void Update(float totalTime, float deltaTime) { IInputMgr inputMgr = IInputMgr.Instance; float offsetX = inputMgr.GetAxis(VirtualAxis.MouseAxisX); float offsetY = -inputMgr.GetAxis(VirtualAxis.MouseAxisY); float scrollOffset = inputMgr.GetAxis(VirtualAxis.MouseAxisZ); var tanX = offsetX * m_RotateSensitivity / m_Controller.Distance; var angleX = Mathf.Atan(tanX) * Mathf.Rad2Deg; var tanY = offsetY * m_RotateSensitivity / m_Controller.Distance; var angleY = Mathf.Atan(tanY) * Mathf.Rad2Deg; float curAngleY = m_Controller.AngleY; if (curAngleY + angleY > m_MaxYDegree) { angleY = m_MaxYDegree - curAngleY; } else if (curAngleY + angleY < m_MinYDegree) { angleY = m_MinYDegree - curAngleY; } m_Controller.AngleOffsetX = angleX; m_Controller.AngleOffsetY = angleY; m_Controller.Distance -= (scrollOffset * m_ScrollWheelSensitivity); m_Controller.Update(totalTime, deltaTime); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here //screen width and height ScreenHeight = GraphicsDevice.Viewport.Height; ScreenWidth = GraphicsDevice.Viewport.Width; //_mSceneMgr _mSceneMgr = new SceneMgr(); //_mEntityMgr _mEntityMgr = new EntityMgr(Content); //_mEntArray _mEntArray = new List <IEntity>(); //_mCollisionMgr _mCollisionMgr = new CollisionMgr(); //_mAIMgr _mAIMgr = new AIMgr(); //_mMindBuilder _mMindBuilder = new MindBuilder(_mAIMgr); //_mInputMgr _mInputMgr = new InputMgr(); //_mRenderMgr _mRenderMgr = new RenderMgr(Content, GraphicsDevice); //_mViewMgr _mViewMgr = new ViewportMgr(); //_mCamera _mCamera = new Camera(); //_mLevel _mLevel = new Level2(); base.Initialize(); graphics.PreferredBackBufferHeight = ScreenHeight / 2; graphics.PreferredBackBufferWidth = ScreenWidth / 2; }