Esempio n. 1
0
    public void endSessionFinal()
    {
        playerConfig.isInGame = false;
        playerConfig.gold    += Gold;
        addRewardToUser();
        ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

        SceneManager.LoadScene("FrontPage");
    }
Esempio n. 2
0
    public void endApplication(List <Tower> towers, float Gold, float numCapturedEnemy, float Wave, float Health, Dictionary <int, int> capturedEnemy)
    {
        playerConfig.userMapConfig = getMapConfig(towers);
        playerConfig.userMapPath   = staticTransition.pathToLevel;
        playerConfig.gameConfig    = new float[] { Gold, numCapturedEnemy, Wave, Health };
        playerConfig.capturedEnemy_duringSession = capturedEnemy;

        ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

        SceneManager.LoadScene("FrontPage");
    }
    public void continueToNewGame()
    {
        playerConfig.isInGame      = false;
        playerConfig.userMapPath   = null;
        playerConfig.userMapConfig = null;
        playerConfig.gameConfig    = null;

        ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

        ToInGame();
    }
Esempio n. 4
0
    public void ToFrontPage()
    {
        Time.timeScale = 1;

        playerConfig.isInGame = false;

        playerConfig.gold = Gold;

        ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

        SceneManager.LoadScene("FrontPage");
    }
        public void Test_Save()
        {
            string path = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "TestConfig.xml";

            MockAppConfig config = new MockAppConfig();
            config.FilePath = path;

            ConfigSaver saver = new ConfigSaver();
            saver.Save(config);

            Assert.IsTrue(File.Exists(path), "The configuration file wasn't found.");
        }
Esempio n. 6
0
    public void ToFrontPageFinal()
    {
        setTimeBack();
        playerConfig.userMapConfig = getMapConfig();
        playerConfig.userMapPath   = staticTransition.pathToLevel;
        print(Gold);
        playerConfig.gameConfig = new float[] { Gold, numCapturedEnemy, Wave, Health };
        playerConfig.capturedEnemy_duringSession = capturedEnemy;

        ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

        SceneManager.LoadScene("FrontPage");
    }
Esempio n. 7
0
        public void Test_Save()
        {
            string path = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "TestConfig.xml";

            MockAppConfig config = new MockAppConfig();

            config.FilePath = path;

            ConfigSaver saver = new ConfigSaver();

            saver.Save(config);

            Assert.IsTrue(File.Exists(path), "The configuration file wasn't found.");
        }
