示例#1
0
 public void DrawSprite(GameInstance self, GameSprite sprite, double x, double y, int subimage,
                        bool relative = false)
 {
     throw new NotImplementedException();
 }
        public override void Load(Microsoft.Xna.Framework.Content.ContentManager Content)
        {
            _keyboard         = new Dictionary <string, Button>();
            Global.onlineCode = "";
            gamePad           = new GamePadMapper(PlayerIndex.One);

            GameSprite background = new GameSprite(Content.Load <Texture2D>("Background\\EnterCode"), Vector2.Zero, Color.White);

            background.Scale = Global.Scale;
            _sprites.Add(background);

            codeFont = new FadingFont(Content.Load <SpriteFont>("Fonts\\BigOutage"), new Vector2(_viewPort.Width / 2, _viewPort.Height / 2), 0.1f, 1.0f, 0.01f, 1.0f, string.Format(""), Color.White, false);
            codeFont.EnableShadow = false;
            codeFont.Position     = new Vector2(col1 + colDiff * 5, row1 - 100);
            codeFont.SetCenterAsOrigin();


            buttons[0, 0]  = loadkey(Content, "1", col1, row1, scale);
            buttons[0, 1]  = loadkey(Content, "2", col1 + colDiff, row1, scale);
            buttons[0, 2]  = loadkey(Content, "3", col1 + colDiff * 2, row1, scale);
            buttons[0, 3]  = loadkey(Content, "4", col1 + colDiff * 3, row1, scale);
            buttons[0, 4]  = loadkey(Content, "5", col1 + colDiff * 4, row1, scale);
            buttons[0, 5]  = loadkey(Content, "6", col1 + colDiff * 5, row1, scale);
            buttons[0, 6]  = loadkey(Content, "7", col1 + colDiff * 6, row1, scale);
            buttons[0, 7]  = loadkey(Content, "8", col1 + colDiff * 7, row1, scale);
            buttons[0, 8]  = loadkey(Content, "9", col1 + colDiff * 8, row1, scale);
            buttons[0, 9]  = loadkey(Content, "0", col1 + colDiff * 9, row1, scale);
            buttons[0, 10] = loadkey(Content, "#", col1 + colDiff * 10, row1, scale);

            buttons[1, 0]  = loadkey(Content, "Q", col1, row1 + rowDiff, scale);
            buttons[1, 1]  = loadkey(Content, "W", col1 + colDiff, row1 + rowDiff, scale);
            buttons[1, 2]  = loadkey(Content, "E", col1 + colDiff * 2, row1 + rowDiff, scale);
            buttons[1, 3]  = loadkey(Content, "R", col1 + colDiff * 3, row1 + rowDiff, scale);
            buttons[1, 4]  = loadkey(Content, "T", col1 + colDiff * 4, row1 + rowDiff, scale);
            buttons[1, 5]  = loadkey(Content, "Y", col1 + colDiff * 5, row1 + rowDiff, scale);
            buttons[1, 6]  = loadkey(Content, "U", col1 + colDiff * 6, row1 + rowDiff, scale);
            buttons[1, 7]  = loadkey(Content, "I", col1 + colDiff * 7, row1 + rowDiff, scale);
            buttons[1, 8]  = loadkey(Content, "O", col1 + colDiff * 8, row1 + rowDiff, scale);
            buttons[1, 9]  = loadkey(Content, "P", col1 + colDiff * 9, row1 + rowDiff, scale);
            buttons[1, 10] = loadkey(Content, "*", col1 + colDiff * 10, row1 + rowDiff, scale);


            buttons[2, 0]  = loadkey(Content, "A", col1, row1 + rowDiff * 2, scale);
            buttons[2, 1]  = loadkey(Content, "S", col1 + colDiff, row1 + rowDiff * 2, scale);
            buttons[2, 2]  = loadkey(Content, "D", col1 + colDiff * 2, row1 + rowDiff * 2, scale);
            buttons[2, 3]  = loadkey(Content, "F", col1 + colDiff * 3, row1 + rowDiff * 2, scale);
            buttons[2, 4]  = loadkey(Content, "G", col1 + colDiff * 4, row1 + rowDiff * 2, scale);
            buttons[2, 5]  = loadkey(Content, "H", col1 + colDiff * 5, row1 + rowDiff * 2, scale);
            buttons[2, 6]  = loadkey(Content, "J", col1 + colDiff * 6, row1 + rowDiff * 2, scale);
            buttons[2, 7]  = loadkey(Content, "K", col1 + colDiff * 7, row1 + rowDiff * 2, scale);
            buttons[2, 8]  = loadkey(Content, "L", col1 + colDiff * 8, row1 + rowDiff * 2, scale);
            buttons[2, 9]  = loadkey(Content, ".", col1 + colDiff * 9, row1 + rowDiff * 2, scale);
            buttons[2, 10] = loadkey(Content, "&", col1 + colDiff * 10, row1 + rowDiff * 2, scale);

            buttons[3, 0]  = loadkey(Content, "Z", col1, row1 + rowDiff * 3, scale);
            buttons[3, 1]  = loadkey(Content, "X", col1 + colDiff, row1 + rowDiff * 3, scale);
            buttons[3, 2]  = loadkey(Content, "C", col1 + colDiff * 2, row1 + rowDiff * 3, scale);
            buttons[3, 3]  = loadkey(Content, "V", col1 + colDiff * 3, row1 + rowDiff * 3, scale);
            buttons[3, 4]  = loadkey(Content, "B", col1 + colDiff * 4, row1 + rowDiff * 3, scale);
            buttons[3, 5]  = loadkey(Content, "N", col1 + colDiff * 5, row1 + rowDiff * 3, scale);
            buttons[3, 6]  = loadkey(Content, "M", col1 + colDiff * 6, row1 + rowDiff * 3, scale);
            buttons[3, 7]  = loadkey(Content, "-", col1 + colDiff * 7, row1 + rowDiff * 3, scale);
            buttons[3, 8]  = loadkey(Content, "_", col1 + colDiff * 8, row1 + rowDiff * 3, scale);
            buttons[3, 9]  = loadkey(Content, "!", col1 + colDiff * 9, row1 + rowDiff * 3, scale);
            buttons[3, 10] = loadkey(Content, "?", col1 + colDiff * 10, row1 + rowDiff * 3, scale);


            back          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, "Back", new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
            back.Scale   *= scale;
            back.Scale    = new Vector2(back.Scale.X + 0.02f, back.Scale.Y);
            back.Origin   = new Vector2(back.Texture.Width / 2, 137);
            back.Position = new Vector2(col1 + 120, row1 + rowDiff * 4 + back.SourceRectangle.Value.Height / 2);

            space          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, " ", new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
            space.Scale   *= scale;
            space.Scale    = new Vector2(space.Scale.X + 0.61f, space.Scale.Y);
            space.Origin   = new Vector2(space.Texture.Width / 2, 137);
            space.Position = new Vector2(col1 + colDiff * 3 + 240, row1 + rowDiff * 4 + space.SourceRectangle.Value.Height / 2);

            done          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, "Done", new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
            done.Scale   *= scale;
            done.Scale    = new Vector2(done.Scale.X + 0.02f, done.Scale.Y);
            done.Origin   = new Vector2(done.Texture.Width / 2, 137);
            done.Position = new Vector2(col1 + colDiff * 8 + 120, row1 + rowDiff * 4 + done.SourceRectangle.Value.Height / 2);



            backBtn          = new Button(Content.Load <Texture2D>("Buttons//Back"), new Vector2(0, 0), Color.White, new Rectangle(0, 149, 159, 169), new Rectangle(0, 0, 159, 149));
            backBtn.Origin   = new Vector2(backBtn.Texture.Width / 2, 169);
            backBtn.Position = new Vector2(177, 907 + backBtn.SourceRectangle.Value.Height / 2);

            _sprites.Add(codeFont);
            _sprites.Add(back);
            _sprites.Add(space);
            _sprites.Add(done);
            _sprites.Add(backBtn);


            if (!Global.UsingKeyboard)
            {
                //done.IsPressed = true;
                //_keyboard["2"].IsPressed = true;
            }
        }
