当前位置: 首页>>代码示例>>C++>>正文


C++ Obj::is_in_inventory方法代码示例

本文整理汇总了C++中Obj::is_in_inventory方法的典型用法代码示例。如果您正苦于以下问题:C++ Obj::is_in_inventory方法的具体用法?C++ Obj::is_in_inventory怎么用?C++ Obj::is_in_inventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Obj的用法示例。


在下文中一共展示了Obj::is_in_inventory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drag_accept_drop

bool InventoryWidget::drag_accept_drop(int x, int y, int message, void *data)
{
 GUI::get_gui()->force_full_redraw();
 DEBUG(0,LEVEL_DEBUGGING,"InventoryWidget::drag_accept_drop()\n");
 if(message == GUI_DRAG_OBJ)
   {
    Obj *obj = (Obj*)data;
    x -= area.x;
    y -= area.y;
    if(target_obj == NULL) //we need to check this so we don't screw up target_obj on subsequent calls
    {
      if(drag_set_target_obj(x, y) == false)
      {
          DEBUG(0,LEVEL_WARNING,"InventoryWidget: Didn't hit any widget object targets!\n");
          return false;
      }
    }
    Actor *src_actor = Game::get_game()->get_player()->get_actor();

    if(obj->get_actor_holding_obj() == actor)
        src_actor = actor;
    else if(!obj->is_in_inventory() && actor == Game::get_game()->get_player()->get_actor())
    {
        Game::get_game()->get_scroll()->display_string("Get-");
        Game::get_game()->get_scroll()->display_string(obj_manager->look_obj(obj, OBJ_SHOW_PREFIX));
    }
    else
        Game::get_game()->get_event()->display_move_text(actor, obj);

    if(!obj->is_in_inventory()
       && !Game::get_game()->get_map_window()->can_get_obj(actor, obj))
    {
        Game::get_game()->get_scroll()->message("\n\nblocked\n\n");
        return false;
    }
    if((Game::get_game()->get_usecode()->has_getcode(obj)
        && !Game::get_game()->get_usecode()->get_obj(obj, actor))
       || !Game::get_game()->get_event()->can_move_obj_between_actors(obj, src_actor, actor))
    {
        Game::get_game()->get_scroll()->message("\n\n");
    	return false;
    }
    else if(!obj->is_in_inventory()
            && obj_manager->obj_is_damaging(obj, Game::get_game()->get_player()->get_actor()))
    {
        Game::get_game()->get_player()->subtract_movement_points(3);
        return false;
    }
    else if(src_actor != actor || !obj->is_in_inventory())
        Game::get_game()->get_scroll()->message("\n\n");

    if(src_actor != actor) // get plus move
         Game::get_game()->get_player()->subtract_movement_points(8);
    else if(!obj->is_in_inventory()) // get
         Game::get_game()->get_player()->subtract_movement_points(3);

    UseCode *usecode = Game::get_game()->get_usecode();
    if(usecode->is_chest(obj) && obj->frame_n == 0) //open chest
        obj->frame_n = 1; //close the chest

    DEBUG(0,LEVEL_DEBUGGING,"Drop Accepted\n");
    return true;
   }

 DEBUG(0,LEVEL_DEBUGGING,"Drop Refused\n");
 return false;
}
开发者ID:Zabeus,项目名称:nuvie,代码行数:67,代码来源:InventoryWidget.cpp


注:本文中的Obj::is_in_inventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。