Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            base.LoadContent();

            var Content = GameRef.Content;
            states = SaveDataParser.SaveStates;

            if (StartMenuScreen.Background is PictureBox)
            {
                background = StartMenuScreen.Background as PictureBox;
                ControlManager.Add(background);
            }
            else
                backgroundAnim = StartMenuScreen.Background as Animation;

            Texture2D arrowTexture = Content.Load<Texture2D>("GUI\\leftarrowUp");
            arrowImage = new PictureBox(arrowTexture, new Rectangle(0, 0, arrowTexture.Width, arrowTexture.Height));
            ControlManager.Add(arrowImage);

            for (int i = 0; i < 5; i++)
            {
                LinkLabel label = new LinkLabel();

                if (SaveDataParser.GetSaveAtIndex(i) == null)
                {
                    label.Text = "-- No Save Game Found --";
                    label.Enabled = false;
                    label.Color = Color.DarkGray;
                }
                else
                    label.Text = SaveDataParser.GetSaveAtIndex(i).Name + " -- " + SaveDataParser.GetSaveAtIndex(i).Time;

                label.Size = label.SpriteFont.MeasureString(label.Text);
                label.Selected += new EventHandler(menuItem_Selected);
                label.Effect = ControlEffect.GLOW;
                labels.Add(label);
                ControlManager.Add(label);
            }

            ControlManager.NextControl();
            ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged);

            Vector2 position = new Vector2(ProjectElements.Data.ProjectData.GameWidth / 2, 100);

            foreach (Control c in ControlManager)
            {
                if (c is LinkLabel)
                {
                    Vector2 offset = new Vector2(c.Size.X / 2, 0);
                    if (c.Size.X > maxItemWidth)
                        maxItemWidth = c.Size.X;
                    c.Position = position - offset;
                    position.Y += c.Size.Y + 10f;
                }
            }
            ControlManager_FocusChanged(labels[0], null);
        }
Ejemplo n.º 2
0
        protected override void SetTexture()
        {
            Texture2D[] imgsRight = new Texture2D[] {
                EntityManager.koopaSheet.GetSubImage(0, 0),
                EntityManager.koopaSheet.GetSubImage(1, 0)
            };

            movRight = new Animation(imgsRight, 300f);
            imgRight = new Image(imgsRight[0]);

            width = 24;
            height = 32;
        }
Ejemplo n.º 3
0
        public override void SetAnimation()
        {
            var sheet = SheetManager.SpriteSheets["player"];

            Texture2D[] imgsUp = new Texture2D[3] { sheet.GetSubImage(0, 3), sheet.GetSubImage(1, 3), sheet.GetSubImage(2, 3) };
            Texture2D[] imgsDown = new Texture2D[3] { sheet.GetSubImage(0, 0), sheet.GetSubImage(1, 0), sheet.GetSubImage(2, 0) };
            Texture2D[] imgsLeft = new Texture2D[3] { sheet.GetSubImage(0, 1), sheet.GetSubImage(1, 1), sheet.GetSubImage(2, 1) };
            Texture2D[] imgsRight = new Texture2D[3] { sheet.GetSubImage(0, 2), sheet.GetSubImage(1, 2), sheet.GetSubImage(2, 2) };

            animUp = new Animation(imgsUp);
            animDown = new Animation(imgsDown);
            animLeft = new Animation(imgsLeft);
            animRight = new Animation(imgsRight);
        }
Ejemplo n.º 4
0
        public override void SetAnimation()
        {
            var sheet = SheetManager.SpriteSheets["allEntities"];

            Texture2D[] imgsUp = new Texture2D[3] { sheet.GetSubImage(6, 3), sheet.GetSubImage(7, 3), sheet.GetSubImage(8, 3) };
            Texture2D[] imgsDown = new Texture2D[3] { sheet.GetSubImage(6, 0), sheet.GetSubImage(7, 0), sheet.GetSubImage(8, 0) };
            Texture2D[] imgsLeft = new Texture2D[3] { sheet.GetSubImage(6, 1), sheet.GetSubImage(7, 1), sheet.GetSubImage(8, 1) };
            Texture2D[] imgsRight = new Texture2D[3] { sheet.GetSubImage(6, 2), sheet.GetSubImage(7, 2), sheet.GetSubImage(8, 2) };

            animUp = new Animation(imgsUp);
            animDown = new Animation(imgsDown);
            animLeft = new Animation(imgsLeft);
            animRight = new Animation(imgsRight);
        }
