Exemple #1
0
        public void DrawScore(SpriteBatch spriteBatch, TextureManager textureManager, Vector2 position1, Vector2 position2)
        {
            spriteBatch.Draw(textureManager.Texture("scoresheet"), position1, SpriteCreators.spriteSourceRectangles["score_SCORE"], Color.White);
            DrawNumber(spriteBatch, textureManager, position1 + new Vector2((float)SpriteCreators.spriteSourceRectangles["score_SCORE"].Width + 30f, 0), playerLeftScore);

            spriteBatch.Draw(textureManager.Texture("scoresheet"), position2, SpriteCreators.spriteSourceRectangles["score_SCORE"], Color.White);
            DrawNumber(spriteBatch, textureManager, position2 + new Vector2((float)SpriteCreators.spriteSourceRectangles["score_SCORE"].Width + 30f, 0), playerRightScore);

        }
Exemple #2
0
        public void DrawNumber(SpriteBatch spriteBatch, TextureManager textureManager, Vector2 position, int number)
        {
            string num = number.ToString();

            for (int i = 0; i < num.Length; i++)
            {
                Texture2D numTexture = textureManager.Texture("scoresheet");
                Rectangle sourcerec = SpriteCreators.spriteSourceRectangles["score_" + num[i]];

                spriteBatch.Draw(numTexture, position + new Vector2(0, 10), sourcerec, Color.White);
                position.X += sourcerec.Width + 10;
            }
        }
Exemple #3
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()
        {
            // TODO: Add your initialization logic here
            GameWorld.Initialize(0, 5700, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f));
            GameWorld.ViewPortXOffset = 0;

            SpriteCreators.Load("Content\\spritesheet.txt");

            // Create the texture manager
            textureManager = new TextureManager(Content);

            // Now load the sprite creator factory helper
            factory = GameObjectFactory.Instance;
            factory.Initialize(textureManager);

            cannonManager = new CannonManager();
            cannonGroups = new List<CannonGroups>();

            client = new ClientNetworking();
            client.Connect();
            client.ActionHandler["shoot"] = new EventHandler(this.HandleNetworkShoot);
            client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate);

            // Add a few sprite creators
            factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat);
            factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog);
            factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom);
            factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1);
            factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2);
            factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3);
            factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight);
            factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon);
            factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel);
            factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar);
            factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab);

            mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups);

            base.Initialize();
        }
 public void Initialize(TextureManager textureManager)
 {
     this.textureManager = textureManager;
 }
Exemple #5
0
 public void Initialize(TextureManager textureManager)
 {
     this.textureManager = textureManager;
 }
Exemple #6
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()
        {
            // TODO: Add your initialization logic here
            GameWorld.Initialize(0, 12234 - ( 1080 * 2), this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f));
            GameWorld.ViewPortXOffset = 0;

            SpriteCreators.Load("Content\\spritesheet.txt");

            MapLoaded = false;

            // Create the texture manager
            textureManager = new TextureManager(Content);

            //Create the audio manager
            AudioManager.Instance.Initialize(Content);


            // Now load the sprite creator factory helper
            factory = GameObjectFactory.Instance;
            factory.Initialize(textureManager);

            cannonManager = new CannonManager();
            cannonGroups = new List<CannonGroups>();


            client = new ClientNetworking();
            client.Connect();
            client.ActionHandler["shoot"] = new EventHandler(this.HandleNetworkShoot);
            client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate);
            client.ActionHandler["plane"] = new EventHandler(this.HandleNetworkPlane);
            client.ActionHandler["createother"] = new EventHandler(this.HandleNetworkCreateOtherStuff);
            client.ActionHandler["reset"] = new EventHandler(this.HandleReset);
            client.ActionHandler["endgame"] = new EventHandler(this.HandleEndGame);
            client.ActionHandler["sendpoints"] = new EventHandler(this.HandleSendPoints);

            // Add a few sprite creators
            factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat);
            factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog);
            factory.AddCreator((int)GameObjectTypes.SUN, SpriteCreators.CreateSun);
            factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom);
            factory.AddCreator((int)GameObjectTypes.PUFF, SpriteCreators.CreatePuff);
            factory.AddCreator((int)GameObjectTypes.DINO, SpriteCreators.CreateDino);
            factory.AddCreator((int)GameObjectTypes.CLOUD1, SpriteCreators.CreateCloud1);
            factory.AddCreator((int)GameObjectTypes.CLOUD2, SpriteCreators.CreateCloud2);
            factory.AddCreator((int)GameObjectTypes.CLOUD3, SpriteCreators.CreateCloud3);
            factory.AddCreator((int)GameObjectTypes.CLOUD4, SpriteCreators.CreateCloud4);
            factory.AddCreator((int)GameObjectTypes.CLOUD5, SpriteCreators.CreateCloud5);
            factory.AddCreator((int)GameObjectTypes.CLOUD6, SpriteCreators.CreateCloud6);
            factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1);
            factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2);
            factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3);
            factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight);
            factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon);
            factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel);
            factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar);
            factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab);
            factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion1);
            factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion2);
            factory.AddCreator((int)GameObjectTypes.PLANE, SpriteCreators.CreatePlane);
            factory.AddCreator((int)GameObjectTypes.CATSPLODE, SpriteCreators.CreateCatsplode);
            factory.AddCreator((int)GameObjectTypes.DUSTSPLODE, SpriteCreators.CreateDustsplode);
            factory.AddCreator((int)GameObjectTypes.YOULOSE, SpriteCreators.CreateYouLose);
            factory.AddCreator((int)GameObjectTypes.YOUWIN, SpriteCreators.CreateYouWin);
            factory.AddCreator((int)GameObjectTypes.SCOREPLUS50, SpriteCreators.CreatePlus50);
            factory.AddCreator((int)GameObjectTypes.SCOREPLUS100, SpriteCreators.CreatePlus100);
            factory.AddCreator((int)GameObjectTypes.SCOREPLUS250, SpriteCreators.CreatePlus250);

            //factory.AddCreator((int)GameObjectTypes.EAHSCSLOGO, SpriteCreators.CreateEAHSCSLogo);

            mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups, ScreenConfiguration);

            base.Initialize();
        }