public void SetCarAbilities(bool singleRaceStarted)
        {
            CarLogic car = G.Sys.PlayerManager_.Current_.playerData_.CarLogic_;

            try
            {
                RandoMap map = randoGame.maps[Game.LevelName];
                if (!singleRaceStarted)
                {
                    jumpShouldBeEnabled  = map.jumpEnabled;
                    wingsShouldBeEnabled = map.wingsEnabled;
                    jetsShouldBeEnabled  = map.jetsEnabled;
                }
                car.Boost_.AbilityEnabled_ = map.boostEnabled;
                car.Jump_.AbilityEnabled_  = jumpShouldBeEnabled;
                car.Wings_.AbilityEnabled_ = wingsShouldBeEnabled;
                car.Jets_.AbilityEnabled_  = jetsShouldBeEnabled;

                // Disable stock show scores so we can display our own thing.
                car.CarLogicLocal_.PlayerDataLocal_.EnableOrDisableShowScores(false);

                Console.WriteLine($"Jump {car.Jump_.AbilityEnabled_} - Wings {car.Wings_.AbilityEnabled_} - Jets {car.Jets_.AbilityEnabled_}");
            }
            catch (KeyNotFoundException)
            {
                // this should only ever happen on Credits or Destination Unknown, so just enable everything
                car.Boost_.AbilityEnabled_ = true;
                car.Jump_.AbilityEnabled_  = true;
                car.Wings_.AbilityEnabled_ = true;
                car.Jets_.AbilityEnabled_  = true;
            }

            car.GetComponent <LocalPlayerControlledCar>().showBackToResetWarning_ = false;
        }
        public void UpdateAbilityState()
        {
            RandoMap map = randoGame.maps[Game.LevelName];
            CarLogic car = G.Sys.PlayerManager_.Current_.playerData_.CarLogic_;

            if (car.Jump_.AbilityEnabled_ && !map.jumpEnabled)
            {
                jumpShouldBeEnabled = true;
            }
            if (car.Wings_.AbilityEnabled_ && !map.wingsEnabled)
            {
                wingsShouldBeEnabled = true;
            }
            if (car.Jets_.AbilityEnabled_ && !map.jetsEnabled)
            {
                jetsShouldBeEnabled = true;
            }
        }
Пример #3
0
        internal static void OnGo(RandoGame randoGame)
        {
            if (Game.LevelName == "Enemy" || Game.LevelName == "Credits")
            {
                return;
            }

            RandoMap map = randoGame.maps[Game.LevelName];

            G.Sys.GameManager_.Level_.Settings_.disableBoosting_    = !map.boostEnabled;
            G.Sys.GameManager_.Level_.Settings_.disableJumping_     = !map.jumpEnabled;
            G.Sys.GameManager_.Level_.Settings_.disableFlying_      = !map.wingsEnabled;
            G.Sys.GameManager_.Level_.Settings_.disableJetRotating_ = !map.jetsEnabled;

            CarLogic car = G.Sys.PlayerManager_.Current_.playerData_.CarLogic_;

            /*car.Boost_.AbilityEnabled_ = map.boostEnabled;
             * car.Jump_.AbilityEnabled_ = map.jumpEnabled;
             * car.Wings_.AbilityEnabled_ = map.wingsEnabled;
             * car.Jets_.AbilityEnabled_ = map.jetsEnabled;*/

            randoGame.abilityState.jumpShouldBeEnabled  = map.jumpEnabled;
            randoGame.abilityState.wingsShouldBeEnabled = map.wingsEnabled;
            randoGame.abilityState.jetsShouldBeEnabled  = map.jetsEnabled;
            //car.GetComponent<HornGadget>().enabled = true;

            foreach (var obj in UnityEngine.Object.FindObjectsOfType <InfoDisplayLogic>())
            {
                if (obj.gameObject.name == "InfoDisplayBox" || obj.gameObject.name == "InfoAndIndicatorDisplayBox")
                {
                    GameObject.Destroy(obj.gameObject);
                }
                else
                {
                    obj.gameObject.RemoveComponent <InfoDisplayLogic>();
                }
            }

            foreach (var obj in UnityEngine.Object.FindObjectsOfType <WingCorruptionZone>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            foreach (var obj in UnityEngine.Object.FindObjectsOfType <AdventureAbilitySettings>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            if (map.abilityEnabled != Ability.None)
            {
                Console.WriteLine($"enables {map.abilityEnabled.ToString()}");
                SetAbilitiesTrigger[] triggers = GameObject.FindObjectsOfType <SetAbilitiesTrigger>();

                foreach (var trigger in triggers)
                {
                    if (!(trigger.visualsOnly_ || !trigger.showAbilityAlert_))
                    {
                        // replace default triggers with a custom solution
                        // (this is an attempt to fix shockingly inconsistent behaviour with the default triggers)
                        // (also it lets us have progressive ability icons!! cool!!)
                        var newTrigger = trigger.gameObject.AddComponent <RandomizerAbilityTrigger>();

                        if (map.abilityEnabled == Ability.Jump)
                        {
                            newTrigger.enableJumping     = true;
                            newTrigger.enableFlying      = randoGame.abilityState.wingsShouldBeEnabled;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = randoGame.abilityState.jetsShouldBeEnabled;
                        }
                        else if (map.abilityEnabled == Ability.Wings)
                        {
                            newTrigger.enableJumping     = randoGame.abilityState.jumpShouldBeEnabled;
                            newTrigger.enableFlying      = true;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = randoGame.abilityState.jetsShouldBeEnabled;
                        }
                        else if (map.abilityEnabled == Ability.Jets)
                        {
                            newTrigger.enableJumping     = randoGame.abilityState.jumpShouldBeEnabled;
                            newTrigger.enableFlying      = randoGame.abilityState.wingsShouldBeEnabled;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = true;
                        }
                        else if (map.abilityEnabled == Ability.Boost)
                        {
                            newTrigger.enableJumping     = randoGame.abilityState.jumpShouldBeEnabled;
                            newTrigger.enableFlying      = randoGame.abilityState.wingsShouldBeEnabled;
                            newTrigger.enableBoosting    = true;
                            newTrigger.enableJetRotating = randoGame.abilityState.jetsShouldBeEnabled;
                        }

                        trigger.gameObject.RemoveComponent <SetAbilitiesTrigger>();
                    }
                    else
                    {
                        GameObject.Destroy(trigger.gameObject);
                    }
                }
            }
            else
            {
                SetAbilitiesTrigger[] triggers = GameObject.FindObjectsOfType <SetAbilitiesTrigger>();

                foreach (var trigger in triggers)
                {
                    GameObject.Destroy(trigger.gameObject);
                }
            }
        }