Ejemplo n.º 5
0
        public Player(ContentManager content)
            : base(new Vector2(AsteroidGame.ScreenBounds.Width / 2, AsteroidGame.ScreenBounds.Height / 2))
        {
            topSpeed = 4;
            SetTexture(content, "player");
            gameContent = content;
            _scale = 0.65f;
            _mass = 40;

            // Load the explosion spritesheet and explosion animation
            explosionSheet = new SpriteSheet(content.Load<Texture2D>("explosion_sheet"),
                90, 90, AsteroidGame.graphics.GraphicsDevice);
            explosion = new Animation(new Texture2D[] {explosionSheet.GetSubImage(0, 0),
                explosionSheet.GetSubImage(1, 0), explosionSheet.GetSubImage(2, 0),
                explosionSheet.GetSubImage(3, 0), explosionSheet.GetSubImage(4, 0),
                explosionSheet.GetSubImage(0, 1),
                explosionSheet.GetSubImage(1, 1), explosionSheet.GetSubImage(2, 1),
                explosionSheet.GetSubImage(3, 1), explosionSheet.GetSubImage(4, 1),
                content.Load<Texture2D>("Blank") , content.Load<Texture2D>("Blank")}, 100f);
        }
Ejemplo n.º 6
0
        public Citizen(Vector2 pos)
            : base("Citizen", pos)
        {
            var rand = new Random();
            var nameIndex = rand.Next(names.Length);
            Name = names[nameIndex];

            Texture2D[] imgs1, imgs2, imgs3;
            imgs1 = new Texture2D[2];
            imgs2 = new Texture2D[2];
            imgs3 = new Texture2D[2];
            for (int i = 0; i < 2; i++)
            {
                imgs1[i] = nameIndex % 2 == 0 ? ProjectData.Content.Load<Texture2D>("Sprites\\Up" + i.ToString()) :
                    ProjectData.Content.Load<Texture2D>("Sprites\\Up" + i.ToString());
            }
            for (int i = 0; i < 2; i++)
            {
                imgs2[i] = nameIndex % 2 == 0 ? ProjectData.Content.Load<Texture2D>("Sprites\\Left" + i.ToString()) :
                    ProjectData.Content.Load<Texture2D>("Sprites\\Left" + i.ToString());
            }
            for (int i = 0; i < 2; i++)
            {
                imgs3[i] = nameIndex % 2 == 0 ? ProjectData.Content.Load<Texture2D>("Sprites\\Down" + i.ToString()) :
                    ProjectData.Content.Load<Texture2D>("Sprites\\Down" + i.ToString());
            }

            movingUp = new Animation(imgs1);
            movingRight = new Animation(imgs2);
            movingDown = new Animation(imgs3);

            avatarUp = new Image(imgs1[0]);
            avatarRight = new Image(imgs2[0]);
            avatarDown = new Image(imgs3[0]);

            dialogue = genericPhrases[rand.Next(genericPhrases.Length)];
        }
