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(); } }
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); }
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); }
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; }