コード例 #1
0
        /// <summary>
        /// On init we create an object pool if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (Active && CreateObjectPool && !_poolCreatedOrFound)
            {
                if (_objectPooler != null)
                {
                    _objectPooler.DestroyObjectPool();
                    owner.ProxyDestroy(_objectPooler.gameObject);
                }

                GameObject objectPoolGo = new GameObject();
                objectPoolGo.name = Owner.name + "_ObjectPooler";
                _objectPooler     = objectPoolGo.AddComponent <MMMiniObjectPooler>();
                _objectPooler.GameObjectToPool = GameObjectToInstantiate;
                _objectPooler.PoolSize         = ObjectPoolSize;
                _objectPooler.transform.SetParent(Owner.transform);
                _objectPooler.MutualizeWaitingPools = MutualizePools;
                _objectPooler.FillObjectPool();
                if ((Owner != null) && (objectPoolGo.transform.parent == null))
                {
                    SceneManager.MoveGameObjectToScene(objectPoolGo, Owner.gameObject.scene);
                }
                _poolCreatedOrFound = true;
            }
        }
コード例 #2
0
ファイル: MMF_Light.cs プロジェクト: zeelamageela/Hammer_Time
        /// <summary>
        /// On init we turn the light off if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (BoundLight == null)
            {
                return;
            }

            _initialRange          = BoundLight.range;
            _initialShadowStrength = BoundLight.shadowStrength;
            _initialIntensity      = BoundLight.intensity;

            if (EventOriginTransform == null)
            {
                EventOriginTransform = owner.transform;
            }

            if (Active)
            {
                if (StartsOff)
                {
                    Turn(false);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// On init, triggers the init events
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (Active && (InitializationEvents != null))
     {
         InitializationEvents.Invoke();
     }
 }
コード例 #4
0
ファイル: MMF_Scale.cs プロジェクト: zeelamageela/Hammer_Time
 /// <summary>
 /// On init we store our initial scale
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (Active && (AnimateScaleTarget != null))
     {
         GetInitialScale();
     }
 }
コード例 #5
0
        /// <summary>
        /// On init we store our initial alpha
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            _proxy         = Owner.gameObject.AddComponent <MMF_BroadcastProxy>();
            _proxy.Channel = Channel;
            PrepareTargets();
        }
コード例 #6
0
 /// <summary>
 /// On init we store our initial scale
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (Active && (SquashAndStretchTarget != null))
     {
         GetInitialScale();
     }
 }
コード例 #7
0
 /// <summary>
 /// On init we stop our particle system
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (StopSystemOnInit)
     {
         StopParticles();
     }
 }
コード例 #8
0
        /// <summary>
        /// On init we turn the light off if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (EventOriginTransform == null)
            {
                EventOriginTransform = owner.transform;
            }
        }
コード例 #9
0
ファイル: MMF_Pause.cs プロジェクト: zeelamageela/Hammer_Time
 /// <summary>
 /// On init we cache our wait for seconds
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     ScriptDrivenPause           = ScriptDriven;
     ScriptDrivenPauseAutoResume = AutoResume ? AutoResumeAfter : -1f;
     if (RandomizePauseDuration)
     {
         PauseDuration = Random.Range(MinPauseDuration, MaxPauseDuration);
     }
 }
コード例 #10
0
 static public void CopyAll(MMF_Player sourceFeedbacks)
 {
     CopiedFeedbacks.Clear();
     foreach (MMF_Feedback feedback in sourceFeedbacks.FeedbacksList)
     {
         Type         feedbackType = feedback.GetType();
         MMF_Feedback newFeedback  = (MMF_Feedback)Activator.CreateInstance(feedbackType);
         EditorUtility.CopySerializedManagedFieldsOnly(feedback, newFeedback);
         CopiedFeedbacks.Add(newFeedback);
     }
 }
コード例 #11
0
 /// <summary>
 /// On init, instantiates the particle system, positions it and nests it if needed
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     if (!Active)
     {
         return;
     }
     if (Mode == Modes.Cached)
     {
         InstantiateParticleSystem();
     }
 }
コード例 #12
0
        /// <summary>
        /// On init we store our initial color
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (TargetText == null)
            {
                return;
            }

            _initialColor = TargetText.color;
        }
