void HeroEnety::attainBase(RaceEunm race) { ValueMap data; float fractionOffset, humanResOffset, HPOffset; switch (mMentalEnum) { case MentalEnum::Normal: fractionOffset = SacrificeValueWhenNormal; humanResOffset = HumanPowerWhenNormal; HPOffset = HitPointWhenNormal; break; case MentalEnum::Captured: fractionOffset = SacrificeValueWhenCaptured; humanResOffset = HumanPowerWhenCaptured; HPOffset = HitPointWhenCaptured; break; default: break; } data.insert(std::make_pair("fractionOffset", Value(fractionOffset))); data.insert(std::make_pair("humanResOffset", Value(humanResOffset))); data.insert(std::make_pair("HPOffset", Value(HPOffset))); data.insert(std::make_pair("RaceEunm", Value(race))); std::string eventName = "event_arrive_base"; EventCustom event = EventCustom(eventName); event.setUserData((void *)(&data)); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); }
void HeroEnety::GoDead(){ if(mStateEunm == StateEunm::Dead) { return; } mStateEunm = StateEunm::Dead; HeroManager::getInstance()->del(this); if (SoldierTypeID == 3) { ValueMap data; data.insert(std::make_pair("raid", Value(roadID))); bool isLeft = false; if (mRaceEunm == RaceEunm::Red) { isLeft = true; } data.insert(std::make_pair("isLeft", Value(isLeft))); std::string eventName = "missionary_dead"; EventCustom event = EventCustom(eventName); event.setUserData((void *)(&data)); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } return; auto callback = CallFuncN::create( CC_CALLBACK_0(HeroEnety::deadcallback,this)); auto dt = DelayTime::create(1); auto fo = FadeOut::create(1); //auto d = Sequence::create((Animate*)Action_Dead, dt, callback, nullptr); auto d = Sequence::create(fo, dt, callback,nullptr); this->runAction(d); }
EventCustom* EventCustom::create(const std::string& eventName, void* data) { EventCustom* event = new EventCustom(eventName); event->setUserData(data); event->autorelease(); return event; }