Exemple #1
0
        /// <summary>
        /// 本地服务器-开启当前服务器集群
        /// </summary>
        private void button_LocalServer_StartCluster_Click(object sender, RoutedEventArgs e)
        {
            int indexLocalFile = listBox_LocalServer_ClusterFile.SelectedIndex;
            int indexLocalPath = dataGrid_LocalServer_ServersPath.SelectedIndex;

            if (indexLocalFile == -1 || indexLocalPath == -1)
            {
                return;
            }

            //保存当前选中的集群配置
            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocalFile].ClusterSetting);
            SavesManager.SetClusterInfo(ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString(), m_ClusterInfo_Local[indexLocalFile]);

            string confdir = ComboBox_LocalServer_SavesFolder.SelectedItem.ToString();
            string cluster = listBox_LocalServer_ClusterFile.SelectedItem.ToString();
            string exefile = (dataGrid_LocalServer_ServersPath.SelectedItem as DataRowView)[2].ToString();
            bool   isShell = (bool)radioButton_LocalServer_OpenType_1.IsChecked;

            //依次开启集群服务器
            foreach (var server in m_ClusterInfo_Local[indexLocalFile].ClusterServers)
            {
                string shard = server.Setting.Shard_Master ? "Master" : "Caves";

                string parameter = ServersManager.CreatParameter(confdir, cluster, shard);
                CreatNewProcess(exefile, parameter, isShell, server.Session);
            }
        }
Exemple #2
0
    private void Awake()
    {
        Instance     = this;
        slotSelected = InmutableData.Instance.slotSelected;

        Load();
    }
Exemple #3
0
 /// <summary>
 /// Метод, который открывает меню загрузки
 /// </summary>
 public void Open()
 {
     CameraManager.IsActiveUI = true;
     SaveGamesList.value      = 0;
     Menu.GetComponent <CanvasGroup>().alpha          = 1;
     Menu.GetComponent <CanvasGroup>().blocksRaycasts = true;
     SaveGamesList.ClearOptions();
     SaveGamesList.AddOptions(SavesManager.GetSaveGames());
     if (SaveGamesList.options.Count == 0)
     {
         List <string> emptySaves = new List <string> {
             "Сохранения отсутствуют"
         };
         SaveGamesList.AddOptions(emptySaves);
         DeleteButton.GetComponent <CanvasGroup>().alpha          = 0.5f;
         DeleteButton.GetComponent <CanvasGroup>().blocksRaycasts = false;
         LoadButton.GetComponent <CanvasGroup>().alpha            = 0.5f;
         LoadButton.GetComponent <CanvasGroup>().blocksRaycasts   = false;
     }
     else
     {
         DeleteButton.GetComponent <CanvasGroup>().alpha          = 1;
         DeleteButton.GetComponent <CanvasGroup>().blocksRaycasts = true;
         LoadButton.GetComponent <CanvasGroup>().alpha            = 1;
         LoadButton.GetComponent <CanvasGroup>().blocksRaycasts   = true;
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        continuer.onClick.AddListener(() =>
        {
            gameObject.SetActive(false);
        });

        settings.onClick.AddListener(() =>
        {
            settingBox.SetActive(true);
        });

        save.onClick.AddListener(() =>
        {
            Ville v = FindObjectOfType<GameManager>().ville;
            //v.Pause();
            v.TempsRestant = FindObjectOfType<Timer>().time;
            SavesManager.SaveGame(v);
            //v.Play();
        });

        quitter.onClick.AddListener(() =>
        {

        });
    }
    public static void LoadGame()
    {
        Data.CurrentGameStep = 0;
        RenderingScript.ClearRenderingObjects();
        foreach (Cell cell in Map.WorldMap)
        {
            if (cell.LinkedBug != null)
            {
                cell.LinkedBug = null;
                cell.Content   = Cell.TypeOfCell.Empty;
            }
        }

        SavesManager.LoadGame();
        foreach (Bug bug in bugs.Bugs)
        {
            bug.Health       = 50;
            bug.LastPosition = null;
            Cell emptyCell = Map.FindEmptyCell(Cell.TypeOfCell.Bug);
            emptyCell.LinkedBug = bug;
            emptyCell.Content   = Cell.TypeOfCell.Bug;
            bug.CurrentPosition = emptyCell.Coordinate;
        }

        SavesManager.NeedLoadGame = false;
    }
Exemple #6
0
        /// <summary>
        /// 本地服务器-保存集群当前配置
        /// </summary>
        private void button_Cluster_SaveIni_Click(object sender, RoutedEventArgs e)
        {
            int    indexLocal = listBox_LocalServer_ClusterFile.SelectedIndex;
            string nameLocal  = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();

            if (tabItem_LocalServer.IsSelected)
            {
                if (indexLocal == -1)
                {
                    return;
                }

                ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocal].ClusterSetting);
                SavesManager.SetClusterInfo(nameLocal, m_ClusterInfo_Local[indexLocal]);
            }

            SftpClient client     = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);
            int        indexCloud = listBox_CloudServer_ClusterFile.SelectedIndex;
            string     nameCloud  = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();

            if (tabItem_CloudServer.IsSelected)
            {
                if (indexCloud == -1)
                {
                    return;
                }
                if (client == null)
                {
                    return;
                }

                ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting);
                SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client);
            }
        }