示例#3
0
        public void InitiateBox()
        {
            box        = new GameSprite("select\\infobox");
            box.Origin = new Vector2(182.5f, 182.5f);
            box.Translate(550, 220);
            box.CanDraw = false;
            AddHUDObjectFront(box);

            star1        = new GameSprite("select\\star1");
            star1.Origin = new Vector2(36.5f, 36.5f);
            star1.Translate(550, 290);
            star1.CanDraw = false;
            AddHUDObjectFront(star1);

            star2        = new GameSprite("select\\star1");
            star2.Origin = new Vector2(36.5f, 36.5f);
            star2.Translate(480, 290);
            star2.CanDraw = false;
            AddHUDObjectFront(star2);

            star3        = new GameSprite("select\\star1");
            star3.Origin = new Vector2(36.5f, 36.5f);
            star3.Translate(620, 290);
            star3.CanDraw = false;
            AddHUDObjectFront(star3);

            song = new SpriteFonts("font\\fontbold");
            song.Translate(435, 95);
            song.Color   = Color.SaddleBrown;
            song.Text    = "AMPAR-AMPAR\n         PISANG";
            song.CanDraw = false;
            AddHUDObjectFront(song);

            line1        = new GameSprite("select\\line");
            line1.Origin = new Vector2(132, 4.5f);
            line1.Translate(550, 180);
            line1.CanDraw = false;
            AddHUDObjectFront(line1);

            region = new SpriteFonts("font\\font");
            region.Translate(440, 195);
            region.Color   = Color.SaddleBrown;
            region.Text    = "South Kalimantan";
            region.CanDraw = false;
            AddHUDObjectFront(region);

            line2        = new GameSprite("select\\line");
            line2.Origin = new Vector2(132, 4.5f);
            line2.Translate(550, 240);
            line2.CanDraw = false;
            AddHUDObjectFront(line2);

            text = new SpriteFonts("font\\font");
            text.Translate(15, 15);
            text.Color = Color.SaddleBrown;
            text.Text  = "Select Level/Region...";
            AddHUDObjectFront(text);

            play        = new GameButton("select\\playbutton", true, false, true);
            play.Origin = new Vector2(90.5f, 44.5f);
            play.Translate(550, 385);
            play.CanDraw  = false;
            play.OnClick += () =>
            {
                if (isLevelSelected)
                {
                    SceneManager.push.Play();
                    SceneManager.SetActiveScene("Level1");
                    SceneManager.ActiveScene.ResetScene();
                    SceneManager.PlaySong(2);

                    play.CanDraw = false;
                }
            };
            AddHUDObjectFront(play);
        }
 private void CreateObject()
 {
     _selectedTexture = _contentManager.Load<Texture2D>("Sprites\\menu_back_selected");
     _notSelectedTexture = _contentManager.Load<Texture2D>("Sprites\\menu_back_notselected");
     Sprite = new GameSprite(_notSelectedTexture) { Alive = true };
 }
