Ejemplo n.º 1
0
        private void _UpdateSingleWaitRandom(WaitRandomData inputData, bool restoreOriginal = false)
        {
            if (inputData.cachedWaitRandom == null)
            {
                throw new NullReferenceException("No WaitRandom Action found on the FSM "
                                                 + inputData.FSMName + " in state " + inputData.FSMStateName);
            }
            float realFactor = (float)(((danceSpeed - 1.0) * (inputData.WaitTimeInverseFactor - 1.0)) + 1.0);

            if (!active || !speedModActive || restoreOriginal)
            {
                realFactor = 1.0f;
            }
            // Stop divide by zero.
            else if (realFactor <= epsilon)
            {
                throw new Exception("To prevent Playmaker undefined behavior," +
                                    " your speed factor must be greater than " +
                                    epsilon + ". But a dance speed of " + danceSpeed +
                                    " set it to " + realFactor);
            }

            inputData.cachedWaitRandom.timeMax = (inputData.defaultMaximum / realFactor);
            inputData.cachedWaitRandom.timeMin = (inputData.defaultMinimum / realFactor);
        }
Ejemplo n.º 2
0
        // Removes the WaitRandom from the list, if it exists. Returns true if it found and removed it.
        public bool RemoveWaitRandomData(WaitRandomData inputData)
        {
            if (!speedModifyWaitRandoms.Contains(inputData))
            {
                return(false);
            }

            _UpdateSingleWaitRandom(inputData, true);
            speedModifyWaitRandoms.Remove(inputData);
            return(true);
        }
Ejemplo n.º 3
0
 // The game doesn't load FsmFloats at the same time as gameobjects so sometimes you have to wait a little bit
 // to get the float values.
 private IEnumerator _WaitForWaitRandomTimeToBeLoaded(WaitRandomData inputData)
 {
     while (inputData.cachedWaitRandom.timeMax.Value <= epsilon)
     {
         yield return(null);
     }
     inputData.SetDefaultFloats(inputData.cachedWaitRandom.timeMin.Value, inputData.cachedWaitRandom.timeMax.Value);
     speedModifyWaitRandoms.Add(inputData);
     if (active && speedModActive)
     {
         _UpdateSingleWaitRandom(inputData);
     }
 }
Ejemplo n.º 4
0
        // Adds a WaitRandom to the list, stored in the struct format WaitRandomData. Use a constructor to build it.
        public void AddWaitRandomData(WaitRandomData inputData)
        {
            if (inputData.CustomGameObject == null)
            {
                inputData.CustomGameObject = gameObject;
            }


            if (inputData.cachedWaitRandom == null)
            {
                inputData.cachedWaitRandom =
                    _getOrCacheFSMWaitRandom(inputData.FSMStateName, inputData.FSMName,
                                             inputData.CustomGameObject, inputData.ElementIndex);
            }

            if (inputData.cachedWaitRandom == null)
            {
                throw new System.NullReferenceException("No WaitRandom Action found on the FSM "
                                                        + inputData.FSMName + " in state " + inputData.FSMStateName);
            }

            float tMax = inputData.cachedWaitRandom.timeMax.Value;

            if (tMax <= epsilon)
            {
                StartCoroutine(_WaitForWaitRandomTimeToBeLoaded(inputData));
            }
            else
            {
                inputData.SetDefaultFloats(inputData.cachedWaitRandom.timeMin.Value, tMax);
                speedModifyWaitRandoms.Add(inputData);

                if (active && speedModActive)
                {
                    _UpdateSingleWaitRandom(inputData);
                }
            }
        }