Ejemplo n.º 7
0
        protected override void SetTexture()
        {
            //var tempTexture = new DrawableRectangle(ProjectData.GraphicsDevice, new Vector2(48, 48), Color.Black, true);
            //imgLeft = new Image(tempTexture.Texture);
            //imgRight = new Image(tempTexture.Texture);
            //width = imgLeft.Width;
            //height = imgLeft.Height;

            imgRight = new Image(ProjectData.Content.Load<Texture2D>("megaman"));

            var imagesRight = new Texture2D[] { EntityManager.runningSheet.GetSubImage(0, 0),
                EntityManager.runningSheet.GetSubImage(0, 1), EntityManager.runningSheet.GetSubImage(0, 2),
                EntityManager.runningSheet.GetSubImage(0, 3), EntityManager.runningSheet.GetSubImage(0, 4) };
            var imagesLeft = new Texture2D[] { EntityManager.runningSheet.GetSubImage(1, 0),
                EntityManager.runningSheet.GetSubImage(1, 1), EntityManager.runningSheet.GetSubImage(1, 2),
                EntityManager.runningSheet.GetSubImage(1, 3), EntityManager.runningSheet.GetSubImage(1, 4) };
            var jumpsRight = new Texture2D[] { EntityManager.jumpSheet.GetSubImage(0, 0),
                EntityManager.jumpSheet.GetSubImage(0, 1), EntityManager.jumpSheet.GetSubImage(0, 2),
                EntityManager.jumpSheet.GetSubImage(0, 2),EntityManager.jumpSheet.GetSubImage(0, 2),
                EntityManager.jumpSheet.GetSubImage(0, 2),EntityManager.jumpSheet.GetSubImage(0, 2),};

            movLeft = new Animation(imagesLeft, 65f);
            movRight = new Animation(imagesRight, 65f);
            jumpRight = new Animation(jumpsRight, 150f);

            width = 44;
            height = 42;
        }
        public static void Initialize(Texture2D particleTexture, Animation explosionFrame)
        {
            ParticleTexture = particleTexture;

            ExplosionFrames.Clear();

            foreach (Texture2D frame in explosionFrame.Images)
            {
                ExplosionFrames.Add(frame);
            }
        }
