Exemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////////
        int character_on_fixture(Character c)
        {
            // reset point for character and not for brush?
              int fixture_below = point_in_fixture (c.x + (c.width / 2), c.y + (c.length / 2), c.z - 1);
              if (fixture_below == -1) fixture_below = point_in_fixture (c.x + 1, c.y + 1, c.z - 1);
              if (fixture_below == -1) fixture_below = point_in_fixture (c.x + c.width - 1, c.y + 1, c.z - 1);
              if (fixture_below == -1) fixture_below = point_in_fixture (c.x + 1, c.y + c.length - 1, c.z - 1);
              if (fixture_below == -1) fixture_below = point_in_fixture (c.x + c.width - 1, c.y + c.length - 1, c.z - 1);

              return fixture_below;
        }
Exemplo n.º 2
0
    ////////////////////////////////////////////////////////////////////////////////

    protected override void Initialize()
      {
      base.Initialize();
      this.IsMouseVisible = true;

      graphics.PreferredBackBufferWidth = screen_width;
      graphics.PreferredBackBufferHeight = screen_height;
      graphics.IsFullScreen = false;//true;
      graphics.ApplyChanges();

      light_buffer = new RenderTarget2D (GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

      // initialize class arrays
      for (int i = 0; i < max_effects;    i += 1) particle_effect[i] = new ParticleEffect ();
      for (int b = 0; b < max_brushes;    b += 1) brush[b] = new Brush ();
      for (int f = 0; f < max_fixtures;   f += 1) fixture[f] = new Fixture ();
      for (int o = 0; o < max_objects;    o += 1) obj[o] = new Object ();
      for (int c = 0; c < max_characters; c += 1) character[c] = new Character ();

      player_level = 2;  // starting level, default 0

      load_map();

      if (player_added_to_map == false)
        {
        add_character ("Richard", (int) C.RICHARD, 64, 64, 256);
        }

      // scroll border is inside box of screen (non-scrolling part)
      scroll_border.X = Convert.ToInt32 (screen_width * 2 / 5);
      scroll_border.Y = Convert.ToInt32 (screen_height * 2 / 5);
      scroll_border.Width = Convert.ToInt32 (screen_width * 1/5);
      scroll_border.Height = Convert.ToInt32 (screen_height * 1/5);

      // menu
      menu_width = Convert.ToInt32 (screen_width * .75);
      menu_height = Convert.ToInt32 (screen_height * .75);
      menu_x = (screen_width - menu_width) / 2;
      menu_y = (screen_height - menu_height) / 2;
      menu_exit_v.X = menu_x + 20;
      menu_exit_v.Y = menu_y + 20;
      }
Exemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////////
        int character_in_fixture(Character c, bool solid_only)
        {
            int f = 0;
              int clip = -1;

              while (clip == -1 && f < total_fixtures)
            {
            if (c.x + (c.width / 2) >= fixture[f].x && c.x - (c.width / 2) <= fixture[f].x + fixture[f].width
            && c.y + (c.length / 2) >= fixture[f].y && c.y - (c.length / 2) <= fixture[f].y + fixture[f].length
            && c.z + c.height >= fixture[f].z && c.z <= fixture[f].z + fixture[f].height)
              {
              if (solid_only == true && fixture[f].solid == false) clip = -1;
              else clip = f;
              }
            f += 1;
            }

              return clip;
        }
Exemplo n.º 4
0
        ////////////////////////////////////////////////////////////////////////////////
        int character_in_brush(Character c)
        {
            int b = 0;
              int clip = -1;

              while (clip == -1 && b < total_brushes)
            {
            if (c.x + (c.width / 2) >= brush[b].x
            && c.x - (c.width / 2) <= brush[b].x + brush[b].width
            && c.y + (c.length / 2) >= brush[b].y
            && c.y - (c.length / 2) <= brush[b].y + brush[b].length
            && c.z + c.height >= brush[b].z
            && c.z <= brush[b].z + brush[b].height)
              {
              if (brush[b].top_texture_number == (int) T.DOOR_RED_V_TOP_CLOSED_TEST && red_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_RED_H_TOP_CLOSED_TEST && red_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_YELLOW_V_TOP_CLOSED_TEST && yellow_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_YELLOW_H_TOP_CLOSED_TEST && yellow_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_GREEN_V_TOP_CLOSED_TEST && green_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_GREEN_H_TOP_CLOSED_TEST && green_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_BLUE_V_TOP_CLOSED_TEST && blue_doors_open == true) clip = -1;
              else if (brush[b].top_texture_number == (int) T.DOOR_BLUE_H_TOP_CLOSED_TEST && blue_doors_open == true) clip = -1;
              else clip = b;
              }
            b += 1;
            }

              return clip;
        }
Exemplo n.º 5
0
        ////////////////////////////////////////////////////////////////////////////////
        public bool is_facing_character(Character target)
        {
            double radians_needed = get_direction (dx, dy, target.dx, target.dy);

              if (radians_needed + MathHelper.ToRadians (45) > MathHelper.ToRadians (360)
              && dir + MathHelper.ToRadians (360) <= radians_needed + MathHelper.ToRadians (45)
              && dir + MathHelper.ToRadians (360) >= radians_needed - MathHelper.ToRadians (45))
            return true;

              else if (radians_needed - MathHelper.ToRadians (45) < MathHelper.ToRadians (0)
              && dir <= radians_needed + MathHelper.ToRadians (45)
              && dir - MathHelper.ToRadians (360) >= radians_needed - MathHelper.ToRadians (45))
            return true;

              else if (dir <= radians_needed + MathHelper.ToRadians(45)
              && dir >= radians_needed - MathHelper.ToRadians(45))
            return true;

              else return false;
        }
Exemplo n.º 6
0
 ////////////////////////////////////////////////////////////////////////////////
 public void face_character(Character target)
 {
     dir = get_direction (x, y, target.x, target.y);
 }
Exemplo n.º 7
0
 ////////////////////////////////////////////////////////////////////////////////
 public void attack_character(Character target_character, int target_id)
 {
     goal = "attack";
       target_type = "character";
       target = target_id;
       subtarget_x = target_character.x;
       subtarget_y = target_character.y;
       subtarget_z = target_character.z;
       face_character (target_character);
       //self_velocity = speed;
 }