コード例 #13
0
 /// <summary>
 /// On init we change the state of our Behaviour if needed
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (Active && (TargetBehaviour != null))
     {
         if (SetStateOnInit)
         {
             SetStatus(StateOnInit);
         }
     }
 }
コード例 #14
0
        /// <summary>
        /// On init we grab our initial softness
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (!Active)
            {
                return;
            }

            _initialSoftness = TargetTMPText.fontMaterial.GetFloat(ShaderUtilities.ID_FaceDilate);
        }
コード例 #15
0
        /// <summary>
        /// On init we store our initial alpha
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (TargetTMPText == null)
            {
                return;
            }

            _initialAlpha = TargetTMPText.alpha;
        }
コード例 #16
0
        /// <summary>
        /// Fires revert events if needed
        /// </summary>
        /// <param name="source"></param>
        public virtual void TriggerOnRevert(MMF_Player source)
        {
            if (!OnRevertIsNull && TriggerUnityEvents)
            {
                OnRevert.Invoke();
            }

            if (TriggerMMFeedbacksEvents)
            {
                MMF_PlayerEvent.Trigger(source, MMF_PlayerEvent.EventTypes.Revert);
            }
        }
コード例 #17
0
        /// <summary>
        /// Fires complete events if needed
        /// </summary>
        /// <param name="source"></param>
        public virtual void TriggerOnComplete(MMF_Player source)
        {
            if (!OnCompleteIsNull && TriggerUnityEvents)
            {
                OnComplete.Invoke();
            }

            if (TriggerMMFeedbacksEvents)
            {
                MMF_PlayerEvent.Trigger(source, MMF_PlayerEvent.EventTypes.Complete);
            }
        }
コード例 #18
0
        /// <summary>
        /// On init we turn the Graphic off if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (Active)
            {
                if (StartsOff)
                {
                    Turn(false);
                }
            }
        }
コード例 #19
0
 /// <summary>
 /// On init we grab our initial values on the target float controller
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     if (Active && (TargetFloatController != null))
     {
         _oneTimeDurationStorage              = TargetFloatController.OneTimeDuration;
         _oneTimeAmplitudeStorage             = TargetFloatController.OneTimeAmplitude;
         _oneTimeCurveStorage                 = TargetFloatController.OneTimeCurve;
         _oneTimeRemapMinStorage              = TargetFloatController.OneTimeRemapMin;
         _oneTimeRemapMaxStorage              = TargetFloatController.OneTimeRemapMax;
         _toDestinationCurveStorage           = TargetFloatController.ToDestinationCurve;
         _toDestinationDurationStorage        = TargetFloatController.ToDestinationDuration;
         _toDestinationValueStorage           = TargetFloatController.ToDestinationValue;
         _revertToInitialValueAfterEndStorage = TargetFloatController.RevertToInitialValueAfterEnd;
     }
 }
コード例 #20
0
        /// <summary>
        /// On init we turn the target property off if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            Target.Initialization(Owner.gameObject);
            _initialIntensity = Target.Level;

            if (Active)
            {
                if (StartsOff)
                {
                    Turn(false);
                }
            }
        }
コード例 #21
0
 /// <summary>
 /// On init we store our texture scale
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (UseMaterialPropertyBlocks)
     {
         _propertyBlock = new MaterialPropertyBlock();
         TargetRenderer.GetPropertyBlock(_propertyBlock);
         _propertyBlockVector.x = TargetRenderer.sharedMaterials[MaterialIndex].GetVector(MaterialPropertyName).w;
         _propertyBlockVector.y = TargetRenderer.sharedMaterials[MaterialIndex].GetVector(MaterialPropertyName).z;
         _initialValue.x        = TargetRenderer.sharedMaterials[MaterialIndex].GetVector(MaterialPropertyName).x;
         _initialValue.y        = TargetRenderer.sharedMaterials[MaterialIndex].GetVector(MaterialPropertyName).y;
     }
     else
     {
         _initialValue = TargetRenderer.materials[MaterialIndex].GetTextureScale(MaterialPropertyName);
     }
 }
コード例 #22
0
        /// <summary>
        /// On init we turn the Image off if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (EventOriginTransform == null)
            {
                EventOriginTransform = Owner.transform;
            }

            if (Active)
            {
                if (StartsOff)
                {
                    Turn(false);
                }
            }
        }
