public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            var origin = new Vector2( m_texture.Width, m_texture.Height ) / 2;

            sprite_batch.Draw( m_texture, GameWorld.SCALE *
                m_body.Position, null, m_tint,
                m_body.Rotation, origin, m_scale * 7, 0.0f, 0 );
        }
        public Polygondrawer( GraphicsDevice device, int width, int height, Camera eye, BlendState blendMode )
        {
            m_device = device;
            effect = new BasicEffect( m_device );
            effect.Projection = Matrix.CreateOrthographicOffCenter( 0, width, height, 0, 0, 1 );

            effect.TextureEnabled = true;
            effect.LightingEnabled = false;

            if ( blendMode == BlendState.AlphaBlend ) {
                m_device.BlendState = BlendState.AlphaBlend;
            }
            else if ( blendMode == BlendState.Additive ) {
                m_device.BlendState = BlendState.Additive;
            }
        }
        public void drawPolygons(Matrix worldeffect,
                  Texture2D texture, VertexPositionTexture[] vertices, BlendState blendMode, Camera eye)
        {
            effect.View = eye.get_transformation();
            effect.World = worldeffect;
            effect.Texture = texture;

            m_samplerstate = new SamplerState();

            m_samplerstate.AddressU = TextureAddressMode.Wrap;
            m_samplerstate.AddressV = TextureAddressMode.Wrap;

            m_device.SamplerStates[0] = m_samplerstate;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

            }
            m_device.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
        }
 //--------------------------------------------------------------------
 // Member variables
 //--------------------------------------------------------------------
 public CameraController( Camera camera, Vector2 target_position )
 {
     m_camera = camera;
 }
 public override void draw( SpriteBatch sprite_batch, Camera eye )
 {
     if ( !m_invisible || ( m_invisible && GameScreen.editor_mode ) ) {
         if ( m_type == TriggerType.TEXTBOX ) {
             if ( GameScreen.editor_mode ) {
                 var origin = new Vector2( m_texture.Width, m_texture.Height ) / 2;
                 sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, null, m_tint,
                               m_body.Rotation, origin, m_scale, 0.0f, 0 );
             }
             sprite_batch.DrawString(TestWorld.game_font, parsedText, new Vector2(m_position.X, m_position.Y) * GameWorld.SCALE, Color.White);
         }
         else {
             var origin = new Vector2( m_texture.Width, m_texture.Height ) / 2;
             sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, null, m_tint,
                               m_body.Rotation, origin, m_scale, 0.0f, 0 );
         }
     }
 }
Example #6
0
        //----------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------
        // draws the physics object.  Default just calls draw in the children.
        public virtual void draw( SpriteBatch sprite_batch, Camera eye )
        {
            var origin = new Vector2( m_texture.Width, m_texture.Height ) / 2;
            if ( m_radius != 0 ) {
                sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, null,
                m_tint, m_body.Rotation, origin, m_radius, 0.0f, 0 );
            }

            if ( m_is_throwable && m_world.m_ninja.m_picking_up && !m_world.m_ninja.throwable_objects.Contains( this )
                && m_world.m_ninja.m_max_throwable_capacity > m_world.m_ninja.throwable_objects.Count ) {
                float dist = Vector2.Distance( m_position, m_world.m_ninja.m_position );
                float combined_radius = ( m_change_size + m_world.m_ninja.m_radius );

                Color m_throwable_aura = Color.DarkGray;

                if ( dist < 5 * combined_radius ) {
                    m_throwable_aura = Color.Gold;

                }
                else if ( dist < 15 * combined_radius ) {
                    m_throwable_aura = new Color( 255, 215, 150, 50 );

                }

                draw_throwable_aura( sprite_batch, eye, m_throwable_aura );
            }
        }
Example #7
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            //Updates camera in ninja class since ninja is the focus of the camera
            //eye.Update();
            m_speed_trail.m_ninja_speed = m_speed;

            // Pick out the right frame
            int image_size = m_texture.Width / NUM_ANIM_FRAMES;
            int frame = (int)m_animation_frame;

            // Draw the ninja aura
            Vector2 origin = new Vector2( TestWorld.highlight_texture.Width,
                  TestWorld.highlight_texture.Height ) / 2;

            Color aura_color = new Color( m_cruise ? 255 : 128, 255 - m_cruise_cooldown, 255, 128 );

            aura_rotation += m_speed * 0.0025f;
            sprite_batch.Draw( TestWorld.highlight_texture,
                GameWorld.SCALE * m_body.Position, null, aura_color,
                aura_rotation, origin, m_radius * 6.29f * (float)Math.Log10( m_speed * 0.0288 + 1 ), 0.0f, 1 );

            origin = new Vector2( image_size,
               m_texture.Height ) / 2;

            // Draw the ninja rectangle
            Rectangle src = new Rectangle( frame * image_size,  //get the frame to display
                                          0,                    //the image only has 1 row of frames
                                          image_size, image_size );    //image height and width

            sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, src,
                             m_tint, m_body.Rotation, origin, m_radius,
                             0.0f, 0
                );
        }
