示例#1
0
void HPersistence::SaveBao(int id){
    BAO_INFO* info = (BAO_INFO*)G::g_bao_infos->objectAtIndex(id);
    if (info ==  NULL) {
        return;
    }
    IntToStringFormat(_getKey, "bao_isget_%d", id);
    IntToStringFormat(_showKey, "bao_show_%d", id);
    IntToStringFormat(_newKey, "bao_new_%d", id);
    setBoolForKey(_getKey,  info->isGot);
    setBoolForKey(_showKey, info->isShowed );
    setBoolForKey(_newKey, info->isNew);
    
    CCUserDefault::sharedUserDefault()->flush();
}
示例#2
0
void HPersistence::SaveStage(int stage_id){
    StageInfo* info = (StageInfo*)G::g_stageInfos->objectAtIndex(stage_id);
    if(info==NULL)
        return;
    char key_IsOpen[30];
    sprintf(key_IsOpen,"stage_%d_isopen",stage_id);
    char key_IsPlay[30];
    sprintf(key_IsPlay,"stage_%d_isplay",stage_id);
    char key_Stars[30];
    sprintf(key_Stars,"stage_%d_stars",stage_id);
    setBoolForKey(key_IsOpen,info->isOpened);
    setBoolForKey(key_IsPlay,info->isPlayed);
    setIntForKey(key_Stars,info->stars);
    char key_IsShowed[30];
    sprintf(key_IsShowed, "stage_%d_isShowed",stage_id);
    setBoolForKey(key_IsShowed,info->isShowed);
    
    CCUserDefault::sharedUserDefault()->flush();
}
示例#3
0
文件: HGloba.cpp 项目: joyfish/Shoot
void G::setBackGroundMusicState(bool isOn,const char* backgroundmusic /*= nullptr*/){
    if (isBackGroundMusicOn() == isOn) {
        return;
    }
    setBoolForKey("isBackGroundMusicOn", isOn);
    UserDefault::getInstance()->flush();
    if (isOn) {
        if(backgroundmusic!=NULL)
            SimpleAudioEngine::getInstance()->playBackgroundMusic(backgroundmusic,true);
    }else{
        SimpleAudioEngine::getInstance()->stopBackgroundMusic(true);
    }
}
示例#4
0
void HPersistence::SaveAchievement(int id){
    ACHIEVE_INFO* info = (ACHIEVE_INFO*)G::g_achieve_infos->objectAtIndex(id);
    if (info == NULL) {
        return;
    }
    char a_c_key[30];
    sprintf(a_c_key, "achieve_c_%d",id);
    char a_s_key[30];
    sprintf(a_s_key, "achieve_s_%d",id);
    setIntForKey(a_c_key, info->complete);
    setBoolForKey(a_s_key, info->achieve_completed_showed);
    char show_key[30];
    sprintf(show_key, "achieve_new_showed_%d",id);
    setBoolForKey(show_key, info->new_showed);
    IntToStringFormat(_time_key, "achieve_complete_time_%d", id)
    setIntForKey(_time_key, info->complete_time);
    IntToStringFormat(_complete_key, "achieve_is_complete_%d", id)
    setBoolForKey(_complete_key, info->is_complete);
    IntToStringFormat(_new_key, "achieve_isNew_%d", id)
    setBoolForKey(_new_key, info->isNew);
    
    CCUserDefault::sharedUserDefault()->flush();
}
示例#5
0
void ScoreLayer::ReadScoreFromFile()
{
	auto userDefault = UserDefault::sharedUserDefault();
	if (!userDefault->getBoolForKey(ScoreFileKey))
	{
		userDefault->setBoolForKey(ScoreFileKey,true);
		userDefault->setIntegerForKey(ScoreKey,0);
		userDefault->flush();
	}
	else
	{
		m_HighestScore = userDefault->getIntegerForKey(ScoreKey);
	}
}
void UserDefaultManager::setDefault()
{
    
    UserDefault *userdefault = UserDefault::getInstance();
    if (!userdefault->getBoolForKey("isSetUp")) {
        userdefault->setBoolForKey("isSetUp", true);
        setIntegerForKey(DiamondCount, 10);
        setIntegerForKey(QuestionCount, 0);
        setIntegerForKey(StarCount, 0);
        setIntegerForKey(RecieveDiamond, 0);
        setIntegerForKey(StarCount, 0);
        setBoolForKey(kIsRemoveAds, false);
        setIntegerForKey(kTotalNum, 0);
        setBoolForKey(kFirstTime, true);
        time_t t = time(0);
        tm * now = localtime(&t);
        __String* timeString = __String::createWithFormat("%d年%d月%d日", now->tm_year, now->tm_mon, now->tm_mday-1);
        log("%d年%d月%d日", now->tm_year, now->tm_mon, now->tm_mday);
        setStringForKey(kLoginTime, timeString->getCString());
        setIntegerForKey(kLastCount, 10);
        setStringForKey(kRecordeTime1, timeString->getCString());
        setIntegerForKey(kViewState, 0);
    }
}
示例#7
0
// on "init" you need to initialize your instance
bool Ending::init()
{
	//////////////////////////////
	// 1. super init first
	if (!Layer::init())
	{
		return false;
	}

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	auto def = UserDefault::getInstance();

	auto trueEnding = def->getIntegerForKey("trueEnding");
	auto happyEnding = def->getIntegerForKey("happyEnding");
	auto goodEnding = def->getIntegerForKey("goodEnding");
	auto badEnding = def->getIntegerForKey("badEnding");
	auto worstEnding = def->getIntegerForKey("worstEnding");

	int result;

	//get the result
	if (trueEnding > happyEnding)
	{
		result = trueEnding;
	}
	else
	{
		result = happyEnding;
	}

	if (result < goodEnding)
	{
		result = goodEnding;
	}

	if (result < badEnding)
	{
		result = badEnding;
	}

	if (result < worstEnding)
	{
		result = worstEnding;
	}

	if (result == trueEnding)
	{
		result = 0;
	}
	else if (result == happyEnding)
	{
		result = 1;
	}
	else if (result == goodEnding)
	{
		result = 2;
	}
	else if (result == badEnding)
	{
		result = 3;
	}
	else if (result == worstEnding)
	{
		result = 4;
	}

	Sprite* sprite;
	Label* label;

	if (result == 0)//true
	{
		label = Label::createWithTTF(" ロボットと共存!!一番良い道を見つけた!最高の未来だ!", "fonts/PixelMplus10-Regular.ttf", 50, Size(600, 0), TextHAlignment::CENTER, TextVAlignment::CENTER);
		sprite = Sprite::create("img/ending/true.png");
	}
	else if (result == 1)//happy
	{
		label = Label::createWithTTF("ロボットを従えさせた!良い未来にはできたけどこれでいいのかな…?", "fonts/PixelMplus10-Regular.ttf", 50, Size(600, 0), TextHAlignment::CENTER, TextVAlignment::CENTER);
		sprite = Sprite::create("img/ending/happy.png");
	}
	else if (result == 2)//good
	{
		label = Label::createWithTTF("人間だけになった!未来を変えることに成功したけどこれでいいのかな?", "fonts/PixelMplus10-Regular.ttf", 50, Size(600, 0), TextHAlignment::CENTER, TextVAlignment::CENTER);
		sprite = Sprite::create("img/ending/good.png");
	}
	else if (result == 3)//bad
	{
		label = Label::createWithTTF("ロボットに支配された!未来は変わらなかった…もっと他にあったんじゃないのか…", "fonts/PixelMplus10-Regular.ttf", 50, Size(600, 0), TextHAlignment::CENTER, TextVAlignment::CENTER);
		sprite = Sprite::create("img/ending/bad.png");
	}
	else if (result == 4)//worst
	{
		label = Label::createWithTTF("ロボットだけになった… 最悪の未来だ、なんでこんなことに…", "fonts/PixelMplus10-Regular.ttf", 50, Size(600, 0), TextHAlignment::CENTER, TextVAlignment::CENTER);
		sprite = Sprite::create("img/ending/worst.png");
	}

	label->setPosition(Vec2(origin.x + visibleSize.width / 2,
		origin.y + visibleSize.height - label->getContentSize().height));
	this->addChild(label, 1);

 
	sprite->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
	this->addChild(sprite, 0);

	def->setBoolForKey("SavedGame", false);

	auto delay = DelayTime::create(7.0f);
	auto titleScene = CallFunc::create([this]() {Director::getInstance()->replaceScene(TitlleScene::createScene()); });
	this->runAction(Sequence::create(delay, titleScene, NULL));

	return true;
}
void UserDefaultManager::setIsFirstBuy(bool isBuy) {
    setBoolForKey(FirstBuy, isBuy);
}
void UserDefaultManager::setIsRemoved(bool remove)
{
    setBoolForKey(kIsRemoveAds, remove);
}
void UserDefaultManager::setFirstTimeModifySql(){
    setBoolForKey(kFirstTimeModify, true);
}
void UserDefaultManager::setisFirstTime(bool isFirst) {
    setBoolForKey(kFirstTime, isFirst);
}
示例#12
0
void GameInfoSave::setMan(int userid, bool isMan)
{
	string str = "gender";
	str.append(int2string(userid).c_str());
	setBoolForKey(str.c_str(), isMan);
}
示例#13
0
void HPersistence::SaveToFile(){
    setIntForKey("game_max_power", G::g_maxPower);
    setIntForKey("game_coin", G::G_getCoin());
    setIntForKey("game_power",G::G_getPower());
    //setIntForKey("game_power",G::g_mPower);
    setIntForKey("game_book", G::G_getBook());
    setBoolForKey("m_bgm", G::g_mIsBackgroundMusicOn);
    setBoolForKey("m_soundEffect", G::g_mIsEffectVolumeOn);
    
    //SaveStage(0);
//    for(int i=0;i<MAX_STAGE;i++){
//        StageInfo* info = (StageInfo*)G::g_stageInfos->objectAtIndex(i);
//        if(info==NULL)
//            continue;
//        char key_IsOpen[30];
//        sprintf(key_IsOpen,"stage_%d_isopen",i);
//        char key_IsPlay[30];
//        sprintf(key_IsPlay,"stage_%d_isplay",i);
//        char key_Stars[30];
//        sprintf(key_Stars,"stage_%d_stars",i);
//        setBoolForKey(key_IsOpen,info->isOpened);
//        setBoolForKey(key_IsPlay,info->isPlayed);
//        setIntForKey(key_Stars,info->stars);
//        char key_IsShowed[30];
//        sprintf(key_IsShowed, "stage_%d_isShowed",i);
//        setBoolForKey(key_IsShowed,info->isShowed);
//    }
    for (int i =0;i<MAX_TOOL_COUNT;i++) {
        ToolInfo* info = (ToolInfo*)G::g_toolinfos->objectAtIndex(i);
        IntToStringFormat(hold_key, "tool_hold_%d",i);
        setIntForKey(hold_key, info->getHoldCount());
        IntToStringFormat(show_key, "tool_new_showed_%d",i);
        setBoolForKey(show_key,  info->new_showed);
    }
    
    
    for(unsigned int i=0;i<G::g_help_infos.size();i++){
        for (unsigned int j=0; j<G::g_help_infos[i].size(); j++) {
            char h_key[30];
            sprintf(h_key,"help_info_%d_%d",i,j);
            setBoolForKey(h_key,G::g_help_infos[i][j]->isShowed);
        }
        //        HELP_INFO* help_info = (HELP_INFO*)G::g_help_infos->objectAtIndex(i);
        //        char h_key[30];
        //        sprintf(h_key,"help_info_%d",i);
        //        help_info->isShowed = getBoolForKey(h_key,false);
    }
//    int help_max_count = G::g_help_infos->count();
//    for(int i=0;i<help_max_count;i++){
//        HELP_INFO* help_info = (HELP_INFO*)G::g_help_infos->objectAtIndex(i);
//        char h_key[30];
//        sprintf(h_key,"help_info_%d",i);
//        setBoolForKey(h_key,help_info->isShowed);
//    }
    for(unsigned int i=0;i<G::g_achieve_infos->count();i++){
        ACHIEVE_INFO* info = (ACHIEVE_INFO*)G::g_achieve_infos->objectAtIndex(i);
        char a_c_key[30];
        sprintf(a_c_key, "achieve_c_%d",i);
        char a_s_key[30];
        sprintf(a_s_key, "achieve_s_%d",i);

        setIntForKey(a_c_key, info->complete);
        

        setBoolForKey(a_s_key, info->achieve_completed_showed);
        
        char show_key[30];
        sprintf(show_key, "achieve_new_showed_%d",i);

        setBoolForKey(show_key, info->new_showed);
        
        IntToStringFormat(_time_key, "achieve_complete_time_%d", i)

        setIntForKey(_time_key, info->complete_time);
        IntToStringFormat(_complete_key, "achieve_is_complete_%d", i)
  
        setBoolForKey(_complete_key, info->is_complete);
        
        IntToStringFormat(_new_key, "achieve_isNew_%d", i)
   
        setBoolForKey(_new_key, info->isNew);
    }
    

    setIntForKey("unlimit_top_score",  G::g_hole_max_score );
    setIntForKey("unlimit_total_dist", G::g_hole_total_depth);
    
    setBoolForKey("tree_scroll_showed", G::tree_scroll_has_showed);
    
    setIntForKey("last_power_recovery_time", G::g_last_power_recovery_time);
    
//    for (int i=0; i<MAX_SHARE; i++) {
//        char got_key[30];
//        sprintf(got_key, "share_reward_got_%d",i);
//        setBoolForKey(got_key, G::g_share_reward_got[i]);
//    }
    
    setBoolForKey("hole_opened", G::g_hole_isOpened);
    setBoolForKey("hole_showed", G::g_hole_isNewShowed);
    
    setBoolForKey("sea_opened", G::g_sea_isOpened);
    setBoolForKey("sea_showed", G::g_sea_isNewShowed);
    
//    for (unsigned int i=0; i<MAX_BAO; i++) {
//        BAO_INFO* info = (BAO_INFO*)G::g_bao_infos->objectAtIndex(i);
//        info->id = i;
//        IntToStringFormat(_getKey, "bao_isget_%d", i);
//        IntToStringFormat(_showKey, "bao_show_%d", i);
//        IntToStringFormat(_newKey, "bao_new_%d", i);
//        setBoolForKey(_getKey,  info->isGot);
//        setBoolForKey(_showKey, info->isShowed );
//        setBoolForKey(_newKey, info->isNew);
//    }
    
    
    for (int i=0; i<MAX_CLOUD; i++) {
        IntToStringFormat(_cloudOpenKey, "cloud_open_%d", i);
        setBoolForKey(_cloudOpenKey, G::g_cloud_isOpened[i]);
    }

    G::g_has_first_saved = true;
    setBoolForKey("has_first_saved", true);
    
    setIntForKey("turntable_time", G::turntable_time);
    setIntForKey("turntable_count", G::turntable_count);
    
    setBoolForKey("shop_th_has_buyed", G::shop_th_has_buyed);
    setBoolForKey("shop_ts_has_buyed",  G::shop_ts_has_buyed);
    
    CCUserDefault::sharedUserDefault()->flush();
}
示例#14
0
文件: HGloba.cpp 项目: joyfish/Shoot
void G::setEffectState(bool isOn){
    if (isEffectOn() == isOn) {
        return;
    }
    setBoolForKey("isEffectOn", isOn);
}