コード例 #1
0
        /// <summary>
        /// Gets the base 0-0-0 TowerModel for this Tower
        ///
        /// Starts with the <see cref="BaseTower"/>, modifies its default properties as needed,
        /// then calls <see cref="CreateTowerModel"/> on it.
        ///
        /// </summary>
        /// <returns>The 0-0-0 TowerModel for this Tower</returns>
        internal TowerModel GetTowerModel()
        {
            if (towerModel == null)
            {
                towerModel = !string.IsNullOrEmpty(BaseTower)
                    ? Game.instance.model.GetTowerFromId(BaseTower).MakeCopy(Id)
                    : new TowerModel(Id, Id);

                towerModel.appliedUpgrades = new Il2CppStringArray(0);
                towerModel.upgrades        = new Il2CppReferenceArray <UpgradePathModel>(0);
                towerModel.towerSet        = TowerSet;
                towerModel.cost            = Cost;

                foreach (var defaultMod in DefaultMods)
                {
                    for (var i = 0; i < towerModel.mods.Count; i++)
                    {
                        var model = towerModel.mods[i];
                        if (model.name != defaultMod)
                        {
                            towerModel.mods = towerModel.mods.RemoveItem(model);
                            break;
                        }
                    }
                }
                towerModel.GetDescendants <Model>().ForEach(model =>
                {
                    model.name  = model.name.Replace(BaseTower, Name);
                    model._name = model._name.Replace(BaseTower, Name);
                });


                //towerModel.portrait = ;
                //towerModel.icon = ;
                //towerModel.display = ;
                //towerModel.GetBehavior<DisplayModel>().display =

                CreateTowerModel(towerModel);
            }

            return(towerModel);
        }