Пример #1
0
        public override void Update()
        {
            m_characterSkinsCache.GetTexture(m_playerData.CharacterSkinName);
            m_playerModel.PlayerClass       = m_playerData.PlayerClass;
            m_playerModel.CharacterSkinName = m_playerData.CharacterSkinName;
            m_playerClassButton.Text        = m_playerData.PlayerClass.ToString();
            if (!m_nameTextBox.HasFocus)
            {
                m_nameTextBox.Text = m_playerData.Name;
            }
            m_characterSkinLabel.Text = CharacterSkinsManager.GetDisplayName(m_playerData.CharacterSkinName);
            m_controlsLabel.Text      = GetDeviceDisplayName(m_inputDevices.Where((WidgetInputDevice id) => (id & m_playerData.InputDevice) != 0).FirstOrDefault());
            ValuesDictionary valuesDictionary = DatabaseManager.FindValuesDictionaryForComponent(DatabaseManager.FindEntityValuesDictionary(m_playerData.GetEntityTemplateName(), throwIfNotFound: true), typeof(ComponentCreature));
            string           dy = valuesDictionary.GetValue <string>("Description");

            if (dy.StartsWith("[") && dy.EndsWith("]"))
            {
                string[] lp = dy.Substring(1, dy.Length - 2).Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                dy = LanguageControl.GetDatabase("Description", lp[1]);
            }
            m_descriptionLabel.Text = dy;
            if (m_playerClassButton.IsClicked)
            {
                m_playerData.PlayerClass = ((m_playerData.PlayerClass == PlayerClass.Male) ? PlayerClass.Female : PlayerClass.Male);
                m_playerData.RandomizeCharacterSkin();
                if (m_playerData.IsDefaultName)
                {
                    m_playerData.ResetName();
                }
            }
            if (m_characterSkinButton.IsClicked)
            {
                CharacterSkinsManager.UpdateCharacterSkinsList();
                IEnumerable <string> items  = CharacterSkinsManager.CharacterSkinsNames.Where((string n) => CharacterSkinsManager.GetPlayerClass(n) == m_playerData.PlayerClass || !CharacterSkinsManager.GetPlayerClass(n).HasValue);
                ListSelectionDialog  dialog = new ListSelectionDialog(LanguageControl.Get(fName, 1), items, 64f, delegate(object item)
                {
                    XElement node       = ContentManager.Get <XElement>("Widgets/CharacterSkinItem");
                    ContainerWidget obj = (ContainerWidget)Widget.LoadWidget(this, node, null);
                    Texture2D texture   = m_characterSkinsCache.GetTexture((string)item);
                    obj.Children.Find <LabelWidget>("CharacterSkinItem.Text").Text    = CharacterSkinsManager.GetDisplayName((string)item);
                    obj.Children.Find <LabelWidget>("CharacterSkinItem.Details").Text = $"{texture.Width}x{texture.Height}";
                    PlayerModelWidget playerModelWidget    = obj.Children.Find <PlayerModelWidget>("CharacterSkinItem.Model");
                    playerModelWidget.PlayerClass          = m_playerData.PlayerClass;
                    playerModelWidget.CharacterSkinTexture = texture;
                    return(obj);
                }, delegate(object item)
                {
                    m_playerData.CharacterSkinName = (string)item;
                    if (m_playerData.IsDefaultName)
                    {
                        m_playerData.ResetName();
                    }
                });
                DialogsManager.ShowDialog(null, dialog);
            }
            if (m_controlsButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 2), m_inputDevices, 56f, (object d) => GetDeviceDisplayName((WidgetInputDevice)d), delegate(object d)
                {
                    WidgetInputDevice widgetInputDevice = (WidgetInputDevice)d;
                    m_playerData.InputDevice            = widgetInputDevice;
                    foreach (PlayerData playersDatum in m_playerData.SubsystemPlayers.PlayersData)
                    {
                        if (playersDatum != m_playerData && (playersDatum.InputDevice & widgetInputDevice) != 0)
                        {
                            playersDatum.InputDevice &= ~widgetInputDevice;
                        }
                    }
                }));
            }
            if (m_addButton.IsClicked && VerifyName())
            {
                m_playerData.SubsystemPlayers.AddPlayerData(m_playerData);
                ScreensManager.SwitchScreen("Players", m_playerData.SubsystemPlayers);
            }
            if (m_deleteButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "warning"), LanguageControl.Get(fName, 3), LanguageControl.Get("Usual", "ok"), LanguageControl.Get("Usual", "cancel"), delegate(MessageDialogButton b)
                {
                    if (b == MessageDialogButton.Button1)
                    {
                        m_playerData.SubsystemPlayers.RemovePlayerData(m_playerData);
                        ScreensManager.SwitchScreen("Players", m_playerData.SubsystemPlayers);
                    }
                }));
            }
            if (m_playButton.IsClicked && VerifyName())
            {
                m_playerData.SubsystemPlayers.AddPlayerData(m_playerData);
                ScreensManager.SwitchScreen("Game");
            }
            if (m_addAnotherButton.IsClicked && VerifyName())
            {
                m_playerData.SubsystemPlayers.AddPlayerData(m_playerData);
                ScreensManager.SwitchScreen("Player", Mode.Initial, m_playerData.SubsystemPlayers.Project);
            }
            if ((base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) && VerifyName())
            {
                if (m_mode == Mode.Initial)
                {
                    GameManager.SaveProject(waitForCompletion: true, showErrorDialog: true);
                    GameManager.DisposeProject();
                    ScreensManager.SwitchScreen("MainMenu");
                }
                else if (m_mode == Mode.Add || m_mode == Mode.Edit)
                {
                    ScreensManager.SwitchScreen("Players", m_playerData.SubsystemPlayers);
                }
            }
            m_nameWasInvalid = false;
        }
