Example #1
0
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            base.LoadContent();
            Content.RootDirectory = "Content";

            var testTexture = Content.Load <Texture2D>("images/Test");
            var testPatch   = new NinePatch(new TextureRegion(testTexture, 40, 0, 40, 40), 16);

            style = new UntexturedStyle(this.SpriteBatch)
            {
                Font = new GenericSpriteFont(
                    Content.Load <SpriteFont>("fonts/gui"),
                    Content.Load <SpriteFont>("fonts/Text"),
                    Content.Load <SpriteFont>("fonts/Text")),
                PanelTexture             = testPatch,
                ButtonTexture            = new NinePatch(new TextureRegion(testTexture, 24, 8, 16, 16), 4),
                TextFieldTexture         = new NinePatch(new TextureRegion(testTexture, 24, 8, 16, 16), 4),
                ScrollBarBackground      = new NinePatch(new TextureRegion(testTexture, 12, 0, 4, 8), 1, 1, 2, 2),
                ScrollBarScrollerTexture = new NinePatch(new TextureRegion(testTexture, 8, 0, 4, 8), 1, 1, 2, 2),
                CheckboxTexture          = new NinePatch(new TextureRegion(testTexture, 24, 8, 16, 16), 4),
                CheckboxCheckmark        = new TextureRegion(testTexture, 24, 0, 8, 8),
                RadioTexture             = new NinePatch(new TextureRegion(testTexture, 16, 0, 8, 8), 3),
                RadioCheckmark           = new TextureRegion(testTexture, 32, 0, 8, 8)
            };

            var music1 = Content.Load <Song>("music/Ivan Happy - Ode");
            var music2 = Content.Load <Song>("music/ivan happy - futility");
            var music3 = Content.Load <Song>("music/KOLARD BEATS - WAKE FROM ETERNAL SLEEP");
            var musics = CreateInstance <SongCollection>();

            musics.Add(music1);
            musics.Add(music2);
            musics.Add(music3);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(musics);
            MediaPlayer.Volume             = Configuration.Options.RealSongVolume;
            SoundEffect.MasterVolume       = Configuration.Options.RealSoundVolume;
            Configuration.OnOptionsChange += options => MediaPlayer.Volume = options.RealSongVolume;
            Configuration.OnOptionsChange += options => SoundEffect.MasterVolume = options.RealSoundVolume;
        }
