当前位置: 首页>>代码示例>>C++>>正文


C++ Heroes::isControlAI方法代码示例

本文整理汇总了C++中Heroes::isControlAI方法的典型用法代码示例。如果您正苦于以下问题:C++ Heroes::isControlAI方法的具体用法?C++ Heroes::isControlAI怎么用?C++ Heroes::isControlAI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Heroes的用法示例。


在下文中一共展示了Heroes::isControlAI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PassableToTile

bool PassableToTile(const Heroes & hero, const Maps::Tiles & toTile, int direct, s32 dst)
{
    // check end point
    if(toTile.GetIndex() == dst)
    {
	// fix toTilePassable with action object
	if(MP2::isPickupObject(toTile.GetObject()))
	    return true;

	// check direct to object
	if(MP2::isActionObject(toTile.GetObject(false), hero.isShipMaster()))
	    return Direction::Reflect(direct) & toTile.GetPassable();

	if(MP2::OBJ_HEROES == toTile.GetObject())
	    return toTile.isPassable(NULL, Direction::Reflect(direct), (hero.isControlAI() ? AI::HeroesSkipFog() : false));
    }

    // check to tile direct
    if(! toTile.isPassable(&hero, Direction::Reflect(direct), (hero.isControlAI() ? AI::HeroesSkipFog() : false)))
	return false;

    if(toTile.GetIndex() != dst)
    {
	if(MP2::isPickupObject(toTile.GetObject()) ||
	    MP2::isActionObject(toTile.GetObject(false), hero.isShipMaster()))
	    return false;

	// check hero/monster on route
	switch(toTile.GetObject())
	{
	    case MP2::OBJ_HEROES:
	    case MP2::OBJ_MONSTER:
		return false;

	    default: break;
	}

	// check monster protection
	if(CheckMonsterProtectionAndNotDst(toTile.GetIndex(), dst))
	    return false;
    }

    return true;
}
开发者ID:gerstrong,项目名称:fheroes2plus,代码行数:44,代码来源:route_pathfind.cpp

示例2: PassableFromToTile

bool PassableFromToTile(const Heroes & hero, s32 from, const s32 & to, int direct, s32 dst)
{
    const Maps::Tiles & fromTile = world.GetTiles(from);
    const Maps::Tiles & toTile = world.GetTiles(to);

    // check start point
    if(hero.GetIndex() == from)
    {
	if(MP2::isActionObject(fromTile.GetObject(false), hero.isShipMaster()))
	{
	    // check direct from object
	    if(! (direct & fromTile.GetPassable()))
		return false;
	}
	else
	{
	    // check from tile direct
	    if(! fromTile.isPassable(&hero, direct, (hero.isControlAI() ? AI::HeroesSkipFog() : false)))
		return false;
	}
    }
    else
    {
	if(MP2::isActionObject(fromTile.GetObject(), hero.isShipMaster()))
	{
	    // check direct from object
	    if(! (direct & fromTile.GetPassable()))
		return false;
	}
	else
	{
	    // check from tile direct
	    if(! fromTile.isPassable(&hero, direct, (hero.isControlAI() ? AI::HeroesSkipFog() : false)))
		return false;
	}
    }

    if(fromTile.isWater() && !toTile.isWater())
    {
	switch(toTile.GetObject())
	{
	    case MP2::OBJ_BOAT:
            case MP2::OBJ_MONSTER:
            case MP2::OBJ_HEROES:
                return false;

	    case MP2::OBJ_COAST:
		return toTile.GetIndex() == dst;

	    default: break;
	}
    }
    else
    if(!fromTile.isWater() && toTile.isWater())
    {
	switch(toTile.GetObject())
	{
	    case MP2::OBJ_BOAT:
                return true;

            case MP2::OBJ_HEROES:
		return toTile.GetIndex() == dst;

	    default: break;
	}
    }

    // check corner water/coast
    if(hero.isShipMaster() && 
	(direct & (Direction::TOP_LEFT | Direction::TOP_RIGHT | Direction::BOTTOM_RIGHT | Direction::BOTTOM_LEFT)))
    {
	switch(direct)
	{
	    case Direction::TOP_LEFT:
		if((Maps::isValidDirection(from, Direction::TOP) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::TOP)).isWater()) ||
		   (Maps::isValidDirection(from, Direction::LEFT) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::LEFT)).isWater()))
		    return false;
		break;

	    case Direction::TOP_RIGHT:
		if((Maps::isValidDirection(from, Direction::TOP) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::TOP)).isWater()) ||
		   (Maps::isValidDirection(from, Direction::RIGHT) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::RIGHT)).isWater()))
		    return false;
		break;

	    case Direction::BOTTOM_RIGHT:
		if((Maps::isValidDirection(from, Direction::BOTTOM) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::BOTTOM)).isWater()) ||
		   (Maps::isValidDirection(from, Direction::RIGHT) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::RIGHT)).isWater()))
		    return false;
		break;

	    case Direction::BOTTOM_LEFT:
		if((Maps::isValidDirection(from, Direction::BOTTOM) &&
		    ! world.GetTiles(Maps::GetDirectionIndex(from, Direction::BOTTOM)).isWater()) ||
//.........这里部分代码省略.........
开发者ID:gerstrong,项目名称:fheroes2plus,代码行数:101,代码来源:route_pathfind.cpp


注:本文中的Heroes::isControlAI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。