public void SendDirection(IOutgoingMessageService <ZoneClientNetPeer> outgoingMessageService) { var direction = new Vector2(xAxisInput.Value, yAxisInput.Value); if (direction.X != 0 && direction.Y != 0) { direction.Normalize(); } if (!previousDirection.Equals(direction)) { if (i < 10) { var playerDirectionMessageData = new PlayerDirectionMessageData(); playerDirectionMessageData.X = direction.X; playerDirectionMessageData.Y = direction.Y; outgoingMessageService.Send(playerDirectionMessageData); System.Console.WriteLine(position); //i++; } } previousDirection = direction; }
public SNMessageData GetMessageData(short type) { ZoneMessageTypes header = (ZoneMessageTypes)type; SNMessageData message = null; switch (header) { #region Authentification case ZoneMessageTypes.PlayerLogin: message = new PlayerLoginMessageData(); break; case ZoneMessageTypes.RequestCharacters: message = new RequestCharactersMessageData(); break; case ZoneMessageTypes.SelectCharacter: message = new SelectCharacterMessageData(); break; case ZoneMessageTypes.CharacterLoaded: message = new CharacterLoadedMessageData(); break; #endregion #region Players case ZoneMessageTypes.PlayerDirection: message = new PlayerDirectionMessageData(); break; #endregion default: loggingService.Log($"Cannot build zone message {header.ToString()}", LogMessageType.WARNING); break; } return(message); }