Exemplo n.º 1
0
        void SendLocalPlayerAndPlayerSettings()
        {
            IPlayerInput playerInput = new PlayerInput(this.LocalClient.Player);
            this.OutgoingMessageQueue.AddToQueue(new Item() { ClientID = this.LocalClient.ID, Type = ItemType.PlayerInput, Data = playerInput });

            if (this.LocalClient.Player.PlayerSettings.IsDirty)
            {
                this.OutgoingMessageQueue.AddToReliableQueue(new Item() { ClientID = this.LocalClient.ID, Type = ItemType.PlayerSettings, Data = this.LocalClient.Player.PlayerSettings.GetDiff() });
                this.LocalClient.Player.PlayerSettings.Clean();
            }
        }
Exemplo n.º 2
0
        public void CanCreatePlayerInputFromPlayerValues()
        {
            var player = MockRepository.GenerateStub<IPlayer>();
            player.Position = new Vector2(3, 4);
            player.PendingShot = new Vector2(8, 9);
            player.PendingStatus = PlayerStatus.Dead;

            var input = new PlayerInput(player);

            Assert.AreEqual(new Vector2(3, 4), input.Position);
            Assert.AreEqual(new Vector2(8, 9), input.PendingShot);
            Assert.AreEqual(PlayerStatus.Dead, input.PendingStatus);
        }
Exemplo n.º 3
0
        public void UpdatesPlayerFromInputCorrectly()
        {
            var player = MockRepository.GenerateStub<IPlayer>();
            player.Status = PlayerStatus.Alive;
            var playerInput = new PlayerInput();
            playerInput.PendingStatus = PlayerStatus.Dead;
            playerInput.PendingShot = new Vector2(100, 200);
            playerInput.Position = new Vector2(1000, 2000);

            playerInput.RefreshPlayerValuesFromInput(player);

            Assert.AreEqual(PlayerStatus.Dead, player.PendingStatus);
            Assert.AreEqual(new Vector2(100, 200), player.PendingShot);
            Assert.AreEqual(new Vector2(1000, 2000), player.Position);
        }
Exemplo n.º 4
0
        public static PlayerInput ReadPlayerInput(this NetBuffer netbuffer)
        {
            PlayerInput input = new PlayerInput();

            input.Position = netbuffer.ReadVector2();
            if (netbuffer.ReadBoolean())
            {
                input.PendingStatus = (PlayerStatus)netbuffer.ReadUInt16();
            }
            if (netbuffer.ReadBoolean())
            {
                input.PendingShot = netbuffer.ReadVector2();
            }

            return input;
        }