Example #8
0
        public TestWorld( Camera view, Editor editor )
            : base(ground_texture.Width, ground_texture.Height,
            new Vector2( 0, GRAVITY ))
        {
            // play bgm

            GameEngine.LevelManager.background_select();
            GameEngine.AudioManager.Play( AudioManager.MusicSelection.tut );

            eye = view;
            //mouse_control = new MouseController( GameEngine.GAME_WIDTH, GameEngine.GAME_HEIGHT );

            //create_world( this, "World_objects.xml" );

            //editor.ninjaBindingSource.DataSource = m_ninja;

            m_world.ContactManager.BeginContact += m_collision_manager.contact_started;
            m_world.ContactManager.EndContact += m_collision_manager.contact_ended;

            Vector2[] new_wall;

            // Create ninja
            m_ninja = new Ninja( this, ninja_animate_texture,
                ninja_position, 1.0f );

            // Add floor tiles
            // Must be created first, so that other objects can be on top of it
            /*  foreach ( var tile in floor_tiles )
              {
                  // Convert dimensions in the other format
                  if ( tile.Length < 4 )
                  {
                      new_wall = new[] {
                          tile[0], new Vector2(tile[0].X + tile[1].X, tile[0].Y),
                          new Vector2(tile[0].X + tile[1].X, tile[0].Y + tile[1].Y),
                          new Vector2(tile[0].X, tile[0].Y + tile[1].Y)
                      };
                  }
                  else new_wall = (Vector2[])tile.Clone();
                  FloorTile b = new FloorTile( this, new_wall, floor_texture, 1.0f, 0.0f, 0.7f );
                  // add_object( b );

              }

              // Create Aliens
              m_alien_easy = new Alien( this, hard_alien_texture,
                  new Vector2( 20, 11 ), 4.0f, Alien.AlienType.EASY,
                  Alien.AlienCollisionType.NORMAL );
              add_object( m_alien_easy );
              m_alien_spiked = new Alien( this, spiked_alien_texture,
                  new Vector2( 24, 2 ), 6.0f, Alien.AlienType.SPIKED,
                  Alien.AlienCollisionType.SPIKED );
              add_object( m_alien_spiked );
              m_alien_plated = new Alien( this, plated_alien_texture,
                  new Vector2( -15, 7 ), 8.0f, Alien.AlienType.PLATED,
                  Alien.AlienCollisionType.PLATED );
              add_object( m_alien_plated );

              // Create Aliens
              alien1 = new Alien( this, easy_alien_texture, alien1_pos, .5f, Alien.AlienType.EASY );
              add_object( alien1 );
              alien2 = new Alien( this, easy_alien_texture, alien2_pos, .5f, Alien.AlienType.EASY );
              add_object( alien2 );
              AlienController alien_controller1 = new AlienController( this, alien1, AlienController.AIType.PEON, m_ninja );
              m_world.AddController( alien_controller1 );
              AlienController alien_controller2 = new AlienController( this, alien1, AlienController.AIType.PEON, m_ninja );
              m_world.AddController( alien_controller2 );
              alien7 = new Alien( this, easy_alien_texture, alien7_pos, .5f, Alien.AlienType.EASY );
              add_object( alien7 );
              AlienController alien_controller7 = new AlienController( this, alien7, AlienController.AIType.ATTACKER, m_ninja );
              m_world.AddController( alien_controller7 );
              alien8 = new Alien( this, easy_alien_texture, alien8_pos, .5f, Alien.AlienType.EASY, rotation: -1.57f );
              add_object( alien8 );
              AlienController alien_controller8 = new AlienController( this, alien8, AlienController.AIType.ATTACKER, m_ninja );
              m_world.AddController( alien_controller8 );
              alien9 = new Alien( this, easy_alien_texture, alien9_pos, .5f, Alien.AlienType.EASY, rotation: 2.33f );
              add_object( alien9 );
              AlienController alien_controller9 = new AlienController( this, alien9, AlienController.AIType.ATTACKER, m_ninja );
              m_world.AddController( alien_controller9 );
              alien10 = new Alien( this, easy_alien_texture, alien10_pos, .5f, Alien.AlienType.EASY );
              add_object( alien10 );
              AlienController alien_controller10 = new AlienController( this, alien10, AlienController.AIType.ATTACKER, m_ninja );
              m_world.AddController( alien_controller10 );
              alien11 = new Alien( this, easy_alien_texture, alien11_pos, .5f, Alien.AlienType.EASY );
              add_object( alien11 );
              AlienController alien_controller11 = new AlienController( this, alien11, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller11 );
              alien12 = new Alien( this, easy_alien_texture, alien12_pos, .5f, Alien.AlienType.EASY );
              add_object( alien12 );
              AlienController alien_controller12 = new AlienController( this, alien12, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller12 );
              alien13 = new Alien( this, easy_alien_texture, alien13_pos, .5f, Alien.AlienType.EASY );
              add_object( alien13 );
              AlienController alien_controller13 = new AlienController( this, alien13, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller13 );
              alien14 = new Alien( this, spiked_alien_texture, alien14_pos, .5f, Alien.AlienType.EASY );
              add_object( alien14 );
              AlienController alien_controller14 = new AlienController( this, alien14, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller14 );
              alien15 = new Alien( this, plated_alien_texture, alien15_pos, .5f, Alien.AlienType.EASY );
              add_object( alien15 );
              AlienController alien_controller15 = new AlienController( this, alien15, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller15 );
              alien16 = new Alien( this, easy_alien_texture, alien16_pos, .5f, Alien.AlienType.EASY );
              add_object( alien16 );
              AlienController alien_controller16 = new AlienController( this, alien16, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller16 );
              alien17 = new Alien( this, easy_alien_texture, alien17_pos, .5f, Alien.AlienType.EASY );
              add_object( alien17 );
              AlienController alien_controller17 = new AlienController( this, alien17, AlienController.AIType.CHASER, m_ninja );
              m_world.AddController( alien_controller17 );
              //alien18 = new Alien( m_world, easy_alien_texture, alien18_pos, .5f, Alien.AlienType.EASY );
              //add_object( alien18 );
              alien19 = new Alien( this, easy_alien_texture, alien19_pos, .5f, Alien.AlienType.MEDIUM );
              add_object( alien19 );
              AlienController alien_controller19 = new AlienController( this, alien19, AlienController.AIType.PATROL, m_ninja );
              m_world.AddController( alien_controller19 );
              //alien20 = new Alien( m_world, easy_alien_texture, alien20_pos, .5f, Alien.AlienType.EASY );
              //add_object( alien20 );

              SharedResourceList alist = new SharedResourceList();
              alist.Add( alien1 );
              alist.Add( alien2 );
              Vector2 offset = new Vector2( 0, 1 );
              SharedResourceList nlist = new SharedResourceList();
              nlist.Add(m_ninja);
              eye.m_curr_target = m_ninja;

              // Create Doors
              door00 = new TriggerableObject( this, door_texture, door00_vertex1, door00_vertex2, 0 );
              add_object( door00 );
              SharedResourceList<TriggerableObject> tlist = new SharedResourceList<TriggerableObject>();
              tlist.Add(door00);
              door0 = new ConditionTriggered( this, door_texture, door0_pos, 0,alist,t_objects:tlist,
                  c_type: ConditionTriggered.ConditionType.EVADE_ALIENS);
              add_object( door0 );
              door1 = new TriggerableObject( this, door_texture, door1_vertex1, door1_vertex2, 0 );
              add_object( door1 );
              door2 = new TriggerableObject( this, door_texture, door2_vertex1, door2_vertex2, 0 );
              add_object( door2 );
              door3 = new TriggerableObject( this, door_texture, door3_vertex1, door3_vertex2, ( (float)Math.PI / 2 ) );
              add_object( door3 );
              door4 = new TriggerableObject( this, door_texture, door4_vertex1, door4_vertex2, ( (float)Math.PI / 2 ) );
              add_object( door4 );
              door5 = new TriggerableObject( this, door_texture, door5_vertex1, door5_vertex2, ( (float)Math.PI / 2 ) );
              add_object( door5 );
              door6 = new TriggerableObject( this, door_texture, door6_vertex1, door6_vertex2, 0 );
              add_object( door6 );
              door7 = new TriggerableObject( this, door_texture, Vector2.Zero, TriggerableObject.TriggerType.GOAL, 0 );
              // add_object( door7 );

            Vector2[] vec = new Vector2[] {
                new Vector2(-20,88), new Vector2(-20,80),new Vector2(2,80),new Vector2(2,88)
            };

            PolygonTrigger poly = new PolygonTrigger( this, pix_texture, ground_switch_inactive_texture, vec, door1, Trigger.TriggerType.FLOOR, 1, 0 );
            add_object( poly );

            //Add Switches
            floor_switch1 = new Trigger( this, ground_switch_active_texture,
                ground_switch_inactive_texture, floor_switch1_pos, door1,
                Trigger.TriggerType.FLOOR, 1, 0 );
            add_object( floor_switch1 );
            wall_switch1 = new Trigger( this, wall_switch_active_texture,
                wall_switch_inactive_texture, wall_switch1_pos, door2,
                Trigger.TriggerType.WALL, 1, (float)Math.PI, texture_name:TNames.wall_switch_inactive );
            add_object( wall_switch1 );
              wall_switch2 = new Trigger( this, wall_switch_active_texture,
                  wall_switch_inactive_texture, wall_switch2_pos, door3,
                  Trigger.TriggerType.WALL, .8f, (float)Math.PI, texture_name: TNames.wall_switch_inactive );
              add_object( wall_switch2 );
              floor_switch2 = new Trigger( this, ground_switch_active_texture,
                  ground_switch_inactive_texture, floor_switch2_pos, door4,
                  Trigger.TriggerType.FLOOR, 1f, 0 );
              add_object( floor_switch2 );
              wall_switch3 = new Trigger( this, wall_switch_active_texture,
                  wall_switch_inactive_texture, wall_switch3_pos, door5,
                  Trigger.TriggerType.WALL, 2, (float)Math.PI / 2, texture_name: TNames.wall_switch_inactive );
              add_object( wall_switch3 );
              wall_switch4 = new Trigger( this, wall_switch_active_texture,
                  wall_switch_inactive_texture, wall_switch4_pos, door6,
                  Trigger.TriggerType.WALL, 2, (float)( 3 * Math.PI / 2 ), texture_name: TNames.wall_switch_inactive );
              add_object( wall_switch4 );
              win_switch = new Trigger( this, ground_switch_active_texture,
                  ground_switch_inactive_texture, win_switch_pos, door7,
                  Trigger.TriggerType.FLOOR, 300, 0 );
              add_object( win_switch );

              // Create Ball
              ball1 = new Ball( this, ball_texture, ball1_pos, 2.0f );
              add_object( ball1 );
              ball2 = new Ball( this, ball_texture, ball2_pos, 2.0f );
              add_object( ball2 );
              ball3 = new Ball( this, ball_texture, ball3_pos, 2.0f );
              add_object( ball3 );
              ball4 = new Ball( this, ball_texture, ball4_pos, 2.0f );
              add_object( ball4 );
              ball5 = new Ball( this, ball_texture, ball5_pos, 2.0f );
              add_object( ball5 );
              ball6 = new Ball( this, ball_texture, ball6_pos, 2.0f );
              add_object( ball6 );
              ball7 = new Ball( this, ball_texture, ball7_pos, 2.0f );
              add_object( ball7 );
              ball8 = new Ball( this, ball_texture, ball8_pos, 2.0f );
              add_object( ball8 );

              var ball_2 = new Ball( this, ball_texture,
                  ninja_position, 1.0f );

              //Add ninja to the world
              add_object( m_ninja );
              add_object( ball_2 );

              */
            editor.ninjaBindingSource.DataSource = m_ninja;
            editor.gameObjectBindingSource.DataSource = m_ninja;

            // Create ninja controller
            m_ninja_controller = new NinjaController( this, m_ninja );
            m_world.AddController( m_ninja_controller );

            // Create mouse controller
            mouse_control = new MouseController( GameScreen.GAME_WIDTH, GameScreen.GAME_HEIGHT );

            /*
            // Create walls
            foreach ( var wall in walls )
            {
                // Convert dimensions in the other format
                if ( wall.Length < 4 )
                {
                    new_wall = new[] {
                        wall[0], new Vector2(wall[0].X + wall[1].X, wall[0].Y),
                        new Vector2(wall[0].X + wall[1].X, wall[0].Y + wall[1].Y),
                        new Vector2(wall[0].X, wall[0].Y + wall[1].Y)
                    };
                }
                else new_wall = (Vector2[]) wall.Clone();

                add_object( new PolygonObject( this, new_wall, wall_texture, 1.0f, 0.0f, 0.7f ) );
            }

            // Create breakable walls
            foreach ( var wall in break_walls )
            {
                // Convert dimensions in the other format
                if ( wall.Length < 4 )
                {
                    new_wall = new[] {
                        wall[0], new Vector2(wall[0].X + wall[1].X, wall[0].Y),
                        new Vector2(wall[0].X + wall[1].X, wall[0].Y + wall[1].Y),
                        new Vector2(wall[0].X, wall[0].Y + wall[1].Y)
                    };
                }
                else new_wall = (Vector2[])wall.Clone();
                PolygonObject b = new PolygonObject( this, new_wall,
                    breakwall_texture_animate[0], 1.0f, 0.0f, 0.7f, 30.0f );
                add_object( b );
            }
            */

            //save_state();
        }