コード例 #23
0
ファイル: MMF_Sound.cs プロジェクト: zeelamageela/Hammer_Time
 /// <summary>
 /// Custom init to cache the audiosource if required
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     if (PlayMethod == PlayMethods.Cached)
     {
         _cachedAudioSource = CreateAudioSource(owner.gameObject, "CachedFeedbackAudioSource");
     }
     if (PlayMethod == PlayMethods.Pool)
     {
         // create a pool
         _pool = new AudioSource[PoolSize];
         for (int i = 0; i < PoolSize; i++)
         {
             _pool[i] = CreateAudioSource(owner.gameObject, "PooledAudioSource" + i);
         }
     }
 }
コード例 #24
0
        /// <summary>
        /// Custom Init
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);
            _triggerParameter = Animator.StringToHash(TriggerParameterName);
            _boolParameter    = Animator.StringToHash(BoolParameterName);
            _intParameter     = Animator.StringToHash(IntParameterName);
            _floatParameter   = Animator.StringToHash(FloatParameterName);

            _randomTriggerParameters = new List <int>();
            foreach (string name in RandomTriggerParameterNames)
            {
                _randomTriggerParameters.Add(Animator.StringToHash(name));
            }

            _randomBoolParameters = new List <int>();
            foreach (string name in RandomBoolParameterNames)
            {
                _randomBoolParameters.Add(Animator.StringToHash(name));
            }
        }
コード例 #25
0
        protected virtual void Initialization()
        {
            // Get properties
            TargetMmfPlayer  = target as MMF_Player;
            _mmfeedbacksList = serializedObject.FindProperty("FeedbacksList");
            _mmfeedbacksInitializationMode         = serializedObject.FindProperty("InitializationMode");
            _mmfeedbacksSafeMode                   = serializedObject.FindProperty("SafeMode");
            _mmfeedbacksAutoPlayOnStart            = serializedObject.FindProperty("AutoPlayOnStart");
            _mmfeedbacksAutoPlayOnEnable           = serializedObject.FindProperty("AutoPlayOnEnable");
            _mmfeedbacksDirection                  = serializedObject.FindProperty("Direction");
            _mmfeedbacksAutoChangeDirectionOnEnd   = serializedObject.FindProperty("AutoChangeDirectionOnEnd");
            _mmfeedbacksDurationMultiplier         = serializedObject.FindProperty("DurationMultiplier");
            _mmfeedbacksForceTimescaleMode         = serializedObject.FindProperty("ForceTimescaleMode");
            _mmfeedbacksForcedTimescaleMode        = serializedObject.FindProperty("ForcedTimescaleMode");
            _mmfeedbacksDisplayFullDurationDetails = serializedObject.FindProperty("DisplayFullDurationDetails");
            _mmfeedbacksCooldownDuration           = serializedObject.FindProperty("CooldownDuration");
            _mmfeedbacksInitialDelay               = serializedObject.FindProperty("InitialDelay");
            _mmfeedbacksCanPlayWhileAlreadyPlaying = serializedObject.FindProperty("CanPlayWhileAlreadyPlaying");
            _mmfeedbacksFeedbacksIntensity         = serializedObject.FindProperty("FeedbacksIntensity");
            _keepPlayModeChanges                   = serializedObject.FindProperty("KeepPlayModeChanges");
            _mmfeedbacksPerformanceMode            = serializedObject.FindProperty("PerformanceMode");
            _mmfeedbacksChanceToPlay               = serializedObject.FindProperty("ChanceToPlay");
            _expandGroupsInInspectors              = MMF_PlayerConfiguration.Instance.InspectorGroupsExpandedByDefault;

            _mmfeedbacksEvents = serializedObject.FindProperty("Events");

            // store GUI bg color
            _originalBackgroundColor = GUI.backgroundColor;

            PrepareFeedbackTypeList();

            foreach (KeyValuePair <int, MMF_FeedbackInspector> inspector in MMF_FeedbackInspectors)
            {
                inspector.Value.OnEnable();
            }

            // we force the styles to initialize on the next OnInspectorGUI call
            _cachedGUI = false;
        }
