void FPGAImage::Execute() { std::string input; console_.SystemPrompt("[IMAGE] "); console_.UserPrompt("[IMAGE] "); if(Interact()) { console_.Write("Enter the new FPGA image\n",CC::SYSTEM); console_.UserPrompt(); std::getline(std::cin, input); boost::erase_all(input, " "); } else input = argList_[0]; fileName_ = IMAGE_PATH + input + IMAGE_EXT; std::ifstream in(fileName_.c_str(), std::ios::in); if(!in) { console_.Write(input + " does not exist\n",CC::SYSTEM); } else { mutex_.Lock(); if(okFrontPanel_.ConfigureFPGA(fileName_) < 0) console_.Write("failed to load" + fileName_ + "\n" ,CC::SYSTEM); else console_.Write("Loaded" + fileName_ + "\n",CC::SYSTEM); mutex_.Unlock(); } }
virtual void Execute(){ bool valid = false; string input; console_.SystemPrompt("[CONFIG] "); console_.UserPrompt("[CONFIG] "); if(Interact()) { console_.Write("Enter the new FPGA image\n",CC::SYSTEM); console_.UserPrompt(); getline(cin, input); erase_all(input, " "); } else input = argList_[0]; fileName_ = IMAGE_PATH + input + IMAGE_EXT; ifstream in(fileName_.c_str(), std::ios::in); if(!in) console_.Write(input + " does not exist\n",CC::SYSTEM); else{ valid = true; mutex_.Lock(); if(okFrontPanel_.ConfigureFPGA(fileName_) < 0) console_.Write("failed to load" + fileName_ + "\n" ,CC::SYSTEM); else console_.Write("Loaded" + fileName_ + "\n",CC::SYSTEM); mutex_.Unlock(); } }
//advanced move function, receives input from input controller and delegates out to a more basic move function //as well as delegating to other player actions. void Player::move() { if (input->GetDown() && !input->GetUp()) { move(DOWN); SetDirection(DOWN); } if (input->GetUp() && !input->GetDown()) { move(UP); SetDirection(UP); } if (input->GetLeft() && !input->GetRight()) { move(LEFT); SetDirection(LEFT); } if (input->GetRight() && !input->GetLeft()) { move(RIGHT); SetDirection(RIGHT); } if (input->GetInteract()) { Interact(); } if (input->GetBusk()) { Busk(); } if (input->GetPanhandle()) { Panhandle(); } }
void Player::update(double dt, World* currentWorld, int currentRoom, ModelHandler * theModel) { m_movementTimer += dt; m_immunityTimer -= dt; //std::cout << m_playerPos << std::endl; if(m_currFear >= 100) { theModel->getPlayer()->setIsHiding(true); theModel->currentWorld = WORLD_MAINMENU; theModel->getCurrLevel() = 0; isDead = true; } else if(m_currFear > 50) { m_movementDelay = 0.09; } else { m_movementDelay = 0.07; // fer weng jew } getPassiveEffect(this->m_playerInventory.getItem(2)); //Slot 2 = Equipment if (!hiding) { move(dt, theModel, currentWorld->collisionData); } Interact(dt, currentWorld, currentWorld->collisionData,theModel); m_fearCooldown -= dt; if(m_fearCooldown <= 0.0) { m_fearCooldown = 0.0; m_currFear -= (float)(dt) * 1.5f; } m_currFear = Math::Clamp(m_currFear,2.f,100.f); m_playerSanity = Math::RandFloatMinMax(1.f,1.5f); }
VOID CheckAntiTppk() { if(IsTownLevel(GetPlayerArea())) { v_AntiTppkBusy=false; return; } if(v_AntiTppkBusy) { for(Room1* pRoom = Myself->pAct->pRoom1; pRoom && v_AntiTppkBusy; pRoom = pRoom->pRoomNext) { for(UnitAny* pUnit = pRoom->pUnitFirst; pUnit && v_AntiTppkBusy; pUnit = pUnit->pListNext) { if(pUnit->dwType == UNIT_TYPE_OBJECT && pUnit->dwTxtFileNo == 59) { if(!stricmp(pUnit->pObjectData->szOwner, Myself->pPlayerData->szName)) { if(GetUnitDist(Myself, pUnit) < 12) { for(INT i = 0; i < 20; i++) { if(!GameReady() || IsTownLevel(GetPlayerArea()) || Myself->dwMode==PLAYER_MODE_DEATH || Myself->dwMode==PLAYER_MODE_DEAD || !TakeNextTP) { v_AntiTppkBusy = false; break; } Interact(pUnit->dwUnitId, UNIT_TYPE_OBJECT, TRUE); Sleep(50); } } } } } } } }
void ControllerComponent::Update(double dt, GridMap * currMap) { m_dInputDelay += dt; m_dMoveDelay += dt; EntityTest * thePlayer = dynamic_cast<EntityTest*>(this->getParent()); auto infoC = this->getParent()->getComponent<InformationComponent>(); if (infoC) { // CONTROL PLAYER if (!this->m_sMovement.m_bIsMoving) { if (m_dMoveDelay > MOVEMENT_DELAY) { if (m_cInputHandler->IsKeyPressed(GLFW_KEY_UP)) { MoveForward(currMap); } else if (m_cInputHandler->IsKeyPressed(GLFW_KEY_LEFT)) { MoveLeft(currMap); } else if (m_cInputHandler->IsKeyPressed(GLFW_KEY_DOWN)) { MoveBackwards(currMap); } else if (m_cInputHandler->IsKeyPressed(GLFW_KEY_RIGHT)) { MoveRight(currMap); } } if (m_dInputDelay > INTERACTION_DELAY) { if (m_cInputHandler->IsKeyPressed(GLFW_KEY_E)) { Interact(currMap); } } } else { float newX, newY; int absX, absY; Vector3 prevPosition = infoC->getPosition(); switch (this->m_sMovement.m_eMoveDirection) { case GridMap::DIRECTION_UP: // X does not Change newY = Math::SmoothDamp(infoC->getPosition().y, this->m_sMovement.m_v3NextPosition.y, 4096.f, 0.001f, 4096.f, dt); infoC->setPosition(Vector3(prevPosition.x, newY, 0.f)); absY = (int)newY; if (m_sMovement.m_v3NextPosition.y == absY) { m_sMovement.m_bIsMoving = false; currMap->getGridMap()[m_sMovement.m_iPlayerIndexY - 1][m_sMovement.m_iPlayerIndexX]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity()); currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity(); } break; case GridMap::DIRECTION_DOWN: // X does not Change newY = Math::SmoothDamp(infoC->getPosition().y, this->m_sMovement.m_v3NextPosition.y, 4096.f, 0.001f, 4096.f, dt); infoC->setPosition(Vector3(prevPosition.x, newY, 0.f)); absY = (int)newY; if (m_sMovement.m_v3NextPosition.y == absY) { m_sMovement.m_bIsMoving = false; currMap->getGridMap()[m_sMovement.m_iPlayerIndexY + 1][m_sMovement.m_iPlayerIndexX]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity()); currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity(); } break; case GridMap::DIRECTION_LEFT: // Y does not Change newX = Math::SmoothDamp(infoC->getPosition().x, this->m_sMovement.m_v3NextPosition.x, 4096.f, 0.001f, 4096.f, dt); infoC->setPosition(Vector3(newX, prevPosition.y, 0.f)); absX = (int)newX; if (m_sMovement.m_v3NextPosition.x == absX) { m_sMovement.m_bIsMoving = false; currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX - 1]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity()); currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity(); } break; case GridMap::DIRECTION_RIGHT: // Y does not Change newX = Math::SmoothDamp(infoC->getPosition().x, this->m_sMovement.m_v3NextPosition.x, 4096.f, 0.001f, 4096.f, dt); infoC->setPosition(Vector3(newX, prevPosition.y, 0.f)); absX = (int)newX; if (m_sMovement.m_v3NextPosition.x == absX) { m_sMovement.m_bIsMoving = false; currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX + 1]->addGridEntity(currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->getGridEntity()); currMap->getGridMap()[m_sMovement.m_iPlayerIndexY][m_sMovement.m_iPlayerIndexX]->removeEntity(); } break; } } } }