public static void ShowInputPopup(this VRCUiPopupManager vrcUiPopupManager, string title, string preFilledText, InputField.InputType inputType, bool keypad, string buttonText, Il2CppSystem.Action <string, List <KeyCode>, Text> buttonAction, Il2CppSystem.Action cancelAction, string boxText = "Enter text....", bool closeOnAccept = true, System.Action <VRCUiPopup> onCreated = null)
 {
     PopupManagerUtils.ShowUiInputPopup(title, preFilledText, inputType, keypad, buttonText, buttonAction, cancelAction, boxText, closeOnAccept, onCreated);
 }
Beispiel #2
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            bool inAGame = InGame.instance != null && InGame.instance.bridge != null;

            //this was a pain to add
            if (Input.GetMouseButtonDown(0) && inAGame && prevEffect == effects[30] && voteTimer < 15)
            {
                var v3 = Input.mousePosition;
                v3.z = camDist;
                v3   = InGame.instance.sceneCamera.ScreenToWorldPoint(v3);

                spawnTower(v3.x, TowerType.Sentry);
                towerPlaced = false;
            }


            if (inAGame)
            {
                voteTimer    += UnityEngine.Time.deltaTime;
                getChatTimer += UnityEngine.Time.deltaTime;
                grieferTimer += UnityEngine.Time.deltaTime;
                foreach (var item in InGame.instance.bridge.GetPlayerHeroes())
                {
                    selectedHero = item.Value;
                }
            }
            else
            {
                System.Console.WriteLine("get in a game to start the chaos mod");
                prevEffect = "none";
                options[0] = "nothing";
                voteTimer  = voteTimerMax;
            }
            if (grieferTimer > 0.1f)
            {
                grieferSpawning = false;
                grieferPlaced   = false;
            }


            //towers shoot half as fast for 20s, credit to hemidemisemipresent
            if (prevEffect == effects[27] && voteTimer < 10)
            {
                foreach (TowerToSimulation towerToSimulation in InGame.instance.bridge.GetAllTowers())
                {
                    StartOfRoundRateBuffModel rateBuffSORModel = new Assets.Scripts.Models.Towers.Behaviors.StartOfRoundRateBuffModel("69", 2f, 500000000000);
                    BehaviorMutator           rateBuffModel    = new Assets.Scripts.Models.Towers.Behaviors.StartOfRoundRateBuffModel.RateMutator(rateBuffSORModel);
                    towerToSimulation.tower.AddMutator(rateBuffModel, 600, true, true, false, true, false, false);
                }
                //prevEffect += " (applied)";
            }
            //camera spins
            if (prevEffect == effects[32] && voteTimer < 50)
            {
                var delta   = UnityEngine.Time.deltaTime;
                var change1 = UnityEngine.Mathf.Sin(camAngle) * 3f * (delta * 60);
                var change2 = UnityEngine.Mathf.Cos(camAngle) * 3f * (delta * 60);
                camPos += new Vector3(change1, change2, change2);
                InGame.instance.sceneCamera.transform.position = camPos;
                camAngle += delta * 0.55f;
                camAngle %= (3.1415f * 2);
                InGame.instance.sceneCamera.transform.LookAt(new UnityEngine.Vector3(0, 0, 0));
            }
            if (prevEffect == effects[32] && voteTimer > 50)
            {
                InGame.instance.sceneCamera.transform.position = new UnityEngine.Vector3(0, 0, 0);
                InGame.instance.sceneCamera.transform.rotation = UnityEngine.Quaternion.Euler(60, 0, 0);
            }
            //teleport everything to mouse
            if (prevEffect == effects[31] && voteTimer < 30)
            {
                var v3 = UnityEngine.Input.mousePosition;
                v3 = InGame.instance.sceneCamera.ScreenToWorldPoint(v3);
                var towers = InGame.instance.bridge.GetAllTowers();
                foreach (var tower in towers)
                {
                    float x = v3.x;
                    float y = v3.y * -2.3f;
                    tower.tower.PositionTower(new Assets.Scripts.Simulation.SMath.Vector2(x, y));
                }
            }
            else if (prevEffect == effects[31] && voteTimer > 30)
            {
                prevEffect += " (done)";
                MoveAllTowers();
            }
            //towers spin like a plane
            if (prevEffect == effects[29] + " (started)" && voteTimer < (voteTimerMax - 26))
            {
                var towers  = InGame.instance.bridge.GetAllTowers();
                var delta   = UnityEngine.Time.deltaTime;
                var change1 = Mathf.Sin(planeAngle) * 0.6f * (delta * 60);
                var change2 = Mathf.Cos(planeAngle) * 0.6f * (delta * 60);
                foreach (var tower in towers)
                {
                    float x = tower.position.x + change1;
                    float y = tower.tower.Node.position.Y - change2;
                    tower.tower.PositionTower(new Assets.Scripts.Simulation.SMath.Vector2(x, y));
                }
                planeAngle += delta * 0.55f;
                planeAngle %= (3.1415f * 2);
            }

            //towers spin
            if (prevEffect == effects[12] && voteTimer < (voteTimerMax - 5))
            {
                var towers = InGame.instance.bridge.GetAllTowers();
                foreach (var tower in towers)
                {
                    tower.tower.RotateTower(5, false);
                }
            }
            //reset 3x speed
            if (prevEffect == effects[10] && voteTimer > (voteTimerMax - 30))
            {
                var models = InGame.instance.bridge.Model.bloons;
                foreach (var model in models)
                {
                    model.Speed /= 3;
                }
                prevEffect += " (done)";
            }
            //reset 0.5x speed
            if (prevEffect == effects[11] && voteTimer > (voteTimerMax - 5))
            {
                var models = InGame.instance.bridge.Model.bloons;
                foreach (var model in models)
                {
                    model.Speed /= 0.5f;
                }
                prevEffect += " (done)";
            }
            //reset each bloon gets a random speed
            if (prevEffect == effects[9] && voteTimer > 55)
            {
                var orig   = Game.instance.model.bloons;
                var models = InGame.instance.bridge.Model.bloons;
                var i      = 0;
                foreach (var model in models)
                {
                    model.speed = orig[i].speed;
                    i++;
                }
                prevEffect += " (done)";
            }

            //spawn villages
            if (prevEffect == effects[33] && voteTimer < 3)
            {
                var x = ((float)random.NextDouble() - 0.5f) * 300f;
                spawnTower(x, TowerType.MonkeyVillage);
            }


            if (getChatTimer > 3.8)
            {
                if (twitchMode)
                {
                    try
                    {
                        chat = System.IO.File.ReadAllLines(chatFile);
                    }
                    catch
                    {
                    }
                }

                for (var i = prevChat; i < chat.Length; i++)
                {
                    var line = chat[i];
                    if (line == "1")
                    {
                        votes[0]++;
                    }
                    if (line == "2")
                    {
                        votes[1]++;
                    }
                    if (line == "3")
                    {
                        votes[2]++;
                    }
                }
                prevChat = chat.Length;

                if (voteTimer > voteTimerMax)
                {
                    if (votes[0] >= votes[1] && votes[0] >= votes[2])
                    {
                        prevEffect = options[0];
                    }
                    else if (votes[1] >= votes[0] && votes[1] >= votes[2])
                    {
                        prevEffect = options[1];
                    }
                    else
                    {
                        prevEffect = options[2];
                    }
                    //one time effects go here
                    try
                    {
                        //add 500 cash
                        if (prevEffect == effects[0])
                        {
                            InGame.instance.bridge.AddCash(500, Simulation.CashSource.Normal);
                        }
                        //start next round
                        if (prevEffect == effects[1])
                        {
                            InGame.instance.bridge.StartRaceRound();
                        }
                        //start next 3 rounds
                        if (prevEffect == effects[2])
                        {
                            InGame.instance.bridge.StartRaceRound();
                            InGame.instance.bridge.StartRaceRound();
                            InGame.instance.bridge.StartRaceRound();
                        }
                        //cash * 0.6
                        if (prevEffect == effects[3])
                        {
                            var cash = InGame.instance.bridge.GetCash() * 0.6;
                            InGame.instance.bridge.SetCash(cash);
                        }
                        //sell random tower
                        if (prevEffect == effects[4])
                        {
                            SellRandomTower();
                        }
                        //sell half of the towers
                        if (prevEffect == effects[5])
                        {
                            //var a = TowerUtils.GetTower(TowerType.PortableLake);

                            int sold   = 0;
                            var towers = InGame.instance.bridge.GetAllTowers();
                            foreach (var t in towers)
                            {
                                var name = Regex.Replace(t.tower.namedMonkeyKey, @"\d+", "");
                                name = name.Replace("Monkey", "");
                                System.Console.WriteLine(name);
                                if (canBeSold.Contains(name) && sold < towers.Count * 0.5)
                                {
                                    InGame.instance.SellTower(t);
                                    sold++;
                                }
                            }
                        }
                        //cash * 0.9
                        if (prevEffect == effects[6])
                        {
                            var cash = InGame.instance.bridge.GetCash() * 0.9;
                            InGame.instance.bridge.SetCash(cash);
                        }
                        //move random tower
                        if (prevEffect == effects[7])
                        {
                            var   towers = InGame.instance.bridge.GetAllTowers();
                            var   tower  = towers[random.Next(0, towers.Count)];
                            float x      = tower.position.x + (float)((random.NextDouble() > 0.5 ? 1 : -1) * (20 + (random.NextDouble() * 40)));
                            float y      = tower.tower.Node.position.Y + (float)((random.NextDouble() > 0.5 ? 1 : -1) * (20 + (random.NextDouble() * 40)));
                            tower.tower.PositionTower(new Assets.Scripts.Simulation.SMath.Vector2(x, y));
                        }
                        //move all towers
                        if (prevEffect == effects[8])
                        {
                            MoveAllTowers();
                        }
                        //each bloon gets a random speed
                        if (prevEffect == effects[9])
                        {
                            var models = InGame.instance.bridge.Model.bloons;
                            foreach (var model in models)
                            {
                                if (model.baseId != "Bfb" && model.baseId != "Zomg" && model.baseId != "Ddt" && model.baseId != "Bad")
                                {
                                    model.Speed = (((float)random.NextDouble()) * 95) + 40;
                                }
                            }
                        }
                        //3x speed
                        if (prevEffect == effects[10])
                        {
                            var models = InGame.instance.bridge.Model.bloons;
                            foreach (var model in models)
                            {
                                model.Speed *= 3;
                            }
                        }
                        //half speed
                        if (prevEffect == effects[11])
                        {
                            var models = InGame.instance.bridge.Model.bloons;
                            foreach (var model in models)
                            {
                                model.Speed *= 0.5f;
                            }
                        }
                        //towers spin happens each frame
                        if (prevEffect == effects[12])
                        {
                        }
                        //nothing effect
                        if (prevEffect == effects[13])
                        {
                        }
                        //reset all cooldowns
                        if (prevEffect == effects[14])
                        {
                            InGame.instance.bridge.ResetAbilityCooldowns(false);
                        }
                        //targeting to last
                        if (prevEffect == effects[15])
                        {
                            foreach (var t in InGame.instance.bridge.GetAllTowers())
                            {
                                string[] valid = new string[] {
                                    "Dart",
                                    "Boomerang",
                                    "BombShooter",
                                    "GlueGunner",
                                    "Sniper",
                                    "Sub",
                                    "Buccaneer",
                                    "Wizard",
                                    "Super",
                                    "Ninja",
                                    "Alchemist",
                                    "Druid",
                                    "Engineer",
                                };
                                var name = Regex.Replace(t.tower.namedMonkeyKey, @"\d+", "");
                                name = name.Replace("Monkey", "");
                                System.Console.WriteLine(name);
                                if (valid.Contains(name))
                                {
                                    t.tower.SetTargetType(TargetType.last);
                                }
                            }
                        }
                        //delete all bloons on screen
                        if (prevEffect == effects[16])
                        {
                            InGame.instance.DeleteAllBloons();
                        }
                        //camgrow fortified
                        if (prevEffect == effects[17])
                        {
                        }
                        //bloons randomly upgrade or take no dmg (30s)
                        if (prevEffect == effects[18])
                        {
                        }
                        //reset lives
                        if (prevEffect == effects[19])
                        {
                            InGame.instance.bridge.ResetHealth();
                        }
                        //spawnGriefer
                        if (prevEffect == "spawn Griefer Jones")
                        {
                            spawnGriefer();
                            prevEffect += " (done)";
                        }
                        //reset plane angle
                        if (prevEffect == effects[29])
                        {
                            planeAngle  = 0;
                            prevEffect += " (started)";
                        }
                        //camera spin
                        if (prevEffect == effects[32])
                        {
                            camPos   = new Vector3(-150, 0, -150);
                            camAngle = 0;
                        }

                        if (prevEffect == "Spawn Ceramic")
                        {
                            Il2CppReferenceArray <BloonEmissionModel> bme = new Il2CppReferenceArray <BloonEmissionModel>(1);
                            bme[0] = (new BloonEmissionModel("Ceramic", 1, "Ceramic"));
                            InGame.instance.bridge.SpawnBloons(bme, 38, 0);
                        }
                        if (prevEffect == "Spawn MOAB")
                        {
                            Il2CppReferenceArray <BloonEmissionModel> bme = new Il2CppReferenceArray <BloonEmissionModel>(1);
                            bme[0] = (new BloonEmissionModel("Moab", 1, "Moab"));
                            InGame.instance.bridge.SpawnBloons(bme, 40, 0);
                        }
                        if (prevEffect == "Spawn BFB")
                        {
                            Il2CppReferenceArray <BloonEmissionModel> bme = new Il2CppReferenceArray <BloonEmissionModel>(1);
                            bme[0] = (new BloonEmissionModel("Bfb", 1, "Bfb"));
                            InGame.instance.bridge.SpawnBloons(bme, 60, 0);
                        }
                        if (prevEffect == "Spawn ZOMG")
                        {
                            Il2CppReferenceArray <BloonEmissionModel> bme = new Il2CppReferenceArray <BloonEmissionModel>(1);
                            bme[0] = (new BloonEmissionModel("Zomg", 1, "Zomg"));
                            InGame.instance.bridge.SpawnBloons(bme, 80, 0);
                        }
                        if (prevEffect == "Spawn DDT")
                        {
                            Il2CppReferenceArray <BloonEmissionModel> bme = new Il2CppReferenceArray <BloonEmissionModel>(1);
                            bme[0] = (new BloonEmissionModel("Ddt", 1, "Ddt"));
                            InGame.instance.bridge.SpawnBloons(bme, 90, 0);
                        }
                        if (prevEffect == "Spawn BAD")
                        {
                            Il2CppReferenceArray <BloonEmissionModel> bme = new Il2CppReferenceArray <BloonEmissionModel>(1);
                            bme[0] = (new BloonEmissionModel("Bad", 1, "Bad"));
                            InGame.instance.bridge.SpawnBloons(bme, 100, 0);
                        }
                    }
                    catch
                    {
                        prevEffect += " (error)";
                    }



                    voteTimer = 0;
                    votes     = new int[] { 0, 0, 0 };

                    string[] temp = new string[effects.Length];
                    effects.CopyTo(temp, 0);
                    var tempEffects = temp.ToList();
                    int round       = InGame.instance.bridge.GetCurrentRound();
                    if (round > 10 && round < 40)
                    {
                        tempEffects.Add("Spawn Ceramic");
                    }
                    if (round > 30)
                    {
                        tempEffects.Add("Spawn MOAB");
                    }
                    if (round > 45)
                    {
                        tempEffects.Add("Spawn BFB");
                    }
                    if (round > 65)
                    {
                        tempEffects.Add("Spawn ZOMG");
                    }
                    if (round > 85)
                    {
                        tempEffects.Add("Spawn DDT");
                    }
                    if (round > 94)
                    {
                        tempEffects.Add("Spawn BAD");
                    }
                    if (selectedHero != TowerType.StrikerJones)
                    {
                        tempEffects.Add("spawn Griefer Jones");
                    }

                    //System.Console.WriteLine(tempEffects.Contains("spawn Griefer Jones"));

                    string[] r = tempEffects.OrderBy(x => random.Next()).ToArray();
                    options[0] = r[0];
                    options[1] = r[1];
                    options[2] = r[2];
                }


                //System.Console.SetCursorPosition(0, 0);
                //System.Console.Clear();
                var sb = new StringBuilder();
                if (twitchMode)
                {
                    sb.AppendLine(" \n \n \n  \n  \n  \n  \n  \n  \n  \n  \n  \n   \n  \n  \n  \n  \n  \n  \n  ");
                    sb.AppendLine("Last effect: " + prevEffect);
                    sb.AppendLine("Option 1: " + options[0] + " (" + votes[0] + " votes)");
                    sb.AppendLine("Option 2: " + options[1] + " (" + votes[1] + " votes)");
                    sb.AppendLine("Option 3: " + options[2] + " (" + votes[2] + " votes)");
                    sb.AppendLine("seconds left to vote: " + (voteTimerMax - voteTimer));
                }
                else
                {
                    sb.AppendLine(" \n \n \n  \n  \n  \n  \n  \n  \n  \n  \n  \n   \n  \n  \n  \n  \n  \n  \n  ");
                    sb.AppendLine("Last effect: " + prevEffect);
                    sb.AppendLine("Next effect: " + options[0]);
                    sb.AppendLine("Timer: " + (voteTimerMax - voteTimer));
                }
                System.Console.Write(sb);



                getChatTimer = 0;
            }


            if (Input.GetKeyDown(KeyCode.F8) && debug)
            {
                //options[0] = effects[29];
                Il2CppSystem.Action <int> deb = (Il2CppSystem.Action <int>) delegate(int eff)
                {
                    if (eff == 1337)
                    {
                        getChatTimer = -9999;
                    }
                    options[0] = effects[eff];
                };
                PopupScreen.instance.ShowSetValuePopup("Debug mode",
                                                       "which effect ?", deb, 1
                                                       );
            }

            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                twitchMode = true;
                System.Console.WriteLine("Twitch mode activated");
            }
        }