示例#5
0
 public bool CheckSpriteCollision(GameSprite sprite1, int subImage1, Matrix3x2 modelWorldTransform1,
                                  GameSprite sprite2, int subImage2, Matrix3x2 modelWorldTransform2)
 {
     return(GetSpriteCollisions(sprite1, subImage1, modelWorldTransform1, sprite2, subImage2, modelWorldTransform2).Any());
 }
示例#6
0
 public void Add(GameSprite sprite)
 {
     this.composition.Add(sprite);
 }
示例#7
0
 public BlockUI(Texture2D texture, Color startColor, Color endColor)
 {
     normalBlockUI   = new NormalBlockUI(texture, startColor, endColor);
     lightBlockUI    = new GameSprite(texture, endColor);
     flashingBlockUI = new FlashingBlockUI(texture, startColor, endColor);
 }
 public GameSpriteDecorator(GameSprite gameSprite)
     : base(gameSprite.SpriteTexture, gameSprite.SpritePosition)
 {
     Animation  = gameSprite.Animation;
     SpeedRatio = gameSprite.SpeedRatio;
 }
示例#9
0
        // Remember to draw objects
        public List <GameObject> generateGameSet()
        {
            questionIsCorrect     = false;
            solutionObjectReplica = null;
            currentGameSet.Clear();
            gameObjectPosition.Clear();

            var set = Content.LoadContent <Texture2D>("Level1\\" + getRandomGameSet());

            List <string> contentName = new List <string>();

            foreach (string s in set.Keys)
            {
                contentName.Add(s);
            }

            List <int> contentRand = genRandomNumberList(0, contentName.Count);

            // Create solution object
            GameSprite solutionSprite = new GameSprite(set[contentName[contentRand[0]]], 1, 1, 0, 0);

            // Create selection objects
            GameSprite selectionSprite1 = new GameSprite(set[contentName[contentRand[1]]], 1, 1, 0, 0);
            GameSprite selectionSprite2 = new GameSprite(set[contentName[contentRand[2]]], 1, 1, 0, 0);
            GameSprite selectionSprite3 = new GameSprite(set[contentName[contentRand[3]]], 1, 1, 0, 0);

            // GameSprite selectionSprite4 = new GameSprite(set1["yellow_ball"]  , 1, 1, 0, 0);


            //---Ryan change the cooordinates
            // Store positions. These are namely 2 on the left, 2 on the right
            gameObjectPosition.Add(new Vector2(190, 235)); //top left
            gameObjectPosition.Add(new Vector2(190, 560)); // bottom left
            gameObjectPosition.Add(new Vector2(735, 235)); // top right
            gameObjectPosition.Add(new Vector2(735, 560)); //btm right

            // Generate position placement choices randomly
            List <int> randPosn = new List <int>();


            while (randPosn.Count != gameObjectPosition.Count)
            {
                int choice = rand.Next(0, gameObjectPosition.Count);
                if (!randPosn.Contains(choice))
                {
                    randPosn.Add(choice);
                }
            }

            // Create solution object
            GameObject solutionObj = new GameObject(solutionSprite, gameObjectPosition[randPosn[0]]);

            solutionObj.isSolutionObject = true;

            // Create a replica of the solution object for display purposes only
            solutionObjectReplica = new GameObject(solutionSprite, 500, 125);

            // left hand side
            GameObject selectionObject1 = new GameObject(selectionSprite1, gameObjectPosition[randPosn[1]]);
            GameObject selectionObject2 = new GameObject(selectionSprite2, gameObjectPosition[randPosn[2]]);

            // right hand side
            GameObject selectionObject3 = new GameObject(selectionSprite3, gameObjectPosition[randPosn[3]]);

            // Kenny Debug Initi
            GameObject lefthand  = new GameObject(selectionSprite3, new Vector2(0, 0));
            GameObject righthand = new GameObject(selectionSprite3, new Vector2(0, 0));

            // Add to current game set
            currentGameSet.Add(solutionObj); //Solution is always the first
            currentGameSet.Add(selectionObject1);
            currentGameSet.Add(selectionObject2);
            currentGameSet.Add(selectionObject3);
            // Kenny Debug
            if (kennyDebug)
            {
                currentGameSet.Add(lefthand);
                currentGameSet.Add(righthand);
            }

            return(currentGameSet);
        }
        public override Entity GetEntity(string move, string shoot, int startX, int startY, int endX, int endY, String bTexture, String eTexture)
        {
            startPos      = new Vector2(startX, startY);
            endPos        = new Vector2(endX, endY);
            bulletTexture = content.Load <Texture2D>("Bullets/" + bTexture);
            sprite        = new GameSprite(content.Load <Texture2D>("Entities/" + eTexture), startPos, Color.White);

            if (move == "MoveLikeFinal")
            {
                if (shoot == "ShootLikeFinal")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeFinal(), new ShootLikeFinal()));
                }
                else if (shoot == "ShootLikeGrunt")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeFinal(), new ShootLikeGrunt()));
                }
                else if (shoot == "ShootLikeMid")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeFinal(), new ShootLikeMid()));
                }
                else if (shoot == "ShootLikePlayer")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeFinal(), new ShootLikePlayer(this.content)));
                }
                else
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikePlayer(this.content)));
                }
            }
            else if (move == "MoveLikeGrunt1")
            {
                if (shoot == "ShootLikeFinal")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeGrunt1(), new ShootLikeFinal()));
                }
                else if (shoot == "ShootLikeGrunt")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeGrunt1(), new ShootLikeGrunt()));
                }
                else if (shoot == "ShootLikeMid")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeGrunt1(), new ShootLikeMid()));
                }
                else if (shoot == "ShootLikePlayer")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeGrunt1(), new ShootLikePlayer(this.content)));
                }
                else
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeGrunt1(), new ShootLikePlayer(this.content)));
                }
            }
            else if (move == "MoveLikeMid")
            {
                if (shoot == "ShootLikeFinal")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeMid(), new ShootLikeFinal()));
                }
                else if (shoot == "ShootLikeGrunt")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeMid(), new ShootLikeGrunt()));
                }
                else if (shoot == "ShootLikeMid")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeMid(), new ShootLikeMid()));
                }
                else if (shoot == "ShootLikePlayer")
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeMid(), new ShootLikePlayer(this.content)));
                }
                else
                {
                    return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeMid(), new ShootLikePlayer(this.content)));
                }
            }
            else if (move == "MoveLikePlayer")
            {
                if (shoot == "ShootLikeFinal")
                {
                    return(new Grunt1(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikeFinal()));
                }
                else if (shoot == "ShootLikeGrunt")
                {
                    return(new Grunt1(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikeGrunt()));
                }
                else if (shoot == "ShootLikeMid")
                {
                    return(new Grunt1(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikeMid()));
                }
                else if (shoot == "ShootLikePlayer")
                {
                    return(new Grunt1(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikePlayer(this.content)));
                }
                else
                {
                    return(new Grunt1(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikePlayer(this.content)));
                }
            }
            else
            {
                return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikePlayer(), new ShootLikePlayer(this.content)));
            }
            return(new Grunt2(startPos, endPos, health, speedMode, sprite, bulletTexture, content, new MoveLikeGrunt1(), new ShootLikeMid()));
        }
 private void CreateObject()
 {
     _texture = _contentManager.Load<Texture2D>("Sprites\\information_panel");
     Sprite = new GameSprite(_texture) { Alive = true };
 }
