public void SaveLevel_TestMethod()
        {
            XMLUtils xmlUtils = new XMLUtils
            {
                FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Properties.Resources.XMLDBName.ToString())
            };

            xmlUtils.DeleteXMLfile();

            SaveGameHelper saveGameHelper = new SaveGameHelper
            {
                Level_ID       = 1,
                Player_ID      = 1,
                Level_Score    = 600,
                Special_Count  = 1,    //wind +
                Monster_Count  = 10,   //lightbolt kills
                Level_Time     = 1000, // time to complete level in seconds
                Level_Attempts = 10,   // how many attempts before completing level
                Char_Points    = 600
            };

            saveGameHelper.SaveLevel();

            DataSet ds   = xmlUtils.ReadXMLfile();
            DataRow rows = (from row in ds.Tables[(int)SaveGameHelper.XMLTbls.player_history].AsEnumerable()
                            where row.Field <string>("player_ID") == StartScreen.PlayerID.ToString() &&
                            !String.IsNullOrWhiteSpace(row.Field <string>("completed").ToString())
                            select row).SingleOrDefault();

            Assert.IsNotNull(rows);
            Assert.IsTrue(!String.IsNullOrWhiteSpace(rows.Field <string>("last_played")));
        }
Exemple #2
0
        private void Add_AchievementData()
        {
            XMLUtils xmlUtils = new XMLUtils
            {
                FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Properties.Resources.XMLDBName.ToString())
            };

            xmlUtils.DeleteXMLfile();

            SaveGameHelper saveGameHelper = new SaveGameHelper
            {
                Level_ID       = 1,
                Player_ID      = 1,
                Level_Score    = 250,
                Special_Count  = 1,    //wind +
                Monster_Count  = 1,    //lightbolt kills
                Level_Time     = 1000, // time to complete level in seconds
                Level_Attempts = 1,    // how many attempts before completing level
                Char_Points    = 2050
            };

            saveGameHelper.SaveLevel();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Star_Light;
            saveGameHelper.Achievement_Data   = 25000 / 10;
            saveGameHelper.SaveAchievement();
        }
Exemple #3
0
    private void OnEnable()
    {
        if (!SaveGameHelper.IsSaveGameDirExist())
        {
            return;
        }

        var saveFiles = SaveGameHelper.GetAllSaveFiles();

        if (saveFiles.Length == 0)
        {
            return;
        }

        scrollViewContent.transform.DetachChildren();

        foreach (var file in saveFiles)
        {
            Debug.Log(Path.GetFileName(file));
            var newItem = Instantiate(item, scrollViewContent.transform, false);
            newItem.transform.localPosition = Vector3.zero;
            Items.Add(newItem);

            newItem.GetComponentInChildren <Text>().text = Path.GetFileNameWithoutExtension(file);

            newItem.GetComponent <Button>().onClick.AddListener(
                () => OnItemClick(newItem));
        }
    }
    public void LoadGameButtonClick()
    {
        ClickSource.PlayOneShot(clickSound);
        Debug.Log("Load Game Button pressed");

        if (!SaveGameHelper.IsSaveGameDirExist())
        {
            ToastManager.Show("Сохранений не найдено!");
            return;
        }

        var saveFiles = SaveGameHelper.GetAllSaveFileNames();

        if (saveFiles.Length == 0)
        {
            ToastManager.Show("Файлов сохранений не найдено!");
            return;
        }

        DialogManager.ShowRadioList(saveFiles, selectedIndex =>
        {
            ClickSource.PlayOneShot(clickSound);
            var saveData = SaveGameHelper.ReadFile(saveFiles[selectedIndex]);

            if (string.IsNullOrEmpty(saveData))
            {
                ToastManager.Show(
                    "Файл " + saveFiles[selectedIndex] + " поврежден!");
                return;
            }

            SaveGameData.Data    = GameData.Deserialize(saveData);
            SaveGameData.LogList = SaveGameData.Data.logs;
            StartGame();
        },
                                    "ЗАГРУЗИТЬ",
                                    "Список сохранений",
                                    MaterialIconHelper.GetIcon(MaterialIconEnum.FILE_DOWNLOAD),
                                    () =>
        {
            ClickSource.PlayOneShot(clickSound);
            Debug.Log("Clicked the Cancel button");
        }, "НАЗАД");

        //menu.SetActive(false);
        //loadGameMenu.SetActive(true);
    }
