void VirusViewer::debugMove(Vector position) { //Tile *tile = map->getTile(position); //map->findAllPathsTo(tile->hx, tile->hy, 10); Tile *tile = map->getTile(position); if (tile->getType() != TILE_EMPTY) { Cell *cell = tile->getCell(); if (cell) { cell->startCloning(FACTION_ENEMY, randomGenerator->getIntNumberBetween(0, 65535)); //cell->startCloning(FACTION_ENEMY, 2); } } else { /* Virus *virus = new Virus(FACTION_ENEMY, randomGenerator->getIntNumberBetween(0, 65535), true); */ Virus *virus = new Virus(FACTION_ENEMY, 920, true); virus->setPosition(position); virus->setOrientation(0.0); double rotateSpeed = randomGenerator->getRealNumberBetween(-1.5, 1.5); virus->setRotateSpeed(rotateSpeed); Entity *entity = (Entity *)virus; map->addEntity(entity); } }
Sequence* GameObjectFactory::createVirusPatternSpawnActionWithPatternTypeAndPosition(BattleField *parent, CreateObjectType virusType, VirusSpawnPatternType patternType, Vec2 rootPos) { auto data = JSONPacker::unpackVirusSpawnPattern(json, patternType); Vector<cocos2d::FiniteTimeAction *> arrayOfActions; for (auto pos : data.positions) { auto callfunc = CallFunc::create([&, rootPos, pos, parent, virusType]() { Virus* virus = static_cast<Virus*>(this->createGameObjectByType(virusType)); virus->setPosition(rootPos + pos); virus->setDelegate(parent); parent->addGameObject(virus); virus->playSpawnAnimation(); }); arrayOfActions.pushBack(callfunc); arrayOfActions.pushBack(DelayTime::create(0.1f)); } return Sequence::create(arrayOfActions); }