示例#1
0
 public BossState(BossController.States myState, TransitionDelegate transitions, System.Action update, System.Action start)
 {
     State          = myState;
     DoesTransition = transitions;
     Update         = update;
     Start          = start;
 }
示例#2
0
        public void transitScene(TScene scene)
        {
            if (transitionDelegate != null)
            {
                transitionDelegate(transitionStartTime + 100000);
            }

            nextScene           = (TScene)scene.clone();
            transitionStartTime = sw.ElapsedMilliseconds;
            transitionDelegate  = delegate(long time)
            {
                const int duration = 400; //ms
                int       elapsed  = (int)(time - transitionStartTime);
                if (elapsed >= duration / 2 && nextScene != null)
                {
                    changeScene(nextScene);
                    nextScene = null;
                }

                if (elapsed >= duration)
                {
                    elapsed            = duration;
                    transitionDelegate = null;
                }

                if (elapsed < duration / 2)
                {
                    currentScene.alpha = 1 - elapsed / (duration / 2f);
                }
                else
                {
                    currentScene.alpha = elapsed / (duration / 2f) - 1;
                }
            };
        }
示例#3
0
    private IEnumerator transitionOut(TransitionDelegate next = null)
    {
        Vector3 startScale = transform.localScale;
        Vector3 goalScale  = new Vector3(0, 0, 0);
        float   diff       = goalScale.x - startScale.x;
        float   startTime  = Time.time;

        while (true)
        {
            float percent = Mathf.Clamp01((Time.time - startTime) / m_transitionTime);
            if (percent == 1.0f)
            {
                transform.localScale = goalScale;
                break;
            }

            percent = m_outCurve.Evaluate(percent);
            float newScale = startScale.x + (percent * diff);
            transform.localScale = new Vector3(newScale, newScale, newScale);

            yield return(0);
        }

        if (next != null)
        {
            StartCoroutine(next());
        }

        yield break;
    }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StatesTransition"/> class.
 /// </summary>
 /// <param name="startState">The start state.</param>
 /// <param name="signal">The signal.</param>
 /// <param name="transitionDelegate">The transition delegate.</param>
 /// <param name="targetState">State of the target.</param>
 public StatesTransition(State startState, Signal signal, TransitionDelegate transitionDelegate, State targetState)
 {
     StartState = startState;
     Signal     = signal;
     TransitionDelegateMethod = transitionDelegate;
     TargetState = targetState;
 }
