示例#1
0
    public void ReadPanel(SavePanel panel)
    {
        selectedSave = panel.saveName;

        if (panel.open)
        {
            return;
        }
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Open(Application.persistentDataPath + "/Saves/" + panel.saveName, FileMode.Open);

        panel.difficultyText.gameObject.SetActive(true);
        panel.moneyText.gameObject.SetActive(true);
        panel.reputationText.gameObject.SetActive(true);

        LayoutRebuilder.ForceRebuildLayoutImmediate(panel.GetComponent <RectTransform>());
        LayoutRebuilder.ForceRebuildLayoutImmediate(saveList.GetComponent <RectTransform>());

        SaveData data = (SaveData)bf.Deserialize(file);

        file.Close();

        panel.nameText.text       = "Name: " + panel.saveName;
        panel.difficultyText.text = "Difficulty: " + (Difficulty)data.settings.difficulty;
        panel.moneyText.text      = "Funds: " + data.playerData.money;
        panel.reputationText.text = "Reputation: " + data.playerData.reputation;

        panel.open = true;
    }
示例#2
0
        static void Autosave(int value)
        {
            var config = Configuration <AutosaveOnPauseConfiguration> .Load();

            if (value != 0 && ASOPTimer.EligibleToSave(config))
            {
                if ((Object)DemoModeLoader.instance != (Object)null)
                {
                    return;
                }
                SavePanel savePanel = UIView.library.Get <SavePanel>("SavePanel");
                if (!((Object)savePanel != (Object)null))
                {
                    return;
                }
                var metaData        = SimulationManager.instance.m_metaData;
                var cityInformation = new CityInformation
                {
                    Name        = metaData.m_CityName,
                    CurrentDate = metaData.m_currentDateTime
                };

                var saveName = config.SaveName.FillTemplate(cityInformation);
                savePanel.AutoSave(saveName);
            }
        }
示例#3
0
        /// <summary>
        ///     Save a level to the local save folder where it can then be sent to all clients.
        /// </summary>
        public static void SaveServerLevel()
        {
            SavePanel sp = UIView.library.Get <SavePanel>("SavePanel");

            if (sp != null)
            {
                sp.SaveGame(SYNC_NAME);
            }
        }
示例#4
0
        public static string GetSavePath()
        {
            SavePanel sp = UIView.library.Get <SavePanel>("SavePanel");

            if (sp != null)
            {
                return(ReflectionHelper.Call <string>(sp, "GetSavePathName", SYNC_NAME, false));
            }
            return(null);
        }
