void Charmander::fireAtEnemies()
{
    int enemyCount = 0;
	for( int i = 0; i < m_Level->getEnemies().size(); i++)
    {
        Enemy* enemy = m_Level->getEnemies().at(i);
        
        if(enemy != NULL && enemy->getIsActive() == true)
        {
            if(MathUtils::withinRange(enemy->getX(),getX(),450.0f) == true || MathUtils::withinRange(enemy->getY(),getY(),450.0f == true))
            {
                enemyCount++;
                Tile* targetTile = m_Level->getTileForPlayer(enemy);
                float centerX = targetTile->getX() + (targetTile->getWidth() / 2.0f);
                float centerY = targetTile->getY() + (targetTile->getHeight() / 2.0f);
                
                if(enemyCount == 1)
                {
                    if(enemy->getIsActive() == true && getIsActive() == true)
                    {
                        fireProjectile(centerX, centerY,"FireBall",500.0f,3);
                    }
                }
                else
                {
                    break;
                }
                
            }
        }
    }
}
Пример #2
0
void COpcProcessVar::sendItemData(){
  try{
    if (getIsActive())
      m_pOpcItem->writeSync(updateValue());
  } catch (OPCException e){
    setIsActive(false);
  }
}
Пример #3
0
void RemoteControl::startShooting(ObserverData* param)
{
    if (getIsActive())
    {
        _state.needsSync = false;
        CCNotificationCenter::sharedNotificationCenter()->postNotification(RESOLVE_SHOOT, param);
        CCLog("wtf is going on why no shoot");
        _state.hasShoot = false;
    }
}
Пример #4
0
void CaseBase::evaluateChanges(ChangeContext& changeContext)
{
	//if we're true to the root, but not yet active, add ourself to the activation queue. If the opposite, i.e. we're no longer true to the root but active, we need to be deactivated.
	if (getIsTrueToRoot()) {
		if (!getIsActive()) {
			changeContext.addCaseToActivate(this);
		}
	} else {
		if (getIsActive()) {
			changeContext.addCaseToDeactivate(this);
		}
	}
	//recursively iterate over the child matches
	MatchBaseStore::iterator I = mMatches.begin();
	for ( ; I != mMatches.end(); ++I) {
		(*I)->evaluateChanges(changeContext);
	}

}
Пример #5
0
void Ball::checkCollision(GameObject* aGameObject)
{
	//Make sure the ball is active, the gameObject isn't NULL and that it is also active
	if(getIsActive() == true && aGameObject != NULL && aGameObject->getIsActive() == true)
	{
		//Determine if the gameObject is a Paddle
		if(strcmp(aGameObject->getType(), GAME_PADDLE_TYPE) == 0)
		{
			handlePaddleCollision((Paddle*)aGameObject);
		}
	}
}
Пример #6
0
void RemoteControl::transferData(ObserverData* param)
{
    if (!getIsActive())
    {
        if (sgl_ConnectionManager.getState() == STATE_JOINED || sgl_ConnectionManager.getState() == STATE_CREATED_JOINED)
        {
            NetworkData ndata;
			std::map<int,float>* data = new std::map<int,float>();

			data->insert(std::pair<int,float>(1, param->getSpeed().x * 0.7f));
			data->insert(std::pair<int,float>(2,  param->getSpeed().y * 0.7f));

			ndata.setData(data);
                        
            sgl_ConnectionManager.sendEvent(ndata, kShoot);
            
            _state.needsSync = true;
        }
    }
}
Пример #7
0
void RemoteControl::update(CCPoint pos, b2Vec2 speed)
{
    if (!getIsActive() && _state.needsSync)
    {
        if (sgl_ConnectionManager.getState() == STATE_JOINED || sgl_ConnectionManager.getState() == STATE_CREATED_JOINED)
        {
            
            CCPoint relp = TerrainMap::getInstance().getRelativeCoordinatesFromPoint(pos);
			
			std::map<int,float>* data = new std::map<int,float>();

			data->insert(std::pair<int,float>(4, relp.x));
			data->insert(std::pair<int,float>(5, relp.y));
			data->insert(std::pair<int,float>(1, speed.x));
			data->insert(std::pair<int,float>(2, speed.x));

			_lastData->setData(data);
            
            sgl_ConnectionManager.sendEvent(*_lastData, kPositionSync);
        }
    }
}
void AnimTimeSensor::frame(Time oTime, UInt32 uiFrame)
{
    Time startT = _sfStartTime  .getValue();
    Time stopT  = _sfStopTime   .getValue();
    Time currT  = _sfTime       .getValue();

    Time length = _sfCycleLength.getValue();
    Time deltaT = 0.0;

    setTime(oTime);

    if(getEnabled() == false)
    {
        if(getIsActive() == true)
        {
            setIsActive(false);
        }

        return;
    }

    if(startT < stopT)
    {
        if(oTime < startT)
        {
            if(getIsActive() == true)
            {
                SLOG << "ATS: start < stop, BEFORE startT, deactivating" << std::endl;

                setFraction(0.f  );
                setAnimTime(0.f  );
                setIsActive(false);
            }

            return;
        }
        else if(oTime > stopT)
        {
            if(getIsActive() == true)
            {
                SLOG << "ATS: start < stop, AFTER stopT";

                setFraction(1.f   );
                setAnimTime(length);

                // only deactivate the second time oTime > stopT
                // to propagate the final state
                if(currT > stopT)
                {
                    PLOG << ", deactivating";

                    setIsActive(false);
                }

                PLOG << std::endl;
            }

            return;
        }
        else
        {
            if(currT <= 0.0)
            {
                deltaT = oTime - startT;
            }
            else
            {
                deltaT = oTime - currT;
            }
        }
    }
    else
    {
        if(oTime < startT)
        {
            if(getIsActive() == true)
            {
                SLOG << "ATS: start >= stop, BEFORE startT, deactivating" << std::endl;

                setFraction(0.f  );
                setAnimTime(0.f  );
                setIsActive(false);
            }

            return;
        }
        else
        {
            if(currT <= 0.0)
            {
                deltaT = oTime - startT;
            }
            else
            {
                deltaT = oTime - currT;
            }
        }
    }

    // use deltaT to update

    Real32 oldAnimT = getAnimTime();
    Real32 newAnimT = getAnimTime();

    if(getForward() == true)
    {
        newAnimT += getTimeScale() * deltaT;
    }
    else
    {
        newAnimT -= getTimeScale() * deltaT;
    }

    if(getLoop() == true)
    {
        newAnimT = osgMod<Real64>(newAnimT, length);
        
        while(newAnimT < 0.f)
            newAnimT += length;

        setAnimTime(newAnimT         );
        setFraction(newAnimT / length);

        if(getIsActive() == false)
            setIsActive(true);
    }
    else
    {
        if(newAnimT < 0.f)
        {
            if(getIsActive() == true)
            {
                SLOG << "ATS: start >= stop, newAnimT < 0";

                setAnimTime(0.f);
                setFraction(0.f);

                // only deactivate the second time newAnimT < 0.f
                // to propagate the final state
                if(oldAnimT <= 0.f)
                {
                    PLOG << ", deactivating";

                    setIsActive(false);
                }

                PLOG << std::endl;
            }
        }
        else if(newAnimT > length)
        {
            if(getIsActive() == true)
            {
                SLOG << "ATS: start >= stop, newAnimT > length";

                setAnimTime(length);
                setFraction(1.f   );

                // only deactivate the second time newAnimT > length
                // to propagate the final state
                if(oldAnimT >= length)
                {
                    PLOG << ", deactivating";

                    setIsActive(false);
                }

                PLOG << std::endl;
            }
        }
        else
        {
            setAnimTime(newAnimT         );
            setFraction(newAnimT / length);

            if(getIsActive() == false)
                setIsActive(true);
        }
    }
}