void
MCMercenaryManager::saveData()
{
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    JsonBox::Array mercenaries;
    CCObject *obj;
    MCMercenary *mercenary;
    char o_id_buffer[5] = {0};
    char *c_str_o_id = o_id_buffer;
    
    CCArray *hired = hired_->getRoles();
    hired->removeObject(MCHero::sharedHero());
    CCARRAY_FOREACH(hired, obj) {
        mercenary = (MCMercenary *) obj;
        mc_object_id_t o_id = mercenary->getID();
        o_id_buffer[0] = o_id.class_;
        o_id_buffer[1] = o_id.sub_class_;
        o_id_buffer[2] = o_id.index_;
        o_id_buffer[3] = o_id.sub_index_;
        JsonBox::Object mercenaryObject;
        
        mercenaryObject["id"] = JsonBox::Value(c_str_o_id);
        mercenaryObject["name"] = JsonBox::Value(mercenary->getName()->getCString());
        mercenaries.push_back(mercenaryObject);
    }
Esempio n. 2
0
void serialize(JsonBox::Value & o, const List_T & v)
{
	JsonBox::Array a;
	a.resize(v.size());
	u32 i = 0;
	for(auto it = v.cbegin(); it != v.cend(); ++it)
	{
		a[i] = *it;
		++it;
		++i;
	}
	o = a;
}
Esempio n. 3
0
inline void serialize(JsonBox::Value & o, const sf::Transform & t)
{
	const float * v = t.getMatrix();

	JsonBox::Array a;
	a.resize(16);

	for(u32 i = 0; i < 16; ++i)
	{
		a[i] = v[i];
	}

	o = a;
}
JsonBox::Array Inventory::jsonArray()
{
	JsonBox::Array a;
	for(auto item : this->items)
	{
		// Skip if the id does not match to the type T
		if(item.first->id.substr(0, entityToString<T>().size()) != entityToString<T>())
			continue;
		// Otherwise add the item to the array
		JsonBox::Array pair;
		pair.push_back(JsonBox::Value(item.first->id));
		pair.push_back(JsonBox::Value(item.second));
		a.push_back(JsonBox::Value(pair));
	}

	return a;
}
Esempio n. 5
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    JsonBox::Object menuItem;
    
    JsonBox::Array menuItemArray;
    
    JsonBox::Object obj1;
    obj1["value1"] = JsonBox::Value("a");
    obj1["value2"] = JsonBox::Value("b");
    JsonBox::Object obj2;
    obj2["value1"] = JsonBox::Value(1);
    obj2["value2"] = JsonBox::Value(2);
    JsonBox::Object obj3;
    obj3["value1"] = JsonBox::Value(true);
    obj3["value2"] = JsonBox::Value(12.12);
    
    menuItemArray.push_back(obj1);
    menuItemArray.push_back(obj2);
    menuItemArray.push_back(obj3);
    
    menuItem["menuItem"] = menuItemArray;
    std::cout << menuItem << std::endl;
    JsonBox::Value v(menuItem);
    v.writeToFile((CCFileUtils::sharedFileUtils()->getWritablePath()+"JsonTest").c_str());
    

    JsonBox::Value v2;
    v2.loadFromFile((CCFileUtils::sharedFileUtils()->getWritablePath()+"JsonTest").c_str());
    std::cout << v2 << std::endl;
    v2.writeToStream(std::cout, true, true);
    v2.writeToFile((CCFileUtils::sharedFileUtils()->getWritablePath()+"JsonTest").c_str(), false, false);
    std::cout<<"--------"<<v2["menuItem"]<<std::endl;
    std::cout<<"--------"<<v2["menuItem"][size_t(0)]<<std::endl;
    return true;
}
void
MCBackpack::loadEffectiveItems()
{
    MCItemManager *itemManager = MCItemManager::sharedItemManager();
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    string data = userDefault->getStringForKey(kMCEffectiveItemsKey, "");
    
    if (MCGameState::sharedGameState()->isSaveFileExists()
        && data.size() > 0) {
#if MC_DEBUG_SAVEDATA == 1
        const char *output = data.c_str();
#else
        const char *input = data.c_str();
        char *output;
        mc_size_t len = strlen(input);
        MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
        JsonBox::Value v;
        v.loadFromString(output);
        
        JsonBox::Array effectiveItems = v.getArray();
        
        healthPotion_->count = effectiveItems.at(0).getInt();
        physicalPotion_->count = effectiveItems.at(1).getInt();
        fireballTrapWide_->count = effectiveItems.at(2).getInt();
        fireballTrapDamage_->count = effectiveItems.at(3).getInt();
        curseTrapWide_->count = effectiveItems.at(4).getInt();
        curseTrapDamage_->count = effectiveItems.at(5).getInt();
        paralysisTrapWide_->count = effectiveItems.at(6).getInt();
        paralysisTrapDamage_->count = effectiveItems.at(7).getInt();
        fogTrapWide_->count = effectiveItems.at(8).getInt();
        fogTrapDamage_->count = effectiveItems.at(9).getInt();
        flashTrapWide_->count = effectiveItems.at(10).getInt();
        flashTrapDamage_->count = effectiveItems.at(11).getInt();
#if MC_DEBUG_SAVEDATA != 1
        delete []output;
#endif
    } else {
        healthPotion_->count = 0;
        physicalPotion_->count = 0;
        fireballTrapWide_->count = 0;
        fireballTrapDamage_->count = 0;
        curseTrapWide_->count = 0;
        curseTrapDamage_->count = 0;
        paralysisTrapWide_->count = 0;
        paralysisTrapDamage_->count = 0;
        fogTrapWide_->count = 0;
        fogTrapDamage_->count = 0;
        flashTrapWide_->count = 0;
        flashTrapDamage_->count = 0;
    }
    
    /* load items */
    healthPotion_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCHealthPotion]);
    healthPotion_->item->retain();
    physicalPotion_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCPhysicalPotion]);
    physicalPotion_->item->retain();
    fireballTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFireballWide]);
    fireballTrapWide_->item->retain();
    fireballTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFireballDamage]);
    fireballTrapDamage_->item->retain();
    curseTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCCurseWide]);
    curseTrapWide_->item->retain();
    curseTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCCurseDamage]);
    curseTrapDamage_->item->retain();
    paralysisTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCParalysisWide]);
    paralysisTrapWide_->item->retain();
    paralysisTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCParalysisDamage]);
    paralysisTrapDamage_->item->retain();
    fogTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFogWide]);
    fogTrapWide_->item->retain();
    fogTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFogDamage]);
    fogTrapDamage_->item->retain();
    flashTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFlashWide]);
    flashTrapWide_->item->retain();
    flashTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFlashDamage]);
    flashTrapDamage_->item->retain();
}
void
MCBackpack::saveEffectiveItems()
{
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    JsonBox::Array effectiveItems;
    
    /* 道具 */
    effectiveItems.push_back(JsonBox::Value((int) healthPotion_->count));
    effectiveItems.push_back(JsonBox::Value((int) physicalPotion_->count));
    effectiveItems.push_back(JsonBox::Value((int) fireballTrapWide_->count));
    effectiveItems.push_back(JsonBox::Value((int) fireballTrapDamage_->count));
    effectiveItems.push_back(JsonBox::Value((int) curseTrapWide_->count));
    effectiveItems.push_back(JsonBox::Value((int) curseTrapDamage_->count));
    effectiveItems.push_back(JsonBox::Value((int) paralysisTrapWide_->count));
    effectiveItems.push_back(JsonBox::Value((int) paralysisTrapDamage_->count));
    effectiveItems.push_back(JsonBox::Value((int) fogTrapWide_->count));
    effectiveItems.push_back(JsonBox::Value((int) fogTrapDamage_->count));
    effectiveItems.push_back(JsonBox::Value((int) flashTrapWide_->count));
    effectiveItems.push_back(JsonBox::Value((int) flashTrapDamage_->count));
    JsonBox::Value effectiveItemsValue(effectiveItems);
    ostringstream outputStream;
    effectiveItemsValue.writeToStream(outputStream);
    string data = outputStream.str();
#if MC_DEBUG_SAVEDATA == 1
    const char *output = data.c_str();
#else
    const char *input = data.c_str();
    char  *output;
    mc_size_t len = strlen(input);
    MCBase64Encode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
    userDefault->setStringForKey(kMCEffectiveItemsKey, output);
#if MC_DEBUG_SAVEDATA != 1
    delete []output;
#endif
}
Esempio n. 8
0
//------------------------------------------------------------------------------
bool TextureAtlas::loadFromJSONFile(const std::string & filePath)
{
	// Parse stream

	log.debug() << "Reading TextureAtlas..." << log.endl();
	JsonBox::Value doc;
	if(!zn::loadFromFile(doc, filePath, 1))
	{
		return false;
	}

	// Globals

	//std::string textureName = doc["texture"].getString();
	s32 prescale = doc["prescale"].getInt();
	s32 timescale = doc["timescale"].getInt();

	// Frames

	JsonBox::Array jframes = doc["frames"].getArray();
	for(auto it = jframes.begin(); it != jframes.end(); ++it)
	{
		Frame f;

		std::string name = (*it)["name"].getString();

		f.rect.left = prescale * (*it)["x"].getInt();
		f.rect.top = prescale * (*it)["y"].getInt();
		f.rect.width = prescale * (*it)["w"].getInt();
		f.rect.height = prescale * (*it)["h"].getInt();

		if(m_frames.find(name) != m_frames.end())
		{
			log.warn() << "TextureAtlas: found duplicate frame \"" << name << "\" in " << filePath << log.endl();
		}

		m_frames[name] = f;
	}

	// Sequences

	JsonBox::Array jsequences = doc["sequences"].getArray();
	for(auto it = jsequences.begin(); it != jsequences.end(); ++it)
	{
		Sequence seq;

		std::string name = (*it)["name"].getString();

		JsonBox::Array jseqframes = (*it)["frames"].getArray();
		for(auto itf = jseqframes.begin(); itf != jseqframes.end(); ++itf)
		{
			SequenceFrame f;

			f.rect.left = prescale * (*itf)["x"].getInt();
			f.rect.top = prescale * (*itf)["y"].getInt();
			f.rect.width = prescale * (*itf)["w"].getInt();
			f.rect.height = prescale * (*itf)["h"].getInt();

			f.duration = timescale * (*itf)["d"].getInt();

			seq.frames.push_back(f);
		}

		if(m_sequences.find(name) != m_sequences.end())
		{
			log.warn() << "TextureAtlas: found duplicate sequence \"" << name << "\" in " << filePath << log.endl();
		}

		m_sequences[name] = seq;
	}

	/*
	// Load texture

	std::string localDir = filePath.substr(0, filePath.find_last_of("/\\"));
	std::string texturePath = localDir + '/' + textureName;
	if(!m_texture.loadFromFile(texturePath))
	{
		log.err() << "TextureAtlas: couldn't load texture \"" << texturePath << '"' << log.endl();
		return false;
	}

	// TODO add JSON option for texture smooth
	m_texture.setSmooth(false);
	*/

	return true;
}
Esempio n. 9
0
void GameOver::finishGetScores(JsonBox::Object js)
{
//	ostringstream oss;
//	oss << js << endl;
//	CCLog("**********************************************************************\n%s", oss.str().c_str());
	
	try {
		KS::KSLog("%", js);
		KS::KSLog("%", js["state"].getString().c_str());
		if(js["state"].getString() != "ok")
			throw string(gt("retrying").c_str());
		mediator->incLoadCount();
		CCLabelBMFont* allUsers = CCLabelBMFont::create(KS_Util::stringWithFormat("%d", js["alluser"].getInt()).c_str(), "main1.fnt");
//		allUsers->setColor(ccc3(0,0,0));
		allUsers->setPosition(ccp(226, 264));
		thiz->addChild(allUsers, 2);
		
		
		
		JsonBox::Array jList = js["list"].getArray();
		int st = js["timestamp"].getInt();
		int z = jList.size();

		float myrank = js["myrank"].getInt();
		int myscore = 0;
		int week = playInfo->currentWeek;
		for(int i=0; i<jList.size() && i < 10; i++)
		{
			JsonBox::Object entry = jList[i].getObject();
			string nick = entry["nick"].getString();
			int score = entry["score"].getInt();
			int duration;
			int rank = entry["rank"].getInt();
			
			duration = entry["playtime"].getInt();
//			if(entry["etime"].getInt() == 0) // 안끝났다면
//			{
//				duration = st - entry["stime"].getInt();
//			}
//			else
//			{
//				duration = entry["etime"].getInt() - entry["stime"].getInt();
//			}

			string mmss;
			if(duration < 3600)
			{
				mmss = KS_Util::stringWithFormat("%2d'%2d\"", (int)(duration / 60), duration % 60);
			}
			else
			{
				int hours = duration / 3600;
				if(hours > 100)
					mmss = KS_Util::stringWithFormat("inf", hours);
				else if(hours > 1)
					mmss = KS_Util::stringWithFormat("%d hrs", hours);
				else
					mmss = KS_Util::stringWithFormat("%d hr", hours);
			}
			
			CCLabelTTF* rankFnt;
			if(!(1 <= rank && rank <= 3))
			{
				rankFnt = CCLabelTTF::create(KS_Util::stringWithFormat("%d", entry["rank"].getInt()).c_str(), defaultFont, 12.f);
				rankFnt->setColor(ccc3(0, 0, 0));
				rankFnt->setPosition(position.rank[i]);
				thiz->addChild(rankFnt, 2);
			}
			CCSprite* flag = CCSprite::createWithSpriteFrameName(KS_Util::stringWithFormat("%s.png", entry["flag"].getString().c_str()).c_str());
			if(flag)
			{
				flag->setPosition(position.flag[i]);
				thiz->addChild(flag, 2);
				flag->setScale(0.9f);
			}
			CCLabelTTF* nickTTF = CCLabelTTF::create(nick.c_str(), defaultFont, 12.f);
			nickTTF->setColor(ccc3(0, 0, 0));
			nickTTF->setAnchorPoint(ccp(0.f, 0.5f));
			nickTTF->setPosition(position.user[i]);
			
			
			thiz->addChild(nickTTF, 2);
			
			CCLabelBMFont* scoreFnt = CCLabelBMFont::create(KS_Util::stringWithFormat("%d", score).c_str(), "rankscore.fnt");
			scoreFnt->setPosition(position.score[i]);
			scoreFnt->setAnchorPoint(ccp(1.f, 0.5f));
			
			
			thiz->addChild(scoreFnt, 2);
			
			CCLabelTTF* timeFnt = CCLabelTTF::create(mmss.c_str(), defaultFont, 12.f);
			timeFnt->setColor(ccc3(0, 0, 0));
			timeFnt->setPosition(position.time[i]);
			if(entry["isme"].getBoolean())
			{
				scoreFnt->setColor(ccc3(255, 0, 0));
				nickTTF->setColor(ccc3(255, 0, 0));
				timeFnt->setColor(ccc3(255, 0, 0));
				if(!(1 <= rank && rank <= 3))
					rankFnt->setColor(ccc3(255, 0, 0));
				myscore = score;
			}
			thiz->addChild(timeFnt, 2);
		}

		if(playInfo->currentGame == "AC")
		{
			putScore(playInfo->acscore, myscore, playInfo->acweekly, myrank, mediator);
		}
		else if(playInfo->currentGame == "AK")
		{
			putScore(playInfo->akscore, myscore, playInfo->akweekly, myrank, mediator);
		}
		else if(playInfo->currentGame == "BS")
		{
			putScore(playInfo->bsscore, myscore, playInfo->bsweekly, myrank, mediator);
		}
		else if(playInfo->currentGame == "HW")
		{
			putScore(playInfo->hwscore, myscore, playInfo->hwweekly, myrank, mediator);
		}
		else if(playInfo->currentGame == "SK")
		{
			putScore(playInfo->skscore, myscore, playInfo->skweekly, myrank, mediator);
		}
		else if(playInfo->currentGame == "HG")
		{
			putScore(playInfo->hgscore, myscore, playInfo->hgweekly, myrank, mediator);
		}
		else  if(playInfo->currentGame == "WORLDCUP")
		{
			putScore(playInfo->wcscore, myscore, playInfo->wcweekly, myrank, mediator);
		}
		CCLog("%d", playInfo->skscore);
		mediator->sendFacebookScore();
		rankPercent.init(1.f, (myrank / (float)js["alluser"].getInt()), 2.f);
		KS::KSLog("% % % ", position.endRankPosition.x, (position.beginRankPosition.x - position.endRankPosition.x), (myrank / (float)js["alluser"].getInt()));
		rankX.init(me->getPosition().x, position.endRankPosition.x + (position.beginRankPosition.x - position.endRankPosition.x) * (myrank / (float)js["alluser"].getInt()),
				   2.f);
		

		


		
	} catch (const string& msg) {
		mediator->showFailedGameOver(msg);
		
	}
	
	
	
}
Esempio n. 10
0
void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject)
{
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");

    switch (menuItem->getTag())
    {
        case kRPGBattleMenuTagSkill:
        {
            CCLog("技能");
            
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagSkill;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
            selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
            selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
            //显示title和分隔线
            addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285));
            CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
            titleLab->setFontFillColor(ccc3(144, 144, 144));
            
            CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
            separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
            separate->setScaleX(0.65);
            separate->setTag(198);
            selectLayer->addChild(separate);
            
            //加载技能数据
            CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
            if(!tableView)
            {
                tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
                tableView->setDirection(kCCScrollViewDirectionVertical);
                tableView->setPosition(CCSizeZero);
                tableView->setDelegate(this);
                tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
                tableView->setTag(197);
                selectLayer->addChild(tableView);
                
            }
            
            this->m_tableItems->removeAllObjects();

            string wq = "";
            JsonBox::Value json;
            json.loadFromString(this->m_playerData->m_skill.c_str());
            JsonBox::Array jsonArr = json.getArray();
            for (int i = 0; i < jsonArr.size(); i++)
            {
                char* str = (char*)malloc(10 * sizeof(char));
                OzgCCUtility::itoa(jsonArr[i].getInt(), str);
                wq.append(str);
                
                if(i + 1 < jsonArr.size())
                    wq.append(", ");
                
                free(str);
            }
            if((int)wq.length() > 0)
            {
                CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString());
                while(!query.eof())
                {
                    RPGSkillBtnData *skill = RPGSkillBtnData::create();
                    skill->m_dataId = query.getIntField("id");
                    skill->m_name = query.getStringField("name_cns");
                    skill->m_MP = query.getIntField("mp");
                    skill->m_skillAttack = query.getIntField("skill_attack");
                    skill->m_type = query.getIntField("type");
                    skill->m_attr = query.getIntField("attr");
                    skill->m_enabled = true;
                    
                    //不能使用技能的情况
                    if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0)
                        skill->m_enabled = false;
                    else if(this->m_playerData->m_MP < skill->m_MP)
                        skill->m_enabled = false;
                    
                    this->m_tableItems->addObject(skill);
                    
                    query.nextRow();
                }
                query.finalize();
            }
            
            tableView->reloadData();
            //加载技能数据 end
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
        }
            break;
        case kRPGBattleMenuTagItems:
        {
            CCLog("道具");
            
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagItems;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
            selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
            selectLayer->setTag(kRPGBattleSceneLayerTagItemsSelectDialog);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
            //显示title和分隔线
            addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("items_title"), 25, ccp(310, 285));
            CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
            titleLab->setFontFillColor(ccc3(144, 144, 144));
            
            CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
            separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
            separate->setScaleX(0.65);
            separate->setTag(198);
            selectLayer->addChild(separate);
            
            //加载道具数据
            CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
            if(!tableView)
            {
                tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
                tableView->setDirection(kCCScrollViewDirectionVertical);
                tableView->setPosition(CCSizeZero);
                tableView->setDelegate(this);
                tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
                tableView->setTag(197);
                selectLayer->addChild(tableView);
            }
            
            this->m_tableItems->removeAllObjects();
            
            CCArray *existingItems = ((RPGBattleSceneLayer*)this->m_parentNode)->m_existingItems;
            
            for (int i = 0; i < existingItems->count(); i++)
                this->m_tableItems->addObject(existingItems->objectAtIndex(i));
            
            tableView->reloadData();
            //加载道具数据 end
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
        }
            break;
        case kRPGBattleMenuTagEscape:
        {
//            CCLog("逃跑");
            
            float success = CCRANDOM_0_1();
            if(success >= 0.0 && success <= 0.5)
            {
//                CCLog("逃跑成功");
                
                this->setEnabled(false);
                this->removeFromParentAndCleanup(true);
                
                ((RPGBattleSceneLayer*)this->m_parentNode)->goToMap();
            }
            else
            {
                ((RPGBattleSceneLayer*)this->m_parentNode)->showMsg((CCString*)this->m_stringList->objectForKey("escape_fail"));
                
                //重置进度条
                this->m_playerData->m_progress = 0.0;
                CCProgressTimer *battleProgress = (CCProgressTimer*)this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagPlayerProgress + this->m_playerData->m_dataId);
                battleProgress->setPercentage(this->m_playerData->m_progress);
                
                ((RPGBattleSceneLayer*)this->m_parentNode)->scheduleUpdate();
                
                CCTMXTiledMap *bgLayer = (CCTMXTiledMap*)this->m_parentNode->getChildByTag(kRPGBattleMenuTagBg);
                bgLayer->removeFromParentAndCleanup(true);
                this->removeFromParentAndCleanup(true);
            }
            
        }
            break;
        case kRPGBattleMenuTagCancel:
        {
//            CCLog("取消");
            this->showMenu();
            
            CCMenuItem *menuCancel = (CCMenuItem*)this->getChildByTag(kRPGBattleMenuTagCancel);
            menuCancel->removeFromParentAndCleanup(true);
            
            switch (this->m_selectedMenuTag)
            {
                case kRPGBattleMenuTagAttack:
                    CCLog("取消攻击");
                    ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
                    ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
                    
                    break;
                case kRPGBattleMenuTagSkill:
                    CCLog("取消技能列表");
                    
                    if(((RPGBattleSceneLayer*)this->m_parentNode)->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog))
                        ((RPGBattleSceneLayer*)this->m_parentNode)->removeChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog, true);
                    
                    ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
                    ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
                    
                    break;
                case kRPGBattleMenuTagItems:
                    CCLog("取消道具列表");
                    
                    if(((RPGBattleSceneLayer*)this->m_parentNode)->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog))
                        ((RPGBattleSceneLayer*)this->m_parentNode)->removeChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog, true);
                    
                    ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
                    ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
                    
                    break;
//                default:
//                    break;
            }
            
        }
            break;
        case kRPGBattleMenuTagCancel2:
        {
            //这个选择了一个技能或道具后,到了选择目标对象的一步,使用到的取消按钮
            
            CCMenuItemSprite *menuCancel = (CCMenuItemSprite*)this->getChildByTag(kRPGBattleMenuTagCancel);
            menuCancel->setVisible(true);
            
            CCMenuItemSprite *menuCancel2 = (CCMenuItemSprite*)this->getChildByTag(kRPGBattleMenuTagCancel2);
            menuCancel2->removeFromParentAndCleanup(true);
            
            if(this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog))
                this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog)->setVisible(true);
            
            if(this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog))
                this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog)->setVisible(true);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
            ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected();
        }
            break;
        default:
        {
            CCLog("攻击");
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagAttack;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
        }
            break;
    }
    
}