コード例 #1
0
        public BloonModel Create(string name, string display, BloonModel baseModel = null)
        {
            BloonModel bloonModel = Create(name, baseModel);

            bloonModel.display = display;
            return(bloonModel);
        }
コード例 #2
0
        /// <summary>
        /// (Cross-Game compatable) Return how much cash this bloon would give if popped by <paramref name="layersPopped"/> number of layers
        /// </summary>
        /// <param name="layersPopped">How many layers of bloons to pop, ignoring layer health. If less than 0, calculates for the entire bloon</param>
        public static int GetTotalCash(this BloonModel bloonModel, int layersPopped = -1)
        {
            if (layersPopped == 0)
            {
                return(0);
            }

            var cashValue = SessionData.Instance.bloonPopValues;
            var children  = bloonModel.GetChildBloonModels(InGame.instance?.GetSimulation());

            if ((layersPopped >= 0) || !cashValue.TryGetValue(bloonModel.GetBaseID(), out int bloonCash))
            {
                bloonCash = 1;
                foreach (BloonModel child in children)
                {
                    bloonCash += child.GetTotalCash(layersPopped - 1);
                }
                if (layersPopped < 0)
                {
                    cashValue.Add(bloonModel.GetBaseID(), bloonCash);
                }
            }

            return(bloonCash);
        }
コード例 #3
0
        public static BloonModel GetNextWeakest(this BloonModel bloonModel, bool allowCamo = false,
                                                bool allowFortified = false, bool allowRegrow = false)
        {
            var allBloonTypes = Game.instance.GetAllBloonModels();

            string bloonId   = bloonModel.id;
            string nextBloon = bloonId;
            int    max       = allBloonTypes.Count - 1; // subtract 1 more here to avoid test bloon

            for (int i = 0; i < max; i++)
            {
                if (bloonId.ToLower() != allBloonTypes[i].name.ToLower())
                {
                    continue;
                }

                if (i == 0)
                {
                    nextBloon = allBloonTypes[0].name;
                    break;
                }
                nextBloon = allBloonTypes[i - 1].name;
                break;
            }

            var nextWeakestBloon = _BloonModel.SetBloonStatus(nextBloon, allowCamo, allowFortified, allowRegrow);

            return(nextWeakestBloon);
        }
コード例 #4
0
        public static BloonModel GetNextStrongest(this BloonModel bloonModel, bool allowCamo = false, bool allowFortified = false, bool allowRegrow = false)
        {
            var allBloonTypes = Game.instance.GetAllBloonModels();

            int        max             = allBloonTypes.Count - 1; // subtract 1 more here to avoid test bloon
            int        currentBloonNum = bloonModel.GetBloonIdNum();
            BloonModel nextBloonModel  = null;

            if (allowCamo || allowFortified || allowRegrow)
            {
                nextBloonModel = _BloonModel.RemoveBloonStatus(allBloonTypes[currentBloonNum + 1].name, !allowCamo, !allowFortified, !allowRegrow);
            }
            else
            {
                string baseBloon = bloonModel.id.Replace("Camo", "").Replace("Fortified", "").Replace("Regrow", "");
                for (int a = bloonModel.GetBloonIdNum(); a < max; a++)
                {
                    if (allBloonTypes[a].name.Contains(baseBloon))
                    {
                        continue;
                    }

                    nextBloonModel = _BloonModel.RemoveBloonStatus(allBloonTypes[a].name, true, true, true);
                    break;
                }
            }

            return(nextBloonModel);
        }