Exemple #5
0
    public void OnDeleteBtnClick()
    {
        ClickSource.PlayOneShot(clickSound);
        foreach (var i in Items)
        {
            if (!i.GetComponentInChildren <Toggle>().isOn)
            {
                continue;
            }
            if (SaveGameHelper.DeleteSaveGame(i.GetComponentInChildren <Text>().text))
            {
                i.transform.parent = null;
            }
        }

        Debug.Log("Clicked on OnDeleteBtnClick");
    }
Exemple #6
0
    public void OnApplyBtnClick()
    {
        Debug.Log("Clicked on OnApplyBtnClick");
        ClickSource.PlayOneShot(clickSound);

        foreach (var i in Items)
        {
            if (!i.GetComponentInChildren <Toggle>().isOn)
            {
                continue;
            }

            var saveData = SaveGameHelper.ReadFile(i.GetComponentInChildren <Text>().text);
            if (string.IsNullOrEmpty(saveData))
            {
                return;
            }

            SaveGameData.Data = GameData.Deserialize(saveData);

            EventManager.TriggerEvent(EventsNames.LoadSaveGameEvent, new EventParam());
        }
    }
        public void SaveAchievement_TestMethod()
        {
            XMLUtils xmlUtils = new XMLUtils
            {
                FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Properties.Resources.XMLDBName.ToString())
            };

            xmlUtils.DeleteXMLfile();

            SaveGameHelper saveGameHelper = new SaveGameHelper
            {
                Level_ID       = 1,
                Player_ID      = 1,
                Level_Score    = 250,
                Special_Count  = 1,    //wind +
                Monster_Count  = 1,    //lightbolt kills
                Level_Time     = 1000, // time to complete level in seconds
                Level_Attempts = 1,    // how many attempts before completing level
                Char_Points    = 2050
            };

            saveGameHelper.SaveLevel();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Star_Light;
            saveGameHelper.Achievement_Data   = 25000 / 10;
            saveGameHelper.SaveAchievement();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Electrocuted;
            saveGameHelper.Achievement_Data   = 600;
            saveGameHelper.SaveAchievement();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Kills_1;
            saveGameHelper.Achievement_Data   = 10;
            saveGameHelper.SaveAchievement();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Kills_2;
            saveGameHelper.Achievement_Data   = 20;
            saveGameHelper.SaveAchievement();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Kills_3;
            saveGameHelper.Achievement_Data   = 30;
            saveGameHelper.SaveAchievement();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Light_Speed_1;
            saveGameHelper.Achievement_Data   = 1000;
            saveGameHelper.SaveAchievement();

            saveGameHelper.Player_Achievement = SaveGameHelper.Achievements.Portal_1;
            saveGameHelper.Achievement_Data   = 1;
            saveGameHelper.SaveAchievement();

            DataSet   ds     = xmlUtils.ReadXMLfile();
            DataTable dt     = ds.Tables[(int)SaveGameHelper.XMLTbls.player_achievement];
            DataTable badges = new DataTable();


            int count = (from row in ds.Tables[(int)SaveGameHelper.XMLTbls.player_achievement].AsEnumerable()
                         where row.Field <string>("player_ID") == StartScreen.PlayerID.ToString() && //player1
                         !String.IsNullOrWhiteSpace(row.Field <string>("achievement_date").ToString())
                         select row).Count();

            Assert.IsNotNull(count);
            Assert.AreNotEqual(0, count);
        }