예제 #1
0
void Interface::Basic::EventDefaultAction(void)
{
    Heroes* hero = GetFocusHeroes();

    if(hero)
    {
	const Maps::Tiles & tile = world.GetTiles(hero->GetIndex());

	// 1. action object
	if(MP2::isActionObject(hero->GetMapsObject(), hero->isShipMaster()) &&
	    (! MP2::isMoveObject(hero->GetMapsObject()) || hero->CanMove()))
	{
	    hero->Action(hero->GetIndex());
	    if(MP2::OBJ_STONELIGHTS == tile.GetObject(false) || MP2::OBJ_WHIRLPOOL == tile.GetObject(false))
		SetRedraw(REDRAW_HEROES);
	    SetRedraw(REDRAW_GAMEAREA);
	}
	else
	// 2. continue
        if(hero->GetPath().isValid())
    	    hero->SetMove(true);
	else
	// 3. hero dialog
	    Game::OpenHeroesDialog(*hero);
    }
    else
    // 4. town dialog
    if(GetFocusCastle())
    {
	Game::OpenCastleDialog(*GetFocusCastle());
    }
}
예제 #2
0
void Interface::Basic::EventContinueMovement(void)
{
    Heroes* hero = GetFocusHeroes();

    if(hero && hero->GetPath().isValid())
	hero->SetMove(! hero->isEnableMove());
}
예제 #3
0
int Interface::Basic::EventExit(void)
{
    Heroes* hero = GetFocusHeroes();

    // stop hero
    if(hero && hero->isEnableMove())
	hero->SetMove(false);
    else
    if(Dialog::YES & Dialog::Message("", _("Are you sure you want to quit?"), Font::BIG, Dialog::YES|Dialog::NO))
	return Game::QUITGAME;

    return Game::CANCEL;
}
예제 #4
0
void Heroes::MoveStep(Heroes & hero, s32 index_from, s32 index_to, bool newpos)
{
    if(newpos)
    {
	hero.Move2Dest(index_to);
	hero.GetPath().PopFront();

	// possible hero is die
	if(!hero.isFreeman() &&
	    index_to == hero.GetPath().GetDestinationIndex())
	{
	    hero.GetPath().Reset();
	    hero.Action(index_to);
	    hero.SetMove(false);
	}
    }
    else
    {
	hero.ApplyPenaltyMovement();
	hero.GetPath().Reset();
	hero.Action(index_to);
	hero.SetMove(false);
    }
}