Exemplo n.º 1
0
        /// <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()
        {
            //Register our ContentManager
            //ContentButler.setGame(this);
            Master.Initialize(this);

            //Setup screen display/graphics device
            ViewportHandler.SetScreen(ScreenWidth, ScreenHeight);
            graphics.PreferredBackBufferWidth       = ViewportHandler.GetWidth();
            graphics.PreferredBackBufferHeight      = ViewportHandler.GetHeight();
            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Graphics.CGraphics.acquireGraphics(ref graphics);



            Master.SetClearColor(Color.CornflowerBlue);

            CTextures.init(Content);

            Master.Push(new DevMenu());
            //Master.Push(new PlayableState());

            Master.GetInputManager().AddInputHandler(new CInput());

            base.Initialize();
        }
Exemplo n.º 2
0
        private void InitializeLocal()
        {
            this._imageOrigin = getTextureOrigin();

            imageOffset = 300 + this._imageOrigin.Y;                  //testing, but fits the screen nicely.
            //imageOffset = 196 + this._imageOrigin.Y; //old, for 64x64
            radius = (ViewportHandler.GetHeight() / 2) + imageOffset; // bad chris
        }
Exemplo n.º 3
0
        public TestCreditState()
        {
            int y = ViewportHandler.GetWidth();
            int x = ViewportHandler.GetHeight();

            foreach (string key in creditsData)
            {
                Credits.Add(new Credit());
                Credits[Credits.Count() - 1].creditText = key;
                Credits[Credits.Count() - 1].position.X = x / 2;
                Credits[Credits.Count() - 1].position.Y = y / 2;
                y += 100;
            }
            MenuText = "Credit Test";
            LoadContent();
        }
Exemplo n.º 4
0
        protected override void LoadContent()
        {
            device      = graphics.GraphicsDevice;
            spriteBatch = new SpriteBatch(device);

            if (resultionIndependent)
            {
                GameResolutionWidth  = ViewportHandler.GetWidth();
                GameResolutionHeight = ViewportHandler.GetHeight();
            }
            else
            {
                GameResolutionWidth  = device.PresentationParameters.BackBufferWidth;
                GameResolutionHeight = device.PresentationParameters.BackBufferHeight;
            }
        }
Exemplo n.º 5
0
    private void ComputeResolution()
    {
        //float deviceWidth;
        //float deviceHeight;
        float leftX, rightX, topY, bottomY;

        //deviceWidth = Screen.width;
        //deviceHeight = Screen.height;

        if (constraint == Constraint.Landscape)
        {
            //camera.orthographicSize : half of the vertical size of the camera
            //camera.aspect : width divided by height
            camera.orthographicSize = 1f / camera.aspect * UnitsSize / 2f;
        }
        else
        {
            camera.orthographicSize = UnitsSize / 2f;
        }

        _height = 2f * camera.orthographicSize;
        _width  = _height * camera.aspect;

        float cameraX, cameraY;

        cameraX = camera.transform.position.x;
        cameraY = camera.transform.position.y;

        leftX   = cameraX - _width / 2;
        rightX  = cameraX + _width / 2;
        topY    = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl      = new Vector3(leftX, topY, 0);
        _tc      = new Vector3(cameraX, topY, 0);
        _tr      = new Vector3(rightX, topY, 0);
        Instance = this;
    }
Exemplo n.º 6
0
        private void CreateGrid()
        {
            int screenWidth  = ViewportHandler.GetWidth();
            int screenHeight = ViewportHandler.GetHeight();

            int boxWidth  = screenWidth / gridBoxesHorizontal;
            int boxHeight = screenHeight / gridBoxesVertical;

            for (int x = 0; x <= screenWidth; x += boxWidth)
            {
                lines.Add(drawingHelper.CreateLine(1, Color.White, new Vector2(x, 0), new Vector2(x, screenHeight)));
            }
            for (int y = 0; y <= screenHeight; y += boxHeight)
            {
                lines.Add(drawingHelper.CreateLine(1, Color.White, new Vector2(0, y), new Vector2(screenWidth, y)));
            }
        }