Пример #2
0
 public override void MeasureOverride(Vector2 parentAvailableSize)
 {
     if (OuterClothing)
     {
         m_modelWidget.Model = CharacterSkinsManager.GetOuterClothingModel(PlayerClass);
     }
     else
     {
         m_modelWidget.Model = CharacterSkinsManager.GetPlayerModel(PlayerClass);
     }
     if (CameraShot == Shot.Body)
     {
         m_modelWidget.ViewPosition = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 1.46f, -3.2f) : new Vector3(0f, 1.39f, -3.04f));
         m_modelWidget.ViewTarget   = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 0.9f, 0f) : new Vector3(0f, 0.86f, 0f));
         m_modelWidget.ViewFov      = 0.57f;
     }
     else
     {
         if (CameraShot != Shot.Bust)
         {
             throw new InvalidOperationException("Unknown shot.");
         }
         m_modelWidget.ViewPosition = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 1.5f, -1.05f) : new Vector3(0f, 1.43f, -1f));
         m_modelWidget.ViewTarget   = ((PlayerClass == PlayerClass.Male) ? new Vector3(0f, 1.5f, 0f) : new Vector3(0f, 1.43f, 0f));
         m_modelWidget.ViewFov      = 0.57f;
     }
     if (OuterClothing)
     {
         m_modelWidget.TextureOverride = OuterClothingTexture;
     }
     else
     {
         m_modelWidget.TextureOverride = ((CharacterSkinName != null) ? CharacterSkinsCache.GetTexture(CharacterSkinName) : CharacterSkinTexture);
     }
     if (AnimateHeadSeed != 0)
     {
         int     num    = (AnimateHeadSeed < 0) ? GetHashCode() : AnimateHeadSeed;
         float   num2   = (float)MathUtils.Remainder(Time.FrameStartTime + 1000.0 * (double)num, 10000.0);
         Vector2 vector = default(Vector2);
         vector.X = MathUtils.Lerp(-0.75f, 0.75f, SimplexNoise.OctavedNoise(num2 + 100f, 0.2f, 1, 2f, 0.5f));
         vector.Y = MathUtils.Lerp(-0.5f, 0.5f, SimplexNoise.OctavedNoise(num2 + 200f, 0.17f, 1, 2f, 0.5f));
         Matrix value = Matrix.CreateRotationX(vector.Y) * Matrix.CreateRotationZ(vector.X);
         m_modelWidget.SetBoneTransform(m_modelWidget.Model.FindBone("Head").Index, value);
     }
     if (!OuterClothing && AnimateHandsSeed != 0)
     {
         int     num3    = (AnimateHandsSeed < 0) ? GetHashCode() : AnimateHandsSeed;
         float   num4    = (float)MathUtils.Remainder(Time.FrameStartTime + 1000.0 * (double)num3, 10000.0);
         Vector2 vector2 = default(Vector2);
         vector2.X = MathUtils.Lerp(0.2f, 0f, SimplexNoise.OctavedNoise(num4 + 100f, 0.7f, 1, 2f, 0.5f));
         vector2.Y = MathUtils.Lerp(-0.3f, 0.3f, SimplexNoise.OctavedNoise(num4 + 200f, 0.7f, 1, 2f, 0.5f));
         Vector2 vector3 = default(Vector2);
         vector3.X = MathUtils.Lerp(-0.2f, 0f, SimplexNoise.OctavedNoise(num4 + 300f, 0.7f, 1, 2f, 0.5f));
         vector3.Y = MathUtils.Lerp(-0.3f, 0.3f, SimplexNoise.OctavedNoise(num4 + 400f, 0.7f, 1, 2f, 0.5f));
         Matrix value2 = Matrix.CreateRotationX(vector2.Y) * Matrix.CreateRotationY(vector2.X);
         Matrix value3 = Matrix.CreateRotationX(vector3.Y) * Matrix.CreateRotationY(vector3.X);
         m_modelWidget.SetBoneTransform(m_modelWidget.Model.FindBone("Hand1").Index, value2);
         m_modelWidget.SetBoneTransform(m_modelWidget.Model.FindBone("Hand2").Index, value3);
     }
     base.MeasureOverride(parentAvailableSize);
 }