Beispiel #1
0
    public void Detach(GameObject go)
    {
        var e = go.GetComponent <Entity>();

        if (e != null)
        {
            e.Destoryed -= OnEntityDestroyed;
        }
        Every.Remove(go);
        if (GODetached != null)
        {
            GODetached(go);
        }
    }
Beispiel #2
0
        public override async Task Update(TimeSpan dt)
        {
            if (Match3.Instance.Keyboard.WasPressed(Key.Escape))
            {
                // Quit
            }

            // as long as can still input, i.e., we're not in a transition...
            if (!pauseInput)
            {
                // change menu selection
                if (Match3.Instance.Keyboard.WasPressed(Key.Up) || Match3.Instance.Keyboard.WasPressed(Key.Down))
                {
                    currentMenuItem = currentMenuItem == 0 ? 1 : 0;
                    await Match3.Instance.Sounds["select"].Play();
                }

                // switch to another state via one of the menu options
                if (Match3.Instance.Keyboard.WasPressed(Key.Enter) || Match3.Instance.Keyboard.WasPressed(Key.Return))
                {
                    if (currentMenuItem == 0)
                    {
                        // tween, using Timer, the transition rect's alpha to 255, then
                        // transition to the BeginGame state after the animation is over
                        Match3.Instance.Timer.Tween(TimeSpan.FromSeconds(1), transitionAlpha, 255, value => transitionAlpha = (int)value, async() =>
                        {
                            Match3.Instance.Timer.Clear();
                            await Match3.Instance.StateMachine.Change("begin-game", new Dictionary <string, object>
                            {
                                ["level"] = 1
                            });
                        });

                        // remove color timer from Timer
                        colorTimer.Remove();

                        // turn off input during transition
                        pauseInput = true;
                    }
                    else
                    {
                        // Quit
                    }
                }
            }

            // update our Timer, which will be used for our fade transitions
            // Timer.Update(dt);
        }