Player::Player (Game *game) : _name( "Nameless hero" ), _level( START_LEVEL ), _exp(0), _initiative(0), _selectedItem( nullptr ), _target( nullptr ), _game( game ) { _powerups[static_cast<uint8_t>(Powerups::HEALTH)] = 0; _powerups[static_cast<uint8_t>(Powerups::MANA)] = 0; _powerups[static_cast<uint8_t>(Powerups::DAMAGE)] = 0; for (uint8_t i = 0; i < 4; ++i) _inventory[i] = nullptr; Field *field = nullptr; while (true) { field = _game->GetBattlefield()->GetRandomField(); if (field->HaveEnemy() || field->HaveItem() || field->HavePowerup() ) continue; break; } _position = field; CalculateStats(); Heal(); Recover(); LookAround(); }
//----------------------------------------------------------------------------- void C_CHostage::UpdateClientSideAnimation() { if (IsDormant()) { return; } m_PlayerAnimState->Update( GetAbsAngles()[YAW], GetAbsAngles()[PITCH] ); // initialize pose parameters char *setToZero[] = { "spine_yaw", "head_roll" }; CStudioHdr *pStudioHdr = GetModelPtr(); for ( int i=0; i < ARRAYSIZE( setToZero ); i++ ) { int index = LookupPoseParameter( pStudioHdr, setToZero[i] ); if ( index >= 0 ) SetPoseParameter( pStudioHdr, index, 0 ); } // orient head and eyes LookAround(); UpdateLookAt( pStudioHdr ); BaseClass::UpdateClientSideAnimation(); }
void CameraComponent::Update(double dt) { auto infoC = this->getParent()->getComponent<InformationComponent>(); switch (m_Camera->getCameraMode()) { case Camera::CM_THIRD_PERSON_FIXED_OFFSET: if (infoC) { LookAround(dt); Vector3 newCamPos = infoC->getPosition() - infoC->getDirection().Normalized() * 30.f; newCamPos.y = infoC->getPosition().y + 40.f; m_Camera->setCameraPos(newCamPos); Vector3 newCamTarget = infoC->getPosition() + infoC->getDirection().Normalized() * 40.f; m_Camera->setCameraTarget(newCamTarget); } break; case Camera::CM_THIRD_PERSON_FOLLOW_ENTITY: if (infoC) { Vector3 newCamPos = infoC->getPosition() + m_v3CamOffset; m_Camera->setCameraPos(newCamPos); Vector3 newCamTarget = infoC->getPosition(); m_Camera->setCameraTarget(newCamTarget); } break; } }
void Bot::Think() { // Call superclass method first Ai::Think(); if (IsGhosting()) return; LookAround(); }
void Player::Act(Directions input_dir) { Field *currentField = _position; Field *nextField = currentField; Field *targetField = GetTargetField(); Battlefield *btl = _game->GetBattlefield(); nextField = btl->GetNextField(currentField, input_dir); if (nextField != nullptr) //if we're moving somewhere { if (nextField == targetField) //where our target is { btl->Fight(this, targetField->GetEnemy(), true); //Kill'em! if ( HaveTarget() ) btl->CalculateNextFight(); //if enemy still alive } else //if target was somewhere else { SetTargetField(nullptr); //forget about it if (nextField->HaveEnemy()) { SetTargetField(nextField); // select new target if any btl->CalculateNextFight(); } else if (nextField->HavePowerup()) { _game->GetDisplay()->SendEvent( TakePowerup(nextField) ); } else { _position = nextField; //if there's no enemy - move there and look around LookAround(); } } } }
ReSyntaxExprNode* ReSyntaxTreeBuilder::Factor() { ReSyntaxExprNode* res; if (tokenizer.Match(__R('('))) { if ((tokenizer.Match(__R('<'), 1) || tokenizer.Match(__R('?'), 1)) && (tokenizer.Match(__R('='), 2) || tokenizer.Match(__R('!'), 2)) ) { res = LookAround(); } else if (tokenizer.Match(__R('<'), 1) && (tokenizer.IsPosDigital(2) || tokenizer.Match(__R('$'), 2))) { res = BackTracedGroup(); Quantifier(res); } else if (tokenizer.Match(__R('<'), 1) && (tokenizer.IsPosDigital(2) || tokenizer.Match(__R('#'), 2))) { res = BackReference(); Quantifier(res); } else //只能通过左括号判断捕获列表 { res = CapturedGroup(); Quantifier(res); } } else if (tokenizer.Match(__R('['))) { if (tokenizer.Match(__R('^'), 1)) { res = NoSelection(); Quantifier(res); } else { res = Selection(); Quantifier(res); } } else if (tokenizer.Finish()) { return nullptr; } else if (!tokenizer.IsPosSpecial()) { ReCharExprNode* tmp = nullptr; Char(tmp); res = tmp; Quantifier(res); } else { return nullptr; } return res; }
/**************************** Update ****************************/ void FPS_Cam::Update(double dt) //constant update { /* Mouse */ LookAround(CU::input.getPitch(), CU::input.getYaw(), dt); }