예제 #1
0
        /// <summary>
        /// Adds an entry for a given powerup to the powerup balance manager.
        /// </summary>
        public static void AddPowerupToPowerupManager(PowerupBuilder feature)
        {
            string powerupBalancePath = UnityPaths.PathPowerupBalanceManager;

            Debug.Assert(File.Exists(powerupBalancePath));

            string featureName = feature.FeatureName;

            string baseBalanceStartTag = feature.BaseBalanceStartTag;
            string baseBalanceEndTag   = UnityPaths.TagPowerupBalanceManagerVariablesEnd;

            string[] lines = File.ReadAllLines(powerupBalancePath);
            int      baseBalanceEndTagLine = FindEndTagLineAfterStartTagLine(baseBalanceStartTag, baseBalanceEndTag, lines, powerupBalancePath);

            #region Assert
            // Assert coding style - one line of blank space
            // between last balance and end tag.
            string _blankLine   = lines[baseBalanceEndTagLine - 1];
            string _lastBalance = lines[baseBalanceEndTagLine - 2];
            Debug.Assert(String.IsNullOrWhiteSpace(_blankLine));
            Debug.Assert(!String.IsNullOrWhiteSpace(_lastBalance));
            #endregion Assert

            int    variableLineNumber = baseBalanceEndTagLine - 1;
            string variableLine       = $"            public {featureName}Balance {featureName};";

            InsertLineToFile(powerupBalancePath, lines, variableLine, variableLineNumber, true);

            AddPowerupManagerStructLines(feature, baseBalanceEndTagLine);
        }
예제 #2
0
        public static void AddPowerup(PowerupBuilder feature)
        {
            LogProgress($"{feature.PowerupType}Powerup", feature);

            FileUtil.CopyNewFeatureCsFile(feature);
            FileUtil.AddPowerupToPowerupManager(feature);
        }
예제 #3
0
 public static void RunPowerupTests(string featureName)
 {
     foreach (PowerupType powerup in Enum.GetValues(typeof(PowerupType)))
     {
         string         name    = $"{featureName}{powerup}";
         PowerupBuilder feature = new PowerupBuilder(name, powerup);
         AddPowerup(feature);
     }
 }
예제 #4
0
        public static void AddPowerup(string featureName)
        {
            PowerupType powerup = (PowerupType)Log.EnumPrompt(typeof(PowerupType));

            PowerupBuilder feature = new PowerupBuilder(featureName, powerup);

            if (ConfirmFeature(feature, "AddPowerup"))
            {
                AddPowerup(feature);
            }
        }
예제 #5
0
        /// <summary>
        /// Adds a balance manager struct entry for a given powerup to the powerup balance manager.
        /// </summary>
        private static void AddPowerupManagerStructLines(PowerupBuilder feature, int baseBalanceEndTagLine)
        {
            string powerupBalancePath = UnityPaths.PathPowerupBalanceManager;

            string featureName          = feature.FeatureName;
            string balanceStructEndLine = UnityPaths.TagPowerupBalanceManagerBalanceStructEnd;

            string[] lines           = File.ReadAllLines(powerupBalancePath);
            int      endOfStructLine = FindNextEquivalentLine(balanceStructEndLine, lines, powerupBalancePath, baseBalanceEndTagLine);

            string powerupBalanceStructTemplatePath = TemplatePaths.PathPowerupBalanceStructTemplate;

            Debug.Assert(File.Exists(powerupBalanceStructTemplatePath));
            string[] structLines = File.ReadAllLines(powerupBalanceStructTemplatePath);

            for (int i = 0; i < structLines.Length; i++)
            {
                structLines[i] = structLines[i].Replace(TemplateName, featureName);
            }

            InsertLinesToFile(powerupBalancePath, lines, structLines, endOfStructLine, true);
        }