Example #9
0
        public override void Initialize()
        {
            m_sprite_batch = ScreenManager.SpriteBatch;
            m_graphics_device = ScreenManager.GraphicsDevice;
            GAME_CONTENT = ScreenManager.ContentManager;

            m_timer = new Timer();
            // m_power_bar = new PowerBar();

            m_paused = false;

            //Create the form to which we will add the editor panel
            form_surface = new Panel();

            //Create an instance of the level editor and put it on the main screen
            editor = new Editor( this );
            editor.MouseHover += new EventHandler( editor_MouseHover );
            Control.FromHandle( ( GameEngine.GameWindow.Handle ) ).VisibleChanged
                += new EventHandler( GameScreen_VisibleChanged );
            form_surface.Width = 300;
            form_surface.Height = Form.FromHandle( GameEngine.GameWindow.Handle ).Height;
            Form.FromHandle( GameEngine.GameWindow.Handle ).Click
                += new System.EventHandler( gameControl_Click );
            Form.FromHandle( GameEngine.GameWindow.Handle ).MouseHover
                += new EventHandler( GameScreen_MouseHover );
            Form.FromHandle( GameEngine.GameWindow.Handle ).MouseLeave
                += new EventHandler( GameScreen_MouseLeave );
            editor_camera_movement = Vector2.Zero;
            FORM_OFFSET = 0;
            editor_mode = false;

            GAME_WIDTH = GameEngine.GraphicsDeviceManager.PreferredBackBufferWidth;
            GAME_HEIGHT = GameEngine.GraphicsDeviceManager.PreferredBackBufferHeight;
            GameEngine.GraphicsDeviceManager.ApplyChanges();

            //m_play_view = new Camera(m_graphics_device.Viewport);
            m_curr_view = new Camera( m_graphics_device.Viewport, 0 );
            // m_curr_view = m_edit_view;

            m_polygon_drawer = new Polygondrawer( m_graphics_device,
                   GAME_WIDTH, GAME_HEIGHT, m_curr_view, BlendState.AlphaBlend );
            LoadContent();
        }
