Exemple #1
0
static void do_action(struct Player *pp, Action ac)
{
    Action pre_action;
    pre_action = previous_action(pp);
    int pre_frame = pre_action.frame;
    int nframe;

    if (equal_action(pre_action, ac))
    {
        nframe = next_frame(pp, ac, pre_frame);
        set_frame(pp, nframe);
        complete_action(pp);
    }
    else if (pre_frame != 0)    // previous action unfinished
    {
        if (action_interruptable(pre_action))
        {
            set_action(pp, ac);
            complete_action(pp); //pp->spd = spd;
        }
        else
            do_action(pp, pre_action);
    }
    else          // previous action finished, set new action
    {
        set_action(pp, ac);
       complete_action(pp);
    }
}
Exemple #2
0
void Player::set_jump(Map *map, bool catapult)
{
    m_media->play_sound("jump.wav");

    if (m_in_water) {
        if (catapult) {
            set_vy(-get_attribute("water_catapult_speed"));
            set_action(Catapult);
        }
        else {
            set_vy(-get_attribute("water_jump_speed"));
            set_action(Jump);
        }
    }
    else {
        if (catapult) {
            set_vy(-get_attribute("catapult_speed"));
            set_action(Catapult);
        }
        else {
            set_vy(-get_attribute("jump_speed"));
            set_action(Jump);
        }
    }

    m_hit_ground = false;
}
Exemple #3
0
/*
 * activate the add point item in the canvas event proc
 */
static void do_add_proc(void *data)
{
    char *s;

    set_action(DO_NOTHING);

    track_add_at = (int) data;

    switch (track_add_at) {
    case ADD_POINT_BEGINNING:
        s = "Add points at the beginning of set";
        break;
    case ADD_POINT_END:
        s = "Add points to the end of set";
        break;
    case ADD_POINT_NEAREST:
        s = "Add points to the nearest position";
        break;
    default:
        return;
    }

    SetLabel(locate_point_message, s);

    set_action(ADD_POINT);
}
void _learning_spell(int cmd, variant *res)
{
    switch (cmd)
    {
    case SPELL_NAME:
        var_set_string(res, "Learning");
        break;
    case SPELL_DESC:
        var_set_string(res, "");
        break;
    case SPELL_CAST:
        if (p_ptr->action == ACTION_LEARN)
            set_action(ACTION_NONE);
        else
            set_action(ACTION_LEARN);
        var_set_bool(res, TRUE);
        break;
    case SPELL_ENERGY:
        var_set_int(res, 0);
        break;
    default:
        default_spell(cmd, res);
        break;
    }
}
Exemple #5
0
/*
 * move a point
 */