示例#12
0
 private static void RemoveEnemy(GameSprite enemy, ICollection <GameSprite> enemies)
 {
     enemies.Remove(enemy);
 }
示例#13
0
        public override void Initialize()
        {
            // set game speed
            SceneManager.RenderContext.GameSpeed = 100;
            random = new Random();

            notes     = new List <Note>();
            longNotes = new List <LongNote>();

            bg = new Background1();
            AddHUDObjectBack(bg);

            pipe = new Pipe("level1\\pipe", 50);
            AddHUDObjectBack(pipe);

            indicator = new Indicator();
            AddHUDObjectFront(indicator);

            text       = new SpriteFonts("font\\font");
            text.Color = Color.SaddleBrown;
            text.Translate(580, 10);
            AddHUDObjectBack(text);

            fire         = new GameButton("level1\\invisbutton", false, false, false);
            fire.CanDraw = false;
            fire.Translate(400, 0);
            fire.OnEnter += () =>
            {
                if (!isFailed && !isFinished)
                {
                    SceneManager.Vibrator.Start(TimeSpan.FromMilliseconds(100));
                    indicator.Pushed();
                    //Debug.WriteLine(MediaPlayer.PlayPosition);
                    if (LongNoteCheck() == 0)
                    {
                        //Debug.WriteLine(mainChar.Sprite.Position.X);
                        SpawnScore(NoteCheck());
                    }
                    else
                    {
                        //Debug.WriteLine(mainChar.Sprite.Position.X);
                        mainChar.LightOnForever();
                        SceneManager.pulse2.Play();
                    }
                }
            };
            fire.OnClick += () =>
            {
                if (!isFailed && !isFinished)
                {
                    //Debug.WriteLine(mainChar.Sprite.Position.X);
                    indicator.Pulled();
                    SpawnScore(NoteCheckOut());
                }
            };
            fire.OnLeave += () =>
            {
                indicator.Pulled();
            };
            AddHUDObjectBack(fire);

            InitiateScoring();
            InitiateNote();
            InitiateLongNote();

            mainChar = new MainCharacter(50, 300, indicator);
            AddSceneObject(mainChar);

            failed        = new GameSprite("level1\\boxfailed");
            failed.Origin = new Vector2(181, 149.5f);
            failed.Translate(400, -300);
            failed.CanDraw = false;
            AddHUDObjectFront(failed);

            finished        = new GameSprite("level1\\boxfinished");
            finished.Origin = new Vector2(230, 181);
            finished.Translate(400, -300);
            finished.CanDraw = false;
            AddHUDObjectFront(finished);

            note       = new SpriteFonts("font\\fontsmall");
            note.Color = Color.Goldenrod;
            note.Translate(265, 280);
            AddHUDObjectFront(note);

            star1        = new GameAnimatedSprite("level1\\star", 12, 40, new Point(73, 73), 6);
            star1.Origin = new Vector2(36.5f, 36.5f);
            star1.Translate(400, -290);
            star1.CanDraw = false;
            AddHUDObjectFront(star1);

            star2        = new GameAnimatedSprite("level1\\star", 12, 40, new Point(73, 73), 6);
            star2.Origin = new Vector2(36.5f, 36.5f);
            star2.Translate(470, -290);
            star2.CanDraw = false;
            AddHUDObjectFront(star2);

            star3        = new GameAnimatedSprite("level1\\star", 12, 40, new Point(73, 73), 6);
            star3.Origin = new Vector2(36.5f, 36.5f);
            star3.Translate(330, -290);
            star3.CanDraw = false;
            AddHUDObjectFront(star3);

            next         = new GameButton("level1\\next", true, false, false);
            next.CanDraw = false;
            next.Translate(420, -215);
            next.OnClick += () =>
            {
                SceneManager.push.Play();
                SceneManager.SetActiveScene("LevelSelect");
                SceneManager.ActiveScene.ResetScene();
                SceneManager.PlaySong(1);
            };
            AddHUDObjectFront(next);

            retry         = new GameButton("level1\\retry", true, false, false);
            retry.CanDraw = false;
            retry.Translate(295, -215);
            retry.OnClick += () =>
            {
            };
            AddHUDObjectFront(retry);

            base.Initialize();
        }