Example #10
0
        public void draw_throwable_aura( SpriteBatch sprite_batch, Camera eye, Color aura_color )
        {
            var origin = new Vector2( TestWorld.highlight_texture.Width,
                TestWorld.highlight_texture.Height ) / 2;

            sprite_batch.Draw( TestWorld.highlight_texture,
                GameWorld.SCALE * m_body.Position, null,
                aura_color,
                m_body.Rotation, origin, 0.7f * m_radius
               , 0.0f, 1 );
        }
Example #11
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            // Pick out the right frame
            int image_size = m_texture.Width / 2;

            int frame = m_active ? 1 : 0;

            var origin = new Vector2( image_size, m_texture.Height ) / 2;

            // Draw the switch rectangle
            Rectangle src = new Rectangle( frame * image_size,  //get the frame to display
                                          0,                    //the image only has 1 row of frames
                                          image_size, m_texture.Height );    //image height and width

            sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, src,
                             m_tint, m_body.Rotation, origin, m_size_scale,
                             0.0f, 0
                );
        }
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            worldeffect = Matrix.CreateRotationZ(m_body.Rotation) *
            Matrix.CreateScale(GameWorld.SCALE) *
            Matrix.CreateTranslation(new Vector3(GameWorld.SCALE * m_body.Position, 0));
            if ( GameScreen.editor_mode ) {

                var drawer = GameScreen.m_polygon_drawer;
                drawer.drawPolygons( worldeffect, m_texture,
                                    m_vertices,
                                    BlendState.AlphaBlend, eye );
            }
        }
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            //scale is 1 for now, need to change
            /* sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position,
                                            null, Color.White, m_rotation, m_origin, 1f, SpriteEffects.None, 0 ); */

            var drawer = GameScreen.m_polygon_drawer;
            foreach ( VertexPositionTexture[] the_vert in m_vertices ) {
                //drawer.drawPolygons( GameWorld.SCALE * m_body.Position, m_body.Rotation, GameWorld.SCALE, TestWorld.wall_texture,
                //                    the_vert,
                //                    BlendState.AlphaBlend, eye );
            }
        }