static void do_ptsmove_proc(void *data)
{
    char *s;
    
    set_action(DO_NOTHING);

    track_move_dir = (int) data;

    switch (track_move_dir) {
    case MOVE_POINT_XY:
        s = "Move points";
        break;
    case MOVE_POINT_X:
        s = "Move points along x";
        break;
    case MOVE_POINT_Y:
        s = "Move points along y";
        break;
    default:
        return;
    }
    SetLabel(locate_point_message, s);

    set_action(MOVE_POINT1ST);
}
Exemple #6
0
//範囲を選択しているかどうかの状態が変わったときの動作
void change_selection(void)
{
    gboolean flag = gtk_text_buffer_get_has_selection(GTK_TEXT_BUFFER(buffer));
    
    set_action("Cut", flag);
    set_action("Copy", flag);
    set_action("Delete", flag);
}
Exemple #7
0
void
signal_setup()
{
	set_action(SIGABRT, act_sig_handle_abort);
	set_action(SIGBUS, act_sig_handle_bus);
	set_action(SIGFPE, act_sig_handle_fpe);
	set_action(SIGILL, act_sig_handle_ill);
	set_action(SIGSEGV, act_sig_handle_segv);
}
void
WalkingBadguy::active_update(float elapsed_time, float dest_x_velocity)
{
  BadGuy::active_update(elapsed_time);

  float current_x_velocity = physic.get_velocity_x ();

  if (frozen)
  {
    physic.set_velocity_x (0.0);
    physic.set_acceleration_x (0.0);
  }
  /* We're very close to our target speed. Just set it to avoid oscillation */
  else if ((current_x_velocity > (dest_x_velocity - 5.0))
      && (current_x_velocity < (dest_x_velocity + 5.0)))
  {
    physic.set_velocity_x (dest_x_velocity);
    physic.set_acceleration_x (0.0);
  }
  /* Check if we're going too slow or even in the wrong direction */
  else if (((dest_x_velocity <= 0.0) && (current_x_velocity > dest_x_velocity))
      || ((dest_x_velocity > 0.0) && (current_x_velocity < dest_x_velocity)))
  {
    /* acceleration == walk-speed => it will take one second to get from zero
     * to full speed. */
    physic.set_acceleration_x (dest_x_velocity);
  }
  /* Check if we're going too fast */
  else if (((dest_x_velocity <= 0.0) && (current_x_velocity < dest_x_velocity))
      || ((dest_x_velocity > 0.0) && (current_x_velocity > dest_x_velocity)))
  {
    /* acceleration == walk-speed => it will take one second to get twice the
     * speed to normal speed. */
    physic.set_acceleration_x ((-1.f) * dest_x_velocity);
  }
  else
  {
    /* The above should have covered all cases. */
    assert (23 == 42);
  }

  if (max_drop_height > -1) {
    if (on_ground() && might_fall(max_drop_height+1))
    {
      turn_around();
    }
  }

  if ((dir == LEFT) && (physic.get_velocity_x () > 0.0)) {
    dir = RIGHT;
    set_action (walk_right_action, /* loops = */ -1);
  }
  else if ((dir == RIGHT) && (physic.get_velocity_x () < 0.0)) {
    dir = LEFT;
    set_action (walk_left_action, /* loops = */ -1);
  }
}
Exemple #9
0
void Actor::reset_attack()
{
    if (m_action == AttackLow) {
        set_action(Crouch);
    }
    else {
        set_action(Still);
    }
}
Exemple #10
0
void Actor::set_attack(void)
{
    if (m_action == Crouch) {
        set_action(LowAttack);
    }
    else {
        set_action(MediumAttack);
    }
    set_vx(0);
}
Exemple #11
0
void Actor::set_attack(void)
{
    if (m_action == Crouch) {
        set_action(AttackLow);
    }
    else {
        set_action(Attack);
    }
    set_vx(0);
}
Exemple #12
0
static int set_buttn(int b, int d)
{
    if (d)
    {
        if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
            return set_action(gui_token(gui_click()));
        if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
            return set_action(GUI_BACK);
    }
    return 1;
}
Exemple #13
0
void Monster::move(Map *map)
{
    set_ay(get_attribute("weight"));

    switch(m_action) {
        case Still:
            break;

        case Move:
            Body::move(map);
            if (get_fall()) {
                set_action(Fall);
            }
            break;

        case Fall:
            Body::move(map);
            if (!get_fall()) {
                m_hit_ground = true;
                set_vx(0);
                set_action(Still);
            }
            break;

        case Jump:
            Body::move(map);
            if (get_fall()) {
                set_action(Still);
            }
            break;

        case Hit:
            if (m_hit == HitPerish) {
                set_vx(0);
                if (m_perish_timer.expired(get_attribute("perish_time"))) {
                    m_hit = HitPerished;
                }
            }
            else if (m_hit_timer.expired(get_attribute("hit_time"))) {
                m_hit_timer.reset();
                set_vx(0);
                set_lock_direction(false);
                m_hit = HitNone;
                set_action(Still);
            }
            Body::move(map);
            break;

        default:
            break;
    }
}
Exemple #14
0
/*
 * Refill the players lamp, or restock his torches
 */