Exemple #7
0
        /// <summary>
        /// 本地服务器-刷新当前服务器集群
        /// </summary>
        private void button_LocalServer_RefreshCluster_Click(object sender, RoutedEventArgs e)
        {
            //获取集群信息
            string saveFolder = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();

            if (saveFolder == "")
            {
                return;
            }

            RefreshClusterData(saveFolder, "Cluster", ref listBox_LocalServer_ClusterFile, null);
            m_ClusterInfo_Local = SavesManager.GetClusterInfo("Cluster", saveFolder);
            if (listBox_LocalServer_ClusterFile.Items.Count != 0)
            {
                listBox_LocalServer_ClusterFile.SelectedIndex = 0;
            }

            int index = listBox_LocalServer_ClusterFile.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            RefreshServersData(m_ClusterInfo_Local[index], ref UI);
            if (m_ClusterInfo_Local[index].ClusterServers.Count != 0)
            {
                dataGrid_ClusterInfo_ServersList.SelectedIndex = 0;
            }
        }
Exemple #8
0
    /// <summary>
    /// Сгенирировать новое поколение на основе предыдущего
    /// </summary>
    public void NewGeneration()
    {
        GenerationNumber++;
        CountBirthBugs = 0;
        var sw = new StreamWriter("stat.txt", true);

        sw.WriteLine("{0} {1}", GenerationNumber, Data.CurrentGameStep);
        sw.Close();

        List <Bug> bugs = new List <Bug>();

        foreach (var bug in Bugs)
        {
            Data.NumberDeadBugs++;
            Map.GetMapCell(bug.CurrentPosition.Y, bug.CurrentPosition.X).Content   = Cell.TypeOfCell.Empty;
            Map.GetMapCell(bug.CurrentPosition.Y, bug.CurrentPosition.X).LinkedBug = null;
            for (int i = 0; i < 10 && Map.CellLists[(int)Cell.TypeOfCell.Empty].Count > 0; i++)
            {
                bugs.Add(new Bug(bug.color, new Genome(bug.Gene, bug.LifeTime + bug.Health)));
            }
        }

        CountBugs = bugs.Count;
        Bugs      = bugs;
        if (GenerationNumber % 10 == 0)
        {
            SavesManager.SaveGame("autosave");
        }
    }
Exemple #9
0
    public void TriggerGameOver()
    {
        AudioLayersManager.Instance.Reset();
        AudioManager.Instance.PlaySoundEffect("GameOver");

        GameOver = true;
        SavesManager.Save();
        gameOverUI.SetActive(true);
    }
 private void Awake()
 {
     fighters.Add(hero);
     fighters.Add(enemy1);
     if (enemy2 != null)
     {
         fighters.Add(enemy2);
     }
     saves = FindObjectOfType <SavesManager>();
 }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this);
 }
Exemple #12
0
 private void Awake()
 {
     if (instance == null)
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
     else if (instance != this)
     {
         //should only ever have one instance if more then one insance it get destroyed here
         Destroy(this.gameObject);
     }
 }
Exemple #13
0
 public SavesManager()
 {
     Debug.Log("Initializing a new SavesManager.");
     if (instance == null)
     {
         instance = this;
         Debug.Log("SavesManager initialization successful.");
     }
     else
     {
         Debug.Log("SavesManager already exists. New initialization unsuccessful.");
     }
 }
 private void Awake()
 {
     Debug.Log("Start");
     saves = FindObjectOfType <SavesManager>();
     if (saves)
     {
         button.interactable = true;
     }
     else
     {
         button.interactable = false;
     }
 }
Exemple #15
0
    public void TriggerGameOver()
    {
        GameOver = true;
        SavesManager.Save();
        UpdateAnalytics();

        if (GameSettings.GameOverSoundEffect)
        {
            AudioManager.Instance.Play("GameOver");
        }

        Camera.main.GetComponent <CameraController>().MoveCameraToTarget(CameraController.InitialPosition, 0.05f);
    }
    public void LoadSaves()
    {
        List <Save> saves     = SavesManager.FetchSaves();
        Transform   container = transform.Find("MyScrollView").Find("Container");

        container.DetachChildren();

        foreach (Save s in saves)
        {
            Transform t = Instantiate(saveTemplate);
            t.parent = container;
            t.GetComponent <SaveTemplateScript>().save = s;
            t.gameObject.SetActive(true);
        }
    }
