Esempio n. 1
0
        private void ParseVariablePause(string line, Variable variable)
        {
            ++currentIndex;

            var pauseElement = new PauseElement();

            if (line[currentIndex] == '_')
            {
                ++currentIndex;

                string numStr;

                currentIndex = ParserHelper.ReadNumber(line, currentIndex, true, out numStr);

                if (string.IsNullOrEmpty(numStr))
                {
                    throw new CompilationException($"'{line[currentIndex]}' isn't a number at {currentLine}:{currentIndex}");
                }

                pauseElement.Duration = PianoSettings.Instance().GetNoteDuration(GetDuration(numStr));
            }
            else if (line[currentIndex] == '@')
            {
                ++currentIndex;

                string varName;

                currentIndex = ParserHelper.ReadWord(line, currentIndex, out varName);

                if (string.IsNullOrEmpty(varName))
                {
                    throw new CompilationException($"Invalid variable name at {currentLine}:{currentIndex}");
                }

                pauseElement.WaitForVariable = varName;
            }
            else
            {
                string numStr;

                currentIndex = ParserHelper.ReadNumber(line, currentIndex, false, out numStr);

                if (string.IsNullOrEmpty(numStr))
                {
                    throw new CompilationException($"'{line[currentIndex]}' isn't a number at {currentLine}:{currentIndex}");
                }

                bool ok = double.TryParse(numStr, out pauseElement.Duration);

                if (!ok)
                {
                    throw new CompilationException($"'{numStr}' isn't a number at {currentLine}:{currentIndex}");
                }
            }

            variable.Elements.Add(pauseElement);
        }
Esempio n. 2
0
 bool IsPausedByInternal(string flag)
 {
     if (pauseInfo != null && pauseInfo.ContainsKey(flag))
     {
         PauseElement pe = pauseInfo[flag] as PauseElement;
         if (pe != null)
         {
             return(pe.timeScale == 0);
         }
     }
     return(false);
 }
Esempio n. 3
0
        // set timeScale for flag
        void SetTimeScaleInternal(string flag, float timeScale)
        {
            // Set pause info
            if (pauseInfo != null)
            {
                bool isContainKey = pauseInfo.ContainsKey(flag);
                if (!isContainKey)
                {
                    if (isAnyFlag)
                    {
                        AddPauseInfo(new string[] { flag });
                    }
                    else
                    {
                        return;
                    }
                }

                PauseElement pe = pauseInfo[flag] as PauseElement;
                if (pe != null)
                {
                    pe.timeScale = timeScale;
                }

                // Check flag
                float minTimeScale = 1;
                float maxTimeScale = 1;

                foreach (DictionaryEntry entry in pauseInfo)
                {
                    PauseElement pEle = entry.Value as PauseElement;
                    if (pEle != null)
                    {
                        minTimeScale = Mathf.Min(minTimeScale, pEle.timeScale);
                        maxTimeScale = Mathf.Max(maxTimeScale, pEle.timeScale);
                    }
                }

                // Set time scale
                if (maxTimeScale > 1)
                {
                    currTimeScale = maxTimeScale;
                }
                else
                {
                    currTimeScale = Mathf.Max(0, minTimeScale);
                }
                Time.timeScale = currTimeScale;
            }
        }
Esempio n. 4
0
        void DrawGUI()
        {
            if (!showDebug)
            {
                return;
            }

            GUILayout.Label(Time.timeScale.ToString());
            foreach (DictionaryEntry entry in pauseInfo)
            {
                PauseElement pEle = entry.Value as PauseElement;
                if (pEle != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label((string)entry.Key);
                    GUILayout.Label(" = " + pEle.timeScale);
                    GUILayout.EndHorizontal();
                }
            }
        }
Esempio n. 5
0
 public DelayManager(PauseElement pauseElement)
 {
     this.pauseElement = pauseElement;
     this.ConstructDelayDictionary();
 }
 public PauseBasedOnDistanceManagerImpl(PauseElement pauseElement)
 {
     PauseElement = pauseElement;
 }