示例#14
0
 public NormalCharger(GameSprite character)
 {
     this.character = character;
 }
示例#15
0
        public override void Load(Microsoft.Xna.Framework.Content.ContentManager Content)
        {
            gamePad = new GamePadMapper(PlayerIndex.One);

            state = ControlScreenState.SelectingControl;

            GameSprite background = new GameSprite(Content.Load <Texture2D>("Background\\Keys"), Vector2.Zero, Color.White);

            background.Scale = Global.Scale;

            XDocument optionsXml = XDocument.Load(@"XML\Options.xml");

            if (Global.UsingKeyboard)
            {
                XElement player1 = optionsXml.Root.Elements(XName.Get("PlayerControls")).Elements(XName.Get("Keyboard")).Elements(XName.Get("Player")).ToList()[0];
                XElement player2 = optionsXml.Root.Elements(XName.Get("PlayerControls")).Elements(XName.Get("Keyboard")).Elements(XName.Get("Player")).ToList()[1];

                Global.LeftPlayer.UpKey    = (Keys)int.Parse(player1.Element(XName.Get("Up")).Value);
                Global.LeftPlayer.DownKey  = (Keys)int.Parse(player1.Element(XName.Get("Down")).Value);
                Global.RightPlayer.UpKey   = (Keys)int.Parse(player2.Element(XName.Get("Up")).Value);
                Global.RightPlayer.DownKey = (Keys)int.Parse(player2.Element(XName.Get("Down")).Value);
            }
            else
            {
                XElement player1 = optionsXml.Root.Elements(XName.Get("PlayerControls")).Elements(XName.Get("GamePad")).Elements(XName.Get("Player")).ToList()[0];
                XElement player2 = optionsXml.Root.Elements(XName.Get("PlayerControls")).Elements(XName.Get("GamePad")).Elements(XName.Get("Player")).ToList()[1];

                Global.LeftPlayer.UpButton    = (GamePadMapper.GamePadButtons) int.Parse(player1.Element(XName.Get("Up")).Value);
                Global.LeftPlayer.DownButton  = (GamePadMapper.GamePadButtons) int.Parse(player1.Element(XName.Get("Down")).Value);
                Global.RightPlayer.UpButton   = (GamePadMapper.GamePadButtons) int.Parse(player2.Element(XName.Get("Up")).Value);
                Global.RightPlayer.DownButton = (GamePadMapper.GamePadButtons) int.Parse(player2.Element(XName.Get("Down")).Value);
            }

            //titleDropInFont = new DropInFont(Content.Load<SpriteFont>("Fonts//JingJingTitle"), new Vector2(_viewPort.Width / 2, _viewPort.Height * 0.1f), new Vector2(_viewPort.Width / 2, _viewPort.Height * 0.1f), dropSpeed, "Controls", Color.White);
            //titleDropInFont.IsVisible = true;
            //titleDropInFont.SetCenterAsOrigin();
            //titleDropInFont.EnableShadow = false;
            //titleDropInFont.TintColor = Color.Black;
            //titleDropInFont.ShadowPosition = new Vector2(titleDropInFont.Position.X - 4, titleDropInFont.Position.Y + 4);
            //titleDropInFont.ShadowColor = Color.Gray;
            if (Global.UsingKeyboard)
            {
                changeRightUpBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.RightPlayer.UpKey.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeRightUpBtn.Origin   = new Vector2(changeRightUpBtn.Texture.Width / 2, 137);
                changeRightUpBtn.Position = new Vector2(1267, 453 + changeRightUpBtn.SourceRectangle.Value.Height / 2);

                changeRightDownBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.RightPlayer.DownKey.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeRightDownBtn.Origin   = new Vector2(changeRightDownBtn.Texture.Width / 2, 137);
                changeRightDownBtn.Position = new Vector2(1267, 718 + changeRightDownBtn.SourceRectangle.Value.Height / 2);

                changeLeftUpBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.LeftPlayer.UpKey.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeLeftUpBtn.Origin   = new Vector2(changeLeftUpBtn.Texture.Width / 2, 137);
                changeLeftUpBtn.Position = new Vector2(635, 453 + changeLeftUpBtn.SourceRectangle.Value.Height / 2);

                changeLeftDownBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.LeftPlayer.DownKey.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeLeftDownBtn.Origin   = new Vector2(changeLeftDownBtn.Texture.Width / 2, 137);
                changeLeftDownBtn.Position = new Vector2(635, 718 + changeLeftDownBtn.SourceRectangle.Value.Height / 2);
            }
            else
            {
                changeRightUpBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.RightPlayer.UpButton.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeRightUpBtn.Origin   = new Vector2(changeRightUpBtn.Texture.Width / 2, 137);
                changeRightUpBtn.Position = new Vector2(1267, 453 + changeRightUpBtn.SourceRectangle.Value.Height / 2);

                changeRightDownBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.RightPlayer.DownButton.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeRightDownBtn.Origin   = new Vector2(changeRightDownBtn.Texture.Width / 2, 137);
                changeRightDownBtn.Position = new Vector2(1267, 718 + changeRightDownBtn.SourceRectangle.Value.Height / 2);

                changeLeftUpBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.LeftPlayer.UpButton.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeLeftUpBtn.Origin   = new Vector2(changeLeftUpBtn.Texture.Width / 2, 137);
                changeLeftUpBtn.Position = new Vector2(635, 453 + changeLeftUpBtn.SourceRectangle.Value.Height / 2);

                changeLeftDownBtn          = new TextButton(Content.Load <Texture2D>("Buttons//Blank"), new Vector2(0, 0), Color.White, Content.Load <SpriteFont>("Fonts\\BigOutage"), Color.White, Global.LeftPlayer.DownButton.ToString(), new Rectangle(0, 117, 404, 137), new Rectangle(0, 0, 404, 117));
                changeLeftDownBtn.Origin   = new Vector2(changeLeftDownBtn.Texture.Width / 2, 137);
                changeLeftDownBtn.Position = new Vector2(635, 718 + changeLeftDownBtn.SourceRectangle.Value.Height / 2);
            }

            /*rightUpDisp = new FadingFont(Content.Load<SpriteFont>("Fonts\\BigOutage"), Vector2.Zero, 0.1f, 1.0f, 0.1f, 1.0f, Global.RightPlayer.UpKey.ToString(), Color.White, true);
             * rightUpDisp.EnableShadow = false;
             * rightUpDisp.Position = new Vector2(changeRightUpBtn.Position.X - rightUpDisp.Size.X / 2, changeRightUpBtn.Bottom - 120);
             */
            /*
             * rightDownDisp = new FadingFont(Content.Load<SpriteFont>("Fonts\\BigOutage"), Vector2.Zero, 0.1f, 1.0f, 0.1f, 1.0f, Global.RightPlayer.DownKey.ToString(), Color.White, true);
             * rightDownDisp.EnableShadow = false;
             * rightDownDisp.Position = new Vector2(changeRightDownBtn.Position.X - rightDownDisp.Size.X / 2, changeRightDownBtn.Bottom - 120);
             *
             * leftUpDisp = new FadingFont(Content.Load<SpriteFont>("Fonts\\BigOutage"), Vector2.Zero, 0.1f, 1.0f, 0.1f, 1.0f, Global.LeftPlayer.UpKey.ToString(), Color.White, true);
             * leftUpDisp.EnableShadow = false;
             * leftUpDisp.Position = new Vector2(changeLeftUpBtn.Position.X - leftUpDisp.Size.X / 2, changeLeftUpBtn.Bottom - 120);
             *
             * leftDownDisp = new FadingFont(Content.Load<SpriteFont>("Fonts\\BigOutage"), Vector2.Zero, 0.1f, 1.0f, 0.1f, 1.0f, Global.LeftPlayer.DownKey.ToString(), Color.White, true);
             * leftDownDisp.EnableShadow = false;
             * leftDownDisp.Position = new Vector2(changeLeftDownBtn.Position.X - leftDownDisp.Size.X / 2, changeLeftDownBtn.Bottom - 120);
             */
            backBtn          = new Button(Content.Load <Texture2D>("Buttons//Back"), new Vector2(0, 0), Color.White, new Rectangle(0, 149, 159, 169), new Rectangle(0, 0, 159, 149));
            backBtn.Origin   = new Vector2(backBtn.Texture.Width / 2, 169);
            backBtn.Position = new Vector2(177, 907 + backBtn.SourceRectangle.Value.Height / 2);

            //_sprites.Add(titleDropInFont);

            _sprites.Add(background);
            _sprites.Add(changeRightUpBtn);
            _sprites.Add(changeRightDownBtn);
            _sprites.Add(changeLeftUpBtn);
            _sprites.Add(changeLeftDownBtn);
            //_sprites.Add(rightUpDisp);
            //_sprites.Add(rightDownDisp);
            //_sprites.Add(leftUpDisp);
            //_sprites.Add(leftDownDisp);

            _sprites.Add(backBtn);

            if (!Global.UsingKeyboard)
            {
                changeLeftUpBtn.IsPressed = true;
            }
        }