Example #14
0
        public override void draw(SpriteBatch sprite_batch, Camera eye)
        {
            var origin = new Vector2(m_texture.Width, m_texture.Height) / 2;
            float width_ratio = m_texture.Width/GameWorld.SCALE;
            float height_ratio = GameWorld.SCALE/m_texture.Height;
            Vector2 draw_pos = m_body.Position;

            for(int i = 0; i<tile_num_x;i++)
            {
                draw_pos.X = m_body.Position.X + i*m_size.X*width_ratio;
                for(int j = 0; j<tile_num_y;j++)
                {
                    draw_pos.Y = m_body.Position.Y + j * m_size.Y * height_ratio;

                    draw_at_pos(sprite_batch,draw_pos);
                }
            }
        }
Example #15
0
 // draws the ball
 // Uses the standard Throwable Object draw
 public override void draw( SpriteBatch sprite_batch, Camera eye )
 {
     base.draw( sprite_batch, eye );
 }
Example #16
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            base.draw( sprite_batch, eye );

            var origin = new Vector2( TestWorld.egg_texture.Width, TestWorld.egg_texture.Height ) / 2;
            Matrix r = Matrix.CreateRotationZ( m_rotation );

            sprite_batch.Draw( TestWorld.egg_texture, GameWorld.SCALE * ( m_body.Position + Vector2.Transform( new Vector2( 0, -m_size * 0.7f ), r ) ), null,
                                 Color.White, m_body.Rotation, origin, m_size_scale * 0.5f,
                                  0.0f, 0 );
        }
Example #17
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            m_size_scale *= 2f;
            base.draw( sprite_batch, eye );
            m_size_scale /= 2f;

            m_size_scale *= 1.4f;
            var origin = new Vector2( TestWorld.egg_texture.Width, TestWorld.egg_texture.Height ) / 2;
            Matrix r = Matrix.CreateRotationZ( m_rotation );
            foreach ( Egg egg in eggs ) {
                if ( egg.intact ) {
                    sprite_batch.Draw( TestWorld.egg_texture, GameWorld.SCALE * ( m_body.Position + Vector2.Transform( egg.pos, r ) ), null,
                                         Color.White, m_body.Rotation + egg.angle, origin, m_size_scale,
                                          0.0f, 0
                                        );
                }
            }
            m_size_scale /= 1.4f;
        }