Example #2
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var tex                  = Content.Load <Texture2D>("TestTextures/Test");
            var fengPortrait         = new TextureRegion(Content.Load <Texture2D>("Portraits/framedFeng"));
            var knightPortrait       = new TextureRegion(Content.Load <Texture2D>("Portraits/framedKnight"));
            var fengPortraitGolden   = new TextureRegion(Content.Load <Texture2D>("Portraits/framedFengGolden"));
            var knightPortraitGolden = new TextureRegion(Content.Load <Texture2D>("Portraits/framedKnightGolden"));

            var titleStyle = new UntexturedStyle(_spriteBatch)
            {
                Font          = new GenericSpriteFont(Content.Load <SpriteFont>("Fonts/alagard")),
                TextScale     = 8.0f,
                PanelTexture  = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
                ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
            };

            var style = new UntexturedStyle(_spriteBatch)
            {
                Font                     = new GenericSpriteFont(Content.Load <SpriteFont>("Fonts/alagard")),
                TextScale                = 2.25f,
                TextFieldTexture         = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
                PanelTexture             = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
                ButtonTexture            = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
                ScrollBarBackground      = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2),
                ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2)
            };

            UiSystem = new UiSystem(Window, GraphicsDevice, style);
            titleUi  = new UiSystem(Window, GraphicsDevice, titleStyle);

            var prgTitle = new Paragraph(Anchor.TopCenter, 1, "Way of The", true)
            {
                PositionOffset = new Vector2(0, 20)
            };
            var prgSubTitle = new Paragraph(Anchor.TopCenter, 1, "Sword", true)
            {
                PositionOffset = new Vector2(0, 140)
            };

            titleUi.Add("title", prgTitle);
            titleUi.Add("subTitle", prgSubTitle);

            var panel   = new Panel(Anchor.Center, new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), positionOffset: Vector2.Zero);
            var imgFeng = new Image(Anchor.Center, new Vector2(200, 200), fengPortrait)
            {
                IsHidden = true, PositionOffset = new Vector2(-150, 20)
            };
            var btnFeng = new Button(Anchor.Center, imgFeng.Size, "")
            {
                HoveredColor   = Color.Transparent,
                NormalColor    = Color.Transparent,
                PositionOffset = new Vector2(-150, 20),
                IsHidden       = true
            };
            var imgKnight = new Image(Anchor.Center, new Vector2(235, 235), knightPortrait)
            {
                IsHidden = true, PositionOffset = new Vector2(150, 32)
            };;
            var btnKnight = new Button(Anchor.Center, imgKnight.Size, "")
            {
                HoveredColor   = Color.Transparent,
                NormalColor    = Color.Transparent,
                PositionOffset = new Vector2(150, 32),
                IsHidden       = true
            };
            var prgAuthor = new Paragraph(Anchor.Center, 1, "By Ethan Eshed", true)
            {
                PositionOffset = new Vector2(0, 80)
            };
            var btnPlay = new Button(Anchor.BottomCenter, new Vector2(200, 50), "Play")
            {
                PositionOffset = new Vector2(0, 35)
            };
            var btnFight = new Button(Anchor.BottomCenter, new Vector2(200, 50), "Fight!")
            {
                IsHidden       = true,
                PositionOffset = new Vector2(0, 35)
            };
            var prgPlayers = new Paragraph(Anchor.Center, 1, "Select your Champion", true)
            {
                PositionOffset = new Vector2(0, -120), IsHidden = true
            };
            var btnProceed = new Button(Anchor.BottomCenter, new Vector2(200, 50), "Proceed")
            {
                IsHidden = true, PositionOffset = new Vector2(0, 35)
            };
            var prgNickName = new Paragraph(Anchor.Center, 1, "Enter your Name", true)
            {
                PositionOffset = new Vector2(-19, -80), IsHidden = true
            };
            var txtBoxNickName = new TextField(Anchor.Center, new Vector2(400, 50))
            {
                IsHidden = true, PositionOffset = new Vector2(0, 30)
            };

            var btnBack = new Button(Anchor.TopRight, new Vector2(200, 50), "Back")
            {
                IsHidden       = true,
                PositionOffset = new Vector2(15, 15),
                OnPressed      = e =>
                {
                    if (!btnFight.IsHidden) // champion select screen
                    {
                        btnProceed.IsHidden     = false;
                        txtBoxNickName.IsHidden = false;
                        prgNickName.IsHidden    = false;
                        e.IsHidden = false;

                        prgPlayers.IsHidden = true;
                        imgFeng.IsHidden    = true;
                        imgKnight.IsHidden  = true;
                        btnFight.IsHidden   = true;
                        btnFeng.IsHidden    = true;
                        btnKnight.IsHidden  = true;
                    }
                    else
                    {
                        prgTitle.IsHidden       = false;
                        prgSubTitle.IsHidden    = false;
                        prgAuthor.IsHidden      = false;
                        btnPlay.IsHidden        = false;
                        btnProceed.IsHidden     = true;
                        txtBoxNickName.IsHidden = true;
                        prgNickName.IsHidden    = true;
                        e.IsHidden = true;
                    }
                }
            };

            btnPlay.OnPressed = e =>
            {
                prgTitle.IsHidden       = true;
                prgSubTitle.IsHidden    = true;
                prgAuthor.IsHidden      = true;
                e.IsHidden              = true;
                btnBack.IsHidden        = false;
                btnProceed.IsHidden     = false;
                txtBoxNickName.IsHidden = false;
                prgNickName.IsHidden    = false;
            };

            btnProceed.OnPressed = e =>
            {
                if (!txtBoxNickName.Text.Equals(""))
                {
                    prgPlayers.IsHidden     = false;
                    imgFeng.IsHidden        = false;
                    imgKnight.IsHidden      = false;
                    btnFight.IsHidden       = false;
                    btnFeng.IsHidden        = false;
                    btnKnight.IsHidden      = false;
                    btnProceed.IsHidden     = true;
                    txtBoxNickName.IsHidden = true;
                    prgNickName.IsHidden    = true;
                    nickName = txtBoxNickName.Text;
                }
            };

            btnFeng.OnPressed = e =>
            {
                imgKnight.Texture = knightPortrait;
                imgFeng.Texture   = fengPortraitGolden;
                champion          = "feng";
            };
            btnFeng.OnMouseEnter = e =>
            {
                imgFeng.Texture = fengPortraitGolden;
            };
            btnFeng.OnMouseExit = e =>
            {
                if (champion != "feng")
                {
                    imgFeng.Texture = fengPortrait;
                }
            };

            btnKnight.OnPressed = e =>
            {
                imgFeng.Texture   = fengPortrait;
                imgKnight.Texture = knightPortraitGolden;
                champion          = "knight";
            };
            btnKnight.OnMouseEnter = e =>
            {
                imgKnight.Texture = knightPortraitGolden;
            };
            btnKnight.OnMouseExit = e =>
            {
                if (champion != "knight")
                {
                    imgKnight.Texture = knightPortrait;
                }
            };

            btnFight.OnPressed = e =>
            {
                if (champion != "none")
                {
                    UiSystem.Dispose();
                    titleUi.Dispose();
                    Exit();
                    Communicator.Setup(champion, nickName);
                }
            };

            panel.AddChild(prgPlayers);
            panel.AddChild(prgAuthor);
            panel.AddChild(btnPlay);
            panel.AddChild(btnBack);
            panel.AddChild(imgFeng);
            panel.AddChild(imgKnight);
            panel.AddChild(btnFight);
            panel.AddChild(btnFeng);
            panel.AddChild(btnKnight);
            panel.AddChild(btnPlay);
            panel.AddChild(txtBoxNickName);
            panel.AddChild(btnProceed);
            panel.AddChild(prgNickName);

            UiSystem.Add("StartMenu", panel);
        }
