void PlayerAi::update(Actor *owner)
{
    if(owner->destructible && owner->destructible->isDead())
    {
        return;
    }

    int dx = 0, dy = 0;
    switch(engine.lastKey.vk)
    {
        case TCODK_UP : dy = -1; break;
        case TCODK_DOWN : dy = 1; break;
        case TCODK_LEFT : dx = -1; break;
        case TCODK_RIGHT : dx = 1; break;
        case TCODK_CHAR : handleActionKey(owner, engine.lastKey.c); break;
        default: break;
    }

    if(dx != 0 || dy != 0)
    {
        engine.gameStatus = Engine::NEW_TURN;
        if(moveOrAttack(owner, owner->x + dx, owner->y + dy))
        {
            engine.map->computeFov();
        }
    }
}
Beispiel #2
0
void Player::update() {
    if ( isDead() ) {
        return;
    }
    
    int dx = 0;
    int dy = 0;
    
    switch(engine.lastKey.vk) {
        case TCODK_CHAR:
            switch (engine.lastKey.c) {
                case 'w':
                    dy--;
                    break;
                case 'e':
                    dy--;
                    dx++;
                    break;
                case 'd':
                    dx++;
                    break;
                case 'c':
                    dy++;
                    dx++;
                    break;
                case 'x':
                    dy++;
                    break;
                case 'z':
                    dy++;
                    dx--;
                    break;
                case 'a':
                    dx--;
                    break;
                case 'q':
                    dy--;
                    dx--;
                    break;
                default:
                    handleActionKey(engine.lastKey.c);
                    break;
            }
            break;
        default:
            break;
    }
    
    if (dx != 0 || dy != 0) {
        engine.gameStatus = Engine::NEW_TURN;
        if ( moveOrAttack(x + dx, y + dy) ) {
            engine.updateFOV = true;
        }
    }
}
Beispiel #3
0
void PlayerAi::update(Actor *owner){
	if (owner->destructible &&owner->destructible->isDead() ) {
		return;
	}

	int levelUpXp = getNextLevelXp(owner);
	if (owner->destructible->xp >= levelUpXp) {
		owner->xpLevel++;
		owner->destructible->xp -= levelUpXp;
		engine.gui->message(TCODColor::yellow,"You feel a strange rush as the enemy falls to the floor!");
		engine.gui->render();
		TCODConsole::root->flush();
		engine.gui->menu.clear();
		engine.gui->menu.addItem(Menu::CONSTITUTION,"+20 HP");
		engine.gui->menu.addItem(Menu::STRENGTH,"+1 Attack");
		engine.gui->menu.addItem(Menu::AGILITY,"+1 Defense");
		
		Menu::MenuItemCode menuItem = Menu::RESUME;
		while (menuItem == Menu::RESUME) {
			menuItem = engine.gui->menu.pick(Menu::PAUSE);
		}
		switch (menuItem) {
			case Menu::CONSTITUTION :
				owner->destructible->maxHp+= 20;
				owner->destructible->hp += 20;
			break;
			case Menu::STRENGTH :
				owner->attacker->basePower += 1;
				owner->attacker->totalPower += 1;
			break;
			case Menu::AGILITY :
				owner->destructible->baseDR += 1;
				owner->destructible->totalDR += 1;
			break;
			default: break;
		}
	}
	
	int dx = 0, dy = 0;
	switch (engine.lastKey.vk) {
		case TCODK_KP5: 
			engine.gameStatus = Engine::NEW_TURN; 
			break;
		case TCODK_UP:
		case TCODK_KP8:
			dy = -1; 
			break;
		case TCODK_KP7:
			dy = -1;
			dx = -1;
			break;
		case TCODK_KP9:
			dy = -1;
			dx = 1;
			break;
		case TCODK_KP1:
			dy = 1;
			dx = -1;
			break;
		case TCODK_KP3:
			dy = 1;
			dx = 1;
			break;
		case TCODK_DOWN: 
		case TCODK_KP2:
			dy = 1; 
			break;
		case TCODK_LEFT: 
		case TCODK_KP4:	
			dx =-1; 
			break;
		case TCODK_RIGHT: 
		case TCODK_KP6: 
			dx = 1; 
			break;
		case TCODK_CHAR: handleActionKey(owner, engine.lastKey.c, (engine.lastKey.rctrl || engine.lastKey.lctrl), (engine.lastKey.ralt || engine.lastKey.lalt)); break;
		default: break;
	}
//		std::cout << "got here"<< std::endl;
	if ( dx != 0 || dy != 0){
		engine.gameStatus = Engine::NEW_TURN;
		if (moveOrAttack(owner,owner->x+dx,owner->y+dy)){
			engine.map->computeFov();
		}
	}
}