private static void MainMenuTickTransitionInExitConfirm(float deltaTime, float fracComplete)
        {
            mainMenuExitConfirmQuestionString.SetAlpha(fracComplete);
            mainMenuExitConfirmYesString.SetAlpha(fracComplete);
            mainMenuExitConfirmNoString.SetAlpha(fracComplete);

            SetIdentTransitionAmount(fracComplete, false);
        }
        private static void MainMenuTickTransitionIn(float deltaTime, float fracComplete)
        {
            SetIdentTransitionAmount(1f - fracComplete, true);

            mainMenuELLogo.Scale = MAIN_MENU_EL_LOGO_TARGET_SCALE * Math.Min(fracComplete * 2f, 1f);

            float transition = MAIN_MENU_BUTTON_TRANSITION_HORIZONTAL_OFFSET * deltaTime;

            mainMenuPlayButtonL.AnchorOffset    = new Vector2(mainMenuPlayButtonL.AnchorOffset.X - transition, mainMenuPlayButtonL.AnchorOffset.Y);
            mainMenuPlayButtonR.AnchorOffset    = new Vector2(mainMenuPlayButtonR.AnchorOffset.X - transition, mainMenuPlayButtonR.AnchorOffset.Y);
            mainMenuMedalsButtonL.AnchorOffset  = new Vector2(mainMenuMedalsButtonL.AnchorOffset.X - transition, mainMenuMedalsButtonL.AnchorOffset.Y);
            mainMenuMedalsButtonR.AnchorOffset  = new Vector2(mainMenuMedalsButtonR.AnchorOffset.X - transition, mainMenuMedalsButtonR.AnchorOffset.Y);
            mainMenuOptionsButtonL.AnchorOffset = new Vector2(mainMenuOptionsButtonL.AnchorOffset.X - transition, mainMenuOptionsButtonL.AnchorOffset.Y);
            mainMenuOptionsButtonR.AnchorOffset = new Vector2(mainMenuOptionsButtonR.AnchorOffset.X - transition, mainMenuOptionsButtonR.AnchorOffset.Y);
            mainMenuExitButtonL.AnchorOffset    = new Vector2(mainMenuExitButtonL.AnchorOffset.X - transition, mainMenuExitButtonL.AnchorOffset.Y);
            mainMenuExitButtonR.AnchorOffset    = new Vector2(mainMenuExitButtonR.AnchorOffset.X - transition, mainMenuExitButtonR.AnchorOffset.Y);

            mainMenuPlayButtonL.SetAlpha(fracComplete);
            mainMenuPlayButtonR.SetAlpha(fracComplete);
            mainMenuMedalsButtonL.SetAlpha(fracComplete);
            mainMenuMedalsButtonR.SetAlpha(fracComplete);
            mainMenuOptionsButtonL.SetAlpha(fracComplete);
            mainMenuOptionsButtonR.SetAlpha(fracComplete);
            mainMenuExitButtonL.SetAlpha(fracComplete);
            mainMenuExitButtonR.SetAlpha(fracComplete);

            if (fracComplete >= 0.9f)
            {
                float finalTenthComplete = (fracComplete - 0.9f) * 10f;

                mainMenuPlayString.SetAlpha(MAIN_MENU_STRING_COLOR.W * finalTenthComplete);
                mainMenuMedalsString.SetAlpha(MAIN_MENU_STRING_COLOR.W * finalTenthComplete);
                mainMenuOptionsString.SetAlpha(MAIN_MENU_STRING_COLOR.W * finalTenthComplete);
                mainMenuExitString.SetAlpha(MAIN_MENU_STRING_COLOR.W * finalTenthComplete);
            }
            if (fracComplete >= 1f)
            {
                mainMenuButtonRingL.SetAlpha(MAIN_MENU_SELECTED_OPTION_ADORNMENTS_ALPHA);
                mainMenuButtonRingR.SetAlpha(MAIN_MENU_SELECTED_OPTION_ADORNMENTS_ALPHA);
                mainMenuButtonFrontL.SetAlpha(MAIN_MENU_SELECTED_OPTION_ADORNMENTS_ALPHA);
                mainMenuButtonFrontR.SetAlpha(MAIN_MENU_SELECTED_OPTION_ADORNMENTS_ALPHA);
                MainMenuSetSelectedButton(0);

                mainMenuStringExciter.CountPerSec       = 15;
                mainMenuStringExciter.OpacityMultiplier = 0.85f;
                mainMenuStringExciter.Speed             = 0.0025f;
                mainMenuStringExciter.ColorOverride     = (Vector3)MAIN_MENU_STRING_SELECTED_COLOR;
                mainMenuStringExciter.Lifetime          = 0.65f;
            }
        }
