Example #1
0
        /// <summary>
        /// Returns if this TowerDetailModel is actually for a Hero
        /// </summary>
        public static bool IsHero(this TowerDetailsModel towerDetailsModel)
        {
            HeroDetailsModel heroDetailsModel = towerDetailsModel.TryCast <HeroDetailsModel>();
            bool             isHero           = heroDetailsModel != null;

            return(isHero);
        }
Example #2
0
        internal static void FinalizeHero(ModHero modHero)
        {
            Game.instance.GetLocalizationManager().textTable[modHero.Id + " Short Description"] =
                modHero.Title;
            Game.instance.GetLocalizationManager().textTable[modHero.Id + " Level 1 Description"] =
                modHero.Level1Description;

            var index = modHero.GetHeroIndex(Game.instance.model.heroSet
                                             .Select(model => model.Cast <HeroDetailsModel>()).ToList());

            if (index >= 0)
            {
                var heroDetailsModel =
                    new HeroDetailsModel(modHero.Id, index, 20, 1, 0, 0, 0, null, false);
                Game.instance.model.AddHeroDetails(heroDetailsModel, index);

                var skinModel = new HeroSkinModel(modHero.Id, modHero.ButtonReference, modHero.Id,
                                                  modHero.Id + " Short Description", modHero.Id + " Description", 0, true,
                                                  new Il2CppReferenceArray <SwapTowerSpriteModel>(0),
                                                  new Il2CppReferenceArray <SwapTowerGraphicModel>(0),
                                                  new Il2CppReferenceArray <SwapTowerSoundModel>(0), "Quincy",
                                                  new Il2CppReferenceArray <SpriteReference>(new[] { modHero.PortraitReference }),
                                                  new Il2CppStringArray(0),
                                                  SoundModel.blank, SoundModel.blank);

                Game.instance.model.skins = Game.instance.model.skins.AddTo(skinModel);
            }
        }
Example #3
0
        /// <summary>
        /// Adds a HeroDetailsModel to the GameModel's HeroSet at a particular index
        /// </summary>
        /// <param name="model"></param>
        /// <param name="heroDetailsModel"></param>
        /// <param name="index"></param>
        public static void AddHeroDetails(this GameModel model, HeroDetailsModel heroDetailsModel, int index)
        {
            var heroSet = model.heroSet.ToList();

            if (index < 0)
            {
                index = 0;
            }
            else if (index > heroSet.Count)
            {
                index = heroSet.Count;
            }
            heroSet.Insert(index, heroDetailsModel);
            model.heroSet = heroSet.ToArray();

            for (var i = 0; i < model.heroSet.Count; i++)
            {
                model.heroSet[i].towerIndex = i;
            }


            var towersIndex = index + model.towerSet.Count;

            if (towersIndex <= Game.towers.Count)
            {
                var towerList = Game.towers.ToList();
                towerList.Insert(towersIndex, heroDetailsModel.towerId);
                Game.towers = towerList.ToArray();
            }
        }