Exemplo n.º 1
0
 public HUDQuad(RenderSet render_set, Vector3d p, Vector3d s) :
     this(render_set, p,
          p + new Vector3d(s.X, 0.0, 0.0),
          p + new Vector3d(s.X, s.Y, 0.0),
          p + new Vector3d(0.0, s.Y, 0.0))
 {
 }
Exemplo n.º 2
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));
            };
        }
Exemplo n.º 3
0
 // Main constructor:
 public BooleanIndicator(RenderSet render_set, double x, double y) :
     base(render_set, x, y, 1.0, 1.0, null, Texture.Get("sprite_indicator"))
 {
     State      = false;
     _Color     = new Color4(Color.SkyBlue);
     _NextLayer = new LayeredSprite(render_set, x, y, 1.0, 1.0, null, Texture.Get("sprite_indicator_gloss"));
 }
Exemplo n.º 4
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"))
 {
 }
Exemplo n.º 5
0
 public TileMap(RenderSet render_set, int countx, int county, Texture texture) :
     base(render_set)
 {
     _CountX  = countx;
     _CountY  = county;
     Texture  = texture;
     IndexMap = new int[_CountX, _CountY];
 }
Exemplo n.º 6
0
 public Drawable(RenderSet render_set)
 {
     _RenderSet = render_set;
     if (_RenderSet != null)
     {
         _RenderSet.Add(this);
     }
     RenderSetTransfer += HandlerenderSetTransfer;
 }
Exemplo n.º 7
0
 public BlueprintLine(Vector3d a, Vector3d b, RenderSet render_set, int millis)
 {
     _RenderSet = render_set;
     _RenderSet.Add(this);
     Lifespan = millis;
     A        = a;
     B        = b;
     Timer.Start();
 }
Exemplo n.º 8
0
 public HUDQuad(RenderSet render_set, Vector3d a, Vector3d b, Vector3d c, Vector3d d)
 {
     A          = a;
     B          = b;
     C          = c;
     D          = d;
     _RenderSet = render_set;
     _RenderSet.Add(this);
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
0
 public RaindropRippleEffect(RenderSet render_set, double x, double y) :
     base(render_set, x, y, Texture.Get("sprite_ripples"))
 {
     //PlayAnimation(_AnimationDefault = new SpriteAnimation(Texture, 100, true, false, "f0", "f1"));
     Lifespan = 2.0;
     _Color   = new Color4(255, 24, 127, 255);
     _Color2  = new Color4(0.0f, (float)ColorRandy.NextDouble() * 0.5f + 0.5f, (float)ColorRandy.NextDouble() * 0.5f + 0.5f, 0.0f);
     Timer.Restart();
 }
Exemplo n.º 11
0
 public Line(Vector3d start, Vector3d end, float thickness, RenderSet render_set) :
     base(render_set)
 {
     _Position  = start;
     _Direction = end;
     Color      = Color.Black;
     Thickness  = thickness;
     InitPhysics();
 }
Exemplo n.º 12
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;
     };
 }
Exemplo n.º 13
0
 public Spidey(RenderSet render_set, double x, double y) :
     base(render_set, x, y, Texture.Get("sprite_spidey_0"))
 {
     if (Body != null)
     {
         Body.OnCollision += HandleOnCollision;
         Body.BodyType     = BodyType.Dynamic;
     }
     JumpTimer.Start();
 }
Exemplo n.º 14
0
 protected StuffOne(RenderSet render_set, double x, double y, double z, int wide, int high, Texture texture) :
     base(render_set)
 {
     _Wide       = wide;
     _High       = high;
     _Position.X = x;
     _Position.Y = y;
     _Position.Z = z;
     _Texture    = texture;
     StuffTimer.Start();
 }
Exemplo n.º 15
0
        public FoodItem(RenderSet render_set, double x, double y, int variant = 0) :
            base(render_set, x, y, Texture.Get("sprite_food_single"))
        {
            Variant = variant % Texture.Regions.Length;
            PlayAnimation(_AnimationDefault = new SpriteAnimation(Texture, true, false, Variant));

            if (Body != null)
            {
                Body.OnCollision += HandleOnCollision;
                Body.BodyType     = BodyType.Static;
            }
        }
