Esempio n. 1
0
void BattleUI::InitHeroUI()
{
    ArmatureDataManager::getInstance()->addArmatureFileInfo("Texiao.ExportJson");
    
    auto layout_Bottom = m_RootWidget->getChildByName<Layout*>("Layout_Bottom");
    
    auto text_HeroText = layout_Bottom->getChildByName<Text*>("Text_HeroText");
    
    auto langId = (int)LanguageIdEnum::SelfLangId;
    auto langText = MultiLanguage::getInstance()->GetText(langId);
    text_HeroText->setString(langText);
    
    auto lbar_HeroHp = layout_Bottom->getChildByName<LoadingBar*>("LBar_HeroHp");
    lbar_HeroHp->setPercent(100);
    
    
    //自动或手动控制战斗
    auto btn_Auto = layout_Bottom->getChildByName<Button*>("Btn_Auto");
    auto btn_UnAuto = layout_Bottom->getChildByName<Button*>("Btn_UnAuto");
    if (BattleData::getInstance()->m_HeroAutoAttack)
    {
        btn_Auto->setVisible(true); btn_UnAuto->setVisible(false);
        
    }else
    {
        btn_Auto->setVisible(false); btn_UnAuto->setVisible(true);
    }
    
    langId = (int)LanguageIdEnum::AutoAttackLangId;
    langText = MultiLanguage::getInstance()->GetText(langId);
    btn_Auto->setTitleText(langText); btn_UnAuto->setTitleText(langText);
    btn_Auto->addClickEventListener([=](Ref* sender)
     {
         btn_Auto->setVisible(false);
         btn_UnAuto->setVisible(true);
         BattleData::getInstance()->m_HeroAutoAttack = false;
         UserData::getInstance()->Update_Value(UserDataEnum::AutoAttack, Value(0));
     });
    
    btn_UnAuto->addClickEventListener([=](Ref* sender)
    {
        btn_Auto->setVisible(true);
        btn_UnAuto->setVisible(false);
        for (auto pb : *m_VecProgressBar) pb->Resume();
        BattleData::getInstance()->m_HeroAutoAttack = true;
        UserData::getInstance()->Update_Value(UserDataEnum::AutoAttack, Value(1) );
    });
    
    auto btn_Bread = layout_Bottom->getChildByName<Button*>("Btn_Bread");
    auto text_BreadName = btn_Bread->getChildByName<Text*>("Text_BreadNAME");
    langId = (int)LanguageIdEnum::BreadLangId;
    langText = MultiLanguage::getInstance()->GetText(langId);
    text_BreadName->setString(langText);
    
    auto text_Bread = btn_Bread->getChildByName<Text*>("Text_Bread");
    
    
    auto bread_Num = 0;
    auto breadData = UserData::getInstance()->Get_MVI_Value(UserDataEnum::BackPack, (int)CfgIdEnum::BreadId);
    if(breadData != Value::Null) bread_Num = breadData.asInt();
    
    text_Bread->setString(StringUtils::format("%d", bread_Num));
    
    auto lbar_Bread = btn_Bread->getChildByName<LoadingBar*>("LBar_Bread");
    
    string pbName = "BreadHpSchedule";
    auto progressBar = new ProgressBar();
    progressBar->SetTotalTime(3); //3秒吃一个面包
    progressBar->SetScheduleName(pbName);
    progressBar->SetLoadingBar(lbar_Bread);
    
    m_VecProgressBar->push_back(progressBar);
    
    progressBar->SetCallBack([this, progressBar]()
     {
         progressBar->Restart();
         progressBar->GetLoadingBar()->setPercent(0);
         m_RootWidget->unschedule(progressBar->GetScheduleName());
     });
    
    
    btn_Bread->addClickEventListener([=](Ref* sender)
     {

         auto bread_Num = 0;
         auto breadData = UserData::getInstance()->Get_MVI_Value(UserDataEnum::BackPack, (int)CfgIdEnum::BreadId);
         if(breadData != Value::Null) bread_Num = breadData.asInt();

         if (bread_Num == 0)
         {
             auto langId = (int)LanguageIdEnum::BreadNotEnoughId;
             auto langText = MultiLanguage::getInstance()->GetText(langId);
             MoveText::getInstance()->AddDefaultTextData(m_RootWidget, langText);
         }else
         {
             if(progressBar->GetRemainTime() == progressBar->GetTotalTime())
             {
                 auto bread_Num = UserData::getInstance()->Update_VMI_Fun(
                                  UserDataEnum::BackPack, (int)CfgIdEnum::BreadId, -1);
                 if (bread_Num >= 0)
                 {
                     text_Bread->setString(StringUtils::format("%d", bread_Num));
                     //回血
                     BattleData::getInstance()->BreadRevertHp();
                     
                     m_RootWidget->schedule([this, progressBar](float f)
                        {
                            progressBar->Update(f);
                        }, progressBar->GetScheduleName());
                 }
             }
             AchievementSystem::getInstance()->CheckAchievement(UserEventType::BattleEatBread, 1);
         }
     });
    
    vector<pair<int, int> >heroVec;
    BattlePubUI::getInstance()->GetBackPackHero(&heroVec);
    auto idx = 0; //创建英雄技能
    for (auto heroData : heroVec)
    {
        auto heroId = heroData.first;
        auto heroNum = heroData.second;
        for (auto i = 0; i < heroNum ; i++)
        {
            CreateHeroEvent(heroId, idx);  idx++;
        }
    }

    auto talentTeamTotalHp = BattleData::getInstance()->m_TalentTeamTotalHp;
    auto text_HeroHp = layout_Bottom->getChildByName<Text*>("Text_HeroHp");
    text_HeroHp->setString(StringUtils::format("%d/%d", talentTeamTotalHp, talentTeamTotalHp));
    
    BattleData::getInstance()->m_HeroHpLBar = lbar_HeroHp;
    BattleData::getInstance()->m_TextHeroHp = text_HeroHp;

}
Esempio n. 2
0
//英雄显示位置
void BattleUI::CreateHeroEvent(int cfgId, int idx)
{

    auto layout_Bottom = m_RootWidget->getChildByName<Layout*>("Layout_Bottom");
    
    string btn_Name = StringUtils::format("Btn_Skill%d", idx);
    auto Btn_Hero = layout_Bottom->getChildByName<Button*>(btn_Name);
    Btn_Hero->setVisible(true);
    
    auto lbar_Name = StringUtils::format("LBar_State%d", idx);
    auto lbar_State = Btn_Hero->getChildByName<LoadingBar*>(lbar_Name);
    lbar_State->setPercent(100);
    
    CfgDataRow dataRow(cfgId);
    auto textName = StringUtils::format("Text_Name%d", idx);
    
    auto text_Name = Btn_Hero->getChildByName<Text*>(textName);
    
    auto skillId = dataRow.GetValue(CfgField::SkillID_V)->asValueVector().begin()->asInt();
    CfgDataRow skillDataRow(skillId);
    auto langId = skillDataRow.GetValue(CfgField::Name)->asInt();
    auto langText = MultiLanguage::getInstance()->GetText(langId);
    text_Name->setString(langText);
    
    auto attack_Speed = dataRow.GetValue(CfgField::Spd_F)->asFloat();
    attack_Speed = 10 / attack_Speed;
    
    Armature* armature = CreateHeroArmature(cfgId);
    
    string pbName = StringUtils::format("HeroSkillSchedule%d", idx);
    auto playName = skillDataRow.GetValue(CfgField::SkillAtksfxID_S)->asString();
    
    auto isGetKong = UserData::getInstance()->Check_VI_Fun(UserDataEnum::TalentList, Value((int)CfgIdEnum::TalentEliminateCD));
    auto progressBar = new ProgressBar();
    progressBar->SetScheduleName(pbName);
    progressBar->SetTotalTime(attack_Speed, isGetKong);
    progressBar->SetLoadingBar(lbar_State);
    
    m_VecProgressBar->push_back(progressBar);
    
    progressBar->SetCallBack([=]()
       {
           progressBar->Restart();
           if (armature->getAnimation()->getAnimationData()->getMovement(playName) == nullptr)
           {
               CCLOGERROR("Armature:%s, not %s", armature->getName().c_str(), playName.c_str());
           }else if(m_IsPlayAnim)
           {
               armature->setVisible(true);
               armature->getAnimation()->play(playName);
           }
           
           if (m_MonsterArmature != nullptr && m_IsPlayAnim)
           {
               m_MonsterArmature->getAnimation()->play(m_Beating);
           }
           
           auto attackResult = BattleData::getInstance()->HeroAttack(cfgId);
           if (attackResult == -1)
           {
               BattleFinish(true);

           }else if(attackResult > 0)
           {
               BufferEffect(attackResult);
           }

           if (!BattleData::getInstance()->m_HeroAutoAttack)
           {
               m_RootWidget->unschedule(pbName);
           }
       });
    
    Btn_Hero->addClickEventListener([this, progressBar, pbName](Ref* sender)
        {
            if(progressBar->GetRemainTime() == progressBar->GetTotalTime())
            {
                m_RootWidget->schedule([this, progressBar](float f)
                   {
                       progressBar->Update(f);
                       
                   }, pbName);
            }
        });
    
    m_RootWidget->schedule([this, progressBar](float f)
       {
           progressBar->Update(f);
           
       }, pbName);
    
    if (BattleData::getInstance()->m_HeroAutoAttack)
    {
        progressBar->Resume();
    }
    
    UIUtils::getInstance()->showProperImg(Btn_Hero, cfgId);
    
}
Esempio n. 3
0
void BattleUI::InitMonsterUI(int cfgId)
{
    
    auto layout_Top = m_RootWidget->getChildByName<Layout*>("Layout_Top");
    
    auto text_Name = layout_Top->getChildByName<Text*>("Text_Name");
    auto text_Desc = layout_Top->getChildByName<Text*>("Text_Desc");
    
    auto text_Hp = layout_Top->getChildByName<Text*>("Text_Hp");

    auto lbar_MonsterHp = layout_Top->getChildByName<LoadingBar*>("LBar_Hp");
    lbar_MonsterHp->setPercent(100);

    auto Lbar_MonsterSkill = layout_Top->getChildByName<LoadingBar*>("LBar_Skill");
    Lbar_MonsterSkill->setPercent(100);
    
    CfgDataRow monsterDataRow(cfgId);
    auto langId = monsterDataRow.GetValue(CfgField::Name)->asInt();
    auto langText = MultiLanguage::getInstance()->GetText(langId);
    text_Name->setString(langText);
    
    langId = monsterDataRow.GetValue(CfgField::MonsterDescribe)->asInt();
    langText = MultiLanguage::getInstance()->GetText(langId);
    text_Desc->setString(langText);
    
    auto monsterHp = monsterDataRow.GetValue(CfgField::Hp)->asInt();
    
    auto buildId = BattleData::getInstance()->m_BuildId;
    //竞技场怪物
    if (buildId == (int)CfgIdEnum::EternalArena)
    {
        auto level = BattleData::getInstance()->m_NextBuildLayer -1;
        auto hpExt = monsterDataRow.GetValue(CfgField::HpCoefficient_F)->asFloat();
        monsterHp += (int)(monsterHp * hpExt * level + 0.5);
    }
    

    text_Hp->setString(StringUtils::format("%d/%d", monsterHp, monsterHp));
    
    auto attack_Speed = monsterDataRow.GetValue(CfgField::Spd_F)->asFloat();
    attack_Speed = 10 / attack_Speed;
    
    
    Armature* armture = CreateMonsterArmature(cfgId);
    string pbName = "MonsterSkillPbSchedule";
    
    auto progressBar = new ProgressBar();
    
    Lbar_MonsterSkill->setUserData(progressBar);
    
    progressBar->SetScheduleName(pbName);
    progressBar->SetTotalTime(attack_Speed);
    progressBar->SetLoadingBar(Lbar_MonsterSkill);
    
    m_VecProgressBar->push_back(progressBar);
    
    progressBar->SetCallBack([=]()
     {
         progressBar->Restart();
         
         if(m_IsPlayAnim) armture->getAnimation()->play(m_Attack);
         
         auto bf = BattleData::getInstance()->MonsterAttack();
         if (bf)
         {
             BattleFinish(false);
         }
     });
    
    m_RootWidget->schedule([this, progressBar](float f)
       {
           progressBar->Update(f);
       }, pbName);

    
    
    auto proType = monsterDataRow.GetValue(CfgField::PropertyID)->asInt();
    ImageView* img_Pro = layout_Top->getChildByName<ImageView*>(StringUtils::format("Img_Pro%d", proType));
    if (img_Pro)    img_Pro->setVisible(true);
    
    BattleData::getInstance()->m_MonsterId = cfgId;
    BattleData::getInstance()->m_MonsterMaxHp = monsterHp;
    BattleData::getInstance()->m_MonsterNowHp = monsterHp;
    BattleData::getInstance()->m_TextMonsterHp =  text_Hp;
    BattleData::getInstance()->m_MonsterHpLBar = lbar_MonsterHp;
    BattleData::getInstance()->m_MonSterProgressBar = progressBar;
}
Esempio n. 4
0
void LogEntry1Data::ResumeSyncSend(void)
	{
	if (!SyncSendPaused)
		{
		return;
		}

	SyncSendPaused = FALSE;

	if (SyncNumber == CERROR)
		{
		return;
		}

	// We just unpaused and we're assigned a record number... tell everybody
	// else all about ourselves.
	GAINEXCLUSIVEACCESS();
	char Buffer[256];
	
	CopyStringToBuffer(Buffer, Name);
	SetName(Buffer);

	CopyStringToBuffer(Buffer, Initials);
	SetInitials(Buffer);

	CopyStringToBuffer(Buffer, Password);
	SetPassword(Buffer);

	CopyStringToBuffer(Buffer, Surname);
	SetSurname(Buffer);

	CopyStringToBuffer(Buffer, Title);
	SetTitle(Buffer);

	CopyStringToBuffer(Buffer, RealName);
	SetRealName(Buffer);

	CopyStringToBuffer(Buffer, PhoneNumber);
	SetPhoneNumber(Buffer);

	CopyStringToBuffer(Buffer, ForwardAddr);
	SetForwardAddr(Buffer);

	CopyStringToBuffer(Buffer, ForwardAddrNode);
	SetForwardAddrNode(Buffer);

	CopyStringToBuffer(Buffer, ForwardAddrRegion);
	SetForwardAddrRegion(Buffer);

	CopyStringToBuffer(Buffer, PromptFormat);
	SetPromptFormat(Buffer);

	CopyStringToBuffer(Buffer, DateStamp);
	SetDateStamp(Buffer);

	CopyStringToBuffer(Buffer, VerboseDateStamp);
	SetVerboseDateStamp(Buffer);

	CopyStringToBuffer(Buffer, Signature);
	SetSignature(Buffer);

	CopyStringToBuffer(Buffer, NetPrefix);
	SetNetPrefix(Buffer);

	CopyStringToBuffer(Buffer, MailAddr1);
	SetMailAddr1(Buffer);

	CopyStringToBuffer(Buffer, MailAddr2);
	SetMailAddr2(Buffer);

	CopyStringToBuffer(Buffer, MailAddr3);
	SetMailAddr3(Buffer);

	CopyStringToBuffer(Buffer, Alias);
	SetAlias(Buffer);

	CopyStringToBuffer(Buffer, LocID);
	SetLocID(Buffer);

	CopyStringToBuffer(Buffer, MorePrompt);
	SetMorePrompt(Buffer);

	CopyStringToBuffer(Buffer, Occupation);
	SetOccupation(Buffer);

	CopyStringToBuffer(Buffer, WhereHear);
	SetWhereHear(Buffer);

	CopyStringToBuffer(Buffer, LastRoom);
	SetLastRoom(Buffer);

	CopyStringToBuffer(Buffer, LastHall);
	SetLastHall(Buffer);

	CopyStringToBuffer(Buffer, DefaultRoom);
	SetDefaultRoom(Buffer);

	CopyStringToBuffer(Buffer, DefaultHall);
	SetDefaultHall(Buffer);

	CopyStringToBuffer(Buffer, TermType);
	SetTermType(Buffer);
	RELEASEEXCLUSIVEACCESS();

	SetBirthDate(BirthDate);
	SetFirstOn(FirstOn);
	SetSex(Sex);
	SetNulls(Nulls);
	SetWidth(Width);
	SetLinesPerScreen(LinesPerScreen);
	SetAttribute(ATTR_NORMAL, attributes[ATTR_NORMAL]);
	SetAttribute(ATTR_BLINK, attributes[ATTR_BLINK]);
	SetAttribute(ATTR_REVERSE, attributes[ATTR_REVERSE]);
	SetAttribute(ATTR_BOLD, attributes[ATTR_BOLD]);
	SetAttribute(ATTR_UNDERLINE, attributes[ATTR_UNDERLINE]);
	SetNumUserShow(NumUserShow);
	SetDefaultProtocol(DefaultProtocol);
	SetCallTime(CallTime);
	SetCallNumber(CallNumber);
	SetTotalTime(TotalTime);
	SetCredits(Credits);
	SetLogins(Logins);
	SetPosted(Posted);
	SetRead(Read);
	SetPasswordChangeTime(PasswordChangeTime);
	SetCallsToday(CallsToday);
	SetCallLimit(CallLimit);
	SetLastMessage(LastMessage);
	SetDL_Bytes(DL_Bytes);
	SetUL_Bytes(UL_Bytes);
	SetDL_Num(DL_Num);
	SetUL_Num(UL_Num);
	SetPoopcount(Poopcount);

	SetDungeoned(IsDungeoned());
	SetForwardToNode(IsForwardToNode());
	SetAutoNextHall(IsAutoNextHall());
	SetEnterBorders(IsEnterBorders());
	SetVerified(IsVerified());
	SetSurnameLocked(IsSurnameLocked());
	SetDefaultHallLocked(IsDefaultHallLocked());
	SetPsycho(IsPsycho());
	SetViewTitleSurname(IsViewTitleSurname());
	SetViewSubjects(IsViewSubjects());
	SetViewSignatures(IsViewSignatures());
	SetOldIBMGraph(IsOldIBMGraph());
	SetOldIBMANSI(IsOldIBMANSI());
	SetOldIBMColor(IsOldIBMColor());
	SetTwirly(IsTwirly());
	SetAutoVerbose(IsAutoVerbose());
	SetPauseBetweenMessages(IsPauseBetweenMessages());
	SetMinibin(IsMinibin());
	SetClearScreenBetweenMessages(IsClearScreenBetweenMessages());
	SetViewRoomInfoLines(IsViewRoomInfoLines());
	SetViewHallDescription(IsViewHallDescription());
	SetVerboseContinue(IsVerboseContinue());
	SetViewCensoredMessages(IsViewCensoredMessages());
	SetViewBorders(IsViewBorders());
	SetOut300(IsOut300());
	SetUserSignatureLocked(IsUserSignatureLocked());
	SetHideMessageExclusions(IsHideMessageExclusions());
	SetDownload(IsDownload());
	SetUpload(IsUpload());
	SetChat(IsChat());
	SetPrintFile(IsPrintFile());
	SetSpellCheckMode(GetSpellCheckMode());
	SetMakeRoom(IsMakeRoom());
	SetVerboseLogOut(IsVerboseLogOut());
	SetConfirmSave(IsConfirmSave());
	SetConfirmAbort(IsConfirmAbort());
	SetConfirmNoEO(IsConfirmNoEO());
	SetUsePersonalHall(IsUsePersonalHall());
	SetYouAreHere(IsYouAreHere());
	SetIBMRoom(IsIBMRoom());
	SetWideRoom(IsWideRoom());
	SetMusic(IsMusic());
	SetCheckApostropheS(IsCheckApostropheS());
	SetCheckAllCaps(IsCheckAllCaps());
	SetCheckDigits(IsCheckDigits());
	SetExcludeEncryptedMessages(IsExcludeEncryptedMessages());
	SetViewCommas(IsViewCommas());
	SetPUnPauses(IsPUnPauses());
	SetRoman(IsRoman());
	SetSuperSysop(IsSuperSysop());

	SetInuse(IsInuse());
	SetUpperOnly(IsUpperOnly());
	SetLinefeeds(IsLinefeeds());
	SetExpert(IsExpert());
	SetAide(IsAide());
	SetTabs(IsTabs());
	SetOldToo(IsOldToo());
	SetProblem(IsProblem());
	SetUnlisted(IsUnlisted());
	SetPermanent(IsPermanent());
	SetSysop(IsSysop());
	SetNode(IsNode());
	SetNetUser(IsNetUser());
	SetAccounting(IsAccounting());
	SetMail(IsMail());
	SetViewRoomDesc(IsViewRoomDesc());
	}