예제 #1
0
파일: BasicBullet.cs 프로젝트: qwook/hungry
 public BasicBullet(Scene scene, double x, double y, double vx, double vy)
     : base(scene.Stage, x, y, Texture.Get("sprite_first_bullet"))
 {
     _Velocity.X = vx;
     _Velocity.Y = vy;
     InitPhysicsLate();
 }
예제 #2
0
 public BaddieRobotCrawlerShooter(Scene scene, double x, double y)
     : base(scene.Stage, x, y, Texture.Get("sprite_robot_1"))
 {
     AnimationIdle = new SpriteAnimation(Texture, 200, true, false, new string[] { "stationary" });
     AnimationCrawl = new SpriteAnimation(Texture, 200, true, false, new string[] { "crawl_0", "crawl_1", "crawl_2", "crawl_3" });
     AnimationArm = new SpriteAnimation(Texture, 200, false, false, new string[] { "arm_0", "arm_1", "arm_2" });
     AnimationArmed = new SpriteAnimation(Texture, 200, true, false, new string[] { "armed" });
     AnimationDisarm = new SpriteAnimation(Texture, 200, false, false, new string[] { "disarm_0", "disarm_1", "disarm_2" });
     AnimationFiring = new SpriteAnimation(Texture, 75, true, false, new string[] { "firing_0", "firing_1", "firing_2", "firing_3", "firing_4" });
     StartAnimation(AnimationFiring);
 }
예제 #3
0
파일: UIButton.cs 프로젝트: qwook/hungry
 public UIButton(Scene scene, double x, double y, SpriteBase.SpriteFrame free, SpriteBase.SpriteFrame selected, UIElementGroup grp)
     : base(scene.HUD, x, y, free.Texture)
 {
     _Group = grp;
     _Group.Add(this);
     _ToFree = new SpriteAnimation(false, false, free);
     _ToSelected = new SpriteAnimation(false, false, selected);
     Refresh += (sender, e) => {
         var animation = this == _Group.ElementFocused ? _ToSelected : _ToFree;
         _AnimationFrameIndex = _AnimationCurrent == animation ? _AnimationFrameIndex : animation.FrameCount - _AnimationFrameIndex - 1;
         _AnimationCurrent = animation;
     };
     OnRefresh(this, new EventArgs());
 }
예제 #4
0
 public BulletCollisionParticle(Scene scene, double x, double y)
     : base(scene.Stage, x, y, Texture.Get("sprite_bullet_collision_particle"))
 {
     Hit = new SpriteAnimation(Texture, 10, false, "f1", "f2", "f3", "f4");
     _AnimationNext = new Lazy<SpriteAnimation>(() => {
         Program.MainGame.AddUpdateEventHandler(this, (sender, e) =>
         {
             RenderSet.Remove (this);
             this.Dispose();
             return true;
         });
         return null;
     });
     PlayAnimation(Hit);
 }
예제 #5
0
        public MusicLooper_LessHackish(Scene scene)
            : base(scene.HUD, -999, -999, Texture.DefaultTexture)
        {
            _Preserve = true;

            RenderSetEntry += (sender, e) =>
            {
                if(e.To.Scene is ISceneGameplay)
                    SetLoop("last_human_loop");
                else
                    SetLoop("induction_loop");
            };

            LoopThread = new Thread(LoopThreadMain);
            LoopThread.Start();
        }
예제 #6
0
파일: BasicBullet.cs 프로젝트: qwook/hungry
 public BulletCollisionParticle(Scene scene, double x, double y)
     : base(scene.Stage, x, y, Texture.Get("sprite_bullet_collision_particle"))
 {
     Hit = new SpriteAnimation(Texture, 10, false, "f1", "f2", "f3", "f4");
     Hit.Sound = Sound.Get ("sfx_bullet_impact");
     WeakReference game_wr = new WeakReference(Set.Scene.Game);
     WeakReference render_set_wr = new WeakReference(Set);
     _AnimationNext = new Lazy<SpriteAnimation>(() => {
         ((PositronGame)game_wr.Target).AddUpdateEventHandler(this, (sender, e) =>
         {
             ((RenderSet)render_set_wr.Target).Remove (this);
             this.Dispose();
             return true;
         });
         return null;
     });
     PlayAnimation(Hit);
 }
예제 #7
0
 public BunkerFloor2(Scene scene, double x, double y)
     : base(scene, x, y, Texture.Get("sprite_bunker_floor_2"))
 {
 }
예제 #8
0
 protected BunkerFloor(Scene scene, double x, double y, Texture texture)
     : base(scene.Stage, x, y, texture)
 {
     _Variant = Variance.Next(Texture.Regions.Length);
     PlayAnimation(_AnimationDefault = new SpriteAnimation(Texture, _Variant));
 }
예제 #9
0
 public BunkerFloor(Scene scene, double x, double y)
     : this(scene, x, y, Texture.Get("sprite_bunker_floor"))
 {
 }
예제 #10
0
파일: UIButton.cs 프로젝트: qwook/hungry
 public UIButton(Scene scene, double x, double y, SpriteBase.SpriteFrame free)
     : this(scene, x, y, free, free)
 {
 }