Exemple #17
0
        /// <summary>
        /// 保存服务器当前配置
        /// </summary>
        private void button_Server_SaveIni_Click(object sender, RoutedEventArgs e)
        {
            int indexLocalServer_ClusterFile = listBox_LocalServer_ClusterFile.SelectedIndex;

            string nameSave    = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();
            string nameCluster = listBox_LocalServer_ClusterFile.SelectedItem?.ToString();


            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocalServer_ClusterFile]);

            for (int i = 0; i < m_ClusterInfo_Local[indexLocalServer_ClusterFile].ClusterServers.Count; i++)
            {
                SavesManager.SetServerInfo(nameSave, nameCluster, m_ClusterInfo_Local[indexLocalServer_ClusterFile].ClusterServers[i]);
            }
        }
    void LoadTopScores()
    {
        var savedGames = SavesManager.LoadGames().OrderByDescending(g => g.GameBegin).ToList();

        TopScoresText.text  = fixedString("UserName  Coins Time    Reason    Date", 53) + "\n" + new string('=', 53) + "\n";
        TopScoresText.text += string.Join("\n", savedGames
                                          .Select(game =>
                                                  fixedString(game.UserName, 10)
                                                  + fixedString(game.Coins.ToString(), 6)
                                                  + fixedString(game.TimeInMazeSeconds.ToString(), 8)
                                                  + fixedString(game.GameOverReason, 10)
                                                  + game.GameBegin.ToString("dd/MM/yyyy HH:mm:ss")
                                                  + "\n").ToArray());
        TopScoresText.text += new string('=', 53);
        TopScoresText.text += new string('\n', 5);
    }
Exemple #19
0
        /// <summary>
        /// 本地服务器-存档文件夹选择变化
        /// </summary>
        private void ComboBox_LocalServer_SavesFolder_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //获取集群信息
            string saveFolder = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();

            if (saveFolder == string.Empty)
            {
                return;
            }
            RefreshClusterData(saveFolder, "Cluster", ref listBox_LocalServer_ClusterFile, null);
            m_ClusterInfo_Local = SavesManager.GetClusterInfo(saveFolder, "Cluster");
            if (listBox_LocalServer_ClusterFile.Items.Count != 0)
            {
                listBox_LocalServer_ClusterFile.SelectedIndex = 0;
            }
        }
Exemple #20
0
        private void UserDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            CreateDefaultTable();
            GetDatabaseData();

            if (SavesManager.GetSavesFolder().Count == 0)
            {
                SavesManager.CreatSavesFolder();
            }
            UI.SaveFolders_Local = SavesManager.GetSavesFolder();

            foreach (var item in ServersManager.GetExistProcess())
            {
                textBox_Servers_Tab_Log.Text += item + "\r\n";
            }
        }
Exemple #21
0
    void SetUpValues()
    {
        Settings set = SavesManager.LoadSettings();

        qualityLevel           = set.quality;
        vsyncValue             = set.vsync;
        musiqueVolume          = set.musiqueVolume;
        noiseVolume            = set.noiseVolume;
        destroyShortcut        = set.shortcutKeyDelete;
        rotateShortcut         = set.shortcutKeyRotate;
        forwardShortcut        = set.shortcutKeyForward;
        backwardShortcut       = set.shortcutKeyBackward;
        rightShortcut          = set.shortcutKeyRight;
        leftShortcut           = set.shortcutKeyLeft;
        moveSensitivity        = set.moveSensibility;
        orientationSensitivity = set.orientationSensibility;
    }
Exemple #22
0
    void Awake()
    {
        if (!Instance)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        SceneManager.sceneLoaded += OnSceneLoaded;
        SavesManager.Load();
    }
Exemple #23
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        Map = GameObject.FindWithTag("MapGenerator").GetComponent <MapGenerator>();

        ScoreManager.InitializeVariables();
        SavesManager.Load();
        GameOver = false;
    }
        private void ConnectWorker_DoWork(object sender, DoWorkEventArgs passValue)
        {
            object[] argument = (object[])passValue.Argument;

            ServerConnect serverConnect = argument[0] as ServerConnect;
            SftpClient    client        = serverConnect.GetSftpClient;

            serverConnect.StartConnect();
            m_ServerConnect.Add(serverConnect);

            if (SavesManager.GetSavesFolder(client).Count == 0)
            {
                SavesManager.CreatSavesFolder(client);
            }
            UI.SaveFolders_Cloud = SavesManager.GetSavesFolder(client);

            passValue.Result = new object[] { serverConnect };
        }