Exemplo n.º 16
0
        public SpriteObject(RenderSet render_set, Texture texture) :
            base(render_set, texture)
        {
            _RenderSet = render_set;

            InitPhysics();
            // HACK: Positioning the body must occur after world
            // has been solved at least one time in order to avoid
            // fixtures being shifted rather than the bodies.
            _RenderSet.Scene.Game.WorldMain.Step(0.0f);

            RenderSetEntry += EnteredRenderSet;             // Virtual default event handler
        }
Exemplo n.º 17
0
        public Dialog(RenderSet render_set, string title, List <DialogStanza> stanzas) :
            base(null)
        {
            _Title     = title;
            Stanzas    = stanzas;
            _RenderSet = render_set;
            _Shown     = false;
            ScaleX     = _RenderSet.Scene.ViewSize.X;
            ScaleY     = (int)(_RenderSet.Scene.ViewSize.Y * 0.25);
            FadeUp     = Texture.Get("sprite_dialog_fade_up");

            SpeakerWriter = new PTextWriter(_RenderSet.Scene.Game, new Size((int)ScaleX, 24));
            SpeechWriter  = new PTextWriter(_RenderSet.Scene.Game, new Size((int)ScaleX, (int)ScaleY));
        }
Exemplo n.º 18
0
        public PolarBear(RenderSet render_set, double x, double y) :
            base(render_set, x, y, Texture.Get("sprite_polarbear"))
        {
            Texture texture = Texture.Get("sprite_polarbear");

            AnimationWalk  = new SpriteAnimation(texture, 100, true, false, "stand", "walk1", "walk2", "walk3", "walk4", "walk5", "walk6", "walk7");
            AnimationSwipe = new SpriteAnimation(texture, 100, true, false, "swipe1", "swipe2", "swipe3", "swipe4");
            PlayAnimation(AnimationWalk);

            if (Body != null)
            {
                Body.OnCollision += HandleOnCollision;
                Body.BodyType     = BodyType.Dynamic;
            }
            JumpTimer.Start();
            AttackTimer.Start();
        }
Exemplo n.º 19
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;
     }
 }
Exemplo n.º 20
0
 public virtual void Dispose()
 {
     _RenderSet = null;
     if (_Blueprints != null)
     {
         for (int i = 0; i < _Blueprints.Count; i++)
         {
             if (_Blueprints[i].Set != null)
             {
                 _Blueprints[i].Set.Remove(_Blueprints[i]);
             }
             _Blueprints[i].Dispose();
             _Blueprints[i] = null;
         }
         _Blueprints.Clear();
         _Blueprints = null;
     }
     RenderSetEntry    = null;
     RenderSetTransfer = null;
 }
Exemplo n.º 21
0
        public SpriteBase(RenderSet render_set, double x, double y, double scalex, double scaley, Texture texture) :
            base(render_set)
        {
            // Size will scale _Texture width and height
            _Color               = Color.White;
            _Scale.X             = scalex;
            _Scale.Y             = scaley;
            _TileX               = 1.0;
            _TileY               = 1.0;
            _AnimationFrameIndex = 0;
            _FrameTimer          = new Stopwatch();
            _AnimationDefault    = _AnimationCurrent = new SpriteAnimation(texture, 0);
            //_FrameStatic = _AnimationDefault.Frames[0];

            // Position for world objects is handled differently
            if (!(this is IWorldObject))
            {
                Corner = new Vector3d(x, y, 0.0);
            }
        }
Exemplo n.º 22
0
        protected Scene(PositronGame game, string name)
        {
            _Game = game;
            _Name = name;

            // TODO: This is awful. Fix it.
            // TODO: Actually fix this.
            // TODO: Seriously, make this -not suck-
            ViewWidth  = _Game.Window.CanvasWidth;
            ViewHeight = _Game.Window.CanvasHeight;

            Background     = new RenderSet(this);
            Rear           = new RenderSet(this);
            Stage          = new RenderSet(this);
            Tests          = new RenderSet(this);
            Front          = new RenderSet(this);
            WorldBlueprint = new RenderSet(this);
            HUD            = new RenderSet(this);
            HUDBlueprint   = new RenderSet(this);
            HUDDebug       = new RenderSet(this);

            // This should contain everything AllRenderSetsInOrder would contain
            // This is an optimization over using an enumerable
            //All = new RenderSet(this, Background, Rear, Stage, Tests, Front, HUD, HUDBlueprint, HUDDebug);

            SceneEntry += (sender, e) =>
            {
                foreach (RenderSet render_set in AllRenderSetsInOrder())
                {
                    render_set.ForEach(element => {
                        if (element is IWorldObject)
                        {
                            IWorldObject w_o = (IWorldObject)element;
                            //Console.WriteLine("Rotation for {0} sprite with rotation {1}", w_o, w_o.Theta);
                        }
                    });
                }
            };
        }
