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


C++ Inventory::getItems方法代码示例

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


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

示例1: getItems

//get item names
int Script::getItems(lua_State* L){
  short x = (short)luaL_checknumber(L, 1);
	short y = (short)luaL_checknumber(L, 2);
  Vector2D pos = Vector2D(x, y);
  Creature* c = dynamic_cast<Creature*>(wrld.getObject(pos));
  if (c){
    Inventory* inv = c->getInventory();
    vector<Item> items = inv->getItems();
    for (unsigned i = 0; i < items.size(); i++){
      string name = items[i].getName();
      lua_pushstring(L, name.c_str());
    }
    return (int)items.size();
  }
  return 0;
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:17,代码来源:script.cpp

示例2: main


//.........这里部分代码省略.........
	      else if (get_status == "unlocked") {
		for (itr_rm = rooms.begin(); itr_rm != rooms.end(); itr_rm++ )
		  {
		    if ((*itr_rm)->getName() == border_name) {
		      current_room = (*itr_rm);
		      cout << current_room->getDescription() << endl;
		      
		    }
		    
		  }
		
		}	
	      }
	      
	    
	    }
	  
	  
	  if (found_trigger == false) {// no trigger is needed fly away my son
	    for (itr_rm = rooms.begin(); itr_rm != rooms.end(); itr_rm++ )
	    {
	      if ((*itr_rm)->getName() == border_name) {
		 current_room = (*itr_rm);
		 cout << current_room->getDescription() << endl;
	      }
		    
	    }
	   }
	}
      }//end if west
      else if (input ==""){}//fix seg fault	
      else if(input == "i"){
	cout << "Inventory:  " ;
	inventory.getItems();
	cout << endl;
      }//end inventory
      else if (input == "open exit"){
	if (current_room->getType() == "exit") {
	  cout << "Game Over" << endl;
	  return 0;
	}
	else {
	  cout << "Error" << endl;
	}
      }
      else{
      input_vector = split(input, ' '); 
      if (input_vector[0] == "read" && input_vector.size() == 2){
	inventory.read(input_vector[1]);
      }
      else if (input_vector[0] == "drop" && input_vector.size() == 2){
	inventory.drop(input_vector[1],current_room);
      }
      else if (input_vector[0] == "put" && input_vector.size() == 4){
	t_item = inventory.getItem(input_vector[1]);
	if (t_item != NULL) {
	  temp_cont = current_room->getContainers();
	  for (int i = 0; i < temp_cont.size(); i++) {
	    if (temp_cont[i]->getName() == input_vector[3]) { // find the container that matches what you are trying to insert item into
	      if (temp_cont[i]->getAccept() == t_item->getName() || temp_cont[i]->getAccept() == "") {
	      temp_cont[i]->addItem(t_item);
	      inventory.removeItem(t_item->getName());
	      cout << "Item " <<t_item->getName() << " added to " << temp_cont[i]->getName() << endl;
	       temp_trigg = temp_cont[i]->getTriggers();
		for (int j = 0; j < temp_trigg.size(); j++) {
		    if (temp_trigg[j]->getObject() == t_item->getName()) {
开发者ID:igalfsg,项目名称:ECE30862,代码行数:67,代码来源:main.cpp


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