Пример #1
0
        private void SaveTowerDef(string path, Tower_Class.Tower tower)
        {
            ConsoleHandler.append("Saving TowerDefiniton");
            string text = tower.ToJson();

            StreamWriter serialize = new StreamWriter(path, false);

            serialize.Write(text);
            serialize.Close();
        }
Пример #2
0
        private void MakeNewTowerDef(string savePath)
        {
            ConsoleHandler.append("Creating new tower definition");
            Tower_Class.Tower tower = new Tower_Class.Tower()
            {
                AircraftList       = { },
                BaseCost           = 0,
                CanBePlacedInWater = false,
                CanBePlacedOnLand  = true,
                CanBePlacedOnPath  = false,
                DefaultWeapons     = { },
                Icon                    = "",
                PlacementH              = 0,
                PlacementW              = 0,
                PlacementRadius         = 0,
                RankToUnlock            = 1,
                RotatesToTarget         = false,
                TargetIsWeaponOrigin    = false,
                TargetingMode           = "First",
                TypeName                = TowerName,
                UseRadiusPlacement      = true,
                SpriteUpgradeDefinition = TowerName + ".json",

                Upgrades = CreateDoubleArray_String(new string[8] {
                    "", "", "", "", "", "", "", ""
                }),
                UpgradeIcons = CreateDoubleArray_String(new string[8] {
                    "", "", "", "", "", "", "", ""
                }),
                UpgradeAvatars = CreateDoubleArray_String(new string[8] {
                    "", "", "", "", "", "", "", ""
                }),

                UpgradeGateway = CreateDoubleArray_UpgradeGateway(new long[8] {
                    0, 0, 0, 0, 0, 0, 0, 0
                }, new long[8] {
                    0, 0, 0, 0, 0, 0, 0, 0
                }),
                UpgradePrices = CreateDoubleArray_Long(new long[8] {
                    0, 0, 0, 0, 0, 0, 0, 0
                })
            };

            SaveTowerDef(savePath, tower);
        }
Пример #3
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);
        }
Пример #4
0
 public static string ToJson(this Tower self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);