Exemplo n.º 1
0
        public DemonSprite(SpriteBasis sb)
        {
            animationAtlas = new Dictionary<AnimationState, Filmstrip>();
            animationAtlas[AnimationState.Idle] = createFilmstrip( 0 );
            animationAtlas[AnimationState.Pressing] = createFilmstrip( 1 );
            animationAtlas[AnimationState.Disappearing] = createFilmstrip( new[] { 1, 2, 3, 4, 5, 6 } );
            animationAtlas[AnimationState.Disappearing].FrameDuration = 120;
            animationAtlas[AnimationState.Hidden] = createFilmstrip( 6 );
            animationAtlas[AnimationState.Reappearing] = createFilmstrip( new[] { 6, 5, 4, 3, 2, 1} );
            animationAtlas[AnimationState.Reappearing].FrameDuration = 120;

            DemonSprite that = this;

            animationAtlas[AnimationState.Disappearing].OnEnd = ( Filmstrip fs ) => {

                that.SetAnimationState( AnimationState.Hidden );

                return this.currentAnimation.FinishProcessAnimation( 0 );
            };

            animationAtlas[AnimationState.Reappearing].OnEnd = ( Filmstrip fs ) => {
                that.SetAnimationState( AnimationState.Idle );

                return this.currentAnimation.FinishProcessAnimation( 0 );
            };

            this.currentAnimation = animationAtlas[AnimationState.Idle];
            this.Sprite = new Sprite(sb, currentAnimation);
        }
Exemplo n.º 2
0
        public WindowSprite( SpriteBasis sb )
        {
            //this.Sprite = new Sprite( sb, null, 0,0,false ); // let's just get a tmp sprite for calculation.  Trust me on this.

            animationAtlas = new Dictionary<AnimationState, Filmstrip>();
            animationAtlas[AnimationState.NormalIdle] = createFilmstrip( 0 );
            animationAtlas[AnimationState.Breaking] = createFilmstrip( new[] { 1, 2, 3 } );
            animationAtlas[AnimationState.Breaking].FrameDuration = 60;
            animationAtlas[AnimationState.AngryDude] = createFilmstrip( new[] { 4,5 } );
            animationAtlas[AnimationState.AngryDude].FrameDuration = 150;
            animationAtlas[AnimationState.DyingDude] = createFilmstrip( new[] { 6, 7 } );
            animationAtlas[AnimationState.DyingDude].FrameDuration = 150;
            animationAtlas[AnimationState.EmptyIdle] = createFilmstrip( 8 );

            WindowSprite that = this;

            animationAtlas[AnimationState.Breaking].OnEnd = ( Filmstrip fs ) => {

                that.SetAnimationState( AnimationState.AngryDude );

                return this.currentAnimation.FinishProcessAnimation( 0 );
            };

            animationAtlas[AnimationState.DyingDude].OnEnd = ( Filmstrip fs ) => {
                that.SetAnimationState( AnimationState.EmptyIdle );

                return this.currentAnimation.FinishProcessAnimation( 0 );
            };

            this.currentAnimation = animationAtlas[AnimationState.NormalIdle];
            this.Sprite = new Sprite(sb, currentAnimation);
        }
Exemplo n.º 3
0
        public BulletSprite(SpriteBasis sb)
        {
            animationAtlas = new Dictionary<AnimationState, Filmstrip>();
            animationAtlas[AnimationState.Bullet] = createFilmstrip(new[] { 0, 1 }, true);

            this.currentAnimation = animationAtlas[AnimationState.Bullet];
            this.Sprite = new Sprite(sb, currentAnimation);
        }
Exemplo n.º 4
0
 public CopSpawner(World world, McgLayer layer, Vector2 location, TimeSpan spawnRate, SpriteBasis copSpriteBasis, SpriteBasis bulletSpriteBasis, Vector2 playerPosition, int spawnRateFuzzMillis = 0)
 {
     this.layer = layer;
     this.world = world;
     this.spawnRate = spawnRate;
     this.location = location;
     this.copSpriteBasis = copSpriteBasis;
     this.spawnRateFuzzMillis = spawnRateFuzzMillis;
     this.playerPosition = playerPosition;
     this.bulletSpriteBasis = bulletSpriteBasis;
 }