示例#5
0
    public void ResetList()
    {
        foreach (Transform child in saveList.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        for (int i = 0; i < saves.Length; i++)
        {
            SavePanel savePanel = Instantiate(savePanelPrefab, saveList).GetComponent <SavePanel>();
            savePanel.saveName      = saves[i];
            savePanel.nameText.text = saves[i];
            savePanel.GetComponent <Button>().onClick.AddListener(() => ReadPanel(savePanel));
        }
    }
示例#6
0
    static void CalledByBtSavePanel()
    {
        SavePanel instance = GetWindow <SavePanel>();

        instance.Show();
    }
示例#7
0
        /// <summary>
        /// Загрузка контента (вызывается после Initialize())
        /// </summary>
        protected override void LoadContent()
        {
            backgroundFont = Content.Load <SpriteFont>(Fnames.OldEnglishTextMT);
            bFont          = Content.Load <SpriteFont>(Fnames.ButtonFont);

            #region Buttons

            int start = 300;
            int step  = (cfg.ResolutionHeight == 600) ? 65 : 50;
            int count = 0;

            Button Continue = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.ContinueB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                         CreateSound3D(Content, Fnames.UIButtonClick),
                                         CreateSound3D(Content, Fnames.UIButtonSelect),
                                         bFont);
            Button New = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.NewB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                    CreateSound3D(Content, Fnames.UIButtonClick),
                                    CreateSound3D(Content, Fnames.UIButtonSelect),
                                    bFont);
            Button Save = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.SaveB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                     CreateSound3D(Content, Fnames.UIButtonClick),
                                     CreateSound3D(Content, Fnames.UIButtonSelect),
                                     bFont);
            Button Load = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.LoadB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                     CreateSound3D(Content, Fnames.UIButtonClick),
                                     CreateSound3D(Content, Fnames.UIButtonSelect),
                                     bFont);
            Button Options = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.OptionsB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                        CreateSound3D(Content, Fnames.UIButtonClick),
                                        CreateSound3D(Content, Fnames.UIButtonSelect),
                                        bFont);
            Button Credits = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.CreditsB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                        CreateSound3D(Content, Fnames.UIButtonClick),
                                        CreateSound3D(Content, Fnames.UIButtonSelect),
                                        bFont);
            Button Exit = new Button(MultiSprite.CreateSprite(Content, spriteBatch, Fnames.ExitGlobalB, new Vector2(Window.ClientBounds.Width / 2f - 122, Window.ClientBounds.Height / 1000f * (start + step * count++)), new Vector2(244, 36), Vector2.One),
                                     CreateSound3D(Content, Fnames.UIButtonClick),
                                     CreateSound3D(Content, Fnames.UIButtonSelect),
                                     bFont);
            Continue.Text          = "";
            Continue.Click        += new EventHandler <MouseElementEventArgs>(Continue_Click);
            Continue.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            Continue.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);
            Continue.Visible       = isContinue = false;
            continueB              = Continue;

            New.Text          = "";
            New.Click        += new EventHandler <MouseElementEventArgs>(New_Click);
            New.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            New.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);

            Save.Text          = "";
            Save.Click        += new EventHandler <MouseElementEventArgs>(Save_Click);
            Save.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            Save.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);

            Load.Text          = "";
            Load.Click        += new EventHandler <MouseElementEventArgs>(Load_Click);
            Load.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            Load.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);

            Options.Text          = "";
            Options.Click        += new EventHandler <MouseElementEventArgs>(Options_Click);
            Options.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            Options.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);

            Credits.Text          = "";
            Credits.Click        += new EventHandler <MouseElementEventArgs>(Credits_Click);
            Credits.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            Credits.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);

            Exit.Text          = "";
            Exit.Click        += new EventHandler <MouseElementEventArgs>(Exit_Click);
            Exit.MouseMove    += new EventHandler <MouseElementEventArgs>(Button_MouseMove);
            Exit.MouseMoveOut += new EventHandler <MouseElementEventArgs>(Button_MouseMoveOut);

            buttons.Add(Continue);
            buttons.Add(New);
            buttons.Add(Save);
            buttons.Add(Load);
            buttons.Add(Options);
            buttons.Add(Credits);
            buttons.Add(Exit);

            #endregion

            #region Panels

            string text = "Do you really want to exit?";
            exitApplyPanel              = new ApplyPanel(this, Content, Sprite.CreateSprite(Content, Fnames.Panel, new Vector2(Window.ClientBounds.Width / 3f, Window.ClientBounds.Height / 3f), new Vector2(780 * (float)Window.ClientBounds.Width / 1280f / 2f, 640 * (float)Window.ClientBounds.Height / 1024f / 3f)), text);
            exitApplyPanel.ApplyAction += new Action(() => Game.Exit());
            exitApplyPanel.ExitAction  += new Action(() => exitApplyPanel.Visible = false);
            exitApplyPanel.Enabled     += new EventHandler <EventArgs>(panel_Enabled);
            exitApplyPanel.Disabled    += new EventHandler <EventArgs>(panel_Disabled);

            optionsPanel              = new OptionsPanel(this, Content, Sprite.CreateSprite(Content, Fnames.Panel, new Vector2(Window.ClientBounds.Width / 5.2f, Window.ClientBounds.Height / 6.8f), new Vector2(780 * (float)Window.ClientBounds.Width / 1280f, 640 * (float)Window.ClientBounds.Height / 1024f)), settings);
            optionsPanel.Enabled     += new EventHandler <EventArgs>(panel_Enabled);
            optionsPanel.Disabled    += new EventHandler <EventArgs>(panel_Disabled);
            optionsPanel.Disabled    += new EventHandler <EventArgs>((object sender, EventArgs e) => settings = (Settings)optionsPanel.ApplyedSettings.Clone());
            optionsPanel.ApplyAction += new Action(() => { if (optionsPanel.ApplyedSettings.MusicIsMuted)
                                                           {
                                                               player.Stop();
                                                           }
                                                           else
                                                           {
                                                               player.Start();
                                                           } });

            text                   = String.Format("{0}\n{1}\n{2}", "Credits: ", "1) Bolshakov Kirill", "http://vk.com/overlordff");
            creditsPanel           = new CreditsPanel(this, Content, Sprite.CreateSprite(Content, Fnames.Panel, new Vector2(Window.ClientBounds.Width / 5.2f, Window.ClientBounds.Height / 6.8f), new Vector2(780 * (float)Window.ClientBounds.Width / 1280f, 640 * (float)Window.ClientBounds.Height / 1024f)), text);
            creditsPanel.Enabled  += new EventHandler <EventArgs>(panel_Enabled);
            creditsPanel.Disabled += new EventHandler <EventArgs>(panel_Disabled);

            savePanel           = new SavePanel(this, Content, Sprite.CreateSprite(Content, Fnames.Panel, new Vector2(Window.ClientBounds.Width / 5.2f, Window.ClientBounds.Height / 6.8f), new Vector2(780 * (float)Window.ClientBounds.Width / 1280f, 640 * (float)Window.ClientBounds.Height / 1024f)));
            savePanel.Enabled  += new EventHandler <EventArgs>(panel_Enabled);
            savePanel.Disabled += new EventHandler <EventArgs>(panel_Disabled);

            loadPanel           = new LoadPanel(this, Content, Sprite.CreateSprite(Content, Fnames.Panel, new Vector2(Window.ClientBounds.Width / 5.2f, Window.ClientBounds.Height / 6.8f), new Vector2(780 * (float)Window.ClientBounds.Width / 1280f, 640 * (float)Window.ClientBounds.Height / 1024f)));
            loadPanel.Enabled  += new EventHandler <EventArgs>(panel_Enabled);
            loadPanel.Disabled += new EventHandler <EventArgs>(panel_Disabled);

            #endregion

            Song deathSong = Content.Load <Song>(Fnames.DeathSong);
            Song epicScore = Content.Load <Song>(Fnames.EpicScore);

            if (random.NextDouble() >= 0.5)
            {
                background = Content.Load <Texture2D>(Fnames.BackgroundSword);
                player.Add(deathSong);
                optionsPanel.Color   = new Color(70, 70, 255);
                creditsPanel.Color   = new Color(70, 70, 255);
                exitApplyPanel.Color = new Color(70, 70, 255);
                savePanel.Color      = new Color(70, 70, 255);
                loadPanel.Color      = new Color(70, 70, 255);
            }
            else
            {
                background = Content.Load <Texture2D>(Fnames.BackgroundKnight);
                player.Add(epicScore);
                optionsPanel.Color   = new Color(174, 160, 75);
                creditsPanel.Color   = new Color(174, 160, 75);
                exitApplyPanel.Color = new Color(174, 160, 75);
                savePanel.Color      = new Color(174, 160, 75);
                loadPanel.Color      = new Color(174, 160, 75);
            }

            Game.Components.Clear();
            Game.Components.Add(new FPS(Game, Fnames.Arial14, new Vector2(Window.ClientBounds.Width / 2f - 25, 0)));
            Game.Components.Add(new GameCursor(Game, Fnames.Cursor));

            Components.Add(exitApplyPanel);
            Components.Add(optionsPanel);
            Components.Add(creditsPanel);
            Components.Add(savePanel);
            Components.Add(loadPanel);
            Components.AddRange(buttons);

            if (!cfg.MusicIsMuted)
            {
                player.Start();
            }
        }