Example #1
0
        public override void LoadContent()
        {
            ProtoHelper.OnChatRecieve += OnChatRecive;
            _ = ProtoHelper.JoinToChatAsync();
            var camera = new OrthographicCamera(_sceneHandler._graphicsDevice);

            mouseSystem = new MouseSystem();

            MouseSystem.OnMouseLeftClick += mouseClick;
            spriteBatch = new SpriteBatch(_sceneHandler._graphicsDevice);
            world       = new WorldBuilder()
                          .AddSystem(new RenderSystem(spriteBatch, camera))
                          .AddSystem(mouseSystem)
                          .Build();

            _sceneHandler._gameComponents.Add(world);

            entityFactory = new EntityFactory(world, _sceneHandler._content, _sceneHandler._graphicsDevice);

            text = entityFactory.CreateText(new Vector2(100, 100), ProtoHelper.nickname, 100);
            playerReadyButtom = entityFactory.CreateReadySign(new Vector2(500, 110));
            readyText         = entityFactory.CreateText(new Vector2(530, 102), "Not ready", 0);
            enemyText         = entityFactory.CreateText(new Vector2(100, 200), "", 100);
            enemyReadyButtom  = entityFactory.CreateReadySign(new Vector2(500, 210));
            enemyReadyText    = entityFactory.CreateText(new Vector2(530, 202), "Not ready", 0);


            LoadGui();

            while (!ProtoHelper.IsChatLive)
            {
                Thread.Sleep(10);
            }

            Thread.Sleep(500);
            ProtoHelper.WriteToChat("!live");


            while (live == null)
            {
                Thread.Sleep(10);
            }

            if ((bool)live == true)
            {
                ChangeStateToGame();
            }

            var player  = _sceneHandler._content.Load <Texture2D>("MiniHead1");
            var upArrow = _sceneHandler._content.Load <Texture2D>("MiniHead1");

            playerSprite    = new Sprite(player);
            enemySprite     = new Sprite(player);
            upArrowSprite   = new Sprite(_sceneHandler._content.Load <Texture2D>("upArrow"));
            downArrowSprite = new Sprite(_sceneHandler._content.Load <Texture2D>("downArrow"));
        }
Example #2
0
        internal override void UpdateScene(GameTime gameTime)
        {
            var keyboardState = KeyboardExtended.GetState();

            if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                ProtoHelper.WriteToChat(chatText.Text);
                var t = text.Get <Text>();
                t.text = $"{ProtoHelper.nickname}: {chatText.Text}";
            }

            _guiSystem.Update(gameTime);
        }
Example #3
0
        internal override void UpdateScene(GameTime gameTime)
        {
            if (IsLoaded)
            {
                if (b2DWorld != null)
                {
                    const float TimeStep           = 1.0f / 60;
                    const int   VelocityIterations = 6;
                    const int   PositionIterations = 2;
                    b2DWorld.Step(TimeStep, VelocityIterations, PositionIterations);
                }

                var keyboardState = KeyboardExtended.GetState();

                var input = Input.none;

                if (keyboardState.IsKeyDown(Keys.Right))
                {
                    input |= Input.right;
                }
                if (keyboardState.IsKeyDown(Keys.Left))
                {
                    input |= Input.left;
                }
                if (keyboardState.IsKeyDown(Keys.Up))
                {
                    input |= Input.up;
                }
                if (keyboardState.IsKeyDown(Keys.Space))
                {
                    input |= Input.kick;
                }
                if (keyboardState.IsKeyUp(Keys.Space))
                {
                    input |= Input.kickUp;
                }
                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    world.Dispose();
                    ProtoHelper.WriteToChat("!disconnect");
                    _sceneHandler.ChangeScene(new MenuScene());
                }
                if (Enemy)
                {
                    input |= Input.enemy;
                }

                inputClient.Send((byte)input, inputEndPoint);
            }
        }
Example #4
0
        private void mouseClick()
        {
            if (mouseSystem.Clicked(new Vector2(500, 110), new Vector2(16, 16)))
            {
                var _playerReadyButtom = playerReadyButtom.Get <AnimatedSprite>();
                if (!ready)
                {
                    _playerReadyButtom.Play("Ready");
                    ProtoHelper.WriteToChat("!Ready");

                    var _ReadyText = readyText.Get <Text>();
                    _ReadyText.text = "Ready";
                }
                else
                {
                    _playerReadyButtom.Play("NotReady");
                    ProtoHelper.WriteToChat("!NotReady");

                    var _ReadyText = readyText.Get <Text>();
                    _ReadyText.text = "Not ready";
                }
                ready = !ready;
            }
            if (mouseSystem.Clicked(new Vector2(690, 80), new Vector2(16, 16)))
            {
                var s = playerSkin + 1;
                playerSkin   = s <= (skin)Enum.GetValues(typeof(skin)).Length - 1 ? s : 0;
                playerSprite = new Sprite(_sceneHandler._content.Load <Texture2D>(playerSkin.ToString()));
                ProtoHelper.WriteToChat($"!SkinChange,{(int)playerSkin}");
            }
            if (mouseSystem.Clicked(new Vector2(690, 120), new Vector2(16, 16)))
            {
                var s = playerSkin - 1;
                playerSkin   = s < 0 ? (skin)Enum.GetValues(typeof(skin)).Length - 1 : s;
                playerSprite = new Sprite(_sceneHandler._content.Load <Texture2D>(playerSkin.ToString()));
                ProtoHelper.WriteToChat($"!SkinChange,{(int)playerSkin}");
            }
        }
Example #5
0
 private void OnJoinButtonClick(object sender, EventArgs e)
 {
     ProtoHelper.WriteToChat("!Start");
 }