Exemplo n.º 1
0
        private int yDiference; //Should be a vector if dealing with 2 axis;

        #endregion Fields

        #region Constructors

        public Camera2D(Main game, Vector2 translation, float rotation, float scale)
            : base(game)
        {
            this.game = game;

            //we need access to viewport to get dimensions of screen
            //we cant use windowDimensions because we may want to create more than one viewport (i.e. for splitscreen)
            this.viewPort = game.GraphicsDevice.Viewport;

            //sets the position of the camera
            this.translation = translation;

            //sets any rotation around Z (i.e. coming out of the screen)
            this.rotation = rotation;

            //sets the zoom level (i.e. if > 1 zoom in, if < 1 zoom out, bounded at minimum value)
            //call property and not this.scale to ensure scale not set to less than minimum
            SCALE = scale;

            //stored for reset
            this.originalTranslation = translation;
            this.originaRotation = rotation;
            this.originalScale = scale;

            //Calc this properly, with game data etc.
            this.minY = 300;
            this.maxY = 2100;

            this.cameraElasticity = 0.1f;
            this.yDiference = 0;
        }
Exemplo n.º 2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Main game = new Main())
     {
         game.Run();
     }
 }
Exemplo n.º 3
0
        public MenuManager(Main game, String[] strMenuTextures,
            String strMenuFont, Integer2 textureBorderPadding)
            : base(game)
        {
            this.game = game;

            //nmcg - create an array of textures
            this.menuTextures = new Texture2D[strMenuTextures.Length];

            //nmcg - load the textures
            for (int i = 0; i < strMenuTextures.Length; i++)
            {
                this.menuTextures[i] =
                    game.Content.Load<Texture2D>(@"" + strMenuTextures[i]);
            }

            //nmcg - load menu font
            this.menuFont = game.Content.Load<SpriteFont>(@"" + strMenuFont);

            //nmcg - stores all menu item (e.g. Save, Resume, Exit) objects
            this.menuItemList = new List<MenuItem>();

            //sets menu texture to fullscreen minus and padding on XY
            this.textureRectangle = new Rectangle(textureBorderPadding.X,
                textureBorderPadding.Y,
                game.SCREENBOUNDS.Width - 2 * textureBorderPadding.X,
                game.SCREENBOUNDS.Height - 2 * textureBorderPadding.Y);
        }
Exemplo n.º 4
0
        public UIManager(Main game)
            : base(game)
        {
            this.depth = 0.05f;

            List<AnimatedTextureData> heartAni = new List<AnimatedTextureData>();
            heartAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("heartFull"));
            heartAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("heartEmpty"));

            List<AnimatedTextureData> keyAni = new List<AnimatedTextureData>();
            keyAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("keyEmpty"));
            keyAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("keyFull"));

            List<AnimatedTextureData> coinNumberAni = new List<AnimatedTextureData>();
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinZero"));
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinOne"));
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinTwo"));
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinThree"));

            this.heartOne = new ModularAnimatedSprite("heartOne",
                heartAni,
                new SpritePresentationInfo(heartAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(5, 5), heartAni[0].FRAMEWIDTH, heartAni[0].FRAMEHEIGHT),
                10);

            this.heartTwo= new ModularAnimatedSprite("heartTwo",
                heartAni,
                new SpritePresentationInfo(heartAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(63, 5), heartAni[0].FRAMEWIDTH, heartAni[0].FRAMEHEIGHT),
                10);

            this.heartThree = new ModularAnimatedSprite("heartThree",
                heartAni,
                new SpritePresentationInfo(heartAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(121, 5), heartAni[0].FRAMEWIDTH, heartAni[0].FRAMEHEIGHT),
                10);

            this.coin = new Sprite("coin",
                SpriteManager.GAME.TEXTUREMANAGER.Get("hud_spritesheet"),
                new SpritePresentationInfo(new Rectangle(55, 0, 47, 47), depth),
                new SpritePositionInfo(new Vector2(5, 55), 47, 47));

            this.coinX = new Sprite("coinX",
                SpriteManager.GAME.TEXTUREMANAGER.Get("hud_spritesheet"),
                new SpritePresentationInfo(new Rectangle(0, 239, 30, 28), depth),
                new SpritePositionInfo(new Vector2(60, 65), 30, 28));

            this.coinNumber = new ModularAnimatedSprite("coinNumber",
                coinNumberAni,
                new SpritePresentationInfo(coinNumberAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(95, 60), coinNumberAni[0].FRAMEWIDTH, coinNumberAni[0].FRAMEHEIGHT),
                10);

            this.key = new ModularAnimatedSprite("key",
                keyAni,
                new SpritePresentationInfo(keyAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(10, 112), keyAni[0].FRAMEWIDTH, keyAni[0].FRAMEHEIGHT),
                10);
        }
