/// <summary>
        /// Sends a CharacterCreate packet to a CityServer.
        /// </summary>
        /// <param name="LoginArgs">Arguments used to log onto the CityServer.</param>
        /// <param name="Character">The character to create on the CityServer.</param>
        public static void SendCharacterCreateCity(LoginArgsContainer LoginArgs, TSOClient.VM.Sim Character)
        {
            PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE_CITY, 0);
            Packet.WriteHeader();

            byte[] EncryptionKey = LoginArgs.Enc.GetDecryptionArgsContainer().ARC4DecryptArgs.EncryptionKey;
            MemoryStream PacketData = new MemoryStream();
            BinaryWriter Writer = new BinaryWriter(PacketData);

            Writer.Write((byte)LoginArgs.Username.Length);
            Writer.Write(Encoding.ASCII.GetBytes(LoginArgs.Username), 0, Encoding.ASCII.GetBytes(LoginArgs.Username).Length);
            Writer.Write((byte)EncryptionKey.Length);
            Writer.Write(EncryptionKey);
            Writer.Write(PlayerAccount.CityToken);
            Writer.Write(Character.Timestamp);
            Writer.Write(Character.Name);
            Writer.Write(Character.Sex);
            Writer.Write(Character.Description);
            Writer.Write((ulong)Character.HeadOutfitID);
            Writer.Write((ulong)Character.BodyOutfitID);
            Writer.Write((byte)Character.AppearanceType);
            Writer.Write((string)Character.CityID.ToString());

            Packet.WriteUInt16((ushort)((ushort)PacketHeaders.UNENCRYPTED + PacketData.Length));
            Packet.WriteBytes(PacketData.ToArray());
            Writer.Close();

            LoginArgs.Client.Send(Packet.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends a CharacterCreate packet to the LoginServer.
        /// </summary>
        /// <param name="Character">The character to create.</param>
        /// <param name="TimeStamp">The timestamp of when this character was created.</param>
        public static void SendCharacterCreate(TSOClient.VM.Sim Character, string TimeStamp)
        {
            PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE, 0);
            Packet.WritePascalString(PlayerAccount.Client.ClientEncryptor.Username);
            Packet.WritePascalString(TimeStamp);
            Packet.WritePascalString(Character.Name);
            Packet.WritePascalString(Character.Sex);
            Packet.WritePascalString(Character.Description);
            Packet.WriteUInt64(Character.HeadOutfitID);
            Packet.WriteUInt64(Character.BodyOutfitID);
            Packet.WriteByte((byte)Character.AppearanceType);

            Packet.WritePascalString(Character.ResidingCity.Name);
            Packet.WriteUInt64(Character.ResidingCity.Thumbnail);
            Packet.WritePascalString(Character.ResidingCity.UUID);
            Packet.WriteUInt64(Character.ResidingCity.Map);
            Packet.WritePascalString(Character.ResidingCity.IP);
            Packet.WriteInt32(Character.ResidingCity.Port);

            byte[] PacketData = Packet.ToArray();
            PlayerAccount.Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE, PacketData);
        }
Exemplo n.º 3
0
 public override void Update(TSOClient.Code.UI.Model.UpdateState statex)
 {
     base.Update(statex);
 }