示例#5
0
        private void startDocument()
        {
            // default values
            bgmOn    = true;
            effectOn = true;
            voiceOn  = true;

            transitionDelegate  = null;
            transitionStartTime = 0;

            // sound emulator
            soundEmulator = new TSoundEmulator(document.libraryManager);

            // play document background
            playBGM(document.backgroundMusic, document.backgroundMusicVolume);


            // load prev button image
            try {
                int prevSceneButtonIndex = document.libraryManager.imageIndex(document.prevSceneButton);
                if (prevSceneButtonIndex == -1)
                {
                    imgPrevButton = TUtil.resizedImage(Properties.Resources.emulator_img_nav_prev, new Size(Program.NAVBUTTON_WIDTH, Program.NAVBUTTON_HEIGHT), Program.NAVBUTTON_STRETCH);
                }
                else
                {
                    imgPrevButton = TUtil.resizedImage(Image.FromFile(document.libraryManager.imageFilePath(prevSceneButtonIndex)), new Size(Program.NAVBUTTON_WIDTH, Program.NAVBUTTON_HEIGHT), Program.NAVBUTTON_STRETCH);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                imgPrevButton = TUtil.resizedImage(Properties.Resources.emulator_img_nav_prev, new Size(Program.NAVBUTTON_WIDTH, Program.NAVBUTTON_HEIGHT), Program.NAVBUTTON_STRETCH);
            }

            // load next button image
            try {
                int nextSceneButtonIndex = document.libraryManager.imageIndex(document.nextSceneButton);
                if (nextSceneButtonIndex == -1)
                {
                    imgNextButton = TUtil.resizedImage(Properties.Resources.emulator_img_nav_next, new Size(Program.NAVBUTTON_WIDTH, Program.NAVBUTTON_HEIGHT), Program.NAVBUTTON_STRETCH);
                }
                else
                {
                    imgNextButton = TUtil.resizedImage(Image.FromFile(document.libraryManager.imageFilePath(nextSceneButtonIndex)), new Size(Program.NAVBUTTON_WIDTH, Program.NAVBUTTON_HEIGHT), Program.NAVBUTTON_STRETCH);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                imgNextButton = TUtil.resizedImage(Properties.Resources.emulator_img_nav_next, new Size(Program.NAVBUTTON_WIDTH, Program.NAVBUTTON_HEIGHT), Program.NAVBUTTON_STRETCH);
            }


            // initial scene
            changeScene(document.currentScene());

            // start timer
            bStepFlag  = true;
            threadStep = new Thread(new ThreadStart(step));
            threadStep.SetApartmentState(System.Threading.ApartmentState.STA);
            threadStep.Start();
        }
示例#6
0
 public void Add(TransitionDelegate transition)
 {
     if (transition == null)
     {
         throw new ArgumentNullException("transition");
     }
     this.List.Add(transition);
 }
示例#7
0
 public bool Contains(TransitionDelegate transition)
 {
     if (transition == null)
     {
         throw new ArgumentNullException("transition");
     }
     return(this.List.Contains(transition));
 }
    public void TransitionScene(int level, bool showLoading, TransitionDelegate transitionDelegate, Action callback)
    {
        // Set level
        _level         = level;
        _levelName     = "";
        _isShowLoading = showLoading;

        TransitionScene(transitionDelegate, callback);
    }
    public void TransitionScene(string levelName, bool showLoading, TransitionDelegate transitionDelegate, Action callback)
    {
        // Set level
        _level         = -1;
        _levelName     = levelName;
        _isShowLoading = showLoading;

        TransitionScene(transitionDelegate, callback);
    }
示例#10
0
    void TransitionScene(TransitionDelegate transitionDelegate, Action callback)
    {
        _isTransitionFinished = false;

        // Active this object
//		gameObject.SetActive(true);

        // Start transition
        StartCoroutine(Transition(transitionDelegate, callback));
    }
示例#11
0
 private IEnumerator switchToNone(TransitionDelegate next = null)
 {
     if (next != null)
     {
         Debug.LogWarning("Ignoring next function Time = " + Time.time);
     }
     //Debug.Log ("switchToNone Time = " + Time.time);
     m_activeObject = null;
     m_joyballIcon.GetComponent <Renderer>().enabled       = false;
     m_constellationIcon.GetComponent <Renderer>().enabled = false;
     m_grabIcons.GetComponent <Renderer>().enabled         = false;
     yield break;
 }
示例#12
0
    private IEnumerator switchToJoyball(TransitionDelegate next = null)
    {
        if (next != null)
        {
            Debug.LogWarning("Ignoring next function");
        }

        m_activeObject = m_joyballIcon;
        m_joyballIcon.GetComponent <Renderer>().enabled       = true;
        m_constellationIcon.GetComponent <Renderer>().enabled = false;
        StartCoroutine(transitionIn());
        yield break;
    }
示例#13
0
            public bool MoveNext()
            {
                if (!this.transitions.MoveNext())
                {
                    this.current = null;
                    return(false);
                }

                TransitionDelegate transition = (TransitionDelegate)this.transitions.Current;

                this.current = (IEdge)transition.DynamicInvoke(new Object[] { this.vertex });
                return(true);
            }
示例#14
0
        public void AddArc(int fromState, int toState, TransitionDelegate <TInput, TRegister> arc)
        {
            if (!this._transitionInfo.ContainsKey(fromState))
            {
                this._transitionInfo.Add(fromState, new Dictionary <int, TransitionDelegate <TInput, TRegister> >());
            }

            if (!this._transitionInfo[fromState].ContainsKey(toState))
            {
                this._transitionInfo[fromState].Add(toState, arc);
            }
            else
            {
                this._transitionInfo[fromState][toState] = arc;
            }
        }
 private DeterministicParser(
     IProducer <TNode> producer,
     RuntimeGrammar grammar,
     TransitionDelegate actionTable,
     ResourceAllocator allocator,
     ILogging logging,
     TaggedStack <TNode> stateStack)
 {
     this.producer    = producer;
     this.grammar     = grammar;
     this.rules       = grammar.Productions.ToArray();
     this.actionTable = actionTable;
     this.allocator   = allocator;
     this.logging     = logging;
     this.stateStack  = stateStack;
 }
 public DeterministicParser(
     IProducer <TNode> producer,
     RuntimeGrammar grammar,
     TransitionDelegate actionTable,
     ResourceAllocator allocator,
     ILogging logging
     )
     : this(
         producer,
         grammar,
         actionTable,
         allocator,
         logging,
         new TaggedStack <TNode>(InitialValueStackSize))
 {
     this.Reset();
 }
示例#17
0
        public ElkhoundGlrParser(
            object context,
            BnfGrammar grammar,
            TransitionDelegate transition,
            GrammarActionDelegate grammarAction,
            int[]                 stateToPriorToken,
            int[]                   conflictActionsTable,
            Func <object, int, IReciever <Msg>, IReciever <Msg> > makeSwitch)
        {
            this.context              = context;
            this.grammar              = grammar;
            this.grammarAction        = grammarAction;
            this.transition           = transition;
            this.stateToPriorToken    = stateToPriorToken;
            this.conflictActionsTable = conflictActionsTable;
            this.gss = new Gss();

            gss.AddTopmost(0);
        }
示例#18
0
 public RnGlrParser(
     RuntimeGrammar grammar,
     int[]               tokenComplexity,
     TransitionDelegate transition,
     int[]               stateToPriorToken,
     int[]               conflictActionsTable,
     IProducer <T> producer,
     ResourceAllocator allocator,
     ILogging logging)
     : this(
         grammar,
         tokenComplexity,
         transition,
         stateToPriorToken,
         conflictActionsTable,
         producer,
         allocator,
         logging,
         new Gss <T>(stateToPriorToken.Length + grammar.Productions.Count))
 {
 }
示例#19
0
        /// <summary>
        /// Adds an arc to the AFA.
        /// </summary>
        /// <param name="fromState">The state from which the arc begins.</param>
        /// <param name="toState">The state at which the arc ends.</param>
        /// <param name="arc">The arc, defined as a method.</param>
        public void AddArc(int fromState, int toState, TransitionDelegate <TInput, TRegister> arc)
        {
            if (IsFinalState(fromState))
            {
                throw new InvalidOperationException(string.Format("AFA cannot have outgoing arcs from final state {0}.", fromState));
            }

            if (!this._transitionInfo.ContainsKey(fromState))
            {
                this._transitionInfo.Add(fromState, new Dictionary <int, TransitionDelegate <TInput, TRegister> >());
            }

            if (!this._transitionInfo[fromState].ContainsKey(toState))
            {
                this._transitionInfo[fromState].Add(toState, arc);
            }
            else
            {
                this._transitionInfo[fromState][toState] = arc;
            }
        }
示例#20
0
    private IEnumerator transitionIn(TransitionDelegate next = null)
    {
        if (m_activeObject == null) // Nothing rendering to fade out.
        {
            if (next != null)
            {
                StartCoroutine(next());
            }
            yield break;
        }

        Vector3 startScale = transform.localScale;
        Vector3 goalScale  = new Vector3(1, 1, 1);
        float   diff       = goalScale.x - startScale.x;
        float   startTime  = Time.time;

        while (true)
        {
            float percent = Mathf.Clamp01((Time.time - startTime) / m_transitionTime);

            if (percent == 1.0f)
            {
                transform.localScale = goalScale;
                break;
            }

            percent = m_inCurve.Evaluate(percent);
            float newScale = startScale.x + (percent * diff);
            transform.localScale = new Vector3(newScale, newScale, newScale);

            yield return(0);
        }

        if (next != null)
        {
            StartCoroutine(next());
        }

        yield break;
    }
示例#21
0
        private RnGlrParser(
            RuntimeGrammar grammar,
            int[]               tokenComplexity,
            TransitionDelegate transition,
            int[]               stateToPriorToken,
            int[]               conflictActionsTable,
            IProducer <T> producer,
            ResourceAllocator allocator,
            ILogging logging,
            Gss <T> gss)
        {
            this.grammar              = grammar;
            this.tokenComplexity      = tokenComplexity;
            this.transition           = transition;
            this.stateToPriorToken    = stateToPriorToken;
            this.conflictActionsTable = conflictActionsTable;
            this.gss        = gss;
            this.nodeBuffer = new T[grammar.MaxRuleSize];
            this.producer   = producer;
            this.allocator  = allocator;
            this.logging    = logging;

            this.pendingReductions = new ModifiedReduction[grammar.Productions.Count];

            switch (producer.ReductionOrder)
            {
            case ReductionOrder.Unordered:
            {
                this.R = new ReductionQueue <T>();
                break;
            }

            case ReductionOrder.ByRuleDependency:
            {
                this.R = new ReductionPathQueue <T>(tokenComplexity, grammar);
                break;
            }
            }
        }
 private void Start()
 {
     m_TransitionDelegate = Transition.GetTransitionDelegate (transition);
 }
示例#23
0
 /// <summary>
 /// Allows an operation to be invoked on transition
 /// </summary>
 /// <param name="transitionAction">The operation to be invoked on transition</param>
 /// <returns>A IStateMachineOnTransition to allow for further transitions</returns>
 public IStateMachineOnTransition <T> OnTransition(TransitionDelegate transitionAction)
 {
     onTransition += transitionAction;
     return(this);
 }
 public void Add(TransitionDelegate transition)
 {
     if (transition == null)
         throw new ArgumentNullException("transition");
     this.List.Add(transition);
 }
示例#25
0
    private IEnumerator switchToJoyball(TransitionDelegate next = null)
    {
        if ( next != null ) {
          Debug.LogWarning("Ignoring next function");
        }

        m_activeObject = m_joyballIcon;
        m_joyballIcon.GetComponent<Renderer>().enabled = true;
        m_constellationIcon.GetComponent<Renderer>().enabled = false;
        StartCoroutine(transitionIn());
        yield break;
    }
 public bool Contains(TransitionDelegate transition)
 {
     if (transition == null)
         throw new ArgumentNullException("transition");
     return this.List.Contains(transition);
 }
示例#27
0
 /// <summary>
 /// Specify additional IStateMachineOnTransition operations to execute on transition
 /// </summary>
 /// <param name="transitionAction">The operation to be invoked on transition</param>
 /// <returns>A IStateMachineOnTransition to allow for further transitions</returns>
 public IStateMachineOnTransition <T> Then(TransitionDelegate transitionAction)
 {
     return(OnTransition(transitionAction));
 }
示例#28
0
 public static LexicalPair CreateLexicalFunc(string abbr, TransitionDelegate transitionDelegate)
 => (abbr, transitionDelegate);
示例#29
0
 private IEnumerator switchToNone(TransitionDelegate next = null)
 {
     if ( next != null ) {
       Debug.LogWarning("Ignoring next function Time = " + Time.time);
     }
     //Debug.Log ("switchToNone Time = " + Time.time);
     m_activeObject = null;
     m_joyballIcon.GetComponent<Renderer>().enabled = false;
     m_constellationIcon.GetComponent<Renderer>().enabled = false;
     m_grabIcons.GetComponent<Renderer>().enabled = false;
     yield break;
 }
示例#30
0
    private IEnumerator transitionOut(TransitionDelegate next = null)
    {
        Vector3 startScale = transform.localScale;
        Vector3 goalScale = new Vector3(0,0,0);
        float diff = goalScale.x - startScale.x;
        float startTime = Time.time;

        while( true ) {
          float percent = Mathf.Clamp01((Time.time - startTime) / m_transitionTime);
          if ( percent == 1.0f ) {
        transform.localScale = goalScale;
        break;
          }

          percent = m_outCurve.Evaluate(percent);
          float newScale = startScale.x + (percent * diff);
          transform.localScale = new Vector3(newScale, newScale, newScale);

          yield return 0;
        }

        if ( next != null ) {
          StartCoroutine(next());
        }

        yield break;
    }
示例#31
0
    private IEnumerator transitionIn(TransitionDelegate next = null)
    {
        if ( m_activeObject == null ) { // Nothing rendering to fade out.
          if ( next != null ) {
        StartCoroutine(next());
          }
          yield break;
        }

        Vector3 startScale = transform.localScale;
        Vector3 goalScale = new Vector3(1,1,1);
        float diff = goalScale.x - startScale.x;
        float startTime = Time.time;

        while( true ) {
          float percent = Mathf.Clamp01((Time.time - startTime) / m_transitionTime);

          if ( percent == 1.0f ) {
        transform.localScale = goalScale;
        break;
          }

          percent = m_inCurve.Evaluate(percent);
          float newScale = startScale.x + (percent * diff);
          transform.localScale = new Vector3(newScale, newScale, newScale);

          yield return 0;
        }

        if ( next != null ) {
          StartCoroutine(next());
        }

        yield break;
    }
示例#32
0
    IEnumerator Transition(TransitionDelegate transitionDelegate, Action callback)
    {
        yield return(new WaitForEndOfFrame());

        // Set texture
        _material.mainTexture = transitionDelegate.GetTexture() ?? TextureHelper.GetScreenshot();

        // Disable main camera
        GameObject mainCamera = GameObject.FindGameObjectWithTag("MainCamera");

        if (mainCamera != null)
        {
            mainCamera.GetComponent <Camera>().enabled = false;
        }

        // Disable canvas
        Canvas canvas = GameObject.FindGameObjectWithTag("MainCanvas").GetComponent <Canvas>();

        if (canvas != null && canvas.gameObject != null)
        {
            canvas.gameObject.SetActive(false);
        }

        // Set mesh
        _meshFilter.mesh = transitionDelegate.GetMesh() ?? _cameraMesh;

        // Set material
        _material.shader = transitionDelegate.GetShader() ?? GetShader("Transitions/Texture With Alpha");
        _material.color  = Color.white;

        // Enable camera
        _camera.enabled = true;

        // Enable mesh renderer
        _meshRenderer.enabled = true;

        // Play transition
        yield return(StartCoroutine(transitionDelegate.Play()));

        // Disable mesh renderer
        _meshRenderer.enabled = false;

        // Disable camera
        _camera.enabled = false;

        // Clean texture
        _material.mainTexture = null;

        // Clean mesh
        _meshFilter.mesh = null;

        // Transition finished
        _isTransitionFinished = true;

        if (callback != null)
        {
            callback();
        }

        // Deactive this object
//		gameObject.SetActive(false);
    }
示例#33
0
 protected void setRequiredCheck(TransitionDelegate td, int s)
 {
     requiredCheck = td;
     requiredCheckFailState = s;
 }
示例#34
0
 protected void addState(int nextState, TransitionDelegate transitionFunction, bool reversible)
 {
     Transition t = new Transition();
     t.del = transitionFunction;
     t.reversible = reversible;
     t.nextState = nextState;
     t.prevState = states.Last();
     transitions.Add(t);
     states.Add(nextState);
 }
 private void Start()
 {
     m_TransitionDelegate = Transition.GetTransitionDelegate (transition);
     m_Value01Timer.Initialize (transitionTime);
 }