コード例 #26
0
        /// <summary>
        /// On init, we set our initial and destination positions (transform will take precedence over vector3s)
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);
            if (Active)
            {
                if (AnimatePositionTarget == null)
                {
                    Debug.LogWarning("The animate position target for " + this + " is null, you have to define it in the inspector");
                    return;
                }

                if (Space == Spaces.RectTransform)
                {
                    _rectTransform = AnimatePositionTarget.GetComponent <RectTransform>();
                }

                if (!DeterminePositionsOnPlay)
                {
                    DeterminePositions();
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// On init we turn the sprite renderer off if needed
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            base.CustomInitialization(owner);

            if (EventOriginTransform == null)
            {
                EventOriginTransform = Owner.transform;
            }

            if (Active)
            {
                if (StartsOff)
                {
                    Turn(false);
                }
            }

            if ((BoundSpriteRenderer != null) && (InitialColorMode == InitialColorModes.InitialColorOnInit))
            {
                _initialColor = BoundSpriteRenderer.color;
            }
        }
コード例 #28
0
 /// <summary>
 /// On init we initialize our number of loops left
 /// </summary>
 /// <param name="owner"></param>
 protected override void CustomInitialization(MMF_Player owner)
 {
     base.CustomInitialization(owner);
     InInfiniteLoop    = InfiniteLoop;
     NumberOfLoopsLeft = NumberOfLoops;
 }
コード例 #29
0
 static public void Trigger(MMF_Player source, EventTypes type)
 {
     OnEvent?.Invoke(source, type);
 }
コード例 #30
0
        /// <summary>
        /// On init we grab our initial color and components
        /// </summary>
        /// <param name="owner"></param>
        protected override void CustomInitialization(MMF_Player owner)
        {
            if (MaterialIndexes.Length == 0)
            {
                MaterialIndexes    = new int[1];
                MaterialIndexes[0] = 0;
            }

            _coroutines = new Coroutine[MaterialIndexes.Length];

            _initialFlickerColors = new Color[MaterialIndexes.Length];
            _propertyIDs          = new int[MaterialIndexes.Length];
            _propertiesFound      = new bool[MaterialIndexes.Length];
            _propertyBlock        = new MaterialPropertyBlock();

            if (Active && (BoundRenderer == null) && (owner != null))
            {
                if (Owner.gameObject.MMFGetComponentNoAlloc <Renderer>() != null)
                {
                    BoundRenderer = owner.GetComponent <Renderer>();
                }
                if (BoundRenderer == null)
                {
                    BoundRenderer = owner.GetComponentInChildren <Renderer>();
                }
            }

            if (BoundRenderer == null)
            {
                Debug.LogWarning("[MMFeedbackFlicker] The flicker feedback on " + Owner.name + " doesn't have a bound renderer, it won't work. You need to specify a renderer to flicker in its inspector.");
            }

            if (Active)
            {
                if (BoundRenderer != null)
                {
                    BoundRenderer.GetPropertyBlock(_propertyBlock);
                }
            }

            for (int i = 0; i < MaterialIndexes.Length; i++)
            {
                _propertiesFound[i] = false;

                if (Active && (BoundRenderer != null))
                {
                    if (Mode == Modes.Color)
                    {
                        _propertiesFound[i] = UseMaterialPropertyBlocks ? BoundRenderer.sharedMaterials[i].HasProperty(_colorPropertyName) : BoundRenderer.materials[i].HasProperty(_colorPropertyName);
                        if (_propertiesFound[i])
                        {
                            _initialFlickerColors[i] = UseMaterialPropertyBlocks ? BoundRenderer.sharedMaterials[i].color : BoundRenderer.materials[i].color;
                        }
                    }
                    else
                    {
                        _propertiesFound[i] = UseMaterialPropertyBlocks ? BoundRenderer.sharedMaterials[i].HasProperty(PropertyName) : BoundRenderer.materials[i].HasProperty(PropertyName);
                        if (_propertiesFound[i])
                        {
                            _propertyIDs[i]          = Shader.PropertyToID(PropertyName);
                            _initialFlickerColors[i] = UseMaterialPropertyBlocks ? BoundRenderer.sharedMaterials[i].GetColor(_propertyIDs[i]) : BoundRenderer.materials[i].GetColor(_propertyIDs[i]);
                        }
                    }
                }
            }
        }