示例#1
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);
     }
 }
示例#2
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);
                }
            }
        }