Exemplo n.º 5
0
        public CivvieSprite(SpriteBasis sb)
        {
            animationAtlas = new Dictionary<AnimationState, Filmstrip>();
            animationAtlas[AnimationState.Idle] = createFilmstrip(0);
            animationAtlas[AnimationState.WalkingRight] = createFilmstrip(new[] { 1, 0, 2, 0 }, true);
            animationAtlas[AnimationState.WalkingLeft] = createFilmstrip(new[] { 3, 7, 4, 7 }, true);
            animationAtlas[AnimationState.Flying] = createFilmstrip(5);
            animationAtlas[AnimationState.Dead] = createFilmstrip(6);

            this.currentAnimation = animationAtlas[AnimationState.Idle];
            this.Sprite = new Sprite(sb, currentAnimation);
        }
Exemplo n.º 6
0
        public DoorSprite( SpriteBasis sb )
        {
            animationAtlas = new Dictionary<AnimationState, Filmstrip>();
            animationAtlas[AnimationState.Stopped] = createFilmstrip( new[] { 0 } );
            animationAtlas[AnimationState.Slow] = createFilmstrip(new[] { 0, 1, 2, 1 });
            animationAtlas[AnimationState.Medium] = createFilmstrip(new[] { 0, 1, 2, 1 }, 75);
            animationAtlas[AnimationState.Fast] = createFilmstrip(new[] { 3, 4 });

            DrawDoor = (int x, int y) => {
                Sprite.Update();
                Sprite.Draw();
            };

            this.currentAnimation = animationAtlas[AnimationState.Slow];
            this.Sprite = new Sprite(sb, currentAnimation);
        }
Exemplo n.º 7
0
        public Entity( SpriteBasis _basis, String ent_name )
            : base(_basis, "Idle Down")
        {
            _facing = Direction.Down;
            obstructing = false;
            obstructable = true;
            tile_obstruction = true;
            autoface = true;
            visible = true;
            follow = null;
            name = ent_name;

            index = -1; // it's up to the map to maintain this
            move_animation_prefix = "Walk ";
            idle_animation_prefix = "Idle ";
            initialize_movement_attributes();
            // Entities come from chrs, so they all have walk and idle animations defined.
        }
Exemplo n.º 8
0
        public CopController( World w, Vector2 r0, CopSprite sprite, McgLayer bulletLayer, SpriteBasis bulletSpriteBasis, Vector2 playerPosition )
        {
            _world = w;

            this.bulletLayer = bulletLayer;

            _fsBody = w.NewBody();
            _fsBody.BodyType = BodyType.Dynamic;
            _fsBody.Position = r0;

            copSprite = sprite;

            MakeLivingFixture();

            shootTimer = TimeSpan.FromSeconds(VERGEGame.rand.Next(3, 10));

            this.bulletSpriteBasis = bulletSpriteBasis;
            this.playerPosition = playerPosition;
        }
Exemplo n.º 9
0
        public Sprite(SpriteBasis spr_basis, Filmstrip anim, int x_coord, int y_coord, bool visibility)
        {
            basis = spr_basis;
            deleted = false;

            // Positioning stuff
            hitbox = new Rectangle(x_coord, y_coord, spr_basis.default_hitbox.Width, spr_basis.default_hitbox.Height);
            exact_pos = new Vector2((float) x_coord, (float) y_coord);
            velocity = acceleration = Vector2.Zero;
            destination = new Rectangle(x_coord - spr_basis.default_hitbox.X, y_coord - spr_basis.default_hitbox.Y, spr_basis.frame_width, spr_basis.frame_height);

            // Display stuff
            opacity = 1.0f;
            rate = 1.0f;
            fixed_frame = -1;
            time_to_next = 0;
            visible = visibility;
            set_animation(anim);

            last_draw_tick = last_logic_tick = VERGEGame.game.tick;
        }
