/** ** The transporter unloads a unit. ** ** @param unit Pointer to unit. */ void HandleActionUnload(CUnit *unit) { int i; int x; int y; if (!CanMove(unit)) { unit->SubAction = 2; } switch (unit->SubAction) { // // Move the transporter // case 0: if (!unit->Orders[0]->Goal) { if (!ClosestFreeDropZone(unit, unit->Orders[0]->X, unit->Orders[0]->Y, &x, &y)) { // Sorry... I give up. unit->ClearAction(); return; } unit->Orders[0]->X = x; unit->Orders[0]->Y = y; } NewResetPath(unit); unit->SubAction = 1; case 1: // The Goal is the unit that we have to unload. if (!unit->Orders[0]->Goal) { // We have to unload everything if ((i = MoveToDropZone(unit))) { if (i == PF_REACHED) { if (++unit->SubAction == 1) { unit->ClearAction(); } } else { unit->SubAction = 2; } } break; } // // Leave the transporter // case 2: // FIXME: show still animations ? LeaveTransporter(unit); if (CanMove(unit) && unit->Orders[0]->Action != UnitActionStill) { HandleActionUnload(unit); } break; } }
bool Oneal::Collision(Entity* E) { // Entity-to-map collision if (E == NULL) { int dice = rand()%100; if (abs(SpeedX) > 0) { //50% to go in opposite direction if (dice > 50 && CanMove(X - SpeedX, Y)) { //std::cout << "Diced " << dice << " to go in the opposite direction. Speed " << SpeedX; SpeedX = -SpeedX; //std::cout << " to " << SpeedX << std::endl; } else if (dice > 25 && CanMove(X, Y + SpeedX)) { //std::cout << "Diced " << dice << " to go down. Speed " << SpeedX << " " << SpeedY; if (SpeedY == 0) SpeedY = SpeedX; SpeedX = 0; //std::cout << " to " << SpeedX << " " << SpeedY << std::endl; } else { //std::cout << "Diced " << dice << " to go up. Speed " << SpeedX << " " << SpeedY; if (SpeedY == 0) SpeedY = -SpeedX; SpeedX = 0; //std::cout << " to " << SpeedX << " " << SpeedY << std::endl; } } if (abs(SpeedY) > 0) { //50% to go in opposite direction if (dice > 50) { //std::cout << "Diced " << dice << " to go in the opposite direction. Speed " << SpeedY; SpeedY = -SpeedY; //std::cout << " to " << SpeedY << std::endl; } else if (dice > 25) { //std::cout << "Diced " << dice << " to go right direction. Speed " << SpeedY << " " << SpeedX; if (SpeedX == 0) SpeedX = SpeedY; SpeedY = 0; //std::cout << " to " << SpeedX << " " << SpeedY << std::endl; } else { if (SpeedX == 0) SpeedX = -SpeedY; SpeedY = 0; } } return false; } else { ; } return true; }
void MoveLeft() { struct Brick b = Brick; b.pos.x--; if (CanMove(b) == TRUE) { b.pos.x++; b.pos.y++; if ( CanMove(b) == FALSE ) Delay=0; DisplayBrick(Brick,FALSE); Brick.pos.x--; Expect(); DisplayBrick(Brick,TRUE); } }
BOOL MoveDown() { struct Brick b = Brick; b.pos.y++; if (CanMove(b) != TRUE) { return TRUE; } if ( CanMove(b) == TRUE ){ DisplayBrick(Brick,FALSE); Brick.pos.y++; DisplayBrick(Brick,TRUE); return FALSE; } }
void MoveUp() { struct Brick b = Brick; if(++b.rotation == 4) b.rotation=0; if (CanMove(b) == TRUE) { DisplayBrick(Brick,FALSE); Brick.rotation=b.rotation; Expect(); DisplayBrick(Brick,TRUE); b.rotation--; b.pos.y++; if ( CanMove(b) == FALSE ) Delay=0; } }
/** ** Show the current order of an unit. ** ** @param unit Pointer to the unit. */ void ShowOrder(const CUnit *unit) { int x1; int y1; COrder *order; if (unit->Destroyed) { return; } // Get current position x1 = CurrentViewport->Map2ViewportX( unit->X) + unit->IX + unit->Type->TileWidth * TileSizeX / 2; y1 = CurrentViewport->Map2ViewportY( unit->Y) + unit->IY + unit->Type->TileHeight * TileSizeY / 2; // If the current order is cancelled show the next one if (unit->OrderCount > 1 && unit->OrderFlush) { order = unit->Orders[1]; } else { order = unit->Orders[0]; } ShowSingleOrder(unit, x1, y1, order); // Show the rest of the orders for (int i = 1 + (unit->OrderFlush ? 1 : 0); i < unit->OrderCount; ++i) { GetOrderPosition(unit, unit->Orders[i - 1], &x1, &y1); ShowSingleOrder(unit, x1, y1, unit->Orders[i]); } // Show order for new trained units if (!CanMove(unit)) { ShowSingleOrder(unit, x1, y1, &unit->NewOrder); } }
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff) { // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff if (creature->HasUnitState(UNIT_STATE_NOT_MOVE)) { creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); return true; } // prevent a crash at empty waypoint path. if (!i_path || i_path->empty()) return false; if (Stopped()) { if (CanMove(diff)) return StartMove(creature); } else { // Set home position at place on waypoint movement. if (!creature->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || !creature->GetTransGUID()) creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); if (creature->IsStopped()) Stop(STOP_TIME_FOR_PLAYER); else if (creature->movespline->Finalized()) { OnArrived(creature); return StartMove(creature); } } return true; }
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff) { // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff if (creature->HasUnitState(UNIT_STATE_NOT_MOVE)) { creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); return true; } // prevent a crash at empty waypoint path. if (!i_path || i_path->empty()) return false; // Xinef: Dont allow dead creatures to move if (!creature->IsAlive()) return false; // prevent movement while casting spells with cast time or channel time if (creature->HasUnitState(UNIT_STATE_CASTING)) { bool stop = true; if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT)) stop = false; if (stop) { Stop(1000); if (!creature->IsStopped()) creature->StopMoving(); return true; } } if (Stopped()) { if (CanMove(diff)) return StartMove(creature); } else { if (creature->IsStopped()) Stop(STOP_TIME_FOR_PLAYER); else { // xinef: code to detect pre-empetively if we should start movement to next waypoint // xinef: do not start pre-empetive movement if current node has delay or we are ending waypoint movement bool finished = creature->movespline->Finalized(); if (!finished && !i_path->at(i_currentNode)->delay && ((i_currentNode != i_path->size() - 1) || repeating)) finished = (creature->movespline->_Spline().length(creature->movespline->_currentSplineIdx()+1) - creature->movespline->timePassed()) < 200; if (finished) { OnArrived(creature); return StartMove(creature); } } } return true; }
bool CPlayerInput::OnActionJump(EntityId entityId, const ActionId& actionId, int activationMode, float value) { bool canJump = ((m_pPlayer->GetStance() == STANCE_ZEROG) || (m_pPlayer->GetStance() == STANCE_SWIM) || m_pPlayer->TrySetStance(STANCE_STAND)); if (CanMove() && canJump && m_pPlayer->GetSpectatorMode() != CActor::eASM_Free && m_pPlayer->GetSpectatorMode() != CActor::eASM_Fixed) { if (value > 0.0f) { if(m_actions & ACTION_PRONE || m_actions & ACTION_CROUCH) { m_actions &= ~ACTION_PRONE; m_actions &= ~ACTION_CROUCH; return false; } //if (m_pPlayer->m_params.speedMultiplier > 0.99f) m_actions |= ACTION_JUMP; if(m_speedLean) m_speedLean = 0.0f; return true; } } // Moved this outside, since if the top condition is false the JUMP flag might not be cleared, // and the player continues jumping as if the jump key was held. m_actions &= ~ACTION_JUMP; m_pPlayer->GetGameObject()->ChangedNetworkState(INPUT_ASPECT); return false; }
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff) { // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff if (creature->HasUnitState(UNIT_STATE_NOT_MOVE)) { creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE); return true; } // prevent a crash at empty waypoint path. if (!i_path || i_path->empty()) return false; if (Stopped()) { if (CanMove(diff)) return StartMove(creature); } else { if (creature->IsStopped()) Stop(STOP_TIME_FOR_PLAYER); else if (creature->movespline->Finalized()) { OnArrived(creature); return StartMove(creature); } } return true; }
bool CPlayerInput::OnActionCrouch(EntityId entityId, const ActionId& actionId, int activationMode, float value) { if (CanMove() && m_pPlayer->GetSpectatorMode() != CActor::eASM_Free && m_pPlayer->GetSpectatorMode() != CActor::eASM_Fixed) { if (g_pGameCVars->cl_crouchToggle) { if (value > 0.0f) { if (!(m_actions & ACTION_CROUCH)) m_actions |= ACTION_CROUCH; else m_actions &= ~ACTION_CROUCH; } } else { if (value > 0.0f) { //if (m_pPlayer->m_params.speedMultiplier > 0.99f) m_actions |= ACTION_CROUCH; } else { m_actions &= ~ACTION_CROUCH; } } } return false; }
bool CPlayerInput::OnActionToggleStance(EntityId entityId, const ActionId& actionId, int activationMode, float value) { if(CanMove()) { if(activationMode == eAAM_OnPress) { if(m_actions & ACTION_PRONE || m_actions & ACTION_CROUCH) { m_fCrouchPressedTime = gEnv->pTimer->GetAsyncTime().GetMilliSeconds(); } else { m_actions |= ACTION_CROUCH; m_fCrouchPressedTime = gEnv->pTimer->GetAsyncTime().GetMilliSeconds(); } } else if(activationMode == eAAM_OnRelease) { if(m_fCrouchPressedTime > 0.0f) { if(m_actions & ACTION_PRONE) { m_actions &= ~ACTION_PRONE; m_actions |= ACTION_CROUCH; } } m_fCrouchPressedTime = -1.0f; } } return false; }
bool CPlayerInput::OnActionSprint(EntityId entityId, const ActionId& actionId, int activationMode, float value) { if (CanMove()) { if (g_pGameCVars->cl_sprintToggle) { if (activationMode == eAAM_OnPress) { if (value > 0.0f) { if (!(m_actions & ACTION_SPRINT)) StartSprint(); else StopSprint(); } } } else { if (value > 0.0f) StartSprint(); else StopSprint(); } } return false; }
/** ** Follow unit to new position ** ** @param unit pointer to unit. ** @param dest unit to be followed ** @param flush if true, flush command queue. */ void CommandFollow(CUnit *unit, CUnit *dest, int flush) { COrder *order; // // Check if unit is still valid? (NETWORK!) // if (!unit->Removed && unit->Orders[0]->Action != UnitActionDie) { if (!CanMove(unit)) { // FIXME: should find a better way for pending orders. order = &unit->NewOrder; ReleaseOrder(order); } else if (!(order = GetNextOrder(unit, flush))) { return; } order->Init(); order->Action = UnitActionFollow; // // Destination could be killed. // Should be handled in action, but is not possible! // Unit::Refs is used as timeout counter. // if (dest->Destroyed) { order->X = dest->X + dest->Type->TileWidth / 2; order->Y = dest->Y + dest->Type->TileHeight / 2; } else { order->Goal = dest; dest->RefsIncrease(); order->Range = 1; } } ClearSavedAction(unit); }
/** ** Let an unit patrol from current to new position ** ** FIXME: want to support patroling between units. ** ** @param unit pointer to unit. ** @param x X map position to patrol between. ** @param y Y map position to patrol between. ** @param flush if true, flush command queue. */ void CommandPatrolUnit(CUnit *unit, int x, int y, int flush) { COrder *order; Assert(x >= 0 && y >= 0 && x < Map.Info.MapWidth && y < Map.Info.MapHeight); // // Check if unit is still valid? (NETWORK!) // if (!unit->Removed && unit->Orders[0]->Action != UnitActionDie) { if (!CanMove(unit)) { // FIXME: should find a better way for pending orders. order = &unit->NewOrder; ReleaseOrder(order); } else if (!(order = GetNextOrder(unit, flush))) { return; } order->Init(); order->Action = UnitActionPatrol; order->X = x; order->Y = y; Assert(!(unit->X & ~0xFFFF) && !(unit->Y & ~0xFFFF)); order->Arg1.Patrol.X = unit->X; order->Arg1.Patrol.Y = unit->Y; } ClearSavedAction(unit); }
bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint32& diff) { // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff if (creature.hasUnitState(UNIT_STAT_NOT_MOVE)) { creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); return true; } // prevent a crash at empty waypoint path. if (!i_path || i_path->empty()) { creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); return true; } if (Stopped(creature)) { if (CanMove(diff, creature)) { StartMove(creature); } } else { if (creature.IsStopped()) { Stop(STOP_TIME_FOR_PLAYER); } else if (creature.movespline->Finalized()) { OnArrived(creature); StartMove(creature); } } return true; }
/* ================ rvMonsterConvoyGround::State_Legs_Move ================ */ stateResult_t rvMonsterConvoyGround::State_Legs_Move ( const stateParms_t& parms ) { enum { STAGE_INIT, STAGE_MOVE }; switch ( parms.stage ) { case STAGE_INIT: move.fl.allowAnimMove = true; move.fl.allowPrevAnimMove = false; move.fl.running = true; move.currentDirection = MOVEDIR_FORWARD; // TODO: Looks like current anim rate never gets reset, so they do not correctly accelerate from a stop // unfortunately, adding this change (with a decent acceleration factor) caused them to do lots of // not-so-good looking short moves. // moveCurrentAnimRate = 0; oldOrigin = physicsObj.GetOrigin ( ); PlayCycle ( ANIMCHANNEL_LEGS, "run", 0 ); StartSound( "snd_move", SND_CHANNEL_BODY3, 0, false, NULL ); return SRESULT_STAGE ( STAGE_MOVE ); case STAGE_MOVE: // If not moving forward just go back to idle if ( !move.fl.moving || !CanMove() ) { StopSound( SND_CHANNEL_BODY3, 0 ); PostAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle", 0 ); return SRESULT_DONE; } // If on the ground update the animation rate based on the normal of the ground plane if ( !ai_debugHelpers.GetBool ( ) && physicsObj.HasGroundContacts ( ) ) { float rate; idVec3 dir; dir = (physicsObj.GetOrigin ( ) - oldOrigin); if ( DistanceTo ( move.moveDest ) < move.walkRange ) { rate = moveAnimRateMin; } else if ( dir.Normalize ( ) > 0.0f ) { rate = idMath::ClampFloat ( -0.7f, 0.7f, physicsObj.GetGravityNormal ( ) * dir ) / 0.7f; rate = moveAnimRateMin + moveAnimRateRange * (1.0f + rate) / 2.0f; } else { rate = moveAnimRateMin + moveAnimRateRange * 0.5f; } moveCurrentAnimRate += ((rate - moveCurrentAnimRate) * moveAccelRate); animator.CurrentAnim ( ANIMCHANNEL_LEGS )->SetPlaybackRate ( gameLocal.time, moveCurrentAnimRate ); } oldOrigin = physicsObj.GetOrigin ( ); return SRESULT_WAIT; } return SRESULT_ERROR; }
void Expect(){ DisplayBrick(expect,FALSE); expect=Brick; expect.t=EXPECT; while(CanMove(expect)) expect.pos.y++; expect.pos.y--; DisplayBrick(expect,TRUE); }
bool CPlayerInput::OnActionMoveForward(EntityId entityId, const ActionId& actionId, int activationMode, float value) { if (CanMove()) { // (jh) release button if(activationMode == 2) { if(!(m_moveButtonState&eMBM_Back)) { // for camera m_moveStickUD = 0; m_deltaMovement.y = 0; if (!(m_moveButtonState&eMBM_Left) && !(m_moveButtonState&eMBM_Right)) m_actions &= ~ACTION_MOVE; } } else { // (jh) this holds the state information m_actions |= ACTION_MOVE; } // (jh) button pressed if(CheckMoveButtonStateChanged(eMBM_Forward, activationMode)) { /* Vec3 v(0.0, 0.0, 0.0); IAIActor* pAIActor = CastToIAIActorSafe(m_pPlayer->GetEntity()->GetAI()); pAIActor->SetSpeed(AISPEED_SPRINT); IAISignalExtraData* exd = gEnv->pAISystem->CreateSignalExtraData(); exd->point = v; pAIActor->SetSignal(AISIGNAL_DEFAULT, "ACT_GOTO", m_pPlayer->GetEntity(), exd); // pAIActor->GoTo() */ if(activationMode != 2) { ApplyMovement(Vec3(0,value * 2.0f - 1.0f,0)); // for camera m_moveStickUD = value * 2.0f - 1.0f; m_deltaMovement.y = value; } m_checkZoom = true; AdjustMoveButtonState(eMBM_Forward, activationMode); } } return false; }
ezQtPropertyContainerWidget::Element& ezQtPropertyContainerWidget::AddElement(ezUInt32 index) { ezQtGroupBoxBase* pSubGroup = CreateElement(m_pGroup); pSubGroup->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); connect(pSubGroup, &ezQtGroupBoxBase::CollapseStateChanged, m_pGrid, &ezQtPropertyGridWidget::OnCollapseStateChanged); connect(pSubGroup, &QWidget::customContextMenuRequested, this, &ezQtPropertyContainerWidget::OnCustomElementContextMenu); QVBoxLayout* pSubLayout = new QVBoxLayout(nullptr); pSubLayout->setContentsMargins(5, 0, 0, 0); pSubLayout->setSpacing(1); pSubGroup->GetContent()->setLayout(pSubLayout); m_pGroupLayout->insertWidget((int)index, pSubGroup); ezQtPropertyWidget* pNewWidget = CreateWidget(index); pNewWidget->setParent(pSubGroup); pSubLayout->addWidget(pNewWidget); pNewWidget->Init(m_pGrid, m_pObjectAccessor, m_pType, m_pProp); { // Add Buttons auto pAttr = m_pProp->GetAttributeByType<ezContainerAttribute>(); if ((!pAttr || pAttr->CanMove()) && m_pProp->GetCategory() != ezPropertyCategory::Map) { // Do we need move buttons at all if we have drag&drop? // ezQtElementGroupButton* pUpButton = new ezQtElementGroupButton(pSubGroup->GetHeader(), // ezQtElementGroupButton::ElementAction::MoveElementUp, pNewWidget); pSubGroup->GetHeader()->layout()->addWidget(pUpButton); // connect(pUpButton, &QToolButton::clicked, this, &ezQtPropertyContainerWidget::OnElementButtonClicked); // ezQtElementGroupButton* pDownButton = new ezQtElementGroupButton(pSubGroup->GetHeader(), // ezQtElementGroupButton::ElementAction::MoveElementDown, pNewWidget); pSubGroup->GetHeader()->layout()->addWidget(pDownButton); // connect(pDownButton, &QToolButton::clicked, this, &ezQtPropertyContainerWidget::OnElementButtonClicked); pSubGroup->SetDraggable(true); connect(pSubGroup, &ezQtGroupBoxBase::DragStarted, this, &ezQtPropertyContainerWidget::OnDragStarted); } if (!pAttr || pAttr->CanDelete()) { ezQtElementGroupButton* pDeleteButton = new ezQtElementGroupButton(pSubGroup->GetHeader(), ezQtElementGroupButton::ElementAction::DeleteElement, pNewWidget); pSubGroup->GetHeader()->layout()->addWidget(pDeleteButton); connect(pDeleteButton, &QToolButton::clicked, this, &ezQtPropertyContainerWidget::OnElementButtonClicked); } } m_Elements.Insert(Element(pSubGroup, pNewWidget), index); return m_Elements[index]; }
void Swipe(){ struct Brick b; b=Brick; b.type = Next.type; if(CanMove(b)){ DisplayBrick( Brick,FALSE); DisplayNext(FALSE); Next.type=Brick.type; Brick.type=b.type; Expect(); DisplayBrick(Brick,TRUE); DisplayNext(TRUE); } }
END_CLASS_STATES /* ================ rvMonsterRepairBot::State_Legs_Move ================ */ stateResult_t rvMonsterRepairBot::State_Legs_Move ( const stateParms_t& parms ) { enum { STAGE_START, STAGE_START_WAIT, STAGE_MOVE, STAGE_MOVE_WAIT, STAGE_STOP, STAGE_STOP_WAIT }; switch ( parms.stage ) { case STAGE_START: PlayAnim ( ANIMCHANNEL_LEGS, "idle_to_run", 4 ); return SRESULT_STAGE ( STAGE_START_WAIT ); case STAGE_START_WAIT: if ( AnimDone ( ANIMCHANNEL_LEGS, 4 ) ) { return SRESULT_STAGE ( STAGE_MOVE ); } return SRESULT_WAIT; case STAGE_MOVE: PlayCycle ( ANIMCHANNEL_LEGS, "run", 4 ); return SRESULT_STAGE ( STAGE_MOVE_WAIT ); case STAGE_MOVE_WAIT: if ( !move.fl.moving || !CanMove() ) { return SRESULT_STAGE ( STAGE_STOP ); } return SRESULT_WAIT; case STAGE_STOP: PlayAnim ( ANIMCHANNEL_LEGS, "run_to_idle", 4 ); return SRESULT_STAGE ( STAGE_STOP_WAIT ); case STAGE_STOP_WAIT: if ( AnimDone ( ANIMCHANNEL_LEGS, 4 ) ) { PostAnimState ( ANIMCHANNEL_LEGS, "Legs_Idle", 4 ); return SRESULT_DONE; } return SRESULT_WAIT; } return SRESULT_ERROR; }
void CWizFolder::MoveToLocation(const CString& strDestLocation) { Q_ASSERT(strDestLocation.right(1) == "/"); Q_ASSERT(strDestLocation.left(1) == "/"); if (!CanMove(Location(), strDestLocation)) return; CString strOldLocation = Location(); //CString strNewLocation; // //CString strLocationName = CWizDatabase::GetLocationName(strOldLocation); // //if (strDestLocation.IsEmpty()) { // strNewLocation = "/" + strLocationName + "/"; //} else { // strNewLocation = strDestLocation + strLocationName + "/"; //} CWizDocumentDataArray arrayDocument; if (!m_db.GetDocumentsByLocationIncludeSubFolders(strOldLocation, arrayDocument)) { TOLOG1(_T("Failed to get documents by location (include sub folders): %1"), strOldLocation); return; } CWizDocumentDataArray::const_iterator it; for (it = arrayDocument.begin(); it != arrayDocument.end(); it++) { WIZDOCUMENTDATA data = *it; Q_ASSERT(data.strLocation.startsWith(strOldLocation)); if (!data.strLocation.startsWith(strOldLocation)) { TOLOG(_T("Error location of document!")); continue; } data.strLocation.Delete(0, strOldLocation.GetLength()); data.strLocation.Insert(0, strDestLocation); if (!m_db.ModifyDocumentInfo(data)) { TOLOG(_T("Failed to move document to new folder!")); continue; } } m_db.LogDeletedFolder(strOldLocation); }
void CPolygon::FixPolygon(CPoint &point) { int i; if(CanMove(point, m_polygon, *countvertex) ) { MessageBox("The polygon would reach over the map boundaries","Area editor",MB_ICONWARNING|MB_OK); } for(i=0;i<(*countvertex);i++) { m_polygon[i].x=(unsigned short) (m_polygon[i].x+point.x); m_polygon[i].y=(unsigned short) (m_polygon[i].y+point.y); } RecalcBox((int) (*countvertex),m_polynum,(POINTS &) (bbox[BBMINX]),(POINTS &) (bbox[BBMAXX]) ); }
bool Heroes::ActionSpellCast(const Spell & spell) { std::string error; if(! CanMove()) { Dialog::Message("", _("Your hero is too tired to cast this spell today. Try again tomorrow."), Font::BIG, Dialog::OK); return false; } else if(spell == Spell::NONE || spell.isCombat() || ! CanCastSpell(spell, &error)) { if(error.size()) Dialog::Message("Error", error, Font::BIG, Dialog::OK); return false; } bool apply = false; switch(spell()) { case Spell::VIEWMINES: apply = ActionSpellViewMines(*this); break; case Spell::VIEWRESOURCES: apply = ActionSpellViewResources(*this); break; case Spell::VIEWARTIFACTS: apply = ActionSpellViewArtifacts(*this); break; case Spell::VIEWTOWNS: apply = ActionSpellViewTowns(*this); break; case Spell::VIEWHEROES: apply = ActionSpellViewHeroes(*this); break; case Spell::VIEWALL: apply = ActionSpellViewAll(*this); break; case Spell::IDENTIFYHERO: apply = ActionSpellIdentifyHero(*this); break; case Spell::SUMMONBOAT: apply = ActionSpellSummonBoat(*this); break; case Spell::DIMENSIONDOOR: apply = ActionSpellDimensionDoor(*this); break; case Spell::TOWNGATE: apply = isShipMaster() ? false : ActionSpellTownGate(*this); break; case Spell::TOWNPORTAL: apply = isShipMaster() ? false : ActionSpellTownPortal(*this); break; case Spell::VISIONS: apply = ActionSpellVisions(*this); break; case Spell::HAUNT: apply = ActionSpellSetGuardian(*this, spell, Monster::GHOST); break; case Spell::SETEGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::EARTH_ELEMENT); break; case Spell::SETAGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::AIR_ELEMENT); break; case Spell::SETFGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::FIRE_ELEMENT); break; case Spell::SETWGUARDIAN: apply = ActionSpellSetGuardian(*this, spell, Monster::WATER_ELEMENT); break; default: break; } if(apply) { DEBUG(DBG_GAME, DBG_INFO, GetName() << " cast spell: " << spell.GetName()); SpellCasted(spell); return true; } return false; }
void CWizFolder::MoveTo(QObject* dest) { CWizFolder* pFolder = dynamic_cast<CWizFolder*>(dest); if (!pFolder) return; if (IsDeletedItems()) return; if (!CanMove(this, pFolder)) { TOLOG2("Can move %1 to %2", Location(), pFolder->Location()); return; } return MoveToLocation(pFolder->Location()); }
void UpdateGhost(Unit &ghost) { ChoosePath(ghost); TryChase(ghost, Pacman); if(CanMove(ghost) == true) { if(MoveForward(ghost, Speed * 0.5f)) { ghost.Rotating = false; } } else { ghost.Face = (Direction) (rand() % 4); } }
bool CPlayerInput::OnActionMoveBack(EntityId entityId, const ActionId& actionId, int activationMode, float value) { if (CanMove()) { if(activationMode == 2) { if(!(m_moveButtonState&eMBM_Forward)) { // for camera m_moveStickUD = 0; m_deltaMovement.y = 0; if (!(m_moveButtonState&eMBM_Left) && !(m_moveButtonState&eMBM_Right)) m_actions &= ~ACTION_MOVE; } } else m_actions |= ACTION_MOVE; if(CheckMoveButtonStateChanged(eMBM_Back, activationMode)) { if(activationMode != 2) { ApplyMovement(Vec3(0,-(value*2.0f - 1.0f),0)); // for camera m_moveStickUD = -(value * 2.0f - 1.0f); m_deltaMovement.y = -value; } if(m_pPlayer->GetActorStats()->inZeroG) { if(activationMode == 2) m_actions &= ~ACTION_ZEROGBACK; else m_actions |= ACTION_ZEROGBACK; } m_checkZoom = true; AdjustMoveButtonState(eMBM_Back, activationMode); } } return false; }
void ChoosePath(Unit &ghost) { int choices = CanMoveTo(ghost, Right) + CanMoveTo(ghost, Left) + CanMoveTo(ghost, Up) + CanMoveTo(ghost, Down); if(ghost.Rotating == false && choices >= 3) { Direction backwards = Invert(ghost.Face); do { ghost.Face = (Direction) (rand() % 4); } while(CanMove(ghost) == false || ghost.Face == backwards); ghost.Rotating = true; } }
void PlayerMovement::Update(float dtime) { m_verticalVelocity += Physics::GetGravity() * dtime; Vector2f deltaMove = Vector2f(0.f, 0.f); auto character = m_object->GetComponent<CharacterComponent>()->GetCharacter(); if (character->CanMove()) { float moveSpeed = character->GetModifiedMoveSpeed(); if (g_input->IsPressed(g_optionsManager->GetKeyForAction(OptionsManager::MOVE_LEFT, m_controlsSet))) { if (character->ControlsInverted()) goto invertRight; invertedLeft: deltaMove += Vector2f(-moveSpeed * dtime, 0.f); if (m_direction.x == 1) { m_direction = Vector2f(-1, 0); SwitchSide(); } } else if (g_input->IsPressed(g_optionsManager->GetKeyForAction(OptionsManager::MOVE_RIGHT, m_controlsSet))) { if (character->ControlsInverted()) goto invertedLeft; invertRight: deltaMove += Vector2f(moveSpeed * dtime, 0.f); if (m_direction.x == -1) { m_direction = Vector2f(1, 0); SwitchSide(); } } if (g_input->IsPressed(g_optionsManager->GetKeyForAction(OptionsManager::JUMP, m_controlsSet)) && m_onGround) { m_verticalVelocity = m_jumpPower; SetOnGround(false); } } m_object->SetPos(m_object->GetPos() + deltaMove + Vector2f(0.f, m_verticalVelocity)); }