Exemplo n.º 7
0
        /// <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()
        {
            //Register our ContentManager
            //ContentButler.setGame(this);
            Master.Initialize(this);

            //Setup screen display/graphics device
            ViewportHandler.SetScreen(ScreenWidth, ScreenHeight);
            graphics.PreferredBackBufferWidth       = ViewportHandler.GetWidth();
            graphics.PreferredBackBufferHeight      = ViewportHandler.GetHeight();
            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Graphics.CGraphics.acquireGraphics(ref graphics);
            graphics.SynchronizeWithVerticalRetrace = true;
            CGraphics.fullScreenRenderTarget        = new RenderTarget2D(CGraphics.GPU, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true, SurfaceFormat.Color, DepthFormat.Depth24);

            _fpsTimer.Elapsed += new ElapsedEventHandler(_fpsHandler);
            _fpsTimer.Enabled  = true;
            _fpsTimer.Start();

            Master.SetClearColor(Color.Black);

            CTextures.init(Content);

            Master.Push(new DevMenu());
            //Master.Push(new PlayableState());

            Master.GetInputManager().AddInputHandler(new CInput());
            CMasterControl.glblInput        = Master.GetInputManager().GetCurrentInputHandler() as Input.CInput;
            CMasterControl.healthController = new Actors.HUD.health.CHealthController(20, 78);
            CMasterControl.magicMeter       = new Actors.HUD.magic.CMagicMeter();

            scaleMatrix = Matrix.CreateScale(
                3f,
                3f,
                1f);

            base.Initialize();
        }
Exemplo n.º 8
0
        protected override void Initialize()
        {
            //GEARSDEBUG VERSION. This is the version of the game module, not the VGE.
            VersionManager.Version = "ALPHA";

            //Register our Game to Master
            Master.Initialize(this);

            //Setup screen display/graphics device
            ViewportHandler.SetScreen(GameResolutionWidth, GameResolutionHeight);
            graphics.PreferredBackBufferWidth  = WindowResolutionWidth;
            graphics.PreferredBackBufferHeight = WindowResolutionHeight;
            //graphics.
            graphics.IsFullScreen = false;
            //graphics.
            graphics.ApplyChanges();


            #if DEBUG
            Window.Title = "Gears [Debug] v." + VersionManager.Version + " using GearsVGE v." + VersionManager.GearsVGEVersion;

            // MAYBE TODO: Make this enum based for easier switching?
            //  DEBUG :: The uncommented line will change the default state that runs first.
            //  Only one of the following Master.Push() lines should be uncommented at a time.
            //Master.Push(new Splash());    //Uncomment this line to start game normally.
            Master.Push(new DebugBootstrapper());        //Uncomment this line to start the game with debug menu.
            //  END of Master.Push() lines
            #else //release
            Window.Title = "Gears v." + VersionManager.Version;
            Master.Push(new Splash());     //Start game normally
            #endif


            Gears.Cloud.Media.AudioPlayer.start();

            //Master.GetInputManager().GetCurrentInputHandler()
            base.Initialize();
        }
Exemplo n.º 9
0
 private void Awake()
 {
     camera   = GetComponent <Camera>();
     Instance = this;
     ComputeResolution();
 }
Exemplo n.º 10
0
 private void Awake()
 {
     camera = GetComponent<Camera>();
     Instance = this;
     ComputeResolution();
 }
Exemplo n.º 11
0
 private void Initialize()
 {
     splashRectangle = new Rectangle(0, 0, ViewportHandler.GetWidth(), ViewportHandler.GetHeight());
 }
Exemplo n.º 12
0
 private void Initialize()
 {
     menuItemFont = Master.GetGame().Content.Load <SpriteFont>(@"Fonts\MenuItem");
     safeArea     = ViewportHandler.GetViewport().TitleSafeArea;
 }
Exemplo n.º 13
0
 private void InitializeLocal()
 {
     imageOffset = 196 + this._imageOrigin.Y;
     radius      = (ViewportHandler.GetHeight() / 2) + imageOffset;// bad chris
 }
Exemplo n.º 14
0
        protected override void Draw(GameTime gameTime)
        {
            Vector3 screenScalingFactor;

            if (resultionIndependent)
            {
                float horScaling = (float)device.PresentationParameters.BackBufferWidth / ViewportHandler.GetWidth();
                float verScaling = (float)device.PresentationParameters.BackBufferHeight / ViewportHandler.GetHeight();
                screenScalingFactor = new Vector3(horScaling, verScaling, 1);
            }
            else
            {
                screenScalingFactor = new Vector3(1, 1, 1);
            }

            Matrix globalTransformation = Matrix.CreateScale(screenScalingFactor);



            /**************************************/
            device.Clear(Master.GetClearColor());

            //spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, globalTransformation);
            spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, RasterizerState.CullNone, null, globalTransformation);
            //spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);//, SaveStateMode.None);//, ViewportHandler.GetScaleMatrix());

            Master.Draw(spriteBatch);

            spriteBatch.End();

            base.Draw(gameTime);
        }