Example #18
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            if ( m_collision_type != AlienCollisionType.SPIKED ) {
                draw_destroyable( sprite_batch, eye );
            }

            if ( m_disabled ) {
                m_tint = Color.Lerp( m_alien_color, m_tint, 0.5f );
            }
            // Block for alien playing dying animation
            if ( m_alien_dying || !m_body.Enabled ) {
                if ( m_alien_dying ) {
                    m_body.LinearDamping = 0;
                }

                m_tint = Color.Lerp( m_alien_color, m_tint, 0.5f );
                m_body.ApplyForce( alien_death_force / Math.Max( 1, m_animation_frame / 2 ) );
                int image_size = m_texture_death.Width / m_death_anim_frames;
                int frame = (int)m_animation_frame;

                Vector2 origin = new Vector2( image_size,
                        m_texture_death.Height ) / 2;

                // Draw the alien rectangle
                Rectangle src = new Rectangle( frame * image_size,  //get the frame to display
                                              0,                    //the image only has 1 row of frames
                                              image_size, m_texture_death.Height );    //image height and width

                sprite_batch.Draw( m_texture_death, GameWorld.SCALE * m_body.Position, src,
                             m_alien_color, m_body.Rotation, origin, m_size_scale,
                             0.0f, 0
                );

                m_animation_frame += (float)0.0005f * image_size;
                if ( frame >= m_death_anim_frames ) {
                    if(!death_sound_played){
                        GameEngine.AudioManager.Play( AudioManager.SFXSelection.alien_death );
                        death_sound_played = true;
                    }
                    m_last_destroy_frame = true;
                    m_body.Enabled = false;
                    destroy();
                }
            }
            // Plays animation for attacking
            else if ( m_is_attacking && m_texture_attack != null ) {

                int image_size = m_texture_attack.Width / m_attack_anim_frames;
                int frame = (int)m_animation_frame;
                Vector2 origin = new Vector2( image_size,
                        m_texture_attack.Height ) / 2;

                // Draw the alien rectangle
                Rectangle src = new Rectangle( frame * image_size,  //get the frame to display
                                              0,                    //the image only has 1 row of frames
                                              image_size, m_texture_attack.Height );    //image height and width

                sprite_batch.Draw( m_texture_attack, GameWorld.SCALE * m_body.Position, src,
                             m_alien_color, m_body.Rotation, origin, m_size_scale,
                             0.0f, 0
                );
                m_animation_frame += 0.0002f * image_size;
                m_animation_frame %= m_attack_anim_frames;
                if ( frame == m_attack_anim_frames ) {
                    m_is_attacking = false;
                    m_animation_frame = 0.0f;
                }
            }
            else {
                var origin = new Vector2( m_texture.Width, m_texture.Height ) / 2;
                sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, null,
                                 m_alien_color, m_body.Rotation, origin, m_size_scale,
                                  0.0f, 0
                                );
            }
            //Aura drawings
            if ( m_alien_dying ) {
                var origin = new Vector2( TestWorld.highlight_texture.Width, TestWorld.highlight_texture.Height ) / 2;

                sprite_batch.Draw(TestWorld.highlight_texture, GameWorld.SCALE * m_body.Position, null,
                   Color.CornflowerBlue, m_body.Rotation, origin,
                    // Number next to max is the minimum size, number next to min is the maximum size
                    m_width_height / 5 * Math.Max( 0.8f, Math.Min( 1.5f, 200 / (float)Math.Pow( ( m_position - m_world.m_ninja.m_position ).Length(), 2 ) ) ), 0.0f, 1 );

            }
            else if ( m_world.m_ninja.m_speed < m_kill_under_speed
                || m_collision_type != AlienCollisionType.NORMAL ) {

                var origin = new Vector2( TestWorld.highlight_texture.Width, TestWorld.highlight_texture.Height ) / 2;

                sprite_batch.Draw( TestWorld.highlight_texture, GameWorld.SCALE * m_body.Position, null,
                   m_tint, m_body.Rotation, origin,
                    // Number next to max is the minimum size, number next to min is the maximum size
                    m_width_height / 5 * Math.Max( 0.8f, Math.Min( 1.5f, 200 / (float)Math.Pow( ( m_position - m_world.m_ninja.m_position ).Length(), 2 ) ) ), 0.0f, 1 );

            }
            else if ( m_world.m_ninja.m_speed < m_destroy_threshold && m_world.m_ninja.m_speed > m_kill_under_speed ) {
                var origin = new Vector2( TestWorld.highlight_texture.Width, TestWorld.highlight_texture.Height ) / 2;

                sprite_batch.Draw( TestWorld.highlight_texture, GameWorld.SCALE * m_body.Position, null,
                   Color.Lerp( m_tint, Color.Silver, .6f ), m_body.Rotation, origin,
                    // Number next to max is the minimum size, number next to min is the maximum size
                    m_width_height / 5 * 1.1f, 0.0f, 1 );

            }
        }
Example #19
0
        public void draw_destroyable( SpriteBatch sprite_batch, Camera eye )
        {
            if ( m_is_destructible && m_world.m_ninja.m_speed > m_destroy_threshold ) {

                var origin = new Vector2( TestWorld.highlight_texture.Width,
                    TestWorld.highlight_texture.Height ) / 2;

                sprite_batch.Draw( TestWorld.highlight_texture,
                    GameWorld.SCALE * m_body.Position, null,
                    Color.Lerp( m_tint, new Color( 0, 255, 0, 1 ), 0.9f ),
                    m_body.Rotation, origin, 0.7f * m_width_height / 5 *
                    Math.Max( 1.2f, Math.Min( 1.8f, m_world.m_ninja.m_speed / m_destroy_threshold ) ), 0.0f, 1 );

            }
        }
        /**
         * Draws the collection of photons to the given graphics context
         * (SpriteBatch).  Note that all objects have been predeclared
         * and are reused.
         */
        public void draw( SpriteBatch sprite_batch, Camera eye )
        {
            Vector2 origin = new Vector2( 0.3f * PHOTON_SIZE );

            // Now, step through each active photon in the queue.
            for ( int ii = 0; ii < m_size; ii++ ) {
                // Find the position of this photon.
                int idx = ( ( m_head + ii ) % MAX_PHOTONS );

                // How big to make the photon.  Decreases with age.
                float scale = 2.0f - (float)m_queue[idx].age / (float)MAX_AGE;

                // How much to rotate the image
                float rotate = 0.0f;

                int R = 0;
                int G = 0;
                int B = 0; ;
                if ( m_ninja_speed < 50 ) {
                    // Color of the photon
                    R = 150;
                    G = 255;
                }
                else if ( m_ninja_speed < 100 ) {
                    R = 255;
                    G = 127;
                }
                else if ( m_ninja_speed >= 100 ) {
                    R = 255;
                }

                //m_queue[idx].color_speed
                Color tint = new Color( R, G,
                      B, (byte)MathHelper.Clamp( ( 1 - m_queue[idx].age /
                      (float)MAX_AGE ) * 255f, 0, 255 ) );
                // Use this information to draw.
                // The last 0 instructs this to draw on top (not underneath)
                sprite_batch.Draw( m_texture, m_queue[idx].pos *
                    GameWorld.SCALE, null, tint, rotate, origin,
                    scale, SpriteEffects.None, 0 );
            }
        }
Example #21
0
        public void Draw( SpriteBatch sprite_batch, Camera eye )
        {
            if ( m_active ) {

                // Pick out the right frame
                int image_size = m_texture.Width / NUM_ANIM_FRAMES;

                Vector2 origin = new Vector2( image_size,
                    m_texture.Height ) / 2;

                // Pick the color
                m_tint = new Color( 255, 255,
                       255, (byte)MathHelper.Clamp( ( 1 - m_animation_frame / (float)NUM_ANIM_FRAMES ) * 255f, 0, 255 ) );

                // Draw the source rectangle
                Rectangle src = new Rectangle( ( m_animation_frame - 1 ) * image_size,  //get the frame to display
                                              0,                    //the image only has 1 row of frames
                                              image_size, image_size );    //image height and width

                sprite_batch.Draw( m_texture, GameWorld.SCALE * m_position, src,
                                 m_tint, m_angle, origin, 0.2f,
                                 0.0f, 0
                    );

            }
        }
Example #22
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            draw_destroyable( sprite_batch, eye );

            if ( m_vertices.Length > 0 ) {
                var drawer = GameScreen.m_polygon_drawer;
                drawer.drawPolygons( worldeffect, m_texture,
                                    m_vertices,
                                    BlendState.AlphaBlend, eye );
            }
            // base.draw(sprite_batch, eye);
        }
 public override void draw( SpriteBatch sprite_batch, Camera eye )
 {
     if ( GameScreen.editor_mode ) {
         base.draw( sprite_batch, eye );
     }
 }
Example #24
0
        //---------------------------------------------------------------
        // Constructor
        //---------------------------------------------------------------
        //
        // TODO: add collision_detection_position as argument to constructor?
        public TestWorld( Camera view, Editor editor, String filename, bool teleport_camera = true )
            : base(ground_texture.Width, ground_texture.Height,
            new Vector2( 0, GRAVITY ))
        {
            // play bgm

            GameEngine.LevelManager.background_select();
            GameEngine.LevelManager.song_select();

            eye = view;
            eye.m_zoom_mult = 1;
            mouse_control = new MouseController( GameScreen.GAME_WIDTH, GameScreen.GAME_HEIGHT );

            create_world( this, filename );

            editor.ninjaBindingSource.DataSource = m_ninja;
            editor.gameObjectBindingSource.DataSource = m_ninja;
            eye.m_curr_target = m_ninja;

            if (teleport_camera)
            {
                eye.m_camera_position = (m_ninja.m_position + new Vector2(0, -12)) * SCALE;
            }

            m_world.ContactManager.BeginContact += m_collision_manager.contact_started;
            m_world.ContactManager.EndContact += m_collision_manager.contact_ended;

            //Queen lisa = new Queen( this, queen_texture, m_ninja.m_position + new Vector2( 0, -50 ), 3, Alien.AlienType.QUEEN, 300 );
            //add_object( lisa );
        }
Example #25
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            var origin = new Vector2( m_texture.Width,
                m_texture.Height ) / 2;

            float diff = m_power - m_world.m_ninja.m_speed;
            float brightness = Math.Max( 0, -diff * 5 );

            sprite_batch.Draw( m_texture, GameWorld.SCALE *
                m_body.Position, null,
                Color.Lerp( m_tint, new Color( Math.Max( 0, diff * 10 ), brightness, brightness ), 0.5f ),
                m_body.Rotation - (float)Math.PI / 2, origin, m_scale, 0.0f, 0
            );
        }