void do_cmd_refill(void)
{
    int slot = equip_find_object(TV_LITE, SV_ANY);

    if (slot)
    {
        object_type *o_ptr = equip_obj(slot);

        if (p_ptr->special_defense & KATA_MUSOU)
            set_action(ACTION_NONE);

        switch (o_ptr->sval)
        {
        case SV_LITE_LANTERN:
            do_cmd_refill_lamp(o_ptr);
            break;
        case SV_LITE_TORCH:
            do_cmd_refill_torch(o_ptr);
            break;
        default:
            msg_print("Your light cannot be refilled.");
        }
    }
    else
        msg_print("You are not wielding a light.");
}
Exemple #15
0
void Walker::move(Map *map)
{
    Monster::move(map);

    switch(m_action) {
        case Still:
            set_action(Move);
            break;

        case Move:
            if (check_ahead(map)) {
                swap_move_dir();
            }

            if (m_dir == Right) {
                set_vx(get_attribute("move_speed"));
            }
            else {
                set_vx(-get_attribute("move_speed"));
            }
            animate_move();
            break;

        default:
            break;
    }

}
bool
Haywire::collision_squished(GameObject& object)
{
  Player* player = dynamic_cast<Player*>(&object);
  if (player && player->is_invincible()) {
    player->bounce (*this);
    kill_fall();
    return true;
  }

  if (is_stunned) {
    player->bounce (*this);
    return true;
  }

  if (!is_exploding) {
    set_action ((dir == LEFT) ? "ticking-left" : "ticking-right", /* loops = */ -1);
    walk_left_action = "ticking-left";
    walk_right_action = "ticking-right";
    set_walk_speed (160);
    time_until_explosion = TIME_EXPLOSION;
    is_exploding = true;
  }

  time_stunned = TIME_STUNNED;
  is_stunned = true;

  player->bounce (*this);
  return true;
}
Exemple #17
0
void RceUpdateProfile::MergeFrom(const RceUpdateProfile& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from._has_bit(0)) {
      mutable_transaction()->::MsgTransaction::MergeFrom(from.transaction());
    }
    if (from._has_bit(1)) {
      set_sku(from.sku());
    }
    if (from._has_bit(2)) {
      set_value(from.value());
    }
    if (from._has_bit(3)) {
      set_key(from.key());
    }
    if (from._has_bit(4)) {
      set_planetid(from.planetid());
    }
    if (from._has_bit(5)) {
      set_action(from.action());
    }
    if (from._has_bit(6)) {
      set_level(from.level());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
Exemple #18
0
void map_t::way_node_add(lpos_t pos) {
  /* check if we are still hovering above the selected way */
  map_item_t *item = item_at(pos);
  if(item_is_selected_way(item)) {
    /* convert mouse position to canvas (world) position */
    const int insert_after = canvas->get_item_segment(item->item, pos);
    if(insert_after >= 0) {
      /* insert it into ways chain of nodes */
      way_t *way = item->object.way;

      /* create new node */
      node_t* node = way->insert_node(appdata.project->osm, insert_after + 1, pos);

      /* clear selection */
      item_deselect();

      /* draw the updated way */
      draw(way);

      /* and now draw the node */
      draw(node);

      /* put gui into idle state */
      set_action(MAP_ACTION_IDLE);

      /* and redo it */
      select_way(way);
    }
  }
}
Exemple #19
0
// -------------------------------------------------------------
// animated, mobile object for adventure map
// -------------------------------------------------------------
void t_actor::on_model_changed()
{
	t_model const& model = get_model();

	t_abstract_adv_actor::on_model_changed();
	set_action( m_action );
}
Exemple #20
0
STATIC MYBOOL scaleCR(lprec *lp, REAL *scaledelta)
{
  REAL *scalechange = NULL;
  int  Result;

  if(!lp->scaling_used) {
    allocREAL(lp, &lp->scalars, lp->sum_alloc + 1, FALSE);
    for(Result = 0; Result <= lp->sum; Result++)
      lp->scalars[Result] = 1;
    lp->scaling_used = TRUE;
  }

  if(scaledelta == NULL)
    allocREAL(lp, &scalechange, lp->sum + 1, FALSE);
  else
    scalechange = scaledelta;

  Result=CurtisReidScales(lp, FALSE, scalechange, &scalechange[lp->rows]);
  if(Result>0) {

    /* Do the scaling*/
    if(scale_updaterows(lp, scalechange, TRUE) ||
       scale_updatecolumns(lp, &scalechange[lp->rows], TRUE))
      lp->scalemode |= SCALE_CURTISREID;

    set_action(&lp->spx_action, ACTION_REBASE | ACTION_REINVERT | ACTION_RECOMPUTE);
  }

  if(scaledelta == NULL)
    FREE(scalechange);

  return((MYBOOL) (Result > 0));
}
Exemple #21
0
void MekaDragon::fire()
{
    if (m_fire_timer.expired(get_attribute("fire_next"))) {
        if (m_bullet_index < m_bullets.size()) {
            if (m_dir == Right) {
                m_bullets[m_bullet_index]->fire(
                    m_x + get_attribute("attack_right"),
                    m_y + get_attribute("attack_medium"),
                    get_attribute("fire_dx"),
                    get_attribute("fire_dy"));
            }
            else if (m_dir == Left) {
                m_bullets[m_bullet_index]->fire(
                    m_x + get_attribute("attack_left"),
                    m_y + get_attribute("attack_medium"),
                    -get_attribute("fire_dx"),
                    get_attribute("fire_dy"));
            }
            m_bullet_index++;
        }
        else {
            m_bullet_index = 0;
            m_idle_timer.reset();
            set_action(Move);
            reset_attack();
        }
    }
}
Exemple #22
0
/*
 * Stop singing if the player is a Bard 
 */
void bard_stop_singing(void)
{
	if (p_ptr->pclass != CLASS_BARD) return;

 	/* Are there interupted song? */
	if (p_ptr->magic_num1[1])
	{
		/* Forget interupted song */
		p_ptr->magic_num1[1] = 0;
		return;
	}

	/* The player is singing? */
	if (!p_ptr->magic_num1[0]) return;

	/* Hack -- if called from set_action(), avoid recursive loop */
	if (p_ptr->action == ACTION_SING) set_action(ACTION_NONE);

	/* Message text of each song or etc. */
	do_spell(REALM_MUSIC, p_ptr->magic_num2[0], SPELL_STOP);

	p_ptr->magic_num1[0] = MUSIC_NONE;
	p_ptr->magic_num2[0] = 0;

	/* Recalculate bonuses */
	p_ptr->update |= (PU_BONUS);

	/* Redraw status bar */
	p_ptr->redraw |= (PR_STATUS);
}
Exemple #23
0
void PlatformApiStub::update_application_list(const ApplicationListUpdate &update) {
    protobuf::bridge::EventSequence seq;
    auto event = seq.mutable_application_list_update();

    for (const auto &a : update.applications) {
        auto app = event->add_applications();
        app->set_name(a.name);
        app->set_package(a.package);

        auto launch_intent = app->mutable_launch_intent();
        launch_intent->set_action(a.launch_intent.action);
        launch_intent->set_uri(a.launch_intent.uri);
        launch_intent->set_type(a.launch_intent.type);
        launch_intent->set_package(a.launch_intent.package);
        launch_intent->set_component(a.launch_intent.component);
        for (const auto &category : a.launch_intent.categories) {
            auto c = launch_intent->add_categories();
            *c = category;
        }

        app->set_icon(a.icon.data(), a.icon.size());
    }

    for (const auto &package : update.removed_applications) {
      auto app = event->add_removed_applications();
      app->set_name("unknown");
      app->set_package(package);
    }

    rpc_channel_->send_event(seq);
}
Exemple #24
0
bool
GoldBomb::collision_squished(GameObject& object)
{
  Player* player = dynamic_cast<Player*>(&object);
  if(player && player->is_invincible()) {
    player->bounce(*this);
    kill_fall();
    return true;
  }
  if(is_valid() && tstate == STATE_NORMAL) {
    tstate = STATE_TICKING;
    frozen = false;
    set_action(dir == LEFT ? "ticking-left" : "ticking-right", 1);
    physic.set_velocity_x(0);

    if (player)
      player->bounce(*this);

    ticking = SoundManager::current()->create_sound_source("sounds/fizz.wav");
    ticking->set_position(get_pos());
    ticking->set_looping(true);
    ticking->set_gain(2.0);
    ticking->set_reference_distance(32);
    ticking->play();
  }
  return true;
}
Exemple #25
0
void MummyDragon::fire()
{
    if (m_fire_timer.expired(get_attribute("fire_next"))) {
        if (m_bullet_index < m_bullets.size()) {
            int delta_x =
                get_attribute("fire_max_dx") - get_attribute("fire_min_dx");
            int delta_y =
                get_attribute("fire_max_dy") - get_attribute("fire_min_dy");
            int fire_dx = (rand() % delta_x) + get_attribute("fire_min_dx");
            int fire_dy = (rand() % delta_y) + get_attribute("fire_min_dy");

            if (m_dir == Right) {
                m_bullets[m_bullet_index]->fire(
                    m_x + get_attribute("attack_right"),
                    m_y + get_attribute("attack_medium"),
                    fire_dx, fire_dy);
            }
            else if (m_dir == Left) {
                m_bullets[m_bullet_index]->fire(
                    m_x + get_attribute("attack_left"),
                    m_y + get_attribute("attack_medium"),
                    -fire_dx, fire_dy);
            }
            m_bullet_index++;
        }
        else {
            m_bullet_index = 0;
            set_action(Move);
            reset_attack();
        }
    }
}
Exemple #26
0
Owl::Owl(const Vector& pos, Direction d) :
  BadGuy(pos, d, "images/creatures/owl/owl.sprite", LAYER_OBJECTS + 1),
  carried_obj_name("skydive"),
  carried_object(NULL)
{
  set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
}
Exemple #27
0
HitResponse
PushButton::collision(GameObject& other, const CollisionHit& hit)
{
  auto player = dynamic_cast<Player*>(&other);
  if (!player) return FORCE_MOVE;
  float vy = player->get_physic().get_velocity_y();

  //player->add_velocity(Vector(0, -150));
  player->get_physic().set_velocity_y(-150);

  if (state != OFF) return FORCE_MOVE;
  if (!hit.top) return FORCE_MOVE;
  if (vy <= 0) return FORCE_MOVE;

  // change appearance
  state = ON;
  float old_bbox_height = m_col.m_bbox.get_height();
  set_action("on", -1);
  float new_bbox_height = m_col.m_bbox.get_height();
  set_pos(get_pos() + Vector(0, old_bbox_height - new_bbox_height));

  // play sound
  SoundManager::current()->play(BUTTON_SOUND);

  // run script
  Sector::get().run_script(script, "PushButton");

  return FORCE_MOVE;
}
Exemple #28
0
Owl::Owl(const ReaderMapping& reader) :
  BadGuy(reader, "images/creatures/owl/owl.sprite", LAYER_OBJECTS + 1),
  carried_obj_name(),
  carried_object(NULL)
{
  if ( !reader.get("carry", carried_obj_name)) carried_obj_name = "skydive";
  set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
}
Exemple #29
0
Monster::Monster(const char *fn, MediaDB *media, int x, int y, Direction dir)
    : Actor(Object::TypeMonster, x, y, dir),
      m_invinsible(false), m_hit_ground(false)
{
    load(fn, media);
    m_curr_hp = get_attribute("hp");
    set_action(Still);
}
Exemple #30
0
void init_window(void)
{
    load_setting();
    
    //メインウィンドウの外観の設定
    main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(main_window), "cedit");
    gtk_window_set_icon(GTK_WINDOW(main_window), get_icon("icon.png"));
    gtk_window_move(GTK_WINDOW(main_window), window_x, window_y);
    gtk_window_set_default_size(GTK_WINDOW(main_window), window_width, window_height);
    
    //ウィンドウの内部の設定
    GtkWidget *main_vbox = gtk_vbox_new(FALSE, 3);
    gtk_container_add(GTK_CONTAINER(main_window), main_vbox);
    init_bar(main_vbox);
    init_editor(main_vbox);
    
    //全体の動作の設定
    init_tag();
    init_library();
    set_action("New", FALSE);
    set_action("Save", FALSE);
    set_action("Undo", FALSE);
    set_action("Redo", FALSE);
    set_action("Cut", FALSE);
    set_action("Copy", FALSE);
    set_action("Delete", FALSE);
    static GtkTargetEntry target[] = {{"text/uri-list",  0, 10}};
    gtk_drag_dest_set(view, GTK_DEST_DEFAULT_ALL, target, 1, GDK_ACTION_COPY);
    gtk_drag_dest_set(main_window, GTK_DEST_DEFAULT_ALL, target, 1, GDK_ACTION_COPY);
    set_signal();
}