Пример #1
0
void MonsterGenerator::update()
{
    if (_waveCounter->isReachMax())
    {
        // you win
        return;
    }
    
    if (_betweenWaveCounter->isReachMax())
    {
        if (_betweenMonsterCounter->isReachMax())
        {
            createMonster();
            _monsterCounter->count(1);
            _betweenMonsterCounter->reset();
            
            if (_monsterCounter->isReachMax())
            {
                _waveCounter->count(1);
                _betweenWaveCounter->reset();
                _monsterCounter->reset();
            }
        }
        else
        {
            _betweenMonsterCounter->count(1);
        }
    }
    else
    {
        _betweenWaveCounter->count(1);
    }
}
Пример #2
0
void MonsterController::createMonsters()
{
	for (int i = 0; i < (MAX_MONSTERS - monsters.size()); i++)
	{
		createMonster();
	}
}
Пример #3
0
void initMap(struct Map * map) {
	// make rooms
	struct Room * hall = createRoom("The Great Hall");
	struct Room * throne = createRoom("The Throne Room");
	struct Room * arena = createRoom("The Arena");
	struct Room * kitchen = createRoom("The Kitchen");

	// link rooms
	hall->north = throne;

	throne->east = kitchen;
	throne->south = hall;
	throne->west = arena;

	arena->east = throne;
	kitchen->west = throne;

	// add minotaur to arena
	arena->bad_guy = createMonster("Minotaur", 12);

	// set starting location
	map->start = hall;
	map->location = map->start;

}
Пример #4
0
mainWin::mainWin(){
	layout = new QHBoxLayout();
    userInputLayout = new QVBoxLayout();
    monsterDisplayLayout = new QVBoxLayout();
    monsterDetailsLayout = new QVBoxLayout();
 	createButton = new QPushButton("Create Monster!");
 	listMonsters = new QListWidget();
 	monsterName = new QLineEdit();
 	nameLabel = new QLabel();
 	attackLabel = new QLabel();
 	defenseLabel = new QLabel();
 	HPLabel = new QLabel();
 	MPLabel = new QLabel();
 	monsterName->setText("Enter a name for your monster!");
 	setupDefaultMonsters();
	layout->addLayout(userInputLayout);
	layout->addLayout(monsterDisplayLayout);
	layout->addLayout(monsterDetailsLayout);
	userInputLayout->addWidget(monsterName);
	userInputLayout->addWidget(ChooseMonsterLabel);
	userInputLayout->addWidget(chooseMonsterType);
	userInputLayout->addWidget(createButton);
	monsterDisplayLayout->addWidget(listMonsters);
	monsterDetailsLayout->addWidget(nameLabel);
	monsterDetailsLayout->addWidget(HPLabel);
	monsterDetailsLayout->addWidget(MPLabel);
	monsterDetailsLayout->addWidget(attackLabel);
	monsterDetailsLayout->addWidget(defenseLabel);
	setLayout(layout);
	connect(createButton, SIGNAL(clicked()),this, SLOT(createMonster()));
	connect(listMonsters,SIGNAL(currentRowChanged(int)), this, SLOT(showMonsterDetails(int)));
}
Пример #5
0
Monster* Monster::createMonster(const std::string& name)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;

	return createMonster(mType);
}
Пример #6
0
Monster* Monster::createMonster(const std::string& name, std::string customName /* = ""*/)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;

	return createMonster(mType, customName);
}
Пример #7
0
Monster* Monster::createMonsterNick(const std::string& name, const std::string& nick)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;
		
	mType->name = nick;		
    mType->realName = name;
	return createMonster(mType);
}
bool LevelBuilderNormalScene::build(bool bStoryMode /* = false */)
{
	createBacks();
	createPhysicsLayer();
	createTransPoints();
	//if (false == bStoryMode)
	{
		createSeer();
	}	
	createNpcs();
	createMonster();
	createMonsterBornPoints();
	if (bStoryMode)
	{		
		showMonsterOrNot(false);
	}

	return true;
}
Пример #9
0
Monster* Monster::createMonster(const std::string& name)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;
		
           mType->name = name; 
           mType->realName = name;
           
    
			//-- sistema de shiny respawn
			
			mType->codenome = ""; 
 		    mType->exists = false;
			
			std::string findText[] = {"Shiny", "Elite", "Elder", "shiny", "elite", "elder"};
            for(int i = 0; i < 6; i++){
            	if(mType->name.find(findText[i]) != std::string::npos){
            		mType->codenome = findText[i]; 
            		mType->exists = true;
            		break;
            	}
            }	
    		
			
			if (mType->exists) {
                mType->realName = mType->name;
                std::string newName = mType->name;	
                std::string from = mType->codenome + " ";	
                std::string to = "";	
                size_t start_pos = 0;
                while((start_pos = newName.find(from, start_pos)) != std::string::npos) {
                    newName.replace(start_pos, from.length(), to);
                    start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
                }
                mType->name = newName;
            } 
            
		
	return createMonster(mType);
}
Пример #10
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Scene::init() )
    {
        return false;
    }

    visibleSize = Director::getInstance()->getVisibleSize();
    origin = Director::getInstance()->getVisibleOrigin();
	en = false;

	TMXTiledMap* tmx = TMXTiledMap::create("map.tmx");
	tmx->setPosition(visibleSize.width / 2, visibleSize.height / 2);
	tmx->setAnchorPoint(Vec2(0.5, 0.5));
	tmx->setScale(Director::getInstance()->getContentScaleFactor());
	this->addChild(tmx, 0);

	//创建一张贴图
	auto texture = Director::getInstance()->getTextureCache()->addImage("$lucia_2.png");
	//从贴图中以像素单位切割,创建关键帧
	auto frame0 = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(0, 0, 113, 113)));
	//使用第一帧创建精灵
	player = Sprite::createWithSpriteFrame(frame0);
	player->setPosition(Vec2(origin.x + visibleSize.width / 2,
		origin.y + visibleSize.height / 2));
	addChild(player, 3);

	//hp条
	Sprite* sp0 = Sprite::create("hp.png", CC_RECT_PIXELS_TO_POINTS(Rect(0, 320, 420, 47)));
	Sprite* sp = Sprite::create("hp.png", CC_RECT_PIXELS_TO_POINTS(Rect(610, 362, 4, 16)));

	//使用hp条设置progressBar
	hp = 100;
	pT = ProgressTimer::create(sp);
	pT->setScaleX(90);
	pT->setAnchorPoint(Vec2(0, 0));
	pT->setType(ProgressTimerType::BAR);
	pT->setBarChangeRate(Point(1, 0));
	pT->setMidpoint(Point(0, 1));
	pT->setPercentage(hp);
	pT->setPosition(Vec2(origin.x + 14 * pT->getContentSize().width, origin.y + visibleSize.height - 2 * pT->getContentSize().height));
	addChild(pT, 1);
	sp0->setAnchorPoint(Vec2(0, 0));
	sp0->setPosition(Vec2(origin.x + pT->getContentSize().width, origin.y + visibleSize.height - sp0->getContentSize().height));
	addChild(sp0, 0);

	// 静态动画
	idle.reserve(1);
	idle.pushBack(frame0);

	// 攻击动画
	attack.reserve(17);
	for (int i = 0; i < 17; i++) {
		auto frame = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(113 * i, 0, 113, 113)));
		attack.pushBack(frame);
	}

	// 可以仿照攻击动画
	// 死亡动画(帧数:22帧,高:90,宽:79)
	auto texture2 = Director::getInstance()->getTextureCache()->addImage("$lucia_dead.png");
	// Todo
	dead.reserve(22);
	for (int i = 0; i < 22; ++i) {
		auto frame= SpriteFrame::createWithTexture(texture2, CC_RECT_PIXELS_TO_POINTS(Rect(79 * i, 0, 79, 90)));
		dead.pushBack(frame);
	}

	// 运动动画(帧数:8帧,高:101,宽:68)
	auto texture3 = Director::getInstance()->getTextureCache()->addImage("$lucia_forward.png");
	// Todo
	run.reserve(8);
	for (int i = 0; i < 8; ++i) {
		auto frame = SpriteFrame::createWithTexture(texture3, CC_RECT_PIXELS_TO_POINTS(Rect(68 * i, 0, 68, 101)));
		run.pushBack(frame);
	}

	auto w = Label::createWithTTF("W", "fonts/arial.ttf", 36);
	auto wItem = MenuItemLabel::create(w, CC_CALLBACK_1(HelloWorld::moveWCallback,this));
	wItem->setPosition(100, 100);

	auto s = Label::createWithTTF("S", "fonts/arial.ttf", 36);
	auto sItem = MenuItemLabel::create(s, CC_CALLBACK_1(HelloWorld::moveSCallback, this));
	sItem->setPosition(100, 50);

	auto a = Label::createWithTTF("A", "fonts/arial.ttf", 36);
	auto aItem = MenuItemLabel::create(a, CC_CALLBACK_1(HelloWorld::moveACallback, this));
	aItem->setPosition(50, 50);

	auto d = Label::createWithTTF("D", "fonts/arial.ttf", 36);
	auto dItem = MenuItemLabel::create(d, CC_CALLBACK_1(HelloWorld::moveDCallback, this));
	dItem->setPosition(150, 50);

	auto x = Label::createWithTTF("X", "fonts/arial.ttf", 36);
	auto xItem = MenuItemLabel::create(x, CC_CALLBACK_1(HelloWorld::moveXCallback, this));
	xItem->setPosition(visibleSize.width-50, 100);

	auto y = Label::createWithTTF("Y", "fonts/arial.ttf", 36);
	auto yItem = MenuItemLabel::create(y, CC_CALLBACK_1(HelloWorld::moveYCallback, this));
	yItem->setPosition(visibleSize.width-100, 50);

	auto menu = Menu::create(wItem, sItem, aItem, dItem, xItem, yItem, NULL);
	menu->setPosition(Vec2::ZERO);
	this->addChild(menu, 1);

	dtime = 160;
	auto temp = CCString::createWithFormat("%d", dtime);
	time = Label::createWithTTF(temp->getCString(),"fonts/arial.ttf",36);
	time->setPosition(visibleSize.width / 2, visibleSize.height - 100);
	this->addChild(time,1);
	schedule(schedule_selector(HelloWorld::timeCallback), 1.0f, kRepeatForever, 1.0f);
	schedule(schedule_selector(HelloWorld::moveCallback), 3.0f, kRepeatForever, 1.0f);

	sc = 0;
	UserDefault::getInstance()->setIntegerForKey("score", sc);
	auto temp1 = CCString::createWithFormat("%d", sc);
	score = Label::createWithTTF(temp1->getCString(), "fonts/arial.ttf", 36);
	score->setPosition(visibleSize.width / 2, visibleSize.height - 50);
	this->addChild(score, 1);

	auto fac = Factory::getInstance();
	for (int i = 0; i < 10; ++i) {
		Sprite* m = fac->createMonster();
		float x1 = random(origin.x, visibleSize.width);
		float y1 = random(origin.y, visibleSize.height);
		m->setPosition(x1, y1);
		this->addChild(m, 3);
	}
    return true;
}