コード例 #1
0
void AntiVisibleTower::shoot(float dt)
{
	//电力足够的话 且没有移动
	if (getMove() == false && isPowerEnough)
	{
		//检测隐形敌人
		for (int i = 0; i < instance->enemyVector.size(); i++)
		{
			auto enemy = instance->enemyVector.at(i);
			auto enemyPos = enemy->getPosition();
			auto enemyType = enemy->getType();
			//只对第二种敌人(隐形敌人有效),否则所有敌人都要隐形
			if (enemyType == 2)
			{

				if (isEnemyInAnyAntiTowerRange(enemy)) //如果敌人在反隐塔vector中任意一个的射程内的话就显形,否则隐形
				{

					enemy->getEnemySprite()->setVisible(true); //图像上显形
					enemy->setIsVisible(true);//功能上显形
				}
				else
				{
					enemy->getEnemySprite()->setVisible(false);//隐形
					enemy->setIsVisible(false);

				}
			}
		}
	}
	
}
コード例 #2
0
void CUIMAAApprenticeManage::show()
{
    if (getIsVisible())return;
    setIsVisible(true);
    setIsTouchEnabled(true);
    CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, 1, true);
    createBasicChild();
}
コード例 #3
0
bool EnemyTest::init()
{
	if (!Sprite::init())
	{
		return false;
	}
	instance = GameManager::getInstance();

	sprite = Sprite::create("monster/monster1/right1.png"); //怪物本身的图片,初始化显示
	addChild(sprite);
	
	iceSprite = Sprite::create("ice.png"); //冰块图片
	iceSprite->setPosition(sprite->getPosition());
	addChild(iceSprite, 2);
	iceSprite->setVisible(false);

	setType(1);//这是第一种敌人
	setIsVisible(true);
	setRunSpeed(3);
	setHpPercentage(100);
	setMoney(2);//只值2元钱
	animationRight = createAnimation("monster/monster1/right", 4, 0.1f,95,84);
	AnimationCache::getInstance()->addAnimation(animationRight, "monster1_right");  //这个cache里存有各种做好的动画,重要,以便后来取出用动画
	animationLeft = createAnimation("monster/monster1/left", 4, 0.1f,95,84);
	AnimationCache::getInstance()->addAnimation(animationLeft, "monster1_left");
	

	createAndSetHpBar();

	schedule(schedule_selector(EnemyTest::changeDirection), 0.4f);
	schedule(schedule_selector(EnemyTest::deFroze), 0.2f); //每隔0.2秒执行一次检测是否减速函数

	////设置schduler来减缓敌人速度
	//CCScheduler *defaultScheduler = CCDirector::sharedDirector()->getScheduler();
	//// Create a new scheduler, and link it to the main scheduler
	//sched1 = new CCScheduler();
	//defaultScheduler->scheduleUpdateForTarget(sched1, 0, false);
	//// Create a new ActionManager, and link it to the new scheudler
	//actionManager1 = new CCActionManager();
	//sched1->scheduleUpdateForTarget(actionManager1, 0, false);
	//// Replace the default ActionManager with the new one.
	//this->setActionManager(actionManager1);

	return true;
}
コード例 #4
0
ファイル: DrawableImage.cpp プロジェクト: ProjectKidona/game
// ハンドルのSet
void DrawableImage::setHandle(const int handle){
    int result;

    // 渡されたハンドルのチェック
    assert("error imageHandle: handle == -1" && handle != -1);

    // ハンドルの設定
    m_handle = handle;

    // 画像の大きさの取得と表示領域を最大に設定
    result = GetGraphSize(m_handle, &m_srcWidth, &m_srcHeight);
    assert(!result && "Error GetGraphSize()");
    m_width = m_srcWidth;
    m_height = m_srcHeight;

    // Visibleに設定
    setIsVisible(true);
}
コード例 #5
0
bool EnemyDisableTower::init() /*override*/
{
	if (!Sprite::init())
	{
		return false;
	}
	instance = GameManager::getInstance();

	sprite = Sprite::create("monster/monster_disable_tower/right1.png"); //怪物本身的图片,初始化显
	addChild(sprite);

	iceSprite = Sprite::create("ice.png"); //冰块图片
	iceSprite->setPosition(sprite->getPosition());
	addChild(iceSprite, 2);
	iceSprite->setVisible(false);

	disableRing = Sprite::create("disableRing.png");
	disableRing->setScale(2);
	addChild(disableRing, 10);
	auto fo = FadeOut::create(1);
	disableRing->runAction(RepeatForever::create(Sequence::create(fo, fo->reverse(), NULL)));

	setType(3);//这是第3种敌人
	setIsVisible(true);//不是隐形单位
	setRunSpeed(4);
	setHpPercentage(100);
	setMoney(8);//只值4元钱
	animationRight = createAnimation("monster/monster_disable_tower/right", 4, 0.1f, 100, 100);
	AnimationCache::getInstance()->addAnimation(animationRight, "monster_disable_right");  //这个cache里存有各种做好的动画,重要,以便后来取出用动画
	animationLeft = createAnimation("monster/monster_disable_tower/left", 4, 0.1f, 100, 100);
	AnimationCache::getInstance()->addAnimation(animationLeft, "monster_disable_left");


	createAndSetHpBar();

	schedule(schedule_selector(EnemyDisableTower::changeDirection), 0.4f);
	schedule(schedule_selector(EnemyDisableTower::deFroze), 0.2f); //每隔0.2秒执行一次检测是否减速函数
	//schedule(schedule_selector(EnemyDisableTower::disableNearbyTower), 0.2f);//每隔0.2秒沉默敌人一次,有问题:不能在敌人这判断,要在炮塔那判断才行,否则会图片会闪烁


	return true;
}
コード例 #6
0
ファイル: GLGameModel.cpp プロジェクト: rku/Settleboard
GLGameModel::GLGameModel(QObject *parent) : QObject(parent)
{
    created = false;

    displayListID = glGenLists(1);
    frameDisplayListID = glGenLists(1);

    pos    = QVector3D(0.0, 0.0, 0.0); 
    scale  = 1.0f;
    angleX = 0.0f;
    angleY = 0.0f;
    angleZ = 0.0f;

    color = Qt::gray;
    setIsLightingEnabled(true);
    setIsHighlighted(false);
    setIsSelectable(false);
    setIsVisible(true);
    setIsEnabled(true);
}
コード例 #7
0
ファイル: Tile.cpp プロジェクト: AeroGlass/g3m
void Tile::render(const G3MRenderContext* rc,
                  const TileRenderContext* trc,
                  const GLState& parentState,
                  std::list<Tile*>* toVisitInNextIteration,
                  const Planet* planet,
                  const Vector3D& cameraNormalizedPosition,
                  double cameraAngle2HorizonInRadians,
                  const Frustum* cameraFrustumInModelCoordinates) {

  const float verticalExaggeration =  trc->getVerticalExaggeration();
  if (verticalExaggeration != _verticalExaggeration) {
    // TODO: verticalExaggeration changed, invalidate tileExtent, Mesh, etc.

    _verticalExaggeration = trc->getVerticalExaggeration();
  }

  TilesStatistics* statistics = trc->getStatistics();
  statistics->computeTileProcessed(this);

  if (isVisible(rc, trc, planet,
                cameraNormalizedPosition,
                cameraAngle2HorizonInRadians,
                cameraFrustumInModelCoordinates)) {
    setIsVisible(true, trc->getTexturizer());

    statistics->computeVisibleTile(this);

    const bool isRawRender = (
                              (toVisitInNextIteration == NULL) ||
                              meetsRenderCriteria(rc, trc)     ||
                              (trc->getParameters()->_incrementalTileQuality && !_textureSolved)
                              );

    if (isRawRender) {
      rawRender(rc, trc, parentState);
      if (trc->getParameters()->_renderDebug) {
        debugRender(rc, trc, parentState);
      }

      statistics->computeTileRendered(this);

      prune(trc->getTexturizer(),
            trc->getElevationDataProvider());
      //TODO: AVISAR CAMBIO DE TERRENO
    }
    else {
      const Geodetic2D lower = _sector._lower;
      const Geodetic2D upper = _sector._upper;

      const Angle splitLongitude = Angle::midAngle(lower._longitude,
                                                   upper._longitude);

      const Angle splitLatitude = trc->getLayerTilesRenderParameters()->_mercator
      /*                               */ ? MercatorUtils::calculateSplitLatitude(lower._latitude,
                                                                                  upper._latitude)
      /*                               */ : Angle::midAngle(lower._latitude,
                                                            upper._latitude);

      std::vector<Tile*>* subTiles = getSubTiles(splitLatitude, splitLongitude);
      if (_justCreatedSubtiles) {
        trc->getLastSplitTimer()->start();
        statistics->computeSplitInFrame();
        _justCreatedSubtiles = false;
      }

      const int subTilesSize = subTiles->size();
      for (int i = 0; i < subTilesSize; i++) {
        Tile* subTile = subTiles->at(i);
        toVisitInNextIteration->push_back(subTile);
      }
    }
  }
  else {
    setIsVisible(false, trc->getTexturizer());

    prune(trc->getTexturizer(),
          trc->getElevationDataProvider());
    //TODO: AVISAR CAMBIO DE TERRENO
  }
}
コード例 #8
0
void IGUIElement::load(io::IAttributeExchangingObject* aeo) throw(CIOException)
{
	setIsVisible(aeo->getBoolean(VISIBLE_ATTR));
	setBound(aeo->getRectangle(BOUND_ATTR));
	setState((EELEMENT_STATE)aeo->getInteger(STATE_ATTR));
}
コード例 #9
0
void CUIMAAApprenticeManage::hide()
{
    setIsVisible(false);
    CCTouchDispatcher::sharedDispatcher()->removeDelegate(this);
    removeAllChildrenWithCleanup(true);
}