Exemple #25
0
        private void button_CloudServer_StartCluster_Click(object sender, RoutedEventArgs e)
        {
            SftpClient client         = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);
            string     nameCloud      = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();
            int        indexCloud     = listBox_CloudServer_ClusterFile.SelectedIndex;
            int        indexCloudFile = listBox_CloudServer_ClusterFile.SelectedIndex;

            if (client == null)
            {
                return;
            }

            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting);
            SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client);

            string confdir = ComboBox_CloudServer_SavesFolder.SelectedItem.ToString();
            string cluster = listBox_CloudServer_ClusterFile.SelectedItem.ToString();
            string exefile = (dataGrid_CloudServer_ServersPath.SelectedItem as DataRowView)[2].ToString();
            string exepath = exefile.Replace("/dontstarve_dedicated_server_nullrenderer", "");

            List <string> screenList = ServersManager.GetExistScreens(UI.Location, UI.Username, UI.Password);

            foreach (var server in m_ClusterInfo_Cloud[indexCloudFile].ClusterServers)
            {
                string shard = server.Setting.Shard_Master ? "Master" : "Caves";

                string parameter = ServersManager.CreatParameter(confdir, cluster, shard);

                string command    = string.Empty;
                string screenName = cluster + "_" + server.Folder;

                if (screenList.Contains(screenName))
                {
                    command = $"screen -xr {screenName}";
                }
                else
                {
                    command += $"cd {exepath}\r";
                    command += $"screen -S {screenName} {"./dontstarve_dedicated_server_nullrenderer"} {parameter}";
                }

                CreatNewScreens(UI.Location, UI.Username, UI.Password, command);
            }
        }
    private void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        saves = FindObjectOfType <SavesManager>();

        switch (saves.level)
        {
        case 0:
            buttons[0].interactable = true;
            buttons[1].interactable = false;
            buttons[2].interactable = false;
            break;

        case 1:
            buttons[0].interactable = false;
            buttons[1].interactable = true;
            buttons[2].interactable = false;
            break;

        case 2:
            buttons[0].interactable = false;
            buttons[1].interactable = false;
            buttons[2].interactable = true;
            break;

        case 3:
            //saves.Delete();
            SceneManager.LoadScene(5);
            break;

        default:
            Debug.LogError("That shouldnt happen");
            break;
        }
    }
    // Use this for initialization

    void Start()
    {
        if (save != null)
        {
            dateSave.text = String.Format("{0:d/M/yyyy HH:mm:ss}", save.SaveDate);
        }

        loadButton.onClick.AddListener(() =>
        {
            SavesManager.LoadGame(save.Key);
        });

        deleteButton.onClick.AddListener(() =>
        {
            string titre   = "Attention";
            string content = "Voulez vous vraiment supprimer cette sauvegarde ?";

            FindObjectOfType <MainMenu>().transform.Find("Prompt").GetComponent <PromptWindow>().OpenPrompt(DeleteSave, () => { }, titre, content);
        });
    }
Exemple #28
0
    void Awake()
    {
        instance = this;
        DontDestroyOnLoad(this);

        m_SavedGames = new Game[5];
        m_GameToLoad = null;

        // Read the saves files from disk or create them if not present
        if (File.Exists(Application.persistentDataPath + "/savedGames.gd"))
        {
            ReadSavesFromDisk();
        }
        else
        {
            for (int i = 0; i < m_SavedGames.Length; i++)
            {
                m_SavedGames[i] = new Game();
            }
        }
    }
Exemple #29
0
    // Start is called before the first frame update
    void Start()
    {
        SetUpValues();
        SetUpQualityManagement();
        SetUpVolumeSettings();
        SetUpVSyncManagement();
        SetUpNoiseSettings();
        SetUpShortcutManagement();

        returnButton.onClick.AddListener(() =>
        {
            mainMenu.gameObject.SetActive(true);
            gameObject.SetActive(false);
        });

        apply.onClick.AddListener(() =>
        {
            UpdateSettings();
            SavesManager.SaveSettings();
        });
    }
        private ApplicationContext()
        {
            ItemsDatabase = Resources.Load <ItemsDatabase>(Constants.ITEMS_DATABASE_PATH);
            if (ItemsDatabase == null)
            {
                Debug.LogError("Can't load items resources");
                return;
            }

            SavesManager = new SavesManager();
            ServerApi    = new ServerAPI(Constants.AUTH_KEY, Constants.SERVER_URL);

            var savedData = SavesManager.LoadData();

            GameApi = new GameAPI(savedData, ServerApi);

            foreach (var gameManager in _managers)
            {
                InitializeManager(gameManager);
            }
        }