Пример #1
0
        /// <summary>
        /// Called when [awake].
        /// </summary>
        private void Awake()
        {
            m_SyncedPosition = GetComponent <SyncedPosition>();
            m_ThemeManager   = GetComponent <ThemeManager>();

            // Subscribe to [player added] to get the synced rng seed
            Messenger.Instance.Subscribe <PlayerAddedMessage>(this, (sender, message) =>
            {
                var playerInfo = message.Player.GetComponent <PlayerInfo>();

                // Always get the seed from the first player
                if (playerInfo.PlayerIndex == 0)
                {
                    Random.seed = playerInfo.WorldSeed;
                }
            });

            // Subscribe to [effect changed] to handle [panic]
            Messenger.Instance.Subscribe <EffectChangedMessage>(this, (sender, message) =>
            {
                if (message.Effect == EffectType.Panic)
                {
                    m_Panic = message.Duration > 0;
                }
            });
        }
Пример #2
0
        /// <summary>
        /// Called when [awake].
        /// </summary>
        private void Awake()
        {
            m_SyncedPosition = GetComponent <SyncedPosition>();

            Shader.SetGlobalFloat("_FogMin", Fog.FogStart);
            Shader.SetGlobalFloat("_FogMax", Fog.FogEnd);

            // Subscribe to [effect changed] to handle [blind]
            Messenger.Instance.Subscribe <EffectChangedMessage>(this, (sender, message) =>
            {
                if (message.Effect == EffectType.Blind)
                {
                    // Choose fog params based on whether the [blind] effect is active or not
                    var fogMin = message.Duration > 0 ? BlindModeFog.FogStart : Fog.FogStart;
                    var fogMax = message.Duration > 0 ? BlindModeFog.FogEnd : Fog.FogEnd;

                    // Apply the params to the shader
                    Shader.SetGlobalFloat("_FogMin", fogMin);
                    Shader.SetGlobalFloat("_FogMax", fogMax);
                }
            });
        }