Exemplo n.º 5
0
        public SpriteManager(Main theGame)
            : base(theGame)
        {
            this.list = new List<Sprite>();

            //store static pointer to game
            game = theGame;
        }
Exemplo n.º 6
0
        public TextureData(Main game, Texture2D texture)
        {
            this.texture = texture;
            setColorData(texture);

            this.fullSourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
            this.centreOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
        }
Exemplo n.º 7
0
        public TextureData(Main game, string path)
        {
            this.texture = game.Content.Load<Texture2D>(@"" + path);
            setColorData(texture);

            this.fullSourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
            this.centreOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
        }
Exemplo n.º 8
0
 public CloudFactory(Main game, List<Rectangle> cloudSources, float minSpeed, int maxClouds, Rectangle boundary)
     : base(game)
 {
     this.minSpeed = minSpeed;
     this.maxClouds = maxClouds;
     this.boundary = boundary;   //level boundary
     this.currentClouds = new List<Cloud>();
     this.cloudSources = cloudSources;
     this.random = new Random();
     this.backgroundDepth = 0.4f;
 }
Exemplo n.º 9
0
        public TextureManager(Main game)
        {
            //Debug to allow us to visualise the bounding rectangle - remove for release
            if (GameData.DEBUG_SHOW_BOUNDING_RECTANGLES)
            {
                DEBUG_BOUNDING_RECTANGLE_TEXTURE = game.Content.Load<Texture2D>(@"Assets\\Debug\\debugrect");
            }

            this.game = game;
            this.textureDictionary = new Dictionary<string, TextureData>();
        }
Exemplo n.º 10
0
        public MouseManager(Main game, bool isVisible)
            : base(game)
        {
            //allows us to set mouse visibility
            this.isVisible = isVisible;
            game.IsMouseVisible = isVisible;

            this.game = game;
            this.bounds = new Rectangle(0,0,1,1);
            this.game.IsMouseVisible = true;
        }
        //code repition not good.
        public AnimatedTextureData(Main game, Texture2D texture, List<Rectangle> frameSources)
            : base()
        {
            this.texture = texture;

            this.numberOfFrames = frameSources.Count;
            this.frameWidth = frameSources[0].Width;
            this.frameHeight = frameSources[0].Height;

            this.fullSourceRectangle = new Rectangle(0, 0, frameWidth, frameHeight);
            this.centreOrigin = new Vector2(frameWidth / 2, frameHeight / 2);

            this.frameSources = frameSources;
            this.textureColorData2DList = new List<Color[,]>(numberOfFrames);
            setColorData(texture);
        }
Exemplo n.º 12
0
 public SoundEffectInfo(Main game, string effectName,
     string effectFileName, float volume, float pitch, float pan, bool loop)
 {
     set(game, effectName, effectFileName, volume, pitch, pan, loop);
 }
Exemplo n.º 13
0
 public void set(Main game, string effectName,
     string effectFileName, float volume, float pitch, float pan, bool loop)
 {
     this.soundEffect = game.Content.Load<SoundEffect>(@"" + effectFileName);
     this.effectFileName = effectFileName;
     this.effectName = effectName;
     this.volume = volume; this.pitch = pitch; this.pan = pan;
     this.loop = loop;
 }