예제 #1
0
 public ProjectileManager(Dictionary <string, Texture2D> _textures, ProjectileEngine _projectileEngine)
 {
     textures         = _textures;
     projectileEngine = _projectileEngine;
 }
예제 #2
0
        /// <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);

            Dictionary <string, Animation> slugHealth = new Dictionary <string, Animation>()
            {
                { "3/4 heart", new Animation(Content.Load <Texture2D>("Slug_status/heart-3_4"), 1) },
                { "2/4 heart", new Animation(Content.Load <Texture2D>("Slug_status/heart-2_4"), 1) },
                { "1/4 heart", new Animation(Content.Load <Texture2D>("Slug_status/heart-1_4"), 1) },
                { "Empty heart", new Animation(Content.Load <Texture2D>("Slug_status/heart-empty"), 1) },
                { "Babo down hit", new Animation(Content.Load <Texture2D>("Babo/Babo down hit"), 1) },
                { "Heart", new Animation(Content.Load <Texture2D>("Slug_status/Heart"), 1) },
            };



            Dictionary <string, Animation> sightAnimation = new Dictionary <string, Animation>()
            {
                { "ON", new Animation(Content.Load <Texture2D>("Sight/Sight_on"), 1) },
                { "OFF", new Animation(Content.Load <Texture2D>("Sight/Sight_off"), 1) },
            };

            var slugTexture     = Content.Load <Texture2D>("Babo/Babo down0 s0");
            var sightTexture    = Content.Load <Texture2D>("Sight/Sight_off");
            var scenarioTexture = Content.Load <Texture2D>("Scenario/Block");
            //scenarioTexture = Content.Load<Texture2D>("Scenario/Beer");

            var projectileMenuTexture = Content.Load <Texture2D>("Slug_status/SaltMenu");

            projectileTexture = new Dictionary <string, Texture2D>()
            {
                { "Normal", Content.Load <Texture2D>("Projectile/Salt") },
                { "Direct", Content.Load <Texture2D>("Projectile/DirectSalt") },
                { "Slimed", Content.Load <Texture2D>("Projectile/NoNewtonianSlimedSalt") },
            };

            slimeTexture = Content.Load <Texture2D>("Projectile/slime2");

            characterSprites = new List <Character>();

            // La mira necessita que li passem inputManager per obtenir la posició del ratolí
            overlaySprites = new List <Sprite>()
            {
                new SightWeapon(sightAnimation, inputManager)
                {
                    Position    = new Vector2(100, 100),
                    Scale       = 0.2f,
                    SolidObject = false,
                    Layer       = 1f,
                },
            };

            scenarioSprites = new List <ScenarioObjects>()
            {
                new ScenarioObjects(scenarioTexture)
                {
                    Position         = new Vector2(400, 100),
                    Scale            = 0.2f,
                    SolidObject      = true,
                    HitBoxScale      = 1f,
                    HasConducitivity = true,
                    Charge           = 'P',
                },

                new ScenarioObjects(scenarioTexture)
                {
                    Position         = new Vector2(400, 500),
                    Scale            = 0.2f,
                    SolidObject      = true,
                    HitBoxScale      = 1f,
                    HasConducitivity = true,
                    Charge           = 'N',
                },
            };

            characterEngine = new CharacterEngine(characterSprites, Content);
            characterEngine.AddKnownCharacter("Kaler", new Vector2(100, 100), 0.20f, 20, 1, Color.White);
            characterEngine.AddKnownCharacter("Babo", new Vector2(300, 300), 0.20f, 40, 2, Color.White);
            characterEngine.AddKnownCharacter("Limax", new Vector2(500, 500), 0.20f, 20, 3, Color.White);


            heartManager = new HeartManager(overlaySprites);
            heartManager.CreateHeart(1, 5, 20, slugHealth, new Vector2(100, 300));
            heartManager.CreateHeart(2, 10, 39, slugHealth, new Vector2(100, 400)); //--------------------- Babo prova
            heartManager.CreateHeart(3, 5, 20, slugHealth, new Vector2(500, 100));  //--------------------- Babo prova

            projectileSprites = new List <Projectile>();
            projectileEngine  = new ProjectileEngine(projectileSprites);
            projectileManager = new ProjectileManager(projectileTexture, projectileEngine);
            projectileManager.CreateSaltMenu(projectileMenuTexture, overlaySprites, 1, 0.1f);

            // punter que apunta al personatge controlat pel jugador
            playerChar  = characterSprites.ToArray()[0];
            playerChar2 = characterSprites.ToArray()[1]; //------------------------- Babo prova
            playerChar3 = characterSprites.ToArray()[2]; //------------------------- Babo prova
            _font       = Content.Load <SpriteFont>("Font");

            //timer
            timer           = new Timer(60);
            timer.AutoReset = true;
            timer.Enabled   = true;
            debugger        = new Debugger(characterSprites, projectileSprites, overlaySprites, slimeSprites, timer.Interval, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, _font);
        }