void CMovement::Update(void) { CRotation* pcRotation; CPosition* pcPosition; SFloat3* psPosition; SQuaternion* psRotation; CTransformNode* pcMatrix; if (miType == MT_PRS) { psRotation = NULL; if (mpcRotationAnimation) { pcRotation = (CRotation*)mpcRotationAnimation->Update(); psRotation = pcRotation->GetRotation(); } psPosition = NULL; if (mpcPositionAnimation) { pcPosition = (CPosition*)mpcPositionAnimation->Update(); psPosition = pcPosition->GetPosition(); } D3DXMatrixTransformation((D3DXMATRIX*)&mpsOutput->sD3DMatrix, NULL, NULL, NULL, NULL, (D3DXQUATERNION*)psRotation, (D3DXVECTOR3*)psPosition); } else if (miType = MT_Matrix) { pcMatrix = (CTransformNode*)mpcMatrixAnimation->Update(); mpsOutput->sD3DMatrix = *pcMatrix->GetMatrix(); } if (mpsOffset) { Float4x4Multiply(&mpsOutput->sD3DMatrix, &mpsOutput->sD3DMatrix, &mpsOffset->sD3DMatrix); } }
E_BEHAVIOR_ACTIONS CAggressiveBehaviorModule::playBehavior(const CGame& inGame) { E_BEHAVIOR_ACTIONS nextAction = E_ACTION_STAY; int opponentIdWithMaxMineCount = -1; int maxMineCount = 0; if (inGame.getOpponentIdWithMaxMineCount(opponentIdWithMaxMineCount, maxMineCount)) { const CHero &targetHero = inGame.getHero(opponentIdWithMaxMineCount); const CPosition targetHeroPos(targetHero.getPosition()); const int targetHeroCellId = inGame.get1DCoordOnBoard(targetHeroPos); const CHero &myHero = inGame.getMyHero(); path_t targetHeroPath; if (inGame.getPathTo(myHero.getId(), targetHeroCellId, false, targetHeroPath)) { // inGame.printPath(targetHeroPath, m_name); const CPosition nextPosition(inGame.get2DCoordOnBoard(*targetHeroPath.cbegin())); int deltaX = nextPosition.getX() - myHero.getPosition().getX(); int deltaY = nextPosition.getY() - myHero.getPosition().getY(); if (deltaX == 1) nextAction = E_ACTION_MOVE_EAST; else if (deltaX == -1) nextAction = E_ACTION_MOVE_WEST; else if (deltaY == 1) nextAction = E_ACTION_MOVE_SOUTH; else if (deltaY == -1) nextAction = E_ACTION_MOVE_NORTH; } else {} } else { // WAIT } // else return nextAction; } // playBehavior
void Chusky::OnBnClickedPositionButton() { CWnd *m_positionWnd; CPosition positionDlg; m_positionWnd = &positionDlg; INT_PTR nResponsePosition = positionDlg.DoModal(); // TODO: 在此添加控件通知处理程序代码 }
void PositionFunction(void* pvCel, float fFractionalTime, void* pvData) { //This is the rotation function which an animation can play. CPosition* pcPosition; pcPosition = (CPosition*)pvCel; pcPosition->Update(fFractionalTime); }
CPosition* CPosition::NewL(MPositionObserver& aObserver) { CPosition* self = new(ELeave) CPosition(aObserver); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); return self; }
void CUtmPoint::ToPosition(CPosition &pos) const { double lat,lon; UtmToLatLonWGS84(m_xzone,m_yzone,m_easting,m_northing, lat,lon); pos.Clear(); pos.SetLatitude(lat); pos.SetLongitude(lon); }
bool CUtmPoint::FromPosition(const CPosition &pos) { Clear(); if(!IsPositionInUtmSpace(pos)) return false; LatLonToUtmWGS84(m_xzone,m_yzone,m_easting,m_northing, pos.GetLatitude(), pos.GetLongitude()); return true; }
void ALeft::execute(const sf::Int32 elapsed) { // TODO: Verif' they are existing components // #1 get all components CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CSpeed * speed; speed = (CSpeed *) parent->getComponent("Speed"); CPosition * position; position = (CPosition *) parent->getComponent("Position"); // #2 add values speed->setHSpeed((speed->getHSpeed())-(acceleration->getHAcceleration())); position->setX((position->getX())+(speed->getHSpeed())); // #3 change sprites TODO // example : if elapsed > modulotime/2 then ... }
void AStand::execute(const sf::Int32 elapsed) { // TODO: Verif' they are existing components // #1 get all components CSpeed * speed; speed = (CSpeed *) parent->getComponent("Speed"); if ((float) std::abs(speed->getHSpeed()) > 1.2) { CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CPosition * position; position = (CPosition *) parent->getComponent("Position"); // #2 add value speed->setHSpeed((speed->getHSpeed())-((float)(speed->getHSpeed())/8.0)); position->setX((position->getX())+(speed->getHSpeed())); } else { speed->setHSpeed(0.0); } // #3 change sprites TODO // example : if elapsed > modulotime/2 then ... }
void ALeft::execute(const sf::Int32 elapsed) { // TODO: Verif' they are existing components // #1 get all components CSpeed * speed; speed = (CSpeed *) parent->getComponent("Speed"); CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CPosition * position; position = (CPosition *) parent->getComponent("Position"); if (speed->getHSpeed() > 1.2) { // #2a go back to 0 speed->setHSpeed((speed->getHSpeed())-((float)(speed->getHSpeed())/8.0)); position->setX((position->getX())+(speed->getHSpeed())); } else { // #2b increase speed speed->setHSpeed((speed->getHSpeed())-(acceleration->getHAcceleration())); position->setX((position->getX())+(speed->getHSpeed())); } // #3 change sprites TODO // example : if elapsed > modulotime/2 then ... }
bool CUIContainer::OnLBtnDown( int x ,int y ) { for (unsigned int i = 0;i < mChilds.size() ; i ++) { CPosition pt = mChilds[i]->ParentToSelf(x,y); if(mChilds[i]->Bound().Contain(x ,y) && mChilds[i]->OnLBtnDown(pt.X() , pt.Y())) { if(mFcousedObj && mFcousedObj != mChilds[i]) { mFcousedObj->OnFocusOut(mChilds[i]); } mFcousedObj = mChilds[i]; return true; } } if(mFcousedObj) { mFcousedObj->OnFocusOut(NULL); mFcousedObj = NULL; } return false; }
void ARight::execute(const sf::Int64 elapsed) { // TODO: Verif' they are existing components // #1 get all components sf::Int64 tempElapsedSum = getElapsedSum() + elapsed; CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CSpeed * speed = (CSpeed *) parent->getComponent("Speed"); CPosition * position = (CPosition *) parent->getComponent("Position"); CSprite * sprite = (CSprite *) parent->getComponent("Sprite"); if (speed->getHSpeed() < -1.2) { // #2a go back to 0 speed->setHSpeed((speed->getHSpeed())-((float)(speed->getHSpeed())/8.0)); position->setX((position->getX())+(speed->getHSpeed())); sprite->updatePosition(); } else { // #2b add values speed->setHSpeed((speed->getHSpeed())+ ((float)elapsed/acceleration->getHAcceleration()* speed->getHSpeedMax())); position->setX((position->getX())+ceil((speed->getHSpeed()))); // round sup sprite->updatePosition(); } // #3 change sprites sf::Int64 temp = 0; int k = 0; //index to read in tab while (temp < tempElapsedSum) { ++k; temp = temp + (getModuloTime()/getSubSprites().size()); } if ((k-1)>=getSubSprites().size()) {k=getSubSprites().size();} sprite->updateSubSprite(getSubSprites().at(k-1)); sprite->setDirection("right"); setElapsedSum(tempElapsedSum%getModuloTime()); }
// Call diz function implies an existing CPosition component void CSprite::updatePosition() { CPosition * position =(CPosition *) parent->getComponent("Position"); sprite.setPosition( position->getX() , position->getY()); }
bool CBound::Contain( CPosition p ) const { return Contain(p.X() , p.Y()); }