Пример #3
0
        private static void SetIdentTransitionAmount(float transitionAmount, bool goingDown)
        {
            if (goingDown)
            {
                transitionAmount = Math.Min(menuELLogoTex.Color.W, 1f - transitionAmount);
            }
            else
            {
                transitionAmount = Math.Max(menuELLogoTex.Color.W, transitionAmount);
            }

            menuELLogoTex.SetAlpha(transitionAmount);
            menuELLogoTex.AnchorOffset = new Vector2(EL_LOGO_TEX_TARGET_X + IDENT_TEX_STARTING_X_OFFSET * (1f - transitionAmount), menuELLogoTex.AnchorOffset.Y);

            menuIdentTex.SetAlpha(transitionAmount);
            menuIdentTex.AnchorOffset = new Vector2(EL_IDENT_TEX_TARGET_X + IDENT_TEX_STARTING_X_OFFSET * (1f - transitionAmount), menuIdentTex.AnchorOffset.Y);

            menuIdentString.SetAlpha(transitionAmount);
            menuIdentString.AnchorOffset = new Vector2(menuIdentString.AnchorOffset.X, EL_IDENT_STRING_TARGET_Y + IDENT_STRING_STARTING_Y_OFFSET * (1f - transitionAmount));

            worldIconTex.SetAlpha(Math.Min(1f - transitionAmount, WORLD_ICON_TARGET_ALPHA));
        }
