public override void OnUpdate() { base.OnUpdate(); bool inAGame = InGame.instance != null && InGame.instance.bridge != null; if (inAGame) { if (InGame.instance.inputManager.SelectedTower != null) { lastSelected = InGame.instance.inputManager.SelectedTower; if (timer == 0) { timer = 0.001f; lastDamage = lastSelected.damageDealt; } timer += UnityEngine.Time.deltaTime; if (timer > 1) { timer = 0; Write("" + (lastSelected.damageDealt - lastDamage)); } } else { timer = 0; lastDamage = 0; if (upgradeTreeButton != null) { Write("UPGRADES"); } } } }
public static void Postfix(TSMThemeAmbidextrousRangs __instance, TowerToSimulation tower) { if (Game.instance.getProfileModel().HasPurchasedNamedMonkeys() == true) { Model towerModel = tower.tower.model; Dictionary <string, string> Names = Game.instance.getProfileModel().namedMonkeyNames; foreach (string key in Names.Keys) { string monkeyName = key.Replace("1", ""); if (towerModel.name.Contains(monkeyName)) { __instance.towerName.text = Names[key]; } else { foreach (string name in moreNames.Keys) { if (towerModel.name.Contains(name)) { __instance.towerName.text = moreNames[name]; } } } } } }
internal static bool Prefix(TowerToSimulation __instance, int pathIndex, Il2CppSystem.Action <bool> callback) { NTowerEntity towerEntity = new NTowerEntity(__instance.tower); var o = new TowerEvents.UpgradeEvent(towerEntity); //Create UpgradePatch instance EventRegistry.instance.DispatchEvent(ref o); //Dispatch it return(!o.IsCancelled()); }
internal static bool Prefix(TowerToSimulation __instance) { NTowerEntity towerEntity = new NTowerEntity(__instance.tower); var o = new TowerEvents.SelectedEvent(towerEntity); //Create SelectedPatch instance EventRegistry.instance.DispatchEvent(ref o); //Dispatch it return(!o.IsCancelled()); }
/// <summary> /// (Cross-Game compatible) Return the Tower associated with this TowerToSimulation /// </summary> /// <param name="towerToSim"></param> /// <returns></returns> public static Tower GetTower(this TowerToSimulation towerToSim) { #if BloonsTD6 return(towerToSim.tower); #elif BloonsAT return(InGame.instance.GetTowers().FirstOrDefault(t => t.GetTowerToSim().Equals(towerToSim))); #endif }
internal static void Prefix(TowerToSimulation tower) { if (tower.tower != null && Main.CurrentBoostIDs.ContainsKey(tower.tower.Id)) { RemoveBoostOn(Main.CurrentBoostIDs[tower.tower.Id]); Main.CurrentBoostIDs.Remove(tower.tower.Id); } }
internal static void Postfix(TSMThemeDefault __instance, TowerToSimulation tower) { if (tower.Def.GetModTower()?.ModTowerSet is ModTowerSet modTowerSet && !tower.IsParagon) { var texture = ResourceHandler.GetTexture(modTowerSet.PortraitReference.GUID); var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 5.4f, 0, SpriteMeshType.FullRect, new Vector4(22.5f, 22.5f, 22.5f, 22.5f)); __instance.towerBackgroundImage.sprite = sprite; } }
public static void Postfix(TSMThemeAmbidextrousRangs __instance, TowerToSimulation tower, TSMButton button) { if (tower.Def.name.Contains(TowerType.SuperMonkey) && tower.Def.tiers[0] >= 3 && tower.Def.tiers[0] < 5 && (button == __instance.leftHandButton || button == __instance.rightHandButton)) { SacrificesOff = !SacrificesOff; Utils.SetTexture(__instance.leftHandButton.transform.Find("Icon").GetComponent <Image>(), SacrificesOff ? "Off" : "On"); Utils.SetTexture(__instance.rightHandButton.transform.Find("Icon").GetComponent <Image>(), SacrificesOff ? "Off" : "On"); foreach (var key in TSMTheme_Patch.text.Keys) { TSMTheme_Patch.text[key].gameObject.SetActiveRecursively(!SacrificesOff); TSMTheme_Patch.icons[key].gameObject.SetActiveRecursively(!SacrificesOff); } } }
internal static void Postfix(TowerToSimulation tower) { if (tower.tower != null) { foreach (var boostingKey in Main.CurrentBoostIDs.Keys) { if (Main.CurrentBoostIDs[boostingKey] == tower.Id) { RemoveBoostOn(tower.Id); var engi = InGame.instance.GetTowerManager().GetTowerById(boostingKey); AddBoost(engi, tower.tower); break; } } } }
public static bool Prefix(TSMThemeEnergisingTotem __instance, TowerToSimulation tower, TSMButton button) { if (tower.worth > 0) { var cash = InGame.instance.bridge.simulation.cashManagers.entries[0].value.cash.Value; if (cash < Utils.RealRechargePrice()) { return(false); } InGame.instance.bridge.simulation.cashManagers.entries[0].value.cash.Value = cash - Utils.RealRechargePrice(); var mm = Game.instance.playerService.Player.Data.monkeyMoney.Value; Game.instance.playerService.Player.Data.monkeyMoney.Value = mm + 20; } return(true); }
public static void Postfix(TowerToSimulation tower) { if (SessionData.CurrentSession.IsCheating) { return; } if (!Settings.LoadedSettings.ApplyToHeros) { return; } if (tower.hero != null) { tower.hero.hero.heroModel.costPerXpToLevel /= 2; } }
public static void Prefix(TowerToSimulation tower) { var settings = Settings.LoadedSettings; if (!settings.ApplyToHeros) { return; } if (settings.CostMultiplier < 1) { settings.CostMultiplier = 1; } if (tower.hero != null) { tower.hero.hero.heroModel.costPerXpToLevel *= settings.CostMultiplier; } return; }
public static void Postfix(TSMThemeEnergisingTotem __instance, TowerToSimulation tower) { if (og == null) { og = __instance.rechargeCostText.m_text; color = __instance.rechargeCostText.color; outline = __instance.rechargeCostText.outlineColor; } if (tower.worth > 0) { __instance.rechargeCostText.SetText("$" + Utils.RealRechargePrice()); __instance.rechargeCostText.outlineColor = new Color32(0, 0, 0, 0); __instance.rechargeCostText.color = Color.white; if (!lastOpened) { __instance.rechargeButton.transform.GetChild(1).Translate(-5000, 0, 0); __instance.rechargeButton.transform.GetChild(1).GetChild(0).Translate(5000, 0, 0); __instance.rechargeButton.transform.GetChild(1).GetChild(1).Translate(4970, 0, 0); } lastOpened = true; } else { __instance.rechargeCostText.SetText(og); __instance.rechargeCostText.outlineColor = outline; __instance.rechargeCostText.color = color; if (lastOpened) { __instance.rechargeButton.transform.GetChild(1).Translate(5000, 0, 0); __instance.rechargeButton.transform.GetChild(1).GetChild(0).Translate(-5000, 0, 0); __instance.rechargeButton.transform.GetChild(1).GetChild(1).Translate(-4970, 0, 0); } lastOpened = false; } }
public override void OnUpdate() { base.OnUpdate(); if (Input.GetKeyDown(KeyCode.F1)) { independentRotation = !independentRotation; Console.WriteLine("independent rotation: " + independentRotation); } bool inAGame = InGame.instance != null && InGame.instance.bridge != null; if (inAGame) { if (InGame.instance.inputManager.SelectedTower != null) { lastSelected = InGame.instance.inputManager.SelectedTower; } if (lastSelected != null && lastSelected.tower != null) { speed *= 0.9f; if (Input.GetKey(KeyCode.UpArrow)) { speed = 2; } if (Input.GetKey(KeyCode.DownArrow)) { speed = -1.3f; } if (Input.GetKey(KeyCode.LeftArrow)) { if (!independentRotation) { lastSelected.tower.RotateTower(speed * 0.02f, true); } else { car.transform.RotateAround(new Vector3(0, 1, 0), speed * -0.02f); } } if (Input.GetKey(KeyCode.RightArrow)) { if (!independentRotation) { lastSelected.tower.RotateTower(speed * -0.02f, true); } else { car.transform.RotateAround(new Vector3(0, 1, 0), speed * 0.02f); } } if (independentRotation) { Vector3 towerpos = new Vector3(lastSelected.tower.Node.position.X, 0, lastSelected.tower.Node.position.Y); if ((car.transform.position - new Vector3(towerpos.x, 0, towerpos.z * -1)).magnitude > 5) { car.transform.rotation = Quaternion.Euler(0, convert(lastSelected.tower.Rotation), 0); car.transform.position = new Vector3(towerpos.x, 0, towerpos.z * -1); } car.transform.position += car.transform.forward * speed; lastSelected.tower.PositionTower(new Assets.Scripts.Simulation.SMath.Vector2(car.transform.position.x, -car.transform.position.z)); } else { float eulerlol = lastSelected.tower.Rotation; car.transform.rotation = Quaternion.Euler(0, eulerlol, 0); Vector3 towerpos = new Vector3(lastSelected.tower.Node.position.X, 0, lastSelected.tower.Node.position.Y); towerpos += car.transform.forward * speed; lastSelected.tower.PositionTower(new Assets.Scripts.Simulation.SMath.Vector2(towerpos.x, towerpos.z)); //for some reason towers live in an alternate universe where rotations and y positions are inverted car.transform.position = new Vector3(towerpos.x, 0, towerpos.z * -1); eulerlol = convert(eulerlol); car.transform.rotation = Quaternion.Euler(0, eulerlol, 0); } } else { car.transform.position = new Vector3(1000, 0, 0); speed = 0; } } }
private void SellTower(TowerToSimulation tower) => InGame.instance.SellTower(tower);
public override void OnUpdate() { base.OnUpdate(); //Input.GetAxis("Mouse X"); //Console.WriteLine(Input.GetAxis("Mouse X")); //Console.WriteLine(Input.GetAxis("Horizontal")); bool inAGame = InGame.instance != null && InGame.instance.bridge != null; if (inAGame) { //var towers = InGame.instance.bridge.GetAllTowers(); //if (towers.Count == 0) return; //if (towerID == towers.Count) towerID = 0; //var tower = towers[towerID]; //InGame.instance.sceneCamera.transform.position = new UnityEngine.Vector3(tower.position.x, 5, tower.tower.Node.position.Y); //InGame.instance.sceneCamera.transform.position -= InGame.instance.sceneCamera.transform.forward * 0.1f; //var old = tower.tower.Node.rotationQuat.EulerAngles; //var eu = new Vector3(old.x, old.y, old.z); //InGame.instance.sceneCamera.transform.rotation.SetEulerAngles(eu); //DartlingMuzzleFlash if (following) { if (InGame.instance.inputManager.SelectedTower != null) { lastSelected = InGame.instance.inputManager.SelectedTower; } if (lastSelected != null && lastSelected.tower != null) { //cam.transform.position = new Vector3(lastSelected.tower.Node.position.X, offset, lastSelected.tower.getPos().y+ Yoffset); cam.transform.position = new Vector3(lastSelected.tower.Node.position.X, offset, (lastSelected.tower.Node.position.Y * -1));// + Yoffset float eulerlol = lastSelected.tower.Rotation; if (eulerlol >= 0) { eulerlol = 180 - eulerlol; } else { eulerlol = -180 - eulerlol; } cam.transform.rotation = Quaternion.Euler(0, eulerlol, 0); } } if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F3)) { following = true; GameObject.Find("Scene").GetComponent <Camera>().enabled = false; if (cam == null) { cam = new GameObject();//GameObject.Instantiate(new GameObject(), new Vector3(5, 5, 5), Quaternion.identity); //cam.transform.position = new Vector3(0, 130, -90); //cam.transform.LookAt(new Vector3(0, 0, 0)); cam.AddComponent <Camera>(); cam.GetComponent <Camera>().orthographic = false; cam.GetComponent <Camera>().fieldOfView = 110; cam.name = "newcam"; //cam.tag = "MainCamera"; //InGame.instance.sceneCamera = cam.GetComponent<Camera>(); //GameObject.Find("Scene").GetComponent<Camera>().enabled = false; } } if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F2)) { following = false; //cam.transform.position = new Vector3(0, 130, -90); //cam.transform.LookAt(new Vector3(0, 0, 0)); GameObject.Find("Scene").GetComponent <Camera>().enabled = true; } if (Input.GetKey(KeyCode.Alpha4)) { if (Input.GetKey(KeyCode.LeftControl)) { offset += 0.12f; } else if (Input.GetKey(KeyCode.LeftShift)) { Yoffset += 0.12f; } else { lastSelected.tower.RotateTower(0.02f, true); } } if (Input.GetKey(KeyCode.Alpha5)) { if (Input.GetKey(KeyCode.LeftControl)) { offset -= 0.12f; } else if (Input.GetKey(KeyCode.LeftShift)) { Yoffset -= 0.12f; } else { lastSelected.tower.RotateTower(-0.02f, true); } } } }
/// <summary> /// (Cross-Game compatible) Return the Tower associated with this TowerToSimulation /// </summary> /// <param name="towerToSim"></param> /// <returns></returns> public static Tower GetTower(this TowerToSimulation towerToSim) { return(InGame.instance.GetTowers().FirstOrDefault(t => t.GetTowerSim().Equals(towerToSim))); }
public static void Postfix(TowerToSimulation tower) { tower.hero.hero.heroModel.costPerXpToLevel = heroUpgradeCost; }
public static void Postfix(TSMThemeAmbidextrousRangs __instance, TowerToSimulation tower) { if (text != null) { foreach (var key in text.Keys) { text[key].gameObject.SetActiveRecursively(false); icons[key].gameObject.SetActiveRecursively(false); } } if (tower.Def.name.Contains(TowerType.SuperMonkey) && tower.Def.tiers[0] >= 3 && tower.Def.tiers[0] < 5) { if (__instance.towerBackgroundImage.sprite == null) { if (magicSprite == null) { foreach (BaseTSMTheme t in TowerSelectionMenu.instance.themeManager.themes) { if (t.GetIl2CppType().IsAssignableFrom(Il2CppType.Of <TSMThemeDefault>())) { TSMThemeDefault td = t.Cast <TSMThemeDefault>(); if (td.magicSprite != null) { magicSprite = td.magicSprite; } } } } if (magicSprite != null) { __instance.magicSprite = magicSprite; ResourceLoader.LoadSpriteFromSpriteReferenceAsync(magicSprite, __instance.towerBackgroundImage, false); } } ; if (__instance.isMonkeyPortraitFlipped) { __instance.leftHandButton.gameObject.SetActive(false); __instance.rightHandButton.gameObject.SetActive(true); } else { __instance.rightHandButton.gameObject.SetActive(false); __instance.leftHandButton.gameObject.SetActive(true); } if (leftSprite == null && rightSprite == null) { leftSprite = __instance.leftHandButton.transform.Find("Icon").GetComponent <Image>().sprite; rightSprite = __instance.rightHandButton.transform.Find("Icon").GetComponent <Image>().sprite; } Utils.SetTexture(__instance.leftHandButton.transform.Find("Icon").GetComponent <Image>(), SacrificesOff ? "Off" : "On"); Utils.SetTexture(__instance.rightHandButton.transform.Find("Icon").GetComponent <Image>(), SacrificesOff ? "Off" : "On"); if (text == null) { text = new Dictionary <string, NK_TextMeshProUGUI> { ["Primary"] = Object.Instantiate(__instance.popCountText, __instance.transform, true), ["Military"] = Object.Instantiate(__instance.popCountText, __instance.transform, true), ["Magic"] = Object.Instantiate(__instance.popCountText, __instance.transform, true), ["Support"] = Object.Instantiate(__instance.popCountText, __instance.transform, true) }; icons = new Dictionary <string, GameObject> { ["Primary"] = Object.Instantiate(__instance.gameObject.transform.Find("TSMPopInfoDefault").Find("PopImage").gameObject, __instance.transform, true), ["Military"] = Object.Instantiate(__instance.gameObject.transform.Find("TSMPopInfoDefault").Find("PopImage").gameObject, __instance.transform, true), ["Magic"] = Object.Instantiate(__instance.gameObject.transform.Find("TSMPopInfoDefault").Find("PopImage").gameObject, __instance.transform, true), ["Support"] = Object.Instantiate(__instance.gameObject.transform.Find("TSMPopInfoDefault").Find("PopImage").gameObject, __instance.transform, true) }; float unit = __instance.popCountText.fontSize / 2; int i = -1; foreach (var key in icons.Keys) { Utils.SetTexture(icons[key].transform.GetComponent <Image>(), key); text[key].transform.Translate(0, i * unit, 0); icons[key].transform.Translate(0, i * unit, 0); i--; } } if (!SacrificesOff) { var worths = Utils.GetTowerWorths(tower.tower); var colors = Utils.GetColors(worths, tower.Def.tiers[0] == 4); foreach (var key in text.Keys) { text[key].gameObject.SetActiveRecursively(true); icons[key].gameObject.SetActiveRecursively(true); text[key].SetText( "$" + worths[key]); text[key].color = colors[key]; } } } else if (tower.Def.baseId == TowerType.BoomerangMonkey && leftSprite != null && rightSprite != null) { Utils.SetTexture(__instance.leftHandButton.transform.Find("Icon").GetComponent <Image>(), null, leftSprite); Utils.SetTexture(__instance.rightHandButton.transform.Find("Icon").GetComponent <Image>(), null, rightSprite); } }