예제 #11
0
파일: UIButton.cs 프로젝트: qwook/hungry
 public UIButton(Scene scene, double x, double y, SpriteBase.SpriteFrame free, SpriteBase.SpriteFrame selected)
     : this(scene, x, y, free, selected, new UIElementGroup())
 {
 }
예제 #12
0
파일: Door.cs 프로젝트: qwook/hungry
 public Door(RenderSet render_set, double x, double y, Scene next_scene)
     : this(render_set, x, y)
 {
     _NextScene = next_scene;
 }
예제 #13
0
        protected void ChangeScene(Scene next_scene)
        {
            if (_CurrentScene == next_scene || next_scene == null)
                return;
            SceneChangeEventArgs scea = new SceneChangeEventArgs (_CurrentScene, next_scene);
            IEnumerable<RenderSet> next_sets = next_scene.AllRenderSetsInOrder ();
            IEnumerator<RenderSet> next_set_enum = next_sets.GetEnumerator ();
            IEnumerable<RenderSet> current_sets = null;
            IEnumerator<RenderSet> current_set_enum = null;
            RenderSetChangeEventArgs rscea;
            if (_CurrentScene != null) {
                // Get the enumerable for the render sets; these need to be in the same order!
                current_sets = _CurrentScene.AllRenderSetsInOrder ();
                current_set_enum = current_sets.GetEnumerator ();					// Enumerate from the beginning of the set enumerable
                foreach (RenderSet render_set in current_sets) {
                    if (!next_set_enum.MoveNext ())
                        break;
                    rscea = new RenderSetChangeEventArgs (render_set, next_set_enum.Current);
                    // Process this scene
                    for (int i = 0; i < render_set.Count;) {						// For each renderable in render set
                        var renderable = render_set [i];
                        if (renderable is ISceneElement) {							// If object also implements scene object
                            ISceneElement scene_object = (ISceneElement)renderable;	// Cast to scene object
                            if (scene_object is IWorldObject) {
                                IWorldObject world_object = (IWorldObject)scene_object;
                                // Disable the body object is not preserved
                                world_object.Body.Enabled &= world_object.Preserve;
                            }
                            if (scene_object.Preserve) { 							// If scene object is preserved
                                next_set_enum.Current.Add (renderable);				// Add in this object
                                render_set.RemoveAt (i);							// Remove from previous
                                scene_object.OnRenderSetTransfer (this, rscea);
                                continue;
                            }
                        }
                        i++;
                    }
                }
                foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder()) {
                    if (!current_set_enum.MoveNext ())
                        break;
                    // Process next scene, PART 1
                    foreach (IRenderable renderable in render_set) {
                        if (renderable is ISceneElement) {							// If object also implements scene object
                            if (renderable is IWorldObject) {
                                IWorldObject world_object = (IWorldObject)renderable;
                                // HACK: temporarily enable all bodies in this renderset
                                // in order to allow deferred updates to affect bodies
                                if(world_object.Body != null)
                                    world_object.Body.Enabled = true;
                            }
                        }
                    }
                }
            }

            if (_CurrentScene != null)
                _CurrentScene.OnSceneExit (this, scea);

            // Enumerate from the beginning of the set enumerable
            if (_CurrentScene != null)
                current_set_enum = current_sets.GetEnumerator ();
            // Process next scene, PART 2
            foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder()) {
                if (current_set_enum != null) {
                    if (!current_set_enum.MoveNext ())
                        break;
                    rscea = new RenderSetChangeEventArgs (current_set_enum.Current, render_set);
                } else
                    rscea = new RenderSetChangeEventArgs (null, render_set);
                foreach (IRenderable renderable in render_set) {
                    if (renderable is ISceneElement) {
                        ISceneElement scene_element = (ISceneElement)renderable;
                        // Body.Enabled should be updated with a RenderSetEntry event handler
                        scene_element.OnRenderSetEntry (this, rscea);
                    }
                }
            }
            var last_scene = _CurrentScene;
            if (last_scene != null) {
                if(last_scene.FollowTarget == null)
                    next_scene.Follow (null);
                else if(last_scene.FollowTarget.Preserve)
                    next_scene.Follow (last_scene.FollowTarget, true);
            }
            next_scene.OnSceneEntry (next_scene, scea);
            _CurrentScene = next_scene; // Update the scene reference
            GC.Collect();
        }
예제 #14
0
 public MusicLooperHACK(Scene scene, object loop_me)
     : base(scene.HUD, -999, -999, Texture.DefaultTexture)
 {
     SetLoop(loop_me);
 }
예제 #15
0
파일: BunkerWall.cs 프로젝트: qwook/hungry
 public BunkerWall(Scene scene, double x, double y)
     : base(scene.Stage, x, y, Texture.Get("sprite_bunker_wall"))
 {
     _Variant = Variance.Next(Texture.Regions.Length);
     PlayAnimation(new SpriteAnimation(Texture, _Variant));
 }
예제 #16
0
파일: Scene.cs 프로젝트: Apelsin/positron
 public SceneChangeEventArgs(Scene from, Scene to)
 {
     From = from;
     To = to;
 }