示例#1
0
文件: HUDQuad.cs 项目: peges/hungry
 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))
 {
 }
示例#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));
            };
        }
示例#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"));
 }
示例#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"))
 {
 }
示例#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];
 }
示例#6
0
文件: Drawable.cs 项目: peges/hungry
 public Drawable(RenderSet render_set)
 {
     _RenderSet = render_set;
     if (_RenderSet != null)
     {
         _RenderSet.Add(this);
     }
     RenderSetTransfer += HandlerenderSetTransfer;
 }
示例#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();
 }
示例#8
0
文件: HUDQuad.cs 项目: peges/hungry
 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);
 }
示例#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;
 }
示例#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();
 }
示例#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();
 }
示例#12
0
文件: Gateway.cs 项目: peges/hungry
 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;
     };
 }
示例#13
0
文件: Spidey.cs 项目: peges/hungry
 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();
 }
示例#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();
 }
示例#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;
            }
        }
示例#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
        }
示例#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));
        }
示例#18
0
文件: PolarBear.cs 项目: peges/hungry
        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();
        }
示例#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;
     }
 }
示例#20
0
文件: Drawable.cs 项目: peges/hungry
 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;
 }
示例#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);
            }
        }
示例#22
0
文件: Scene.cs 项目: peges/hungry
        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);
                        }
                    });
                }
            };
        }
示例#23
0
文件: Player.cs 项目: peges/hungry
        // 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();
        }
示例#24
0
文件: Door.cs 项目: peges/hungry
 public Door(RenderSet render_set, Door destination) :
     this(render_set, destination.PositionX, destination.PositionY, destination)
 {
 }
示例#25
0
文件: Gateway.cs 项目: peges/hungry
 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 });
 }
示例#26
0
文件: Gateway.cs 项目: peges/hungry
 public Gateway(RenderSet render_set, double x, double y, Gateway sync_gateway) :
     this(render_set, x, y, sync_gateway._State)
 {
 }
示例#27
0
文件: Gateway.cs 项目: peges/hungry
 public Gateway(RenderSet render_set, double x, double y, bool initial_state = false) :
     this(render_set, x, y, new SharedState <bool>(initial_state))
 {
 }
示例#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));
 }
示例#29
0
文件: Door.cs 项目: peges/hungry
 public Door(RenderSet render_set, double x, double y) :
     base(render_set, x, y, Texture.Get("sprite_doorway"))
 {
 }
示例#30
0
文件: Door.cs 项目: peges/hungry
 public Door(RenderSet render_set, double x, double y, Scene next_scene) :
     this(render_set, x, y)
 {
     _NextScene = next_scene;
 }