Esempio n. 1
0
 internal static void Patch(ref bool __result, Vector2 at, TowerModel tm)
 {
     if (TrackPowers.ContainsKey(tm.name))
     {
         var map = InGame.instance.UnityToSimulation.simulation.Map;
         __result = map.GetAllAreasOfTypeThatTouchPoint(at).ToArray()
                    .Any(area => area.areaModel.type == AreaType.track);
     }
 }
Esempio n. 2
0
        internal static void Postfix(InputManager __instance)
        {
            if (__instance.SelectedTower == null)
            {
                return;
            }

            if (!CurrentSession.MoveKeyHeld)
            {
                return;
            }

            var tower    = __instance.SelectedTower.GetSimTower();
            var mousePos = __instance.cursorPositionWorld;
            var newPos   = new Assets.Scripts.Simulation.SMath.Vector2(mousePos);

            tower.PositionTower(newPos);
        }
Esempio n. 3
0
            public static void Postfix()
            {
                bool inAGame = InGame.instance != null && InGame.instance.bridge != null;

                if (inAGame)
                {
                    //mousepos stuff
                    var v3 = UnityEngine.Input.mousePosition;
                    v3 = InGame.instance.sceneCamera.ScreenToWorldPoint(v3);
                    List <TowerToSimulation> towers = InGame.instance.bridge.GetAllTowers();
                    foreach (TowerToSimulation tts in towers)
                    {
                        Tower      tower      = tts.tower;
                        Pet        pet        = tower.Pet;
                        TowerModel towerModel = tower.towerModel;
                        float      x          = v3.x;
                        float      y          = v3.y * -2.3f;
                        if (pet != null)
                        {
                            Assets.Scripts.Simulation.SMath.Vector2 pos = new Assets.Scripts.Simulation.SMath.Vector2(x, y); // z wonky af
                            PetModel model = pet.petModel;
                            model.isFlying = false;
                            pet.petModel   = model;
                            pet.SetPosition(pos);
                        }


                        if (towerModel.tiers[0] == 1 && towerModel.tiers[1] == 0 && towerModel.tiers[2] == 0 && towerModel.baseId == TowerType.SuperMonkey)
                        {
                            //tts.tower.Node.graphic.transform.localScale = new UnityEngine.Vector3(0.001f, 0.001f, 0.001f);
                            if (tts != null && tts.tower != null && tts.tower.Node != null && tts.tower.Node.graphic != null && tts.tower.Node.graphic.transform != null)
                            {
                                tts.tower.Node.graphic.transform.localScale = new UnityEngine.Vector3(0.001f, 0.001f, 0.001f);
                            }


                            tower.PositionTower(new Assets.Scripts.Simulation.SMath.Vector2(x, y), false);
                        }
                    }
                }
            }
Esempio n. 4
0
        private static float MyGetTowerSetWorth(string towerSet, Tower tower)
        {
            float total = 0;

            var allTowers = InGame.instance.UnityToSimulation.GetAllTowers();

            foreach (var tts in allTowers)
            {
                if (tts.tower.towerModel.towerSet != towerSet || tower.Id == tts.tower.Id)
                {
                    continue;
                }
                var po1 = new Assets.Scripts.Simulation.SMath.Vector2(tts.tower.Position.X, tts.tower.Position.Y);
                var po2 = new Assets.Scripts.Simulation.SMath.Vector2(tower.Position.X, tower.Position.Y);
                if (po1.Distance(po2) < tower.towerModel.range)
                {
                    total += tts.worth;
                }
            }

            return(total);
        }
Esempio n. 5
0
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (InGame.instance != null)
            {
                if (InGame.instance.bridge != null)
                {
                    if (InGame.instance.bridge.GetAllBloons() != null)
                    {
                        bool foundBoss = false;
                        // Checks if the boss is active

                        try
                        {
                            foreach (Bloon bloon in InGame.instance.GetBloons())
                            {
                                //  Bloon bloon = InGame.instance.GetBloons();

                                if (bloon.bloonModel.name.Contains("Boss"))
                                {
                                    foundBoss = true;

                                    // Allows rounds to be sent even when the boss is active. Stopped working in v27

                                    bloon.spawnRound = 140;

                                    // Records all the boss's details for boss mechanics
                                    bloon.Scale.X     = bossScaleX;
                                    bloon.Scale.Y     = bossScaleY;
                                    bossPercTrack     = bloon.PercThroughMap();
                                    currentBossHealth = bloon.health;
                                    bossPosition      = bloon.Position.ToVector2();

                                    // If the boss reaches the end, moves it to the entrance and deducts lives, or game over if you dont have enough
                                    if (bossPercTrack > 0.98f)
                                    {
                                        bloon.Move(-bloon.path.Length);

                                        if (InGame.instance.GetHealth() < healthToLose)
                                        {
                                            InGame.instance.Lose();
                                        }
                                        else
                                        {
                                            InGame.instance.SetHealth(InGame.instance.GetHealth() - healthToLose);
                                            healthToLose += cycleIncrease;
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }


                        if (!foundBoss)
                        {
                            // If the boss isnt active, resets the health lost per cycle and sets the health to 0 to clear the display
                            healthToLose      = initialHealthToLose;
                            currentBossHealth = 0;
                        }
                    }
                }
            }
        }