Esempio n. 8
0
        /// <summary>
        /// 保存配置
        /// </summary>
        /// <param name="config"></param>
        public static bool SaveConfig(Config config)
        {
            ConfigSaver cs       = new ConfigSaver();
            bool        isUpdate = false;

            #region 判断配置路径是否发生变化,如果发生变化,则告诉状态管理器
            try
            {
                string[] prePaths  = GetCurrentConfig().LogPath.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                string[] currPaths = config.LogPath.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                string preFolder  = GetCurrentConfig().Folder.Trim();
                string currFolder = config.Folder.Trim();

                if (prePaths.Count() == currPaths.Count() && preFolder == currFolder)
                {
                    foreach (string path in currPaths)
                    {
                        if (!prePaths.Contains(path))
                        {
                            isUpdate = true; break;
                        }
                    }
                }
                else
                {
                    isUpdate = true;
                }
            }
            catch (System.Exception)
            {
                isUpdate = false;
            }
            #endregion
            if (isUpdate)
            {
                bool status = cs.SaveConfig(config);
                if (status)
                {
                    StatusManager.SetPathUpdate();
                }
                return(status);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 9
0
    //need big change
    //need to add discription to every nodes
    public void upgrade()
    {
        upgradeIndicator.SetActive(true);

        float timeSinceLastClick = Time.time - lastClickTime;

        if (timeSinceLastClick <= Double_click_interval)
        {
            print("tree#: " + (current_treeNode.nodeOfTree) + ", node#: " + (current_treeNode.rank));

            upgradeIndicator.SetActive(false);

            playerConfig.gold -= stateCalculator.upgradeStat(current_treeNode.goldCost, current_treeNode.goldCostMultiplier, current_treeNode.nodeLevel);

            playerConfig.trees[currentButtonOfTree][current_treeNode.rank][0]++;

            upgradePage.GetComponent <textHandler>().setValue(playerConfig.gold);

            playerConfig.trees[currentButtonOfTree][current_treeNode.rank][1] = current_treeNode.upgradeDisplay;

            ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

            upgradePage.getNewPlayerConfig();

            if (playerConfig.gold < current_treeNode.priceDisplay)
            {
                upgradeButton.interactable = false;
            }


            if (current_treeNode.rank == 0)
            {
                if (currentTree != upgradePage.allTrees[0].GetComponent <Tree>() && currentTree != upgradePage.allTrees[1].GetComponent <Tree>())
                {
                    if (current_treeNode.nodeLevel >= 1)
                    {
                        upgradeButton.interactable = false;
                    }
                }
            }
        }
        lastClickTime = Time.time;
        StatRefresh();
    }
    public void ToInGame()
    {
        if (playerConfig.isInGame == false)
        {
            playerConfig.isInGame    = true;
            playerConfig.userMapPath = staticTransition.pathToLevel;
            playerConfig.gameConfig  = new float[] { 10, 0, 0, 10 };


            ConfigSaver.save(staticTransition.userID, staticTransition.userPass, playerConfig);

            staticTransition.pathToLevel = path;
            gameObject.SetActive(false);

            staticTransition.isNewGame = true;

            SceneManager.LoadScene("InGame");
        }
        else
        {
            isGameStartedPrompt.SetActive(true);
        }
    }
Esempio n. 11
0
    public static void playerInitiation(string Username, string password)
    {
        string saveFile = playinitPathPrefix + Username + ".txt";

        PlayerConfig config = new PlayerConfig();

        config.Username = Username;
        config.Password = password;

        config.isInGame = false;

        config.userMapPath = null;

        config.userMapConfig = null;

        config.gameConfig = null;

        config.capturedEnemy_duringSession = new Dictionary <int, int>();

        config.allCapturedEnemy = new Dictionary <int, int>();

        config.gold = 200;

        //first value in the list is level, second is increment
        //first four elements of tower are the same

        config.trees = new Dictionary <int, float[][]>
        {
            {
                //utility
                0, new float[][]
                {
                    new float[] { 1, 1 },                                 //inGame_life
                    new float[] { 1, 1 }                                  //inGame_gold
                }
            },

            {
                //general upgrade
                1, new float[][]
                {
                    new float[] { 1, 0 },                                 //general_damage
                    new float[] { 1, 0 },                                 //general_range
                    new float[] { 1, 0 },                                 //general_atk_speed
                    new float[] { 1, 0 }                                  //general_effect
                }
            },

            {
                //first tower
                2, new float[][]
                {
                    new float[] { 0, 0 },
                    new float[] { 1, 0 },                                 //damage
                    new float[] { 1, 0 },                                 //range
                    new float[] { 1, 0 },                                 //atk_speed
                    new float[] { 1, 0 }                                  //effect
                }
            },

            {
                //second tower
                3, new float[][]
                {
                    new float[] { 0, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 }
                }
            },

            {
                //third tower
                4, new float[][]
                {
                    new float[] { 0, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 }
                }
            },

            {
                //fourth tower
                5, new float[][]
                {
                    new float[] { 0, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 }
                }
            },

            {
                //fifth tower
                6, new float[][]
                {
                    new float[] { 0, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 }
                }
            },

            {
                //sixth tower
                7, new float[][]
                {
                    new float[] { 0, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 },
                    new float[] { 1, 0 }
                }
            }
        };

        ConfigSaver.save <PlayerConfig>(saveFile, config);
    }
Esempio n. 12
0
        /// <summary>
        /// 保存配置
        /// </summary>
        /// <param name="config"></param>
        public static bool SaveConfig(Config config)
        {
            ConfigSaver cs = new ConfigSaver();

            return(cs.SaveConfig(config));
        }