示例#16
0
        // * Indlæser diverse animationer STATISK (kaldes af GameController) så de ikke genindlæses i hver instans
        public static void InitializeGraphics()
        {
            Animations = new Dictionary <string, GameSprite>();
            string rifleRoot = GameController.imageRoot + "/rifle_infantry";

            List <string> directionDirs = new List <string>(8);

            directionDirs.Add("up");
            directionDirs.Add("upright");
            directionDirs.Add("right");
            directionDirs.Add("downright");
            directionDirs.Add("down");
            directionDirs.Add("downleft");
            directionDirs.Add("left");
            directionDirs.Add("upleft");

            foreach (string direction in directionDirs)
            {
                GameSprite        runSprite = new GameSprite();
                List <GameSprite> sprites   = new List <GameSprite>();
                for (int i = 1; i <= 6; i++)
                {
                    string imagePath = rifleRoot + "/run/" + direction + "/" + i + ".png";
                    if (File.Exists(imagePath))
                    {
                        SpriteImage spriteImg   = new SpriteImage(imagePath, Color.Transparent);
                        SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                        runSprite.AddFrame(spriteFrame);
                    }
                    else
                    {
                        throw new FileNotFoundException("404 on " + imagePath);
                    }
                }
                Animations.Add("run_" + direction, runSprite);
            }

            GameSprite dieSprite = new GameSprite();

            // * Gentag ikke, afspil kun død én gang,
            // * hvorefter IsDonePlaying angiver om vi officielt kan slette enheden
            dieSprite.RepeatCount = 0;
            for (int i = 1; i <= 7; i++)
            {
                string imagePath = rifleRoot + "/die/right/" + i + ".png";
                if (File.Exists(imagePath))
                {
                    SpriteImage spriteImg   = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    dieSprite.AddFrame(spriteFrame);
                }
                else
                {
                    throw new FileNotFoundException("404 on " + imagePath);
                }
            }
            Animations.Add("die_right", dieSprite);

            GameSprite standSprite = new GameSprite();

            for (int i = 1; i <= 1; i++)
            {
                string imagePath = rifleRoot + "/stand/right.png";
                if (File.Exists(imagePath))
                {
                    SpriteImage spriteImg   = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    standSprite.AddFrame(spriteFrame);
                }
                else
                {
                    throw new FileNotFoundException("404 on " + imagePath);
                }
            }
            Animations.Add("stand_right", standSprite);

            foreach (string direction in directionDirs)
            {
                GameSprite attackSprite = new GameSprite();
                attackSprite.RepeatCount = 0;
                for (int i = 1; i <= 8; i++)
                {
                    string imagePath = rifleRoot + "/attack/" + direction + "/" + i + ".png";
                    if (File.Exists(imagePath))
                    {
                        SpriteImage spriteImg   = new SpriteImage(imagePath, Color.Transparent);
                        SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                        attackSprite.AddFrame(spriteFrame);
                    }
                    else
                    {
                        throw new FileNotFoundException("404 on " + imagePath);
                    }
                }
                Animations.Add("attack_" + direction, attackSprite);
            }

            GameSprite piffSprite = new GameSprite();

            piffSprite.RepeatCount = 0;
            for (int i = 0; i <= 3; i++)
            {
                string imagePath = GameController.resourceRoot + "/images/gunfire/piffpiff " + i + ".png";
                if (File.Exists(imagePath))
                {
                    SpriteImage spriteImg   = new SpriteImage(imagePath, Color.Transparent);
                    SpriteFrame spriteFrame = new SpriteFrame(spriteImg, 5);
                    piffSprite.AddFrame(spriteFrame);
                }
                else
                {
                    throw new FileNotFoundException("404 on " + imagePath);
                }
            }
            Animations.Add("piff", piffSprite);
        }
