Exemple #1
0
        private void DupUpgradesFile(string savePath)
        {
            ConsoleHandler.append("Duplicating base tower's UpgradeDefinitions");
            string baseTowerUpgradeDef = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\UpgradeDefinitions\\" + BaseTowerName_NoExt + ".upgrades";

            if (!File.Exists(baseTowerUpgradeDef))
            {
                ConsoleHandler.append("The Base Tower's UpgradeDefinitions wasn't found. Creating a new one instead.");
                MakeNewUpgradesFile(savePath);
                return;
            }
            if (!JSON_Reader.IsValidJson(File.ReadAllText(baseTowerUpgradeDef)))
            {
                ConsoleHandler.append("The Base Tower's UpgradeDefinitions has invalid JSON. Creating a new one instead.");
                MakeNewUpgradesFile(savePath);
                return;
            }

            UpgradesFile upgrades = UpgradesFile.FromJson(baseTowerUpgradeDef);

            if (upgrades.Upgrades == null)
            {
                ConsoleHandler.append("The Base Tower's UpgradeDefinitions is empty. Creating a new one instead.");
                MakeNewUpgradesFile(savePath);
                return;
            }

            SaveUpgradesFile(upgrades, savePath);
        }
Exemple #2
0
        private void MakeDupTowerSpriteUpgradeDef(string savePath)
        {
            ConsoleHandler.append("Duplicating base tower's TowerSpriteUpgrade file");
            string baseTowerSpriteDefPath = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\TowerSpriteUpgradeDefinitions\\" + BaseTowerName_NoExt + ".json";

            if (!File.Exists(baseTowerSpriteDefPath))
            {
                ConsoleHandler.append("The Base TowerSpriteUpgradeDefinition doesn't exist. Creating a new one instead.");
                MakeNewTowerSpriteUpgradeDef(savePath);
                return;
            }
            if (!JSON_Reader.IsValidJson(File.ReadAllText(baseTowerSpriteDefPath)))
            {
                ConsoleHandler.append("The Base TowerSpriteUpgradeDefinition has invalid JSON. Creating a new one instead.");
                MakeNewTowerSpriteUpgradeDef(savePath);
                return;
            }

            if (File.Exists(savePath))
            {
                File.Delete(savePath);
            }

            ConsoleHandler.append("Saving TowerSpriteUpgrade file");
            File.Copy(baseTowerSpriteDefPath, savePath);
        }
Exemple #3
0
        public string GetSpecialtyBuilding()
        {
            string specialtyBuilding = "";
            string projPath          = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\";

            ConsoleHandler.append("Searching for base tower's specialty building...");
            foreach (var x in Directory.GetFiles(projPath + "SpecialtyDefinitions"))
            {
                string json = File.ReadAllText(x);
                if (!JSON_Reader.IsValidJson(json))
                {
                    continue;
                }

                SpecialtyBuildingClass s = new SpecialtyBuildingClass();
                s = SpecialtyBuildingClass.FromJson(json);

                if (s != null && s.RelatedTower != null && s.RelatedTower == BaseTowerName_NoExt)
                {
                    specialtyBuilding = x.Replace(projPath + "SpecialtyDefinitions\\", "");
                    ConsoleHandler.append("Found base tower's specialty building called:  " + specialtyBuilding);
                    break;
                }
            }
            return(specialtyBuilding);
        }
Exemple #4
0
        private string CheckJSONFromFile(string path)
        {
            if (!File.Exists(path))
            {
                ConsoleHandler.append_CanRepeat("Unable to make jsonObject because it doesnt exist at:  " + path);
                return("");
            }

            string text = File.ReadAllText(path);

            if (JSON_Reader.IsValidJson(text))
            {
                return(text);
            }
            return("");
        }
Exemple #5
0
        private void MakeDupSpecialty(string savePath)
        {
            ConsoleHandler.append("Duplicating base tower's specialty building");
            SpecialtyBuildingClass specialty = new SpecialtyBuildingClass();

            string baseSpecialName = GetSpecialtyBuilding();

            string baseSpecialPath = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\SpecialtyDefinitions\\" + baseSpecialName;

            if (!File.Exists(baseSpecialPath))
            {
                ConsoleHandler.append("Unable to find the base tower's specialty building by RelatedTower property" +
                                      ". Creating a new one instead.");
                MakeNewSpecialty(savePath);
                return;
            }
            if (!JSON_Reader.IsValidJson(File.ReadAllText(baseSpecialPath)))
            {
                ConsoleHandler.append("The Base specialty building has invalid JSON. Using a new one instead.");
                MakeNewSpecialty(savePath);
                return;
            }

            SpecialtyBuildingClass baseSpecialty = new SpecialtyBuildingClass();

            baseSpecialty = SpecialtyBuildingClass.FromJson(baseSpecialPath);

            FileInfo f = new FileInfo(savePath);

            specialty.FileName = f.Name;
            specialty.Name     = baseSpecialty.Name;
            specialty.Icon     = baseSpecialty.Icon;
            specialty.Building = baseSpecialty.Building;

            specialty.Prices       = baseSpecialty.Prices;
            specialty.RelatedTower = TowerName;

            specialty.Tiers = baseSpecialty.Tiers;
            SaveSpecialty(savePath, specialty);
        }
Exemple #6
0
        private void MakeDupeTowerDef(string savePath)
        {
            ConsoleHandler.append("Duplicating base tower's TowerDefinition");
            string baseTowerDefPath = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\TowerDefinitions\\" + BaseTowerName_NoExt + ".tower";

            if (!File.Exists(baseTowerDefPath))
            {
                ConsoleHandler.append("The Base Tower's TowerDefinition wasn't found. Creating a new one instead.");
                MakeNewTowerDef(savePath);
                return;
            }
            if (!JSON_Reader.IsValidJson(File.ReadAllText(baseTowerDefPath)))
            {
                ConsoleHandler.append("The Base Tower's TowerDefinition has invalid JSON. Creating a new one instead.");
                MakeNewTowerDef(baseTowerDefPath);
                return;
            }

            Tower_Class.Tower tower = Tower_Class.Tower.FromJson(baseTowerDefPath);
            tower.TypeName = TowerName;
            tower.SpriteUpgradeDefinition = TowerName + ".json";

            SaveTowerDef(savePath, tower);
        }