Пример #1
0
        protected PressureSwitch(RenderSet render_set, double x, double y,
                                 ActionEventHandler state_changed,
                                 SharedState <SwitchState> state,
                                 SharedState <double> latch_expiration,
                                 Stopwatch latch_timer, double latch_time,
                                 Texture texture) :
            base(render_set, x, y, texture)
        {
            TurnOn                     = new SpriteAnimation(Texture, 50, new int [] { 0, 1, 2, 3 });
            TurnOff                    = new SpriteAnimation(Texture, 50, new int [] { 3, 2, 1, 0 });
            _LatchTimer                = latch_timer;
            _LatchTime                 = latch_time;
            _LatchExpiration           = latch_expiration;
            _State                     = state;
            _State.SharedStateChanged += (sender, e) => {
                switch (e.CurrentState)
                {
                case SwitchState.Open:
                    PlayAnimation(TurnOff);
                    break;

                case SwitchState.Closed:
                    PlayAnimation(TurnOn);
                    break;
                }
                state_changed(sender, new ActionEventArgs(e.CurrentState, this));
            };
        }
Пример #2
0
 public override void Dispose()
 {
     Action           = null;
     _State           = null;
     _LatchExpiration = null;
     base.Dispose();
 }
Пример #3
0
 protected PressureSwitch(RenderSet render_set, double x, double y,
                          ActionEventHandler state_changed,
                          SharedState <SwitchState> state,
                          SharedState <double> latch_expiration,
                          Stopwatch latch_timer, double latch_time) :
     this(render_set, x, y, state_changed, state, latch_expiration, latch_timer, latch_time, Texture.Get("sprite_floor_switch"))
 {
 }
Пример #4
0
 protected ProjectileSwitch(RenderSet render_set, double x, double y,
                            ActionEventHandler state_changed,
                            SharedState <SwitchState> state,
                            SharedState <double> latch_expiration,
                            Stopwatch latch_timer, double latch_time) :
     base(render_set, x, y, state_changed, state, latch_expiration, latch_timer, latch_time, Texture.Get("sprite_projectile_switch"))
 {
     Theta = 0.0;
 }
Пример #5
0
 protected Gateway(RenderSet render_set, double x, double y, SharedState <bool> sync_state, Texture texture) :
     base(render_set, x, y, texture)
 {
     _State = sync_state;
     _State.SharedStateChanged += (sender, e) =>
     {
         PlayAnimation(e.CurrentState ? Open : Close);
         Body.Enabled = (_RenderSet.Scene == _RenderSet.Scene.Game.CurrentScene) && !e.CurrentState;
     };
 }
Пример #6
0
 protected ExtenderPlatform(RenderSet render_set, double x, double y, SharedState <bool> sync_state) :
     base(render_set, x, y, Texture.Get("sprite_extender_platform"))
 {
     Extend          = new SpriteAnimation(Texture, 50, false, false, new[] { "collapsed", "t1", "t2", "extended" });
     Collapse        = new SpriteAnimation(Texture, 50, false, false, new[] { "extended", "t2", "t1", "collapsed" });
     _State          = sync_state;
     RenderSetEntry += (sender, e) => {
         PlayAnimation(_AnimationDefault = new SpriteAnimation(false, false, _State ? Collapse.Frames[0] : Extend.Frames[0]));
     };
     _State.SharedStateChanged += (sender, e) =>
     {
         PlayAnimation(e.CurrentState ? Extend : Collapse);
         Body.Enabled = (Set.Scene == Set.Scene.Game.CurrentScene) && e.CurrentState;
     };
     if (Body != null)
     {
         Body.OnCollision += HandleOnCollision;
     }
 }
Пример #7
0
 protected Gateway(RenderSet render_set, double x, double y, SharedState <bool> sync_state) :
     this(render_set, x, y, sync_state, Texture.Get("sprite_gateway"))
 {
     Open  = new SpriteAnimation(Texture, 50, new int [] { 0, 1, 2, 3 });
     Close = new SpriteAnimation(Texture, 50, new int [] { 3, 2, 1, 0 });
 }
Пример #8
0
 public SharedStateChangeEventArgs(T previous_state, T current_state, SharedState <T> self)
 {
     _PreviousState = previous_state;
     _CurrentState  = current_state;
     _Self          = self;
 }
Пример #9
0
 protected SmallGateway(RenderSet render_set, double x, double y, SharedState <bool> sync_state) :
     base(render_set, x, y, sync_state, Texture.Get("sprite_mini_gate"))
 {
     Open  = new SpriteAnimation(Texture, 50, false, "closed", "opening_1", "opening_2", "open");
     Close = new SpriteAnimation(Texture, 50, false, "open", "opening_2", "opening_1", "closed");
 }