Exemplo n.º 10
0
        public Sprite(String name, String anim, int x_coord, int y_coord, bool visibility)
        {
            basis = get_basis_from_name(name);
            deleted = false;

            // Positioning stuff
            hitbox = new Rectangle(x_coord, y_coord, basis.default_hitbox.Width, basis.default_hitbox.Height);
            exact_pos = new Vector2((float) x_coord, (float) y_coord);
            velocity = acceleration = Vector2.Zero;
            destination = new Rectangle(x_coord - basis.default_hitbox.X, y_coord - basis.default_hitbox.Y, basis.frame_width, basis.frame_height);

            // Display stuff
            opacity = 1.0f;
            angle = 0f;
            angular_momentum = 0f;
            //angular_momentum = 10f; // Uncomment for AWESOME FUN PARTY TIME
            rate = 1.0f;
            fixed_frame = -1;
            time_to_next = 0;
            visible = visibility;
            set_animation(anim);

            last_draw_tick = last_logic_tick = VERGEGame.game.tick;
        }
Exemplo n.º 11
0
 public Sprite(SpriteBasis spr_basis, Filmstrip anim)
     : this(spr_basis, anim, 0, 0, false)
 {
 }
Exemplo n.º 12
0
 public Sprite(SpriteBasis spr_basis, String anim)
 {
 }
Exemplo n.º 13
0
 public Entity( SpriteBasis _basis )
     : this(_basis, "")
 {
 }
Exemplo n.º 14
0
        internal override void Load()
        {
            Game1 game1 = (Game1)Game1.game;
            //Vector2[] verts = new [] {
            //    new Vector2 { X = -100, Y = 0 },
            //    new Vector2 { X = -70, Y = 0 },
            //    new Vector2 { X = -100, Y = 30 }
            //};

            //Wall _wallTri = new Wall(_world, verts);
            McgNode rendernode;
            Vector2 floor = Coords.Screen2Physics(new Vector2 { X = 0, Y = 215 });
            _world = new World(new Vector2 { X = 0, Y = -80 }, floor.Y);

            Vector2 _666pos = Coords.Screen2Physics(new Vector2 { X = 280, Y = 218 });
            Vector2 _666size = Coords.Screen2Physics(new Vector2 { X = 100, Y = 210 }, true);

            Wall _wall0 = new Wall(_world, -100, 1);

            Vector2[] verts = new[] {
                Coords.Screen2Physics(new Vector2 { X = 340, Y = 32 }),
                Coords.Screen2Physics(new Vector2 { X = 300, Y = 32 }),
                Coords.Screen2Physics(new Vector2 { X = 300, Y = 200 }),
                Coords.Screen2Physics(new Vector2 { X = 340, Y = 200 }),
            };

            Wall _wall1 = new Wall(_world, verts);
            //Wall _wall1 = new Wall(_world, _666pos.X, -1);

            List<SpriteBasis> civilianList = new List<SpriteBasis>();

            for( int i = 0; i < game1.im_civvies.Length; i++ ) {
                SpriteBasis civSpriteBasis = new SpriteBasis( 16, 16, 7, 7 );
                civSpriteBasis.image = game1.im_civvies[i];
                civilianList.Add( civSpriteBasis );
            }

            SpriteBasis copSpriteBasis = new SpriteBasis(16, 16, 10, 10);
            copSpriteBasis.image = game1.im_cop;

            SpriteBasis bulletSpriteBasis = new SpriteBasis(7, 7, 2, 2);
            bulletSpriteBasis.image = game1.im_bullet;

            mcg = new McGrenderStack();
            Game1.game.setMcGrender(mcg);

            mcg.AddLayer( "skybox" );
            mcg.AddLayer( "clouds" );
            mcg.AddLayer( "background" );
            mcg.AddLayer( "corpses" );
            mcg.AddLayer( "cars" );

            McgLayer l = mcg.GetLayer( "skybox" );
            /// this is wrong.
            Rectangle rectTitle = new Rectangle( 0, 0, 320, 240 );
            rendernode = l.AddNode(
                new McgNode( game1.im_skybox, rectTitle, l, 0, 0 )
            );

            l = mcg.GetLayer("background");
            rendernode = l.AddNode(
                new McgNode(game1.im_stage, rectTitle, l, 0, 0)
            );

            l = mcg.GetLayer( "clouds" );

            for( int i = 0; i < 40; i++ ) {
                int x = VERGEGame.rand.Next( -400, 350 );
                int y = VERGEGame.rand.Next(0,150);
                int d = VERGEGame.rand.Next(50000,200000);
                rendernode = l.AddNode(
                    new McgNode( game1.im_clouds[i%9], null, l, x,y ,600,y,d )
                );

                rendernode.OnStop = ( McgNode node ) => {
                    int x1 = VERGEGame.rand.Next( -400, -100 );
                    int y1 = VERGEGame.rand.Next( 0, 150 );
                    int d1 = VERGEGame.rand.Next( 50000, 200000 );

                    node.SetNewMovement( x1, y1, 400, y1, d1 );
                };
            }

            /// this all should be encapsulated eventually.  CORPSEMAKER.
            l = mcg.GetLayer("corpses");

            var doorSpriteBasis = new SpriteBasis(38, 24, 5, 5);
            doorSpriteBasis.image = game1.im_door;
            var doorSprite = new DoorSprite(doorSpriteBasis);
            _gun = new DoorController(
                _world,
                Coords.Screen2Physics(new Vector2 { X = 32, Y = 206 }),
                Coords.Screen2Physics(new Vector2 { X = 19, Y = 12 }, true),
                doorSprite
            );
            _gun.Impulse = new Vector2 { X = -10, Y = 10 };

            rendernode = l.AddNode(
                new McgNode(_gun, l, 60, 200)
            );

            var demonSpriteBasis = new SpriteBasis(9, 19, 7, 7);
            demonSpriteBasis.image = game1.im_demon;
            var demonSprite = new DemonSprite( demonSpriteBasis );
            _evilDemon = new DemonController( _world,
                Coords.Screen2Physics(new Vector2 { X = 286, Y = 26 }),
                Coords.Screen2Physics(new Vector2 { X = 5, Y = 10 }, true),
                demonSprite
            );
            rendernode = l.AddNode(
                new McgNode(_evilDemon, l, -1, -1)
            );

            List<WindowController> windowList = new List<WindowController>();
            var windowSpriteBasis = new SpriteBasis( 14, 14, 9, 9 );
            windowSpriteBasis.image = game1.im_windowbreak;
            for( int i = 0; i < 6; i++ ) {
                var windowSprite = new WindowSprite( windowSpriteBasis );
                var windowController = new WindowController( _world,
                    Coords.Screen2Physics( new Vector2 { X = 297, Y = ( 53 + ( i * 22 ) + ( i > 1 ? 1 : 0 ) + ( i > 2 ? 1 : 0 ) ) } ),
                    Coords.Screen2Physics( new Vector2 { X = 7, Y = 7 }, true ),
                    windowSprite
                );
                rendernode = l.AddNode(
                    new McgNode( windowController, l, -1, -1 )
                );

                windowList.Add( windowController );
            }

            windowControllerList = windowList.ToArray();

            //spawn guys
            Vector2 spawnerR = Coords.Screen2Physics(new Vector2 { X = 325, Y = 218 });

            var civvieSpawner = new CivvieSpawner( _world, l, spawnerR, TimeSpan.FromSeconds( 2 ), civilianList.ToArray(), 1000 );
            l.AddNode(new McgNode(civvieSpawner, l, 80, 20));

            //spawn cops
            var copSpawner = new CopSpawner(_world, l, spawnerR, TimeSpan.FromSeconds(3), copSpriteBasis, bulletSpriteBasis, Coords.Screen2Physics(new Vector2 { X = 286, Y = 26 }),2000);
            l.AddNode(new McgNode(copSpawner, l, 80, 20));
        }