示例#17
0
        public List <GameObject> generateGameSet()
        {
            intervalBtwQuestion   = 0;
            intervalPerQuestion   = 0;
            questionIsCorrect     = false;
            solutionObjectReplica = null;
            currentGameSet.Clear();
            gameObjectPosition.Clear();

            gameLevelManagement.loadGameSets();

            var           set         = content.LoadContent <Texture2D>(gameLevelManagement.getCurrentLevelContent());
            List <string> contentName = new List <string>();

            foreach (string s in set.Keys)
            {
                contentName.Add(s);
            }

            List <int> contentRand = genRandomNumberList(0, contentName.Count);

            // Create solution object
            GameSprite solutionSprite = new GameSprite(set[contentName[contentRand[0]]], 1, 1, 0, 0);

            // Create selection objects
            GameSprite selectionSprite1 = new GameSprite(set[contentName[contentRand[1]]], 1, 1, 0, 0);
            GameSprite selectionSprite2 = new GameSprite(set[contentName[contentRand[2]]], 1, 1, 0, 0);
            GameSprite selectionSprite3 = new GameSprite(set[contentName[contentRand[3]]], 1, 1, 0, 0);

            // Store positions. These are namely 2 on the left, 2 on the right
            gameObjectPosition.Add(new Vector2(190, 235)); //top left
            gameObjectPosition.Add(new Vector2(190, 560)); // bottom left
            gameObjectPosition.Add(new Vector2(735, 235)); // top right
            gameObjectPosition.Add(new Vector2(735, 560)); //btm right

            // Generate position placement choices randomly
            List <int> randPosn = new List <int>();

            while (randPosn.Count != gameObjectPosition.Count)
            {
                int choice = rand.Next(0, gameObjectPosition.Count);
                if (!randPosn.Contains(choice))
                {
                    randPosn.Add(choice);
                }
            }

            // Create solution object
            GameObject solutionObj = new GameObject(solutionSprite, gameObjectPosition[randPosn[0]]);

            solutionObj.isSolutionObject = true;

            // Create a replica of the solution object for question display
            solutionObjectReplica = new GameObject(solutionSprite, 470, 105);

            GameObject selectionObject1 = new GameObject(selectionSprite1, gameObjectPosition[randPosn[1]]);
            GameObject selectionObject2 = new GameObject(selectionSprite2, gameObjectPosition[randPosn[2]]);
            GameObject selectionObject3 = new GameObject(selectionSprite3, gameObjectPosition[randPosn[3]]);

            // Add to current game set
            currentGameSet.Add(solutionObj); //Solution is always the first
            currentGameSet.Add(selectionObject1);
            currentGameSet.Add(selectionObject2);
            currentGameSet.Add(selectionObject3);

            return(currentGameSet);
        }
