/// <summary>
        /// (Cross-Game compatible) Duplicate this TowerModel with a unique name. Very useful for making custom TowerModels
        /// </summary>
        /// <param name="towerModel"></param>
        /// <param name="newTowerId">Set's the new towerId of this copy. By default the baseId will be set to this as well</param>
        /// <returns></returns>
        internal static TowerModel MakeCopyInternal(TowerModel towerModel, string newTowerId)
        {
            var duplicate = towerModel.Duplicate();

            duplicate.name = newTowerId;
            return(duplicate);
        }
示例#2
0
        public static void EnableForTower(Tower tower, TowerModel towerModel)
        {
            CurrentTowerIDs.Add(tower.Id);

            var removeAbility = true;

            towerModel = towerModel.Duplicate();

            foreach (var upgrade in AllUpgrades.Keys)
            {
                if (tower.towerModel.appliedUpgrades.Contains(upgrade))
                {
                    if (upgrade == "Summon Phoenix")
                    {
                        foreach (var t2s in InGame.instance.UnityToSimulation.GetAllTowers())
                        {
                            if (t2s.tower.parentTowerId == tower.Id)
                            {
                                t2s.tower.Destroy();
                                break;
                            }
                        }
                    }
                    if (upgrade == "Wizard Lord Phoenix")
                    {
                        foreach (var t2s in InGame.instance.UnityToSimulation.GetAllTowers())
                        {
                            if (t2s.tower.parentTowerId == tower.Id)
                            {
                                if (t2s.tower.towerModel.baseId == "LordPhoenix")
                                {
                                    t2s.tower.Destroy();
                                }
                                else
                                {
                                    var lord    = Game.instance.model.GetTower(TowerType.WizardMonkey, tower.towerModel.tiers[0], 5, tower.towerModel.tiers[2]);
                                    var phoenix = lord.GetBehavior <TowerCreateTowerModel>().towerModel;
                                    t2s.tower.SetTowerModel(phoenix);
                                }
                            }
                        }
                    }

                    var methodName = upgrade.Replace(" ", "").Replace("'", "")
                                     .Replace("-", "").Replace(".", "");

                    var methodInfo = typeof(Towers).GetMethod(methodName);
                    if (methodInfo == null)
                    {
                        MelonLogger.Log("Couldn't find method " + methodName);
                    }
                    else
                    {
                        methodInfo.Invoke(null, new object[] { towerModel });
                    }

                    if (upgrade == "Supply Drop" || upgrade == "Elite Sniper" || upgrade == "Carpet of Spikes" ||
                        upgrade == "Support Chinook" || upgrade == "Special Poperations" || upgrade == "Overclock" ||
                        upgrade == "Ultraboost")
                    {
                        removeAbility = false;
                    }

                    break;
                }
            }

            if (removeAbility)
            {
                towerModel.behaviors = towerModel.behaviors.RemoveItemOfType <Model, AbilityModel>();
            }

            tower.SetTowerModel(towerModel);

            InGame.instance.bridge.OnAbilitiesChangedSim();
        }