Ejemplo n.º 9
0
        protected override void LoadContent()
        {
            base.LoadContent();

            ContentManager Content = Game.Content;
            Color selectedColor = Color.Navy;

            int selectedWallpaper = new Random().Next(4);   // Choose between four backgrounds

            switch (selectedWallpaper)
            {
                case 0:   // This is the animation. Hence, the texture2d array
                    {
                        Texture2D[] images = new Texture2D[8];
                        for (int i = 0; i < 8; i++)
                        {
                            images[i] = Content.Load<Texture2D>("Backgrounds\\exploded_bg\\water" + i.ToString());
                        }
                        backGround = new Animation(images);
                        Background = backGround;
                        break;
                    }
                case 1:
                    {
                        Texture2D bg1 = Content.Load<Texture2D>("Backgrounds\\bamboo");
                        picBackGround = new PictureBox(bg1, new Rectangle(0, 0, ProjectData.GameWidth, ProjectData.GameHeight),
                            new Rectangle(0, 0, bg1.Width, bg1.Height));
                        picBackGround.Position = new Vector2(0, 0);
                        ControlManager.Add(picBackGround);
                        break;
                    }
                case 2:
                    {
                        Texture2D bg2 = Content.Load<Texture2D>("Backgrounds\\temple");
                        picBackGround = new PictureBox(bg2, new Rectangle(0, 0, ProjectData.GameWidth, ProjectData.GameHeight),
                            new Rectangle(0, 0, bg2.Width, bg2.Height));
                        picBackGround.Position = new Vector2(0, 0);
                        ControlManager.Add(picBackGround);
                        break;
                    }
                case 3:
                    {
                        Texture2D bg3 = Content.Load<Texture2D>("Backgrounds\\marketplace");
                        picBackGround = new PictureBox(bg3, new Rectangle(0, 0, bg3.Width, ProjectData.GameHeight),
                            new Rectangle(0, 0, bg3.Width, bg3.Height));
                        picBackGround.Position = new Vector2(0, 0);
                        ControlManager.Add(picBackGround);
                        break;
                    }

            }

            if (selectedWallpaper > 0)
                Background = picBackGround;

            Texture2D arrowTexture = Content.Load<Texture2D>("GUI\\leftarrowUp");
            arrowImage = new PictureBox(arrowTexture, new Rectangle(0, 0, arrowTexture.Width, arrowTexture.Height));
            arrowImage.Effect = ControlEffect.FLASH;
            ControlManager.Add(arrowImage);

            title = new Label();
            title.SpriteFont = Content.Load<SpriteFont>("Fonts\\titleFont");
            title.Text = "O  R  I  G  I  N  S";
            title.Size = title.SpriteFont.MeasureString(title.Text);

            if (selectedWallpaper == 0)
                title.Color = Color.Black;

            title.Position = new Vector2(ProjectElements.Data.ProjectData.GameWidth / 2 -
                title.Size.X / 2, ProjectData.GameHeight / 8);
            ControlManager.Add(title);

            continueGame = new LinkLabel();
            continueGame.Enabled = (ProjectData.cachedSave != null);
            continueGame.Text = "Continue...";
            continueGame.Size = continueGame.SpriteFont.MeasureString(continueGame.Text);
            continueGame.Selected += new EventHandler(menuItem_Selected);

            if (!continueGame.Enabled)
                continueGame.Color = new Color(30, 30, 30);

            ControlManager.Add(continueGame);

            startGame = new LinkLabel();
            startGame.Text = "New Game";
            startGame.Size = startGame.SpriteFont.MeasureString(startGame.Text);
            startGame.Selected += menuItem_Selected;
            ControlManager.Add(startGame);

            loadGame = new LinkLabel();
            loadGame.Enabled = SaveDataParser.SaveStates.Count > 0;
            loadGame.Text = "Load Game";
            loadGame.Size = loadGame.SpriteFont.MeasureString(loadGame.Text);
            loadGame.Selected += menuItem_Selected;

            if (!loadGame.Enabled)
                loadGame.Color = new Color(30, 30, 30);

            ControlManager.Add(loadGame);

            exitGame = new LinkLabel();
            exitGame.Text = "Quit";
            exitGame.Size = exitGame.SpriteFont.MeasureString(exitGame.Text);
            exitGame.Selected += menuItem_Selected;
            ControlManager.Add(exitGame);

            ControlManager.NextControl();

            ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged);
            Vector2 position = new Vector2(ProjectElements.Data.ProjectData.GameWidth / 2, ProjectData.GameHeight / 1.75f);

            foreach (Control c in ControlManager)
            {
                if (c is LinkLabel)
                {
                    Vector2 offset = new Vector2(c.Size.X / 2, 0);
                    if (c.Size.X > maxItemWidth)
                        maxItemWidth = c.Size.X;
                    c.Position = position - offset;
                    position.Y += c.Size.Y + 10f;
                    c.Effect = ControlEffect.GLOW;
                    c.FlashDuration = 300;

                    if (selectedWallpaper == 0)
                    {
                        c.Color = Color.Black;
                        ((LinkLabel)c).SelectedColor = selectedColor;
                    }
                }
            }

            if (continueGame.Enabled)
                ControlManager_FocusChanged(continueGame, null);
            else
                ControlManager_FocusChanged(startGame, null);
        }
        protected override void LoadContent()
        {
            base.LoadContent();

            Art.Load(gameRef.Content);

            backgroundoverlay = new DrawableRectangle(GraphicsDevice, new Vector2(Game1.GAME_WIDTH, Game1.GAME_HEIGHT), Color.White, true).Texture;

            SpriteSheet explosionSs = new SpriteSheet(content.Load<Texture2D>("explosion"), 32, 32, gameRef.GraphicsDevice);
            Texture2D[] imgs = new Texture2D[] {
                explosionSs.GetSubImage(0, 0),
                explosionSs.GetSubImage(1, 0),
                explosionSs.GetSubImage(2, 0)
            };
            var explode = new Animation(imgs);
            EffectManager.Initialize(content.Load<Texture2D>("particle"), explode);

            if (singlePlayer)
                backgroundImage = content.Load<Texture2D>("Screen Images\\apocalypselondon");
        }