Exemplo n.º 23
0
        // Main constructor:
        public Player(RenderSet render_set, double x, double y, Texture texture) :
            base(render_set, x, y, texture)
        {
            HealthChanged += (object sender, HealthChangedEventArgs e) => { _Health = Math.Max(0, e.HealthNow); };
            OnHealthChanged(this, _HealthMax);

            AnimationStand        = new SpriteAnimation(texture, "stand");
            AnimationWalk         = new SpriteAnimation(texture, 100, true, false, "stand", "walk1", "walk2", "walk3", "walk4", "walk5", "walk6");
            AnimationStationaryFw = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, "protag standing facing front");
            AnimationWalkFw       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag walking front 1", "protag walking front 2", "protag walking front 3", "protag walking front 4");
            AnimationStationaryBk = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, "protag standing back" );
            AnimationWalkBk       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag walking back 1", "protag walking back 2", "protag walking back 3", "protag walking back 4");

            AnimationCrouch = new SpriteAnimation(texture, "stand");       // new SpriteAnimation(texture, true, "protag crouch");
            AnimationCrawl  = new SpriteAnimation(texture, "stand");       // new SpriteAnimation(texture, 150, true, "protag crouch walk 1", "protag crouch walk 2", "protag crouch walk 3", "protag crouch walk 4");

            AnimationPreJump       = new SpriteAnimation(texture, true, "jump");
            AnimationJumping       = new SpriteAnimation(texture, true, "jump");
            AnimationEndJump       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, "protag jumping 4");
            AnimationEndJump.Sound = Sound.Get("sfx_player_land_two_feet");

            AnimationSlingshot       = new SpriteAnimation(texture, 50, true, false, "shoot1", "shoot2", "shoot3", "shoot4");
            AnimationAimGunFwd       = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun");
            AnimationAimGunFwdUp     = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun up");
            AnimationAimGunFwdDown   = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun down");
            AnimationAimGunFwdCrouch = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun crouch");
            AnimationAimGunFwdJump   = new SpriteAnimation(texture, "stand"); // new SpriteAnimation(texture, true, "protag aiming gun jump");

            AnimationTakeHit = new SpriteAnimation(texture, "hit1", "hit2");

            AnimationPreJump.Frames[0].FrameTime = 100;
            //AnimationPreJump.Frames[1].FrameTime = 50;

            AnimationEndJump.Frames[0].FrameTime = 200;

            _FrameTimer.Start();
            JumpTimer.Start();
        }
Exemplo n.º 24
0
Arquivo: Door.cs Projeto: peges/hungry
 public Door(RenderSet render_set, Door destination) :
     this(render_set, destination.PositionX, destination.PositionY, destination)
 {
 }
Exemplo n.º 25
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 });
 }
Exemplo n.º 26
0
 public Gateway(RenderSet render_set, double x, double y, Gateway sync_gateway) :
     this(render_set, x, y, sync_gateway._State)
 {
 }
Exemplo n.º 27
0
 public Gateway(RenderSet render_set, double x, double y, bool initial_state = false) :
     this(render_set, x, y, new SharedState <bool>(initial_state))
 {
 }
Exemplo n.º 28
0
 public SideWalkTile(RenderSet render_set, double x, double y) :
     base(render_set, x, y, Texture.Get("sprite_sidewalk"))
 {
     _Variant = Variance.Next(Texture.Regions.Length);
     PlayAnimation(new SpriteAnimation(Texture, _Variant));
 }
Exemplo n.º 29
0
Arquivo: Door.cs Projeto: peges/hungry
 public Door(RenderSet render_set, double x, double y) :
     base(render_set, x, y, Texture.Get("sprite_doorway"))
 {
 }
Exemplo n.º 30
0
Arquivo: Door.cs Projeto: peges/hungry
 public Door(RenderSet render_set, double x, double y, Scene next_scene) :
     this(render_set, x, y)
 {
     _NextScene = next_scene;
 }