ourCreatures::ourCreatures(int hp, int maxHp, string creatName) { setName(creatName); setHp(hp); setMaxHp(maxHp); }
ourCreatures::ourCreatures() { setName("none"); setElemWeak("none"); setElemStren("none"); setElem("none"); setHp(0); setMaxHp(0); }
void GameLayer::initMembers() { std::vector<std::string> fileNames { "CardBlue.png", "CardRed.png", "CardGreen.png", "CardYellow.png", "CardPurple.png" }; std::vector<Character::Element> elements { Character::Element::Water, Character::Element::Fire, Character::Element::Wind, Character::Element::Holy, Character::Element::Shadow, }; for (int i = 0; i < fileNames.size(); i++) { //メンバー auto memberData = Character::create(); memberData->setMaxHp(200); memberData->setHp(200); memberData->setElement(elements[i]); _memberDatum.pushBack(memberData); //メンバーの表示 auto member = Sprite::create(fileNames[i].c_str()); member ->setPosition(Point(70 + i * 125, 598)); addChild(member, ZOrder::Char); //メンバーヒットポイントバー枠の表示 auto hpBg = Sprite::create("HpCardBackground.png"); hpBg->setPosition(Point(70 + i * 125, 554)); addChild(hpBg, ZOrder::CharHp); //メンバーヒットポイントバーの表示 auto hpBarForMember = ProgressTimer::create(Sprite::create("HpCardGreen.png")); hpBarForMember->setPosition(Point(hpBg->getContentSize().width / 2, hpBg->getContentSize().height / 2)); hpBarForMember->setType(ProgressTimer::Type::BAR); hpBarForMember->setMidpoint(Point::ZERO); hpBarForMember->setBarChangeRate(Point(1, 0)); hpBarForMember->setPercentage(memberData->getHpPercentage()); hpBg->addChild(hpBarForMember); //配列に格納 _members.pushBack(member); _hpBarForMembers.pushBack(hpBarForMember); } }
ReinforceSoldier2* ReinforceSoldier2::createReinforceSoldier(Point point) { auto reinforceSoldier = new ReinforceSoldier2(); if (reinforceSoldier && reinforceSoldier->init()) { reinforceSoldier->setLocation(point); reinforceSoldier->setMaxHp(80); reinforceSoldier->setCurrHp(80); reinforceSoldier->setForce(10); reinforceSoldier->setState(SoldierStateNone); reinforceSoldier->birth(point); reinforceSoldier->autorelease(); return reinforceSoldier; } CC_SAFE_DELETE(reinforceSoldier); return NULL; }
EnemyDisableTower* EnemyDisableTower::createEnemyDisableTower(Vector<Node*> points, int hp) { auto dis = new EnemyDisableTower(); if (dis && dis->init()) { dis->setPointsVector(points); dis->runFollowPoint(); //这里就开始执行行走了 dis->autorelease(); dis->setMaxHp(hp); dis->setCurrHp(hp); return dis; } else { delete dis; dis = nullptr; return nullptr; } }
bool BattleHero::init(int kantaiNumber, cocos2d::Node *parent, int row) { this->parent=parent; parent->addChild(this); this->kantaiNumber=kantaiNumber; card=new CharacterCard(kantaiNumber); this->addChild(card); hpBar->setPosition(163,391-41*row); this->addChild(hpBar); if (row==1) { border=Sprite::create("interface/BattleMain/BattleMain_479.png"); flagIcon=Sprite::create("interface/BattleMain/BattleMain_88.png"); flagIcon->setPosition(148,417-41); } else { border=Sprite::create("interface/BattleMain/BattleMain_474.png"); } border->setPosition(84,413-41*row); addChild(border); card->setPosition(80,410-41*row); currentHpLabel->setPosition(180,410-41*row); maxHpLabel->setPosition(197,410-41*row); addChild(currentHpLabel); addChild(maxHpLabel); battleBar=new BattleBar(parent); setMaxHp(info->getMaxHp()); setCurrentHp(info->getCurrHp()); return true; }
EnemyTest* EnemyTest::createEnemyTest(Vector<Node*> points, int hp) { auto test = new EnemyTest(); if (test && test->init()) { test->setPointsVector(points); test->runFollowPoint(); //这里就开始执行行走了 test->autorelease(); test->setMaxHp(hp); test->setCurrHp(hp); return test; } else { delete test; test = nullptr; return nullptr; } }
Raider* Raider::createMonster(std::vector<Point> points) { auto monster = new Raider(); if (monster && monster->init()) { monster->setPointsVector(points); monster->setMaxHp(160); monster->setCurrHp(160); monster->setMoney(30); monster->setRunSpeed(40); monster->setArmor(10); monster->setForce(8); monster->setAttackBySoldier(true); monster->runNextPoint(); monster->autorelease(); return monster; } CC_SAFE_DELETE(monster); return NULL; }
Quetzal* Quetzal::createMonster(std::vector<Point> points) { auto monster = new Quetzal(); if (monster && monster->init()) { monster->setPointsVector(points); monster->setMaxHp(500); monster->setCurrHp(500); monster->setMoney(20); monster->setForce(45); monster->setArmor(10); monster->setAttackBySoldier(false); monster->setRunSpeed(60); monster->runNextPoint(); monster->autorelease(); return monster; } CC_SAFE_DELETE(monster); return NULL; }
Gorilla* Gorilla::createMonster(std::vector<Point> points) { auto monster = new Gorilla(); if (monster && monster->init()) { monster->setPointsVector(points); monster->setMaxHp(2500); monster->setCurrHp(2500); monster->setMoney(500); monster->setForce(60); monster->setArmor(0); monster->setAttackBySoldier(true); monster->setRunSpeed(30); monster->runNextPoint(); monster->autorelease(); return monster; } CC_SAFE_DELETE(monster); return NULL; }
Wolf* Wolf::createMonster(std::vector<Point> points) { auto monster = new Wolf(); if (monster && monster->init()) { monster->setPointsVector(points); monster->setMaxHp(35); monster->setCurrHp(35); monster->setRunSpeed(100); monster->runNextPoint(); monster->setMoney(20); monster->setArmor(0); monster->setForce(2); monster->setAttackBySoldier(true); monster->autorelease(); return monster; } CC_SAFE_DELETE(monster); return NULL; }
Boss_Efreeti* Boss_Efreeti::createMonster(std::vector<Point> points,std::vector<std::vector<std::vector<Point>>> sonpath) { auto monster = new Boss_Efreeti(); if (monster && monster->init()) { monster->setPointsVector(points); monster->setMaxHp(5550); monster->setCurrHp(5550); monster->setMoney(1500); monster->sonPath = sonpath; monster->setForce(50); monster->setArmor(10); monster->setAttackByTower(true); monster->setAttackBySoldier(true); monster->setRunSpeed(20); monster->runNextPoint(); monster->autorelease(); return monster; } CC_SAFE_DELETE(monster); return NULL; }
bool Thief::init() { if (!Sprite::init()) { return false; } setRunSpeed(9); setMaxHp(10); setCurrHp(10); sprite = Sprite::createWithSpriteFrameName("enemyRight1_1.png"); this->addChild(sprite); animationRight = createAnimation("enemyRight1", 4, 0.1f); AnimationCache::getInstance()->addAnimation(animationRight, "runright"); animationLeft = createAnimation("enemyLeft1", 4, 0.1f); AnimationCache::getInstance()->addAnimation(animationLeft, "runleft"); animationExplode= createAnimation("explode", 6, 0.15f); AnimationCache::getInstance()->addAnimation(animationExplode, "explode"); createAndSetHpBar(); schedule(schedule_selector(EnemyBase::changeDirection), 0.4f); return true; }
Tremor* Tremor::createMonster(std::vector<Point> points) { auto monster = new Tremor(); if (monster && monster->init()) { monster->setPointsVector(points); monster->setMaxHp(35); monster->setCurrHp(35); monster->setMoney(10); monster->setForce(4); monster->setArmor(0); monster->setForce(8); monster->setAttackByTower(false); monster->setAttackBySoldier(true); monster->setRunSpeed(50); monster->runNextPoint(); monster->autorelease(); return monster; } CC_SAFE_DELETE(monster); return NULL; }