Ejemplo n.º 11
0
        protected override void LoadContent()
        {
            base.LoadContent();

            var Content = gameRef.Content;

            IOManager.Init();

            blackOverlay = new DrawableRectangle(GraphicsDevice,
                new Vector2(MainGame.GAME_WIDTH, MainGame.GAME_HEIGHT), Color.White, true).Texture;

            blurOverlay = new GaussianBlur(gameRef);
            blurOverlay.ComputeKernel(7, 2.0f);

            titleImage = Content.Load<Texture2D>("Images\\title");

            title = new Label();
            title.SpriteFont = Content.Load<SpriteFont>("Fonts\\title");
            title.Text = "";
            title.Color = Color.White;
            title.Position = new Vector2(MainGame.GAME_WIDTH / 2 - title.Width / 2, 90);
            controls.Add(title);

            Texture2D[] images = new Texture2D[8];
            for (int i = 0; i < images.Length; i++)
            {
                images[i] = Content.Load<Texture2D>("Images\\waterfall\\water" + i.ToString());
            }

            anim = new Animation(images);

            #region Menu State
            menuControls = new ControlManager(gameRef, Content.Load<SpriteFont>("Fonts\\default"));

            var start = new LinkLabel(0) { Name = "lnklblStart", Text = "New Game" };
            var load = new LinkLabel(1) { Name = "lnklblLoad", Text = "Load Game" };
            var options = new LinkLabel(2) { Name = "lnklblOptions", Text = "Options" };
            var quit = new LinkLabel(3) { Name = "lnklblQuit", Text = "Quit Game" };

            menuControls.Add(start);
            menuControls.Add(load);
            menuControls.Add(options);
            menuControls.Add(quit);

            Vector2 startPos = new Vector2(MainGame.GAME_WIDTH / 2, MainGame.GAME_HEIGHT / 1.8f);
            foreach (Control c in menuControls)
            {
                if (c is LinkLabel)
                {
                    var l = (LinkLabel)c;
                    var offset = new Vector2(c.Width / 2, 0);
                    c.Position = startPos - offset;
                    c.Selected += new EventHandler(LinkLabel_Selected);
                    c.Effect = ControlEffect.PULSE;
                    c.Color = Color.Black;
                    ((LinkLabel)c).SelectedColor = Color.DarkBlue;

                    l.OnMouseIn += LinkLabel_OnMouseIn;

                    startPos.Y += c.Height + 10f;
                }
            }

            menuControls.SelectControl(0);
            #endregion

            #region New Game State
            newGameControls = new ControlManager(gameRef, Content.Load<SpriteFont>("Fonts\\default"));

            Label prompt = new Label();
            prompt.Text = "Enter your name";
            prompt.Name = "lblNamePrompt";
            prompt.Position = new Vector2(MainGame.GAME_WIDTH / 2 -
                prompt.SpriteFont.MeasureString(prompt.Text).X / 2, 200);
            newGameControls.Add(prompt);

            TextBox name = new TextBox(GraphicsDevice);
            name.Name = "txtName";
            name.Position = new Vector2(prompt.Position.X + 40, prompt.Position.Y + prompt.Height + 10);
            name.BackColor = Color.Transparent;
            name.ForeColor = Color.White;
            newGameControls.Add(name);

            LinkLabel startGame = new LinkLabel(2) { Name = "lnklblNewGame", Text = "Start" };
            startGame.Position = new Vector2(prompt.Position.X, name.Position.Y + 44);
            startGame.OnMouseIn += LinkLabel_OnMouseIn;
            startGame.Selected += (o, e) =>
            {
                Config.currentlyPlaying = newGameControls[1].Text;
                SwitchStateWithFade(new LoadingState(gameRef, StateManager, new GameplayState(gameRef, StateManager)));
            };
            startGame.Effect = ControlEffect.PULSE;

            LinkLabel cancel = new LinkLabel(3) { Name = "lnklblCancel", Text = "Cancel" };
            cancel.Position = new Vector2(prompt.Position.X + prompt.Width - cancel.Width, startGame.Position.Y);
            cancel.OnMouseIn += LinkLabel_OnMouseIn;
            cancel.Selected += (o, e) => { currentState = State.Menu; };
            cancel.Effect = ControlEffect.PULSE;

            newGameControls.Add(startGame);
            newGameControls.Add(cancel);
            #endregion

            #region Load Game State
            loadGameControls = new ControlManager(gameRef, Content.Load<SpriteFont>("Fonts\\default"));

            List<EntityProperties> saves = new List<EntityProperties>();
            saves = IOManager.GetAllPlayerDatas();

            startPos = new Vector2(MainGame.GAME_WIDTH / 2, 0);
            int counter = 0;
            foreach (EntityProperties ep in saves)
            {
                var lnklblLoadSave = new LinkLabel(counter++);
                lnklblLoadSave.AutoSize = true;
                lnklblLoadSave.Name = "lnklblLoadSave";
                lnklblLoadSave.Text = ep.Name + " | " + ep.TimeOfSave;
                lnklblLoadSave.OnMouseIn += LinkLabel_OnMouseIn;
                lnklblLoadSave.Selected += (o, e) => { SwitchStateWithFade(new LoadingState(gameRef, StateManager, new GameplayState(gameRef, StateManager, ep))); };
                lnklblLoadSave.Effect = ControlEffect.PULSE;

                var offset = new Vector2(lnklblLoadSave.Width / 2, 0);
                lnklblLoadSave.Position = startPos - offset;
                startPos.Y += lnklblLoadSave.Height + 10;
                loadGameControls.Add(lnklblLoadSave);
            }

            var goBack_Load = new LinkLabel(loadGameControls.Count);
            goBack_Load.Name = "lnklblGoBackLoad";
            goBack_Load.Text = "Go Back";
            goBack_Load.Effect = ControlEffect.PULSE;
            goBack_Load.Position = new Vector2(MainGame.GAME_WIDTH / 2 - goBack_Load.Width / 2, MainGame.GAME_HEIGHT - goBack_Load.Height - 100);
            goBack_Load.OnMouseIn += LinkLabel_OnMouseIn;
            goBack_Load.Selected += (o, e) => { currentState = State.Menu; };
            loadGameControls.Add(goBack_Load);

            #endregion

            #region Options Game State

            #endregion

            #region Quit State
            quitControls = new ControlManager(gameRef, Content.Load<SpriteFont>("Fonts\\default"));

            Label areYouSure1 = new Label();
            areYouSure1.Name = "lblAreYouSure?";
            areYouSure1.Text = "Are you sure you want to quit?";
            areYouSure1.Position = new Vector2(MainGame.GAME_WIDTH / 2 - areYouSure1.SpriteFont.MeasureString(
                areYouSure1.Text).X / 2, 140);
            quitControls.Add(areYouSure1);

            LinkLabel yes = new LinkLabel(1) { Name = "lnklblYes", Text = "Yes" };
            yes.Position = new Vector2(areYouSure1.Position.X + 40, areYouSure1.Position.Y + areYouSure1.Height + 50);
            yes.OnMouseIn += LinkLabel_OnMouseIn;
            yes.Selected += (o, e) => { gameRef.Exit(); };
            yes.Effect = ControlEffect.PULSE;

            LinkLabel no = new LinkLabel(2) { Name = "lnklblNo", Text = "No" };
            no.Position = new Vector2(areYouSure1.Position.X + areYouSure1.Width - no.Width - 40, yes.Position.Y);
            no.OnMouseIn += LinkLabel_OnMouseIn;
            no.Selected += (o, e) => { currentState = State.Menu; };
            no.Effect = ControlEffect.PULSE;

            quitControls.Add(yes);
            quitControls.Add(no);
            #endregion

            debugFont = Content.Load<SpriteFont>("Fonts\\version");
        }