Пример #4
0
        private static void Tick(float deltaTime)
        {
            if (deltaTime > 1f)
            {
                return;
            }
            lock (staticMutationLock) {
                if (currentMenuState == MenuState.InGame)
                {
                    return;
                }
                if (cameraLight != null)
                {
                    cameraLight.Position = AssetLocator.MainCamera.Position;
                }
                if (isTransitioning)
                {
                    transitionTimeElapsed += deltaTime;
                    if (transitionTimeElapsed >= transitionTime)
                    {
                        EndTransition(deltaTime - (transitionTimeElapsed - transitionTime));
                    }
                    if (currentMenuState == MenuState.InGame)
                    {
                        return;
                    }
                }
                else
                {
                    if (downKeyState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - downKeyState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - downKeyState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                downKeyState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerDownLocal = triggerDown;
                                if (triggerDownLocal != null)
                                {
                                    triggerDownLocal();
                                }
                            }
                        }
                    }
                    if (upKeyState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - upKeyState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - upKeyState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                upKeyState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerUpLocal = triggerUp;
                                if (triggerUpLocal != null)
                                {
                                    triggerUpLocal();
                                }
                            }
                        }
                    }
                    if (leftKeyState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - leftKeyState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - leftKeyState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                leftKeyState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerLeftLocal = triggerLeft;
                                if (triggerLeftLocal != null)
                                {
                                    triggerLeftLocal();
                                }
                            }
                        }
                    }
                    if (rightKeyState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - rightKeyState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - rightKeyState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                rightKeyState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerRightLocal = triggerRight;
                                if (triggerRightLocal != null)
                                {
                                    triggerRightLocal();
                                }
                            }
                        }
                    }
                    if (downLSState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - downLSState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - downLSState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                downLSState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerDownLocal = triggerDown;
                                if (triggerDownLocal != null)
                                {
                                    triggerDownLocal();
                                }
                            }
                        }
                    }
                    if (upLSState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - upLSState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - upLSState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                upLSState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerUpLocal = triggerUp;
                                if (triggerUpLocal != null)
                                {
                                    triggerUpLocal();
                                }
                            }
                        }
                    }
                    if (leftLSState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - leftLSState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - leftLSState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                leftLSState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerLeftLocal = triggerLeft;
                                if (triggerLeftLocal != null)
                                {
                                    triggerLeftLocal();
                                }
                            }
                        }
                    }
                    if (rightLSState.IsDown)
                    {
                        float timeSinceDepression = EntityModule.ElapsedTime - rightLSState.LastDepress;
                        if (timeSinceDepression >= Config.InitialRepeatTimeDelay)
                        {
                            float timeSinceLastTrigger = EntityModule.ElapsedTime - rightLSState.LastTrigger;
                            if (timeSinceLastTrigger >= Config.SuccessiveRepeatTimeDelay)
                            {
                                rightLSState.LastTrigger = EntityModule.ElapsedTime;
                                var triggerRightLocal = triggerRight;
                                if (triggerRightLocal != null)
                                {
                                    triggerRightLocal();
                                }
                            }
                        }
                    }
                }

                if (!inDeferenceMode)
                {
                    AssetLocator.MainCamera.Rotate(BACKDROP_ROT_QUAT.Subrotation(deltaTime));

                    var deadBits = activeSillyBits.RemoveWhere(sb => sb.Transform.Translation.Y < AssetLocator.MainCamera.Position.Y - SILLY_BIT_DROP_HEIGHT);
                    foreach (var deadBit in deadBits)
                    {
                        deadBit.Dispose();
                    }

                    float timeSinceLastBitDrop = EntityModule.ElapsedTime - lastSillyBitDrop;
                    if (timeSinceLastBitDrop >= SILLY_BIT_DROP_INTERVAL / Config.PhysicsLevel + sillyBitSpawnRandomExtra)
                    {
                        int            sillyBitIndex = RandomProvider.Next(0f, 1f) <= SILLY_BIT_IS_EGG_CHANCE ? -1 : RandomProvider.Next(0, AssetLocator.SillyBitsHandles.Length);
                        SillyBitEntity newBit        = new SillyBitEntity(sillyBitIndex);
                        newBit.SetGravity(GameplayConstants.GRAVITY_ACCELERATION * RandomProvider.Next(0.025f, 0.175f) * Vector3.DOWN);
                        newBit.AngularVelocity = new Vector3(
                            RandomProvider.Next(-MathUtils.PI, MathUtils.PI),
                            RandomProvider.Next(-MathUtils.PI, MathUtils.PI),
                            RandomProvider.Next(-MathUtils.PI, MathUtils.PI)
                            );
                        Vector3 lateralOffset =
                            AssetLocator.MainCamera.Orientation
                            * SILLY_BIT_DROP_FORWARD_OFFSET
                            * Quaternion.FromAxialRotation(
                                Vector3.DOWN,
                                RandomProvider.Next(
                                    -SILLY_BIT_DROP_CONE * (1f - SILLY_BIT_CAM_ROT_CONE_BIAS),
                                    SILLY_BIT_DROP_CONE * SILLY_BIT_CAM_ROT_CONE_BIAS
                                    )
                                );
                        newBit.SetTranslation(AssetLocator.MainCamera.Position + Vector3.UP * SILLY_BIT_DROP_HEIGHT + lateralOffset);

                        activeSillyBits.Add(newBit);

                        HUDSound.PostPassEggPop.Play(0.2f, RandomProvider.Next(0.5f, 1.5f));
                        lastSillyBitDrop         = EntityModule.ElapsedTime;
                        sillyBitSpawnRandomExtra = RandomProvider.Next(0f, MAX_RANDOM_SPAWN_EXTRA_TIME);
                    }

                    float timeSinceLastBitExplosion = EntityModule.ElapsedTime - lastSillyBitExplosion;
                    if (timeSinceLastBitExplosion >= SILLY_BIT_EXPLOSION_INTERVAL / Config.PhysicsLevel + sillyBitExplosionRandomExtra && activeSillyBits.Any())
                    {
                        var nonEggBits = activeSillyBits.Except(bit => bit.BitIndex == -1);
                        if (nonEggBits.Any())
                        {
                            var targetBit = nonEggBits.ElementAt(RandomProvider.Next(0, nonEggBits.Count()));
                            for (int i = 0; i < SILLY_BIT_EXPLOSION_SIZE; ++i)
                            {
                                Vector3 targetDir = new Vector3(
                                    RandomProvider.Next(-1f, 1f),
                                    RandomProvider.Next(-1f, 1f),
                                    RandomProvider.Next(-1f, 1f)
                                    );
                                if (targetDir == Vector3.ZERO)
                                {
                                    targetDir = AssetLocator.MainCamera.Orientation;
                                }

                                SillyBitEntity newBit = new SillyBitEntity(targetBit.BitIndex);
                                newBit.AngularVelocity = new Vector3(
                                    RandomProvider.Next(-MathUtils.PI, MathUtils.PI),
                                    RandomProvider.Next(-MathUtils.PI, MathUtils.PI),
                                    RandomProvider.Next(-MathUtils.PI, MathUtils.PI)
                                    );
                                newBit.SetTranslation(targetBit.Transform.Translation + targetDir.WithLength(PhysicsManager.ONE_METRE_SCALED * 0.1f));
                                newBit.Velocity = targetDir.WithLength(PhysicsManager.ONE_METRE_SCALED * 0.5f);
                                newBit.SetGravity(GameplayConstants.GRAVITY_ACCELERATION * RandomProvider.Next(0.025f, 0.175f) * Vector3.DOWN);

                                activeSillyBits.Add(newBit);
                            }
                            HUDSound.PostPassShowMenu.Play(RandomProvider.Next(0f, 0.5f), RandomProvider.Next(1.5f, 0.5f));
                        }


                        lastSillyBitExplosion        = EntityModule.ElapsedTime;
                        sillyBitExplosionRandomExtra = RandomProvider.Next(0f, MAX_RANDOM_EXPLOSION_EXTRA_TIME);
                    }

                    if (menuIdentTex.Color.W == 0f && worldIconTex.Color.W < WORLD_ICON_TARGET_ALPHA)
                    {
                        worldIconTex.AdjustAlpha(WORLD_ICON_ALPHA_PER_SEC * deltaTime);
                        if (worldIconTex.Color.W > WORLD_ICON_TARGET_ALPHA)
                        {
                            worldIconTex.SetAlpha(WORLD_ICON_TARGET_ALPHA);
                        }
                    }
                }

                if (versionString.Color.W < WORLD_ICON_TARGET_ALPHA)
                {
                    versionString.AdjustAlpha(WORLD_ICON_ALPHA_PER_SEC * deltaTime);
                    if (versionString.Color.W > WORLD_ICON_TARGET_ALPHA)
                    {
                        versionString.SetAlpha(WORLD_ICON_TARGET_ALPHA);
                    }
                }

                var transitionTickLocal = transitionTick;
                if (transitionTickLocal != null)
                {
                    transitionTickLocal(deltaTime, transitionTimeElapsed / transitionTime);
                }
                var tickLocal = tick;
                if (tickLocal != null)
                {
                    tickLocal(deltaTime);
                }
            }
        }