示例#18
0
        // Remember to draw objects
        public List <GameObject> generateGameSet()
        {
            solutionObjectReplica = null;
            currentGameSet.Clear();
            gameObjectPosition.Clear();
            int xSpacing = 5;

            var set = Content.LoadContent <Texture2D>("Level1\\" + getRandomGameSet());

            List <string> contentName = new List <string>();

            foreach (string s in set.Keys)
            {
                contentName.Add(s);
            }

            List <int> contentRand = genRandomNumberList(0, contentName.Count);

            // Create solution object
            GameSprite solutionSprite = new GameSprite(set[contentName[contentRand[0]]], 1, 1, 0, 0);

            // Create selection objects
            GameSprite selectionSprite1 = new GameSprite(set[contentName[contentRand[1]]], 1, 1, 0, 0);
            GameSprite selectionSprite2 = new GameSprite(set[contentName[contentRand[2]]], 1, 1, 0, 0);
            GameSprite selectionSprite3 = new GameSprite(set[contentName[contentRand[3]]], 1, 1, 0, 0);

            // GameSprite selectionSprite4 = new GameSprite(set1["yellow_ball"]  , 1, 1, 0, 0);

            // Store positions. These are namely 2 on the left, 2 on the right
            gameObjectPosition.Add(new Vector2(82, 145));                                                                                //top left
            gameObjectPosition.Add(new Vector2(82, solutionSprite.Height * 4 + 145));                                                    // bottom left
            gameObjectPosition.Add(new Vector2(Window.ClientBounds.Width - solutionSprite.Width - 82, 145));                             // top right
            gameObjectPosition.Add(new Vector2(Window.ClientBounds.Width - solutionSprite.Width - 82, solutionSprite.Height * 4 + 145)); //btm right

            // Generate position placement choices randomly
            List <int> randPosn = new List <int>();


            while (randPosn.Count != gameObjectPosition.Count)
            {
                int choice = rand.Next(0, gameObjectPosition.Count);
                if (!randPosn.Contains(choice))
                {
                    randPosn.Add(choice);
                }
            }

            // Create solution object
            GameObject solutionObj = new GameObject(solutionSprite, gameObjectPosition[randPosn[0]]);

            solutionObj.isSolutionObject = true;

            // Create a replica of the solution object for display purposes only
            solutionObjectReplica = new GameObject(solutionSprite, 550, 52);

            // left hand side
            GameObject selectionObject1 = new GameObject(selectionSprite1, gameObjectPosition[randPosn[1]]);
            GameObject selectionObject2 = new GameObject(selectionSprite2, gameObjectPosition[randPosn[2]]);

            // right hand side
            GameObject selectionObject3 = new GameObject(selectionSprite3, gameObjectPosition[randPosn[3]]);

            // Add to current game set
            currentGameSet.Add(solutionObj); //Solution is always the first
            currentGameSet.Add(selectionObject1);
            currentGameSet.Add(selectionObject2);
            currentGameSet.Add(selectionObject3);

            return(currentGameSet);
        }
示例#19
0
 public UltraCharger(GameSprite character)
 {
     this.character = character;
 }
示例#20
0
 public void AddSprite(GameSprite sp)
 {
     this.affectSprites.Add(sp);
 }
示例#21
0
 private void CreateObject()
 {
     RandomizeTexture();
     Sprite = new GameSprite(_texture) { Alive = true };
     RadomizeSpritePostion();
 }
示例#22
0
 public void RemoveSprite(GameSprite sp)
 {
     this.affectSprites.Remove(sp);
 }
示例#23
0
 private void CreateObject()
 {
     _texture = _contentManager.Load<Texture2D>("Sprites\\player_angel");
     Sprite = new GameSprite(_texture) { Alive = true };
 }
示例#24
0
        /// <summary>
        /// Gets the individual pixel coordinates of a collision between two sprites.
        /// </summary>
        /// <param name="sprite1">The first sprite.</param>
        /// <param name="subImage1">The subimage of the first sprite.</param>
        /// <param name="modelWorldTransform1">The transformation matrix of the first sprite.</param>
        /// <param name="sprite2">The second sprite.</param>
        /// <param name="subImage2">The subimage of the second sprite.</param>
        /// <param name="modelWorldTransform2">The transformation matrix of the second sprite.</param>
        /// <returns>An enumerable of (x, y) tuple values representing the pixels in the collision.</returns>
        public IEnumerable <(int x, int y)> GetSpriteCollisions(GameSprite sprite1, int subImage1,
                                                                Matrix3x2 modelWorldTransform1, GameSprite sprite2, int subImage2, Matrix3x2 modelWorldTransform2)
        {
            // First, transform the bounding boxes to account for sprite origin, rotations, scaling, and position.
            var bb1 = GetSpriteTransformedBoundingBox(sprite1, modelWorldTransform1);
            var bb2 = GetSpriteTransformedBoundingBox(sprite2, modelWorldTransform2);

            // Invert the transformation matrixes so we can map world coordinates into sprite coordinates.
            Matrix3x2.Invert(modelWorldTransform1, out var spriteLocalTransform1);
            Matrix3x2.Invert(modelWorldTransform2, out var spriteLocalTransform2);

            // Get the intersection of both bounding boxes.
            var bbIntersection = bb1.Intersection(ref bb2);

            // If the bounding boxes don't overlap, there is no collision.
            if (!bbIntersection.IsValid)
            {
                yield break;
            }

            // Get the collision mask for each sprite.
            var mask1 = sprite1.SeparateCollisionMasks ? sprite1.CollisionMasks[subImage1] : sprite1.CollisionMasks[0];
            var mask2 = sprite2.SeparateCollisionMasks ? sprite2.CollisionMasks[subImage2] : sprite2.CollisionMasks[0];

            // Look at each pixel in the bounding box intersection.
            for (var x = bbIntersection.Left; x <= bbIntersection.Right; x++)
            {
                for (var y = bbIntersection.Top; y <= bbIntersection.Bottom; y++)
                {
                    // Transform the pixel coordinate to sprite coordinates for both sprites
                    // using the inverted world matrix.
                    var localV1 = Vector2.Transform(new Vector2(x, y), spriteLocalTransform1);
                    var localV2 = Vector2.Transform(new Vector2(x, y), spriteLocalTransform2);

                    // Check if the respective sprite coordinates overlap solid pixels in both sprites.
                    if (mask1.HitTest((int)localV1.X, (int)localV1.Y) &&
                        mask2.HitTest((int)localV2.X, (int)localV2.Y))
                    {
                        yield return(x, y);
                    }
                }
            }
        }