コード例 #5
0
        /// <summary>
        /// Get the BloonModel of the bloonId you enter
        /// </summary>
        /// <param name="bloonId">The ID of the bloon you want</param>
        /// <returns></returns>
        public static BloonModel GetBloon(string bloonId, bool isCamo = false, bool isFortified = false, bool isRegrow = false,
                                          bool ignoreException        = true)
        {
            BloonModel result = null;

            if (Game.instance == null)
            {
                return(result);
            }
            else if (Game.instance.model == null)
            {
                return(result);
            }

            try
            {
                result = Game.instance.model.GetBloon(bloonId);
            }
            catch (Exception e)
            {
                if (ignoreException)
                {
                    return(result);
                }
            }

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// (Cross-Game compatible) Return the Base ID of this BloonModel
        /// </summary>
        /// <param name="bloonModel"></param>
        /// <returns></returns>
        public static string GetBaseID(this BloonModel bloonModel)
        {
#if BloonsTD6
            return(bloonModel.baseId);
#elif BloonsAT
            return(bloonModel.baseType.ToString());
#endif
        }
コード例 #7
0
 public BloonModel Create(string name, bool camo, bool regrow, bool fortified, BloonModel baseModel = null)
 {
     BloonModel bloonModel = Create(name, baseModel);
     bloonModel.isCamo = camo;
     bloonModel.isGrow = regrow;
     bloonModel.isFortified = fortified;
     return bloonModel;
 }
コード例 #8
0
        private BloonModel GetRandomBloon(BloonModel currentBloon)
        {
            var randBloonNum   = GetRandomBloonNum(currentBloon);
            var allBloonTypes  = Game.instance.GetAllBloonModels();
            var randBloonModel = allBloonTypes[randBloonNum];
            var nextBloon      = randBloonModel.GetNextStrongest(settings.AllowRandomCamos, settings.AllowRandomFortified, settings.AllowRandomRegrows);

            return(nextBloon);
        }
コード例 #9
0
        public BloonModel Create(string name, BloonModel baseModel = null)
        {
            BloonModel model      = (baseModel is null) ? Game.instance.model.GetBloon("Red") : baseModel;
            BloonModel bloonModel = model.Clone().Cast <BloonModel>();

            bloonModel.name = name;
            bloonModel.id   = name;

            return(bloonModel);
        }
コード例 #10
0
        /// <summary>
        /// (Cross-Game compatible) Spawn a BloonModel on the map
        /// </summary>
        /// <param name="spawner"></param>
        /// <param name="bloonModel"></param>
        public static void Emit(this Spawner spawner, BloonModel bloonModel)
        {
#if BloonsTD6
            Il2CppSystem.Collections.Generic.List <Bloon.ChargedMutator> chargedMutators    = new Il2CppSystem.Collections.Generic.List <Bloon.ChargedMutator>();
            Il2CppSystem.Collections.Generic.List <BehaviorMutator>      nonChargedMutators = new Il2CppSystem.Collections.Generic.List <BehaviorMutator>();
            spawner.Emit(bloonModel, InGame.Bridge.GetCurrentRound(), 0);
#elif BloonsAT
            var emissionModel = new BloonEmissionModel(bloonType: bloonModel.baseType);
            spawner.Emit(emissionModel);
#endif
        }
コード例 #11
0
        public static List <BloonToSimulation> GetBloonSims(this BloonModel bloonModel)
        {
            Il2CppSystem.Collections.Generic.List <BloonToSimulation> bloonSims = InGame.instance?.GetUnityToSimulation()?.GetAllBloons();
            if (bloonSims is null || !bloonSims.Any())
            {
                return(null);
            }

            List <BloonToSimulation> results = bloonSims.Where(b => b.GetBaseModel().IsEqual(bloonModel)).ToList();

            return(results);
        }
コード例 #12
0
        /// <summary>
        /// Spawn this BloonModel on the map right now
        /// </summary>
        public static void SpawnBloonModel(this BloonModel bloonModel)
        {
            Assets.Scripts.Simulation.Track.Spawner spawner = InGame.instance?.GetMap()?.spawner;
            if (spawner is null)
            {
                return;
            }

            Il2CppSystem.Collections.Generic.List <Bloon.ChargedMutator> chargedMutators    = new Il2CppSystem.Collections.Generic.List <Bloon.ChargedMutator>();
            Il2CppSystem.Collections.Generic.List <BehaviorMutator>      nonChargedMutators = new Il2CppSystem.Collections.Generic.List <BehaviorMutator>();
            spawner.Emit(bloonModel, InGame.Bridge.GetCurrentRound(), 0, chargedMutators, nonChargedMutators);
        }
コード例 #13
0
        private int GetRandomBloonNum(BloonModel currentBloon)
        {
            var allBloonTypes = Game.instance.GetAllBloonModels();
            int maxBloonNum   = allBloonTypes.Count - 2; //subtracting 2 to avoid test bloon
            int maxRand       = (settings.maxRandomChange > 0) ? settings.maxRandomChange : 0;
            var randNum       = rand.Next(0, maxRand);

            var currentBloonNum      = currentBloon.GetBloonIdNum();
            var nextPossibleBloonNum = currentBloonNum + randNum;
            var nextBloonNum         = (nextPossibleBloonNum <= maxBloonNum) ? nextPossibleBloonNum : maxBloonNum;

            return(nextBloonNum);
        }
コード例 #14
0
        /// <summary>
        /// Set the statuses of the bloon. Will change bloonModel if one exists with these statuses
        /// </summary>
        /// <param name="setCamo">Should have camo?</param>
        /// <param name="setFortified">Should have fortify?</param>
        /// <param name="setRegrow">Should have regrow?</param>
        public static void SetBloonStatus(this Bloon bloon, [Optional] bool setCamo, [Optional] bool setFortified, [Optional] bool setRegrow)
        {
            Assets.Scripts.Models.GameModel model = Game.instance.model;
            BloonModel bloonModel = bloon.bloonModel;

            string camoText      = (setCamo && model.GetBloon(bloonModel.baseId + "Camo") != null) ? "Camo" : "";
            string fortifiedText = (setFortified && model.GetBloon(bloonModel.baseId + "Fortified") != null) ? "Fortified" : "";
            string regrowText    = (setRegrow && model.GetBloon(bloonModel.baseId + "Regrow") != null) ? "Regrow" : "";

            string newBloonID = bloonModel.baseId + regrowText + fortifiedText + camoText;

            bloon.bloonModel = Game.instance.model.GetBloon(newBloonID);
            bloon.UpdateDisplay();
        }
コード例 #15
0
            public static void Postfix()
            {
                foreach (BloonModel bloon in Game.instance.model.bloons)
                {
                    if (bloon.name.Contains("BadFortified"))
                    {
                        // Creates a copy of a Fortified Bad
                        BloonModel boss = bloon.Clone().Cast <BloonModel>();

                        // Sets the boss display to boss.png
                        boss.display = ModContent.GetDisplayGUID <Boss>();

                        // Boss has no immunities by default. Can be changed if you'd like
                        boss.bloonProperties = BloonProperties.None;
                        boss.tags.Add("Boss");
                        foreach (DamageStateModel state in boss.damageDisplayStates)
                        {
                            // Sets all damage states to the boss
                            state.displayPath = boss.display;
                        }


                        boss.maxHealth = initialBossHealth;

                        boss.isBoss = true;

                        boss.id = "Boss";

                        boss.updateChildBloonModels = true;

                        // Removes children


                        boss.childBloonModels = new Il2CppSystem.Collections.Generic.List <BloonModel> {
                        };
                        SpawnChildrenModel spawnChildrenModel = boss.GetBehavior <SpawnChildrenModel>();
                        spawnChildrenModel.children = new string[] { };

                        // Registers the boss bloon
                        Game.instance.model.bloons = Game.instance.model.bloons.Take(0).Append(boss).Concat(Game.instance.model.bloons.Skip(0)).ToArray();
                    }
                }

                foreach (RoundSetModel round in Game.instance.model.roundSets)
                {
                    // Spawns the boss on round 3 by calling it by id
                    round.rounds[2].groups[0].bloon = "Boss";
                    round.rounds[2].groups[0].count = 1;
                }
            }
コード例 #16
0
        public static int GetBloonIdNum(this BloonModel bloonModel)
        {
            var allBloons = Game.instance.model.bloons;

            for (int i = 0; i < allBloons.Count; i++)
            {
                if (allBloons[i].name.ToLower() != bloonModel.name.ToLower())
                {
                    continue;
                }
                return(i);
            }
            return(-1);
        }
コード例 #17
0
        /// <summary>
        /// (Cross-Game compatible) Spawn this BloonModel on the map right now
        /// </summary>
        public static void SpawnBloonModel(this BloonModel bloonModel)
        {
            Assets.Scripts.Simulation.Track.Spawner spawner = InGame.instance?.GetMap()?.spawner;
            if (spawner is null)
            {
                return;
            }

#if BloonsTD6
            Il2CppSystem.Collections.Generic.List <Bloon.ChargedMutator> chargedMutators    = new Il2CppSystem.Collections.Generic.List <Bloon.ChargedMutator>();
            Il2CppSystem.Collections.Generic.List <BehaviorMutator>      nonChargedMutators = new Il2CppSystem.Collections.Generic.List <BehaviorMutator>();
            spawner.Emit(bloonModel, InGame.instance.GetUnityToSimulation().GetCurrentRound(), 0);
#elif BloonsAT
            spawner.Emit(bloonModel);
#endif
        }
コード例 #18
0
ファイル: Main.cs プロジェクト: hemisemidemipresent/BTD-Docs
        public static void BloonSpawnedEvent(InitialiseEvent.Pre e)
        {
            settings = JsonUtils.Load <Settings>();

            int next = new Random().Next(0, 100);

            if (next > settings.chanceToBeStronger_zeroToOneHundred)
            {
                return;
            }

            BloonModel nextBloon = GetNextBloon(e.model.name);

            if (nextBloon != null)
            {
                e.model = nextBloon;
            }
        }
コード例 #19
0
        private BloonModel GetNextBloon(BloonModel currentBloon)
        {
            BloonModel newBloon = currentBloon;

            if (!settings.UseRandomlyStrongerBloons)
            {
                newBloon.SetBloonModel(settings.ForceAllBloonsCamo, settings.ForceAllBloonsFortified, settings.ForceAllBloonsRegrow);
            }
            else
            {
                if (IsBloonRandom())
                {
                    newBloon = GetRandomBloon(currentBloon);
                }
            }

            return(newBloon);
        }
コード例 #20
0
        /// <summary>
        /// Remove current statuses from bloon
        /// </summary>
        /// <param name="removeCamo">Should remove camo if present?</param>
        /// <param name="removeFortify">Should remove fortify if present?</param>
        /// <param name="removeRegrow">Should remove regrow if present?</param>
        public static void RemoveBloonStatus(this Bloon bloon, bool removeCamo, bool removeFortify, bool removeRegrow)
        {
            string bloonId = bloon.bloonModel.id;

            if (bloonId.Contains("Camo") && removeCamo)
            {
                bloonId = bloonId.Replace("Camo", "");
            }
            if (bloonId.Contains("Fortified") && removeFortify)
            {
                bloonId = bloonId.Replace("Fortified", "");
            }
            if (bloonId.Contains("Regrow") && removeRegrow)
            {
                bloonId = bloonId.Replace("Regrow", "");
            }

            BloonModel newBloonModel = Game.instance.model.GetBloon(bloonId);

            bloon.bloonModel = newBloonModel;
            bloon.UpdateDisplay();
        }
コード例 #21
0
        /// <summary>
        /// Set bloon to be regrow or not. Will change bloonModel to regrow version if it exists
        /// </summary>
        /// <param name="isRegrow">Should bloon be regrow</param>
        public static void SetRegrow(this Bloon bloon, bool isRegrow)
        {
            BloonModel bloonModel = bloon.bloonModel;

            bloon.SetBloonStatus(bloonModel.isCamo, bloonModel.isFortified, isRegrow);
        }
コード例 #22
0
        /// <summary>
        /// Set bloon to be fortified or not. Will change bloonModel to fortified version if it exists
        /// </summary>
        /// <param name="isFortified">Should bloon be fortified</param>
        public static void SetFortified(this Bloon bloon, bool isFortified)
        {
            BloonModel bloonModel = bloon.bloonModel;

            bloon.SetBloonStatus(bloonModel.isCamo, isFortified, bloonModel.isGrow);
        }
コード例 #23
0
 /// <summary>
 /// (Cross-Game compatible) Remove the first Behavior of type T
 /// </summary>
 /// <typeparam name="T">The Behavior you want to remove</typeparam>
 /// <param name="model"></param>
 /// <param name="behavior"></param>
 public static void RemoveBehavior <T>(this BloonModel model, T behavior) where T : Model
 {
     model.behaviors = model.behaviors.RemoveItem(behavior);
     model.RemoveChildDependant(behavior);
 }
コード例 #24
0
 /// <summary>
 /// (Cross-Game compatible) Remove all Behaviors of type T
 /// </summary>
 /// <typeparam name="T">The Behavior you want to remove</typeparam>
 /// <param name="model"></param>
 public static void RemoveBehaviors <T>(this BloonModel model) where T : Model
 {
     model.behaviors = model.behaviors.RemoveItemsOfType <Model, T>(model);
 }
コード例 #25
0
 public void AddToGame(BloonModel bloonModel)
 {
     Game.instance.model.bloons = Game.instance.model.bloons.AddTo(bloonModel);
 }
コード例 #26
0
 GetChildBloonModels(this BloonModel bloonModel, Simulation simulation)
 {
     return(bloonModel.GetChildBloonModels(simulation.model));
 }
コード例 #27
0
 /// <summary>
 /// Create a BloonEmissionModel from a bloonModel
 /// </summary>
 /// <param name="bloonModel">The bloon model that these bloons should be</param>
 /// <param name="number">Number of Bloons in this emission</param>
 /// <param name="spacing">Space between each bloon in this emission</param>
 public static Il2CppReferenceArray <BloonEmissionModel> CreateBloonEmissions(this GameModel model, BloonModel bloonModel, int number, float spacing)
 {
     return(model.CreateBloonEmissions(bloonModel.name, number, spacing));
 }
コード例 #28
0
 internal static void Postfix(BloonToSimulation __instance, UnityToSimulation sim,
                              ulong id, Vector3 position, float distanceTravelled, float pathTotalDistance, BloonModel def)
 {
     SessionData.bloonTracker.TrackBloonToSim(__instance);
 }
コード例 #29
0
 public NBloon(BloonModel bloonModel)
 {
     this.bloonModel = bloonModel;
 }
コード例 #30
0
 /// <summary>
 /// Get the next strongest bloon. Ex: the next strongest bloon after Red is Red Regrow
 /// </summary>
 /// <param name="bloon">The bloon id of the current bloon. Ex: Red</param>
 /// <param name="allowCamo">Is it okay if the next bloon is a camo bloon. Ex: Red => RedCamo</param>
 /// <param name="allowFortified">Is it okay if the next bloon is a Fortified bloon. Ex: Red => RedFortified</param>
 /// <param name="allowRegrow">Is it okay if the next bloon is a Regrow bloon. Ex: Red => RedRegrow</param>
 /// <returns>The next strongest bloon</returns>
 public static BloonModel GetNextStrongestBloon(BloonModel bloon, bool allowCamo = true,
                                                bool allowFortified = true, bool allowRegrow = true, bool ignoreException = false) => GetNextStrongestBloon(bloon.name,
                                                                                                                                                            allowCamo, allowFortified, allowRegrow, true);