Ejemplo n.º 12
0
        public Player(PlayerIndex playerIndex)
            : base(Vector2.Zero)
        {
            this.playerIndex = playerIndex;

            // Initialize the player based on playerIndex
            // ---------------------------------------------------------------
            // I seperate the initialization of players into two if statements:
            // PlayerIndex.One and PlayerIndex.Two.  As of right now, I won't
            // add any more (for laziness sake) and will keep initialization
            // like this.  I'm sorry if this code offends you.
            // ---------------------------------------------------------------
            if (playerIndex == PlayerIndex.One)
            {
                // Set the position to be on the left side of the screen
                Position = new Vector2(0, Game1.GAME_HEIGHT / 2 - height / 2);

                // Set the shooting key based on playerIndex
                shootingKey = Keys.Tab;

                // Organize the moving keys
                movingKeys = new Keys[4] { Keys.W, Keys.S, Keys.A, Keys.D };

                // Tint is chosen from the IntroState
                tint = IntroState.player1Color;
                sprite.Tint = tint;

                // First player will be facing right
                dir = 1;
                flipped = false;

                GunOffset = new Vector2(width / 2, 0);
            }
            else if (playerIndex == PlayerIndex.Two)
            {
                // Set the position to be on the right side of the screen
                Position = new Vector2(Game1.GAME_WIDTH - width, Game1.GAME_HEIGHT / 2 - height / 2);

                // Set the shooting key based on playerIndex
                shootingKey = Keys.RightControl;

                // Organize the moving keys
                movingKeys = new Keys[4] { Keys.Up, Keys.Down, Keys.Left, Keys.Right };

                // Tint is chosen from the IntroState
                tint = IntroState.player2Color;
                sprite.Tint = tint;

                // Second player will be facing left
                dir = -1;
                flipped = true;

                GunOffset = new Vector2(-width / 2, 0);
            }
            else
            {
                // Remember how I said I only support PlayerIndex One and Two?
                // This is where I kindly remind you if you forget.
                // ----------------------------------------------------------
                throw new Exception("Unsupported PlayerIndex - please only use indeces one and two");
            }

            // Default weapons will be Pistols.  If you wanna change it, go ahead
            // ------------------------------------------------------------------
            equippedWeapon = new Shotgun(this, shootingKey);

            // This font is used for the player information that is on screen
            // --------------------------------------------------------------
            font = Game1.content.Load<SpriteFont>("defaultFont");

            // And here I make the animation for the player. Easy Peasy.
            // ---------------------------------------------------------
            Texture2D[] imgs = new Texture2D[] {
                Game1.content.Load<Texture2D>("helicopter1"),
                Game1.content.Load<Texture2D>("helicopter2")
            };
            playerAnim = new Animation(imgs, 20f);

            // And here I have the basic rectangles used for the life bar.
            // The life bar stuff is pretty basic right now
            // ----------------------------------------------------------
            var tex = new DrawableRectangle(Game1.graphics.GraphicsDevice, new Vector2(10, 10), Color.White, true).Texture;
            lifeBg = tex;
            lifeFg = tex;

            // Set the force field size to be bigger than the player
            // -----------------------------------------------------
            forceFieldWidth = width + 30;
            forceFieldHeight = height + 30;

            // Temporary setting the force field texture to a white rectangle
            // --------------------------------------------------------------
            forceFieldTex = new DrawableRectangle(Game1.graphics.GraphicsDevice, new Vector2(forceFieldWidth, forceFieldHeight), Color.White, true).Texture;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Sets the animations and avatars of an entity . . .
        /// Follow the guidelines for making spritesheets
        /// </summary>
        /// <param name="start">Start position on the sprite sheet</param>
        /// <param name="sheetName">Key for spritesheet dictionary</param>
        /// <param name="realWidth"></param>
        /// <param name="realHeight"></param>
        protected void SetTexture(Vector2 start, string sheetName, int realWidth = 0, int realHeight = 0)
        {
            SpriteSheet sheet = SpriteSheetManager.EntitySprites[sheetName];

            int x = (int)start.X;
            int y = (int)start.Y;

            avatarDown = new Image(sheet.GetSubImage(x + 1, y));
            avatarUp = new Image(sheet.GetSubImage(x + 1, y + 3));
            avatarRight = new Image(sheet.GetSubImage(x + 1, y + 2));

            Texture2D[] imagesDown = new Texture2D[] { sheet.GetSubImage(x, y),
                sheet.GetSubImage(x + 1, y), sheet.GetSubImage(x + 2, y)};
            Texture2D[] imagesLeft = new Texture2D[] { sheet.GetSubImage(x, y + 1),
                sheet.GetSubImage(x + 1, y + 1), sheet.GetSubImage(x + 2, y + 1)};
            Texture2D[] imagesRight = new Texture2D[] {sheet.GetSubImage(x, y + 2),
                sheet.GetSubImage(x + 1, y + 2), sheet.GetSubImage(x + 2, y + 2) };
            Texture2D[] imagesUp = new Texture2D[] { sheet.GetSubImage(x, y + 3),
                sheet.GetSubImage(x + 1, y + 3), sheet.GetSubImage(x + 2, y + 3)};

            movingDown = new Animation(imagesDown);
            movingRight = new Animation(imagesRight);
            movingUp = new Animation(imagesUp);

            spriteWidth = avatarDown.Width;
            spriteHeight = avatarDown.Height;

            if (realWidth != 0)
                this.realWidth = realWidth;
            else
                this.realWidth = spriteWidth;

            if (realHeight != 0)
                this.realHeight = realHeight;
            else
                this.realHeight = spriteHeight;
        }
Ejemplo n.º 14
0
        protected void SetCustomTexture(Vector2 start, string sheetName, int frames,
                                        int realWidth = 0, int realHeight = 0, float duration = 100f)
        {
            SpriteSheet sheet = SpriteSheetManager.EntitySprites[sheetName];

            int x = (int)start.X;
            int y = (int)start.Y;

            avatarDown = new Image(sheet.GetSubImage(x + frames - 1, y));
            avatarUp = new Image(sheet.GetSubImage(x + frames - 1, y + 1));
            avatarRight = new Image(sheet.GetSubImage(x, y + 2));

            Texture2D[] imagesDown = new Texture2D[frames];
            Texture2D[] imagesRight = new Texture2D[frames];
            Texture2D[] imagesUp = new Texture2D[frames];

            for (int i = 0; i < frames; i++)
            {
                imagesDown[i] = sheet.GetSubImage(x + i, y);
                imagesUp[i] = sheet.GetSubImage(x + i, y + 1);
                imagesRight[i] = sheet.GetSubImage(x + i, y + 2);
            }

            movingDown = new Animation(imagesDown, duration);
            movingRight = new Animation(imagesRight, duration);
            movingUp = new Animation(imagesUp, duration);

            spriteWidth = avatarDown.Width;
            spriteHeight = avatarDown.Height;

            if (realWidth != 0)
                this.realWidth = realWidth;
            else
                this.realWidth = spriteWidth;

            if (realHeight != 0)
                this.realHeight = realHeight;
            else
                this.realHeight = spriteHeight;
        }
Ejemplo n.º 15
0
        protected void SetCustomAttackingAnimCustom(string sheetName, int spriteWidth, int spriteHeight,
                                                    int frames, float duration = 100f)
        {
            SpriteSheet sheet = SpriteSheetManager.EntitySprites[sheetName];

            int x = 0;
            int y = 0;

            Texture2D[] imagesDown = new Texture2D[frames];
            Texture2D[] imagesRight = new Texture2D[frames];
            Texture2D[] imagesUp = new Texture2D[frames];

            for (int i = 0; i < frames; i++)
            {
                imagesDown[i] = sheet.GetSubImage(x + i, y);
                imagesUp[i] = sheet.GetSubImage(x + i, y + 1);
                imagesRight[i] = sheet.GetSubImage(x + i, y + 2);
            }

            attackingDown = new Animation(imagesDown, duration);
            attackingRight = new Animation(imagesRight, duration);
            attackingUp = new Animation(imagesUp, duration);

            spriteWidth = avatarDown.Width;
            spriteHeight = avatarDown.Height;
        }