Exemplo n.º 4
0
 void OkButton_OnButtonClick(TSOClient.Code.UI.Framework.UIElement button)
 {
     GameFacade.Controller.ShowPersonCreation((CityInfo)CityListBox.SelectedItem.Data);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handle when a user selects a city
        /// </summary>
        /// <param name="element"></param>
        void CityListBox_OnChange(TSOClient.Code.UI.Framework.UIElement element)
        {
            var selectedItem = CityListBox.SelectedItem;
            if (selectedItem == null)
            {
                return;
            }

            var city = (CityInfo)selectedItem.Data;

            String gamepath = GameFacade.GameFilePath("");
            int CityNum = GameFacade.GetCityNumber(city.Name);
            string CityStr = gamepath + "cities\\" + ((CityNum >= 10) ? "city_00" + CityNum.ToString() : "city_000" + CityNum.ToString());

            //Take a copy so we dont change the original when we alpha mask it
            Texture2D cityThumbTex = TextureUtils.Copy(GameFacade.GraphicsDevice, Texture2D.FromFile(
               GameFacade.Game.GraphicsDevice, CityStr + "\\Thumbnail.bmp"));
            TextureUtils.CopyAlpha(ref cityThumbTex, thumbnailAlphaImage);

            CityThumb.Texture = cityThumbTex;
            DescriptionText.CurrentText = city.Description;
            DescriptionText.VerticalScrollPosition = 0;

            /** Validate **/
            var isValid = true;
            if (city.Status == CityInfoStatus.Reserved)
            {
                isValid = false;
                /** Already have a sim in this city **/
                ShowCityErrorDialog(CityReservedDialogTitle, CityReservedDialogMessage);
            }
            else if (city.Status == CityInfoStatus.Full)
            {
                isValid = false;
                /** City is full **/
                ShowCityErrorDialog(CityFullDialogTitle, CityFullDialogMessage);
            }
            else if (city.Status == CityInfoStatus.Busy)
            {
                isValid = false;
                /** City is busy **/
                ShowCityErrorDialog(CityBusyDialogTitle, CityBusyDialogMessage);
            }

            OkButton.Disabled = !isValid;
        }
Exemplo n.º 6
0
 void CancelButton_OnButtonClick(TSOClient.Code.UI.Framework.UIElement button)
 {
     UIScreen.RemoveDialog(this);
 }
        private void Client_OnReceivedData(TSOClient.Network.PacketStream Packet)
        {
            switch (Packet.PacketID)
            {
                case 0x01:
                    UIPacketHandlers.OnInitLoginNotify(NetworkFacade.Client, Packet);
                    NetworkFacade.UpdateLoginProgress(2);
                    break;
                case 0x02:
                    NetworkFacade.LoginWait.Set();
                    UIPacketHandlers.OnLoginFailResponse(ref NetworkFacade.Client, Packet);
                    break;
                case 0x05:
                    NetworkFacade.LoginOK = true;
                    NetworkFacade.LoginWait.Set();

                    NetworkFacade.UpdateLoginProgress(3);

                    UIPacketHandlers.OnCharacterInfoResponse(Packet, NetworkFacade.Client);
                    break;
                case 0x06:
                    UIPacketHandlers.OnCityInfoResponse(Packet);
                    break;
            }
        }
        /// <summary>
        /// Handle when a user selects a city
        /// </summary>
        /// <param name="element"></param>
        void CityListBox_OnChange(TSOClient.Code.UI.Framework.UIElement element)
        {
            var selectedItem = CityListBox.SelectedItem;
            if (selectedItem == null)
            {
                return;
            }

            var city = (CityInfo)selectedItem.Data;
            //Take a copy so we dont change the original when we alpha mask it
            var cityThumb = TextureUtils.Copy(Texture2D.FromFile(GameFacade.GraphicsDevice, new MemoryStream(ContentManager.GetResourceFromLongID(city.Thumbnail))));
            TextureUtils.CopyAlpha(ref cityThumb, thumbnailAlphaImage);

            CityThumb.Texture = cityThumb;
            DescriptionText.CurrentText = city.Description;
            DescriptionText.VerticalScrollPosition = 0;

            /** Validate **/
            var isValid = true;
            if (city.Status == CityInfoStatus.Reserved)
            {
                isValid = false;
                /** Already have a sim in this city **/
                ShowCityErrorDialog(CityReservedDialogTitle, CityReservedDialogMessage);
            }else if (city.Status == CityInfoStatus.Full)
            {
                isValid = false;
                /** City is full **/
                ShowCityErrorDialog(CityFullDialogTitle, CityFullDialogMessage);
            }
            else if (city.Status == CityInfoStatus.Busy)
            {
                isValid = false;
                /** City is busy **/
                ShowCityErrorDialog(CityBusyDialogTitle, CityBusyDialogMessage);
            }

            OkButton.Disabled = !isValid;
        }
Exemplo n.º 9
0
        public void HandleMouseEvents(TSOClient.Code.UI.Model.UpdateState state)
        {
            var mouseBtnDown = state.MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            var mouseDif = mouseBtnDown != LastMouseDownState;
            LastMouseDownState = mouseBtnDown;

            if (mouseDif)
            {
                if (mouseBtnDown)
                {
                    if (LastMouseDown != null)
                    {
                        /** We already have mouse down on an object **/
                        return;
                    }
                    if (LastMouseOver != null)
                    {
                        LastMouseDown = LastMouseOver;
                        LastMouseDown.Callback(UIMouseEventType.MouseDown, state);
                    }
                }
                else
                {
                    if (LastMouseDown != null)
                    {
                        LastMouseDown.Callback(UIMouseEventType.MouseUp, state);
                        LastMouseDown = null;
                    }
                }
            }

            if (state.MouseEvents.Count > 0)
            {
                var topMost =
                    state.MouseEvents.OrderByDescending(x => x.Element.Depth).First();

                /** Same element **/
                if (LastMouseOver == topMost)
                {
                    return;
                }

                if (LastMouseOver != null)
                {
                    LastMouseOver.Callback(UIMouseEventType.MouseOut, state);
                }

                topMost.Callback(UIMouseEventType.MouseOver, state);
                LastMouseOver = topMost;
            }
            else
            {
                if (LastMouseOver != null)
                {
                    LastMouseOver.Callback(UIMouseEventType.MouseOut, state);
                    LastMouseOver = null;
                }
            }
        }
Exemplo n.º 10
0
        public override void Update(TSOClient.Code.UI.Model.UpdateState state)
        {
            base.Update(state);

            if (m_doDrag)
            {
                /** Drag the dialog box **/
                var position = Parent.GetMousePosition(state.MouseState);
                this.X = position.X - m_dragOffsetX;
                this.Y = position.Y - m_dragOffsetY;
            }
        }
Exemplo n.º 11
0
        public void Update(TSOClient.Code.UI.Model.UpdateState state)
        {
            var done = new List<UITweenInstance>();

            lock (m_ActiveTweens)
            {
                if (m_ActiveTweens.Count == 0) { return; }

                var now = state.Time.TotalRealTime.Ticks;

                var copy = m_ActiveTweens.ToList();
                foreach (var tween in copy)
                {
                    tween.Update(now, state);
                    if (!tween.Active)
                    {
                        /** Done **/
                        done.Add(tween);
                    }
                }
            }

            foreach (var tween in done)
            {
                tween.Complete();
            }
        }
Exemplo n.º 12
0
        private void Controller_OnLoginStatus(TSOClient.Network.Events.LoginEvent e)
        {
            m_InLogin = false;
            if (e.Success)
            {
                /** Save the username **/
                GlobalSettings.Default.LastUser = LoginDialog.Username;
                GlobalSettings.Default.Save();
                /** Go to the select a sim page, make sure we do this in the UIThread **/
                GameFacade.Controller.ShowPersonSelection();
            }
            else
            {
                if (e.VersionOK)
                {
                    //EventQueue is static, so shouldn't need to be locked.
                    if (EventSink.EventQueue[0].ECode == EventCodes.BAD_USERNAME ||
                        EventSink.EventQueue[0].ECode == EventCodes.BAD_PASSWORD)
                    {
                        UIAlertOptions Options = new UIAlertOptions();
                        Options.Message = GameFacade.Strings.GetString("210", "26 110");
                        Options.Title = GameFacade.Strings.GetString("210", "21");
                        Options.Buttons = UIAlertButtons.OK;
                        UI.Framework.UIScreen.ShowAlert(Options, true);

                        //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any
                        //events that may have been added to the end.
                        EventSink.EventQueue.Remove(EventSink.EventQueue[0]);
                    }
                    else if (EventSink.EventQueue[0].ECode == EventCodes.AUTHENTICATION_FAILURE)
                    {
                        //Restart authentication procedure.
                        NetworkFacade.Controller.InitialConnect(LoginDialog.Username.ToUpper(), LoginDialog.Password.ToUpper());

                        //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any
                        //events that may have been added to the end.
                        EventSink.EventQueue.Remove(EventSink.EventQueue[0]);
                    }

                    /** Reset **/
                    LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4");
                    LoginProgress.Progress = 0;
                    m_InLogin = false;
                }
                else
                {
                    UIAlertOptions Options = new UIAlertOptions();
                    Options.Message = "Your client was not up to date!";
                    Options.Title = "Invalid version";
                    Options.Buttons = UIAlertButtons.OK;
                    UI.Framework.UIScreen.ShowAlert(Options, true);

                    /** Reset **/
                    LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4");
                    LoginProgress.Progress = 0;
                    m_InLogin = false;
                }
            }
        }
Exemplo n.º 13
0
 public void OnZoomChange(TSOClient.Code.Rendering.Lot.Model.HouseRenderState state)
 {
 }
Exemplo n.º 14
0
        public override void Update(TSOClient.Code.UI.Model.UpdateState state)
        {
            base.Update(state);

            if (AutoRotate)
            {
                var startAngle = RotationStartAngle;
                var time = state.Time.TotalRealTime.Ticks;
                var phase = (time % RotationSpeed) / RotationSpeed;

                var multiplier = Math.Sin((Math.PI * 2) * phase);
                var newAngle = startAngle + (RotationRange * multiplier);

                SimRender.RotationX = (float)MathUtils.DegreeToRadian(newAngle);
            }
        }
Exemplo n.º 15
0
 public override void OnZoomChanged(TSOClient.Code.Rendering.Lot.Model.HouseRenderState state)
 {
     m_Dirty = true;
 }
Exemplo n.º 16
0
        private void Controller_OnLoginProgress(TSOClient.Network.Events.ProgressEvent e)
        {
            var stage = e.Done;

            LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", (stage + 4).ToString());
            LoginProgress.Progress = 25 * stage;
        }
Exemplo n.º 17
0
        private void Controller_OnLoginStatus(TSOClient.Network.Events.LoginEvent e)
        {
            m_InLogin = false;
            if (e.Success)
            {
                /** Go to the select a sim page, make sure we do this in the UIThread **/
                GameFacade.Controller.ShowPersonSelection();
            }
            else
            {
                if (e.VersionOK)
                {
                    UIAlertOptions Options = new UIAlertOptions();
                    Options.Message = GameFacade.Strings.GetString("210", "26 110");
                    Options.Title = GameFacade.Strings.GetString("210", "21");
                    Options.Buttons = UIAlertButtons.OK;
                    UI.Framework.UIScreen.ShowAlert(Options, true);

                    /** Reset **/
                    LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4");
                    LoginProgress.Progress = 0;
                    m_InLogin = false;
                }
                else
                {
                    UIAlertOptions Options = new UIAlertOptions();
                    Options.Message = "Your client was not up to date!";
                    Options.Title = "Invalid version";
                    Options.Buttons = UIAlertButtons.OK;
                    UI.Framework.UIScreen.ShowAlert(Options, true);

                    /** Reset **/
                    LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4");
                    LoginProgress.Progress = 0;
                    m_InLogin = false;
                }
            }
        }
Exemplo n.º 18
0
 public void OnZoomChange(TSOClient.Code.Rendering.Lot.Model.HouseRenderState state)
 {
     InvalidateCamera();
     Components.ForEach(x => x.OnZoomChange(state));
 }