Example #3
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var tex = Content.Load <Texture2D>("TestTextures/Test");

            vicCount     = 0;
            vicTimeCount = 0;

            var style = new UntexturedStyle(_spriteBatch)
            {
                Font                     = new GenericSpriteFont(Content.Load <SpriteFont>("Fonts/alagard")),
                TextScale                = 2.0f,
                PanelTexture             = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
                ButtonTexture            = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
                ScrollBarBackground      = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2),
                ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2)
            };

            UiSystem = new UiSystem(Window, GraphicsDevice, style);

            var pnlOptions = new Panel(Anchor.Center, new Vector2(350, 400), positionOffset: Vector2.Zero)
            {
                IsHidden = true
            };
            var btnOptions = new Button(Anchor.TopLeft, new Vector2(200, 50), "Options")
            {
                PositionOffset = new Vector2(15, 15)
            };
            var btnHitbox = new Button(Anchor.TopLeft, new Vector2(220, 50), "HitboxLayout:")
            {
                PositionOffset = new Vector2(25, 25)
            };
            var prgHitbox = new Paragraph(Anchor.TopRight, 1, "Off", true)
            {
                PositionOffset = new Vector2(25, 33)
            };
            var btnExit = new Button(Anchor.Center, new Vector2(220, 50), "Exit Game")
            {
                PositionOffset = new Vector2(0, 0)
            };
            var btnOk = new Button(Anchor.BottomCenter, new Vector2(220, 50), "Ok")
            {
                PositionOffset = new Vector2(0, 30)
            };
            var btnMainMenu = new Button(Anchor.Center, new Vector2(220, 50), "Main Menu")
            {
                PositionOffset = new Vector2(0, -70)
            };

            pnlDefeat = new Panel(Anchor.Center, new Vector2(350, 400), positionOffset: Vector2.Zero)
            {
                IsHidden = true
            };
            var prgDefeat = new Paragraph(Anchor.TopCenter, 1, "Defeat", true)
            {
                PositionOffset = new Vector2(0, 33)
            };
            var btnMenu = new Button(Anchor.Center, new Vector2(220, 50), "Main Menu")
            {
                PositionOffset = new Vector2(0, 70)
            };
            var btnExitGame = new Button(Anchor.BottomCenter, new Vector2(220, 50), "Exit Game")
            {
                PositionOffset = new Vector2(0, 30)
            };
            var prgDeath = new Paragraph(Anchor.Center, 1, "You Died.", true)
            {
                PositionOffset = new Vector2(0, -50)
            };

            btnVictory = new Button(Anchor.TopCenter, new Vector2(700, 50), "")
            {
                PositionOffset = new Vector2(0, 90), IsHidden = true, IsDisabled = true
            };

            btnOptions.OnPressed = e =>
            {
                pnlOptions.IsHidden   = false;
                btnOptions.IsDisabled = true;
            };

            btnOk.OnPressed = e =>
            {
                pnlOptions.IsHidden   = true;
                btnOptions.IsDisabled = false;
            };

            btnHitbox.OnPressed = e =>
            {
                if (prgHitbox.Text == "Off")
                {
                    prgHitbox.Text = "On";
                    AnimationManager.HitboxLayout = true;
                }
                else
                {
                    prgHitbox.Text = "Off";
                    AnimationManager.HitboxLayout = false;
                }
            };

            btnExit.OnPressed = e =>
            {
                Communicator.ExitSoftware = true;
                Exit();
            };

            btnExitGame.OnPressed = e =>
            {
                Communicator.ExitSoftware = true;
                Exit();
            };

            btnMenu.OnPressed = e =>
            {
                Exit();
            };

            btnMainMenu.OnPressed = e =>
            {
                Exit();
            };

            pnlOptions.AddChild(btnHitbox);
            pnlOptions.AddChild(prgHitbox);
            pnlOptions.AddChild(btnExit);
            pnlOptions.AddChild(btnOk);
            pnlOptions.AddChild(btnMainMenu);
            pnlDefeat.AddChild(btnMenu);
            pnlDefeat.AddChild(prgDefeat);
            pnlDefeat.AddChild(btnExitGame);
            pnlDefeat.AddChild(prgDeath);

            UiSystem.Add("OptionsPanel", pnlOptions);
            UiSystem.Add("DefeatPanel", pnlDefeat);
            UiSystem.Add("OptionsButton", btnOptions);
            UiSystem.Add("VictoryStatement", btnVictory);

            int idCount1 = 0;
            int idCount2 = 0;

            animations = new Dictionary <champions, Dictionary <string, Animation> >()
            {
                { champions.Feng, new Dictionary <string, Animation>()

                  {
                      { "Run_Left", new Animation(Content.Load <Texture2D>("Feng/Run_Left"), 8, idCount1++) },
                      { "Run_Right", new Animation(Content.Load <Texture2D>("Feng/Run_Right"), 8, idCount1++) },
                      { "Jump_Right", new Animation(Content.Load <Texture2D>("Feng/Jump_Right"), 2, idCount1++) },
                      { "Jump_Left", new Animation(Content.Load <Texture2D>("Feng/Jump_Left"), 2, idCount1++) },
                      { "Fall_Right", new Animation(Content.Load <Texture2D>("Feng/Fall_Right"), 2, idCount1++) },
                      { "Fall_Left", new Animation(Content.Load <Texture2D>("Feng/Fall_Left"), 2, idCount1++) },
                      { "Idle_Right", new Animation(Content.Load <Texture2D>("Feng/Idle_Right"), 8, idCount1++) },
                      { "Idle_Left", new Animation(Content.Load <Texture2D>("Feng/Idle_Left"), 8, idCount1++) },
                      { "Attack1_Right", new Animation(Content.Load <Texture2D>("Feng/Attack1_Right"), 6, idCount1++) },
                      { "Attack_Right", new Animation(Content.Load <Texture2D>("Feng/Attack_Right"), 12, idCount1++) },
                      { "Attack1_Left", new Animation(Content.Load <Texture2D>("Feng/Attack1_Left"), 6, idCount1++) },
                      { "Attack_Left", new Animation(Content.Load <Texture2D>("Feng/Attack_Left"), 12, idCount1++) },
                      { "Hurt_Right", new Animation(Content.Load <Texture2D>("Feng/Hurt_Right"), 4, idCount1++) },
                      { "Hurt_Left", new Animation(Content.Load <Texture2D>("Feng/Hurt_Left"), 4, idCount1++) },
                      { "Death_Right", new Animation(Content.Load <Texture2D>("Feng/Death_Right"), 6, idCount1++) },
                      { "Death_Left", new Animation(Content.Load <Texture2D>("Feng/Death_Left"), 6, idCount1++) }
                  } },

                { champions.Knight, new Dictionary <string, Animation>()

                  {
                      { "Run_Left", new Animation(Content.Load <Texture2D>("Knight/Run_Left"), 10, idCount2++) },
                      { "Run_Right", new Animation(Content.Load <Texture2D>("Knight/Run_Right"), 10, idCount2++) },
                      { "Jump_Right", new Animation(Content.Load <Texture2D>("Knight/Jump_Right"), 3, idCount2++) },
                      { "Jump_Left", new Animation(Content.Load <Texture2D>("Knight/Jump_Left"), 3, idCount2++) },
                      { "Fall_Right", new Animation(Content.Load <Texture2D>("Knight/Fall_Right"), 4, idCount2++) },
                      { "Fall_Left", new Animation(Content.Load <Texture2D>("Knight/Fall_Left"), 4, idCount2++) },
                      { "Idle_Right", new Animation(Content.Load <Texture2D>("Knight/Idle_Right"), 8, idCount2++) },
                      { "Idle_Left", new Animation(Content.Load <Texture2D>("Knight/Idle_Left"), 8, idCount2++) },
                      { "Attack1_Right", new Animation(Content.Load <Texture2D>("Knight/Attack1_Right"), 6, idCount2++) },
                      { "Attack_Right", new Animation(Content.Load <Texture2D>("Knight/Attack_Right"), 6, idCount2++) },
                      { "Attack1_Left", new Animation(Content.Load <Texture2D>("Knight/Attack1_Left"), 6, idCount2++) },
                      { "Attack_Left", new Animation(Content.Load <Texture2D>("Knight/Attack_Left"), 6, idCount2++) },
                      { "Hurt_Right", new Animation(Content.Load <Texture2D>("Knight/Hurt_Right"), 3, idCount2++) },
                      { "Hurt_Left", new Animation(Content.Load <Texture2D>("Knight/Hurt_Left"), 3, idCount2++) },
                      { "Death_Right", new Animation(Content.Load <Texture2D>("Knight/Death_Right"), 10, idCount2++) },
                      { "Death_Left", new Animation(Content.Load <Texture2D>("Knight/Death_Left"), 10, idCount2++) }
                  } }
            };

            hitBoxManager.AquireData(GraphicsDevice);

            background = new Sprite(Content.Load <Texture2D>("maps/pixel hills"));

            Feng.ground   = new Vector2(100, GraphicsDevice.Viewport.Height - 270);
            Knight.ground = new Vector2(100, GraphicsDevice.Viewport.Height - 130); // 200

            champions champ = StartMenu.champion == "feng" ? champions.Feng : champions.Knight;
            Character character;
            Vector2   g;

            if (champ == champions.Feng)
            {
                character = new Feng();
                g         = Feng.ground;
            }
            else
            {
                character = new Knight();
                g         = Knight.ground;
            }

            Communicator.SetGround(g.Y);

            sprites = new List <Sprite>()
            {
                new Sprite(animations[champ], champ, StartMenu.nickName)
                {
                    Position = new Vector2(g.X, g.Y),
                    Id       = Communicator.ClientId,
                    Champion = character
                }
            };

            UiSystem.Add(sprites[0].Id.ToString() + "h", sprites[0].healthBar);
            UiSystem.Add(sprites[0].Id.ToString() + "n", sprites[0].nickName);

            Thread thr = new Thread(Communicator.Receive);

            thr.Start();

            StartMenu.champion = "none";
        }