示例#1
0
 public Selector( GameWorld world, Texture2D texture,
     Vector2 position, float radius, Editor edit )
     : base(world, texture,
         position, radius)
 {
     editor = edit;
 }
示例#2
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();
        }
示例#3
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 );
        }
示例#4
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();
        }