Example #26
0
        public override void Draw( SpriteBatch sprite_batch, Camera eye )
        {
            if ( eye.m_curr_target != null && eye.m_curr_target.m_body != null ) { eye.Update(); }
            sprite_batch.End();
            MouseState ms = Mouse.GetState();
            if ( !m_ninja.m_is_killed ) {
                // set the mousecontroller's field
                mouse_control.m_center = m_ninja.m_position;
            }

            //            m_background = GameScreen.m_background;
            //            Vector2 origin = new Vector2( m_background.Width,
            //                m_background.Height ) / 2;
            //            Color background_tint = Color.WhiteSmoke;

            //            if (m_background == Statics.get_texture("Art/speedup-RedSquarebackground"))
            //            {
            //                background_tint = new Color(70,255,255);
            //            }
            //            else if (m_background == Statics.get_texture("Art/speedup-IceClouds"))
            //            {
            //               background_tint = new Color(50,50,50);
            //            }
            //            else if ( m_background != TestWorld.ground_texture )
            //            {
            //                background_tint = new Color(120,120,120);
            //            }

            //           /* sprite_batch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend,
            //=======
            //            if ( m_background != TestWorld.ground_texture && m_background != Statics.get_texture( "Art/speedup-RedSquarebackground" ) ) {
            //                background_tint = new Color( 120, 120, 120 );
            //            }
            //            else if ( m_background == Statics.get_texture( "Art/speedup-RedSquarebackground" ) ) {
            //                background_tint = new Color( 70, 255, 255 );
            //            }
            //            else if ( m_background == Statics.get_texture( "Art/speedup-IceClouds" ) ) {
            //                background_tint = new Color( 50, 50, 100 );
            //            }
            //            sprite_batch.Begin( SpriteSortMode.BackToFront, BlendState.AlphaBlend,
            //>>>>>>> 0d56fc3fc89fef40509bd59baafb8122e2700b5f
            //                null,
            //                              null, null, null, eye.get_background_transformation() );
            //            {
            //                foreach ( GameObject tile in m_background_tiles ) {
            //                    tile.draw( sprite_batch, eye );
            //                }
            //            }

            //            sprite_batch.End();*/

            //            sprite_batch.Begin( SpriteSortMode.BackToFront, null,
            //                 SamplerState.LinearWrap,
            //                               null, null, null, eye.get_background_transformation() );

            //            sprite_batch.Draw( m_background,
            //               eye.m_camera_position - new Vector2( GameScreen.GAME_WIDTH * 6f,
            //               GameScreen.GAME_HEIGHT * 5f ),
            //               new Rectangle( (int)( eye.m_camera_position.X / 7 ),
            //               (int)( eye.m_camera_position.Y / 7 ),
            //               (int)( m_background.Width * 2.5 / eye.m_camera_zoom ),
            //                (int)( m_background.Height * 1 / eye.m_camera_zoom ) ),
            //               background_tint, 0, origin, 7f, 0, 0 );

            //            sprite_batch.End();

            //test camera control
            //zoom out when going fast
            //pans direction towards velocity
            if ( !m_ninja.m_is_dead ) {
                if ( !GameScreen.editor_mode && eye.m_curr_target is Ninja ) {

                    if ( m_ninja.m_speed > 110 ) {
                        eye.m_zoom_change = 0.2f;
                    }
                    else if ( m_ninja.m_speed < 80 && m_ninja.m_speed > 70 ) {
                        eye.m_zoom_change = 0.25f;
                    }
                    else if ( m_ninja.m_speed < 40 && m_ninja.m_speed > 20 ) {
                        eye.m_zoom_change = 0.3f;
                    }
                    else if ( m_ninja.m_speed < 0.001f ) {
                        eye.m_zoom_change = 0.45f;
                    }
                    else if ( m_ninja.m_speed < 0.0001f ) {
                        eye.m_zoom_change = 0.6f;
                    }
                }
            }

            sprite_batch.Begin( SpriteSortMode.Texture,
                BlendState.AlphaBlend,
                              null, null, null, null,
                              eye.get_transformation() );

            //Draws all the GameObjects
            base.Draw( sprite_batch, eye );

            sprite_batch.End();

            sprite_batch.Begin( SpriteSortMode.BackToFront,
              BlendState.Additive, null, null, null, null,
              eye.get_transformation() );

            // Draw the photon trail
            m_ninja.m_speed_trail.draw( sprite_batch, eye );
            m_ninja.m_sonicboom.Draw( sprite_batch, eye );

            sprite_batch.End();

            sprite_batch.Begin();
        }
Example #27
0
        public override void draw( SpriteBatch sprite_batch, Camera eye )
        {
            var origin = new Vector2( m_texture.Width, m_texture.Height ) / 2;
            if ( m_size == Vector2.Zero ) {
                if ( m_radius != 0 ) {
                    float scale = m_radius / m_texture.Width * GameWorld.SCALE * 2;
                    sprite_batch.Draw( m_texture, GameWorld.SCALE * m_body.Position, null,
                    m_tint, m_body.Rotation, origin, scale, 0.0f, 0 );
                }
            }
            else {

                sprite_batch.Draw( m_texture, GameWorld.SCALE *
                    m_body.Position, null, m_tint,
                    m_body.Rotation, origin, m_scale, 0.0f, 0
                );
            }
        }
Example #28
0
 // Uses the PolygonObject Draw
 public override void draw( SpriteBatch sprite_batch, Camera eye )
 {
     var drawer = GameScreen.m_polygon_drawer;
     //drawer.drawPolygons( GameWorld.SCALE * m_draw_location, 0, GameWorld.SCALE, m_texture,
     //                    m_vertices,
     //                    BlendState.AlphaBlend, eye );
 }
Example #29
0
        // draws all objects in the physics world
        public virtual void Draw( SpriteBatch sprite_batch, Camera eye )
        {
            m_count += 0.1f;
            Texture2D mouse_texture = TestWorld.shuriken;
            var origin = new Vector2( mouse_texture.Width, mouse_texture.Height ) / 2;

            sprite_batch.Draw( mouse_texture, GameWorld.SCALE * m_mouse_pos_transform(), null,
            Color.Gold, m_count, origin, 0.1f / GameScreen.m_curr_view.m_camera_zoom, 0.0f, 1 );

            foreach ( GameObject obj in m_objects )
                if ( obj is BackgroundTile ) {
                    //DO NOTHING
                }
                else if ( GameScreen.within_screen_bounds( obj.m_body.Position ) ) { obj.draw( sprite_batch, eye ); }

                else if ( obj is PolygonObject ) {

                    // if ( GameScreen.within_screen_bounds
                    //     ( obj.m_body.Position, vertices: ((PolygonObject)obj).m_verts ) )
                    { obj.draw( sprite_batch, eye ); }

                }

                else if ( obj is SelectBox ) { obj.draw( sprite_batch, eye ); }
        }