// Run if there is a collision with an object of a different group void ControlPlayer::OnCollision(PhysicsCollisionGroups otherGroup, std::weak_ptr<PhysicsEntity> otherEntity) { // Check if collision was with a enemy bullet if(otherGroup == PhysicsCollisionGroups::GroupD) { // Delete the bullet no matter what otherEntity._Get()->GetGameObject()._Get()->Destroy(); // Decrement player health _health--; // Add 1 point for being hit by enemy bullets auto scoreKeeperObj = GameObjectContainer::GetByName("ScoreKeeper"); auto scoreKeeper = scoreKeeperObj._Get()->GetCustomComponent<component::ScoreKeeper>(); scoreKeeper._Get()->AddScore(1); _deathSnd._Get()->Play(); } // Check if player is out of health if(_health < 1) { SceneRegistry::LoadScene<scene::GameOverScene>(); } }
bool GlobalSettings::GetAcceptChangesByDialogClosing() const { #if defined(Q_OS_ANDROID) return _Get(Key_AcceptChangesByDialogClosing, true).toBool(); #else return _Get(Key_AcceptChangesByDialogClosing, false).toBool(); #endif }
Qt::Orientation GlobalSettings::GetMenuOrientation() { #if defined(Q_OS_ANDROID) return (Qt::Orientation)_Get(Key_MenuOrientation, Qt::Vertical).toInt(); #else return (Qt::Orientation)_Get(Key_MenuOrientation, Qt::Horizontal).toInt(); #endif }
bool GlobalSettings::GetMainWindowMaximized() { #if defined(Q_OS_ANDROID) return _Get(Key_MainWindowMaximized, true).toBool(); #else return _Get(Key_MainWindowMaximized, false).toBool(); #endif }
// Loads without clearing current scene bool GameOverScene::LoadAdditive() { // Load the desired GameObjects here // Find persistant ScoreKeeper and make un-persistant auto scoreKeeper = GameObjectContainer::GetByName("ScoreKeeper"); if(!scoreKeeper.expired()) { scoreKeeper._Get()->SetPersistance(false); } // Make a cube GameObject auto cube = GameObjectContainer::Create(); cube._Get()->AddComponent<ObjectRendererComponent>(); auto renderer = cube._Get()->GetComponent<ObjectRendererComponent>(); renderer._Get()->GetRenderer()._Get()->SetMaterial( MaterialRegistry::GetByName("GameOver") ); // Adjust the camera in front of the cube auto theCamera = Camera::GetInstance(); theCamera._Get()->SetPosition(Vector3(0.0f, 0.0f, 1.0f)); theCamera._Get()->LookAtPoint(Vector3(0.0f, 0.0f, 0.0f)); // Add the functionality for the Game Over screen auto gameOverCtrlr = GameObjectContainer::Create(); gameOverCtrlr._Get()->AddCustomComponent<component::ManageGameOver>(); auto scoreEvaluator = GameObjectContainer::Create(); scoreEvaluator._Get()->AddCustomComponent<component::ScoreEvaluator>(); auto scoreFontRenderer = scoreEvaluator._Get()->GetComponent<FontRendererComponent>()._Get()->GetRenderer(); scoreFontRenderer._Get()->SetPosition(190, 487); return true; }
std::weak_ptr<GameObject> OctoPrefab::MakeObject() { // Create GameObject and name it std::weak_ptr<GameObject> go = GameObjectContainer::Create(); go._Get()->SetName("Octo"); // Setup other properties here go._Get()->AddComponent<sfew::ObjectRendererComponent>(); auto renderer = go._Get()->GetComponent<sfew::ObjectRendererComponent>(); renderer._Get()->GetRenderer()._Get()->SetMesh(sfew::MeshRegistry::GetByName("OctohedronMesh")); renderer._Get()->GetRenderer()._Get()->SetMaterial(sfew::MaterialRegistry::GetByName("OrangePatches")); // Return weak pointer return go; }
// Loads without clearing current scene bool DemoScene::LoadAdditive() { // Load the desired GameObjects here // Cube object auto cubePrefab = PrefabricationRegistry::Get<prefab::CubePrefab>(); auto cubeObject = cubePrefab._Get()->MakeObject(); // FPS Text display object auto fpsPrefab = PrefabricationRegistry::Get<prefab::FpsPrefab>(); auto fpsObject = fpsPrefab._Get()->MakeObject(); //fpsObject._Get()->SetPersistance(true); // Octohedron object auto octoPrefab = PrefabricationRegistry::Get<prefab::OctoPrefab>(); auto octoObject = octoPrefab._Get()->MakeObject(); octoObject._Get()->AddComponent<PhysicsComponent>(); auto phys = octoObject._Get()->GetComponent<PhysicsComponent>(); phys._Get()->GetPhysicsEntity()._Get()->SetRotationalAcceleration(Vector3(0.0f, 51.0f, 0.0f)); auto aSound = AudioRegistry::GetByName("PlayerLaserSnd"); aSound._Get()->Play(); return true; }
bool SQTable::Set(const SQObjectPtr &key, const SQObjectPtr &val) { _HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1)); if (n) { n->val = val; return true; } return false; }
bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val) { assert(sqi_type(key) != OT_NULL); GC_MUTATED(this); SQHash h = HashObj(key) & (_numofnodes - 1); _HashNode *n = _Get(key, h); if (n) { n->val = val; return false; } _HashNode *mp = &_nodes[h]; n = mp; //key not found I'll insert it //main pos is not free if(sqi_type(mp->key) != OT_NULL) { n = _firstfree; /* get a free place */ SQHash mph = HashObj(mp->key) & (_numofnodes - 1); _HashNode *othern; /* main position of colliding node */ if (mp > n && (othern = &_nodes[mph]) != mp){ /* yes; move colliding node into free position */ while (othern->next != mp){ assert(othern->next != NULL); othern = othern->next; /* find previous */ } othern->next = n; /* redo the chain with `n' in place of `mp' */ n->key = mp->key; n->val = mp->val;/* copy colliding node into free pos. (mp->next also goes) */ n->next = mp->next; mp->key = _null_; mp->val = _null_; mp->next = NULL; /* now `mp' is free */ } else{ /* new node will go into free position */ n->next = mp->next; /* chain new position */ mp->next = n; mp = n; } } mp->key = key; for (;;) { /* correct `firstfree' */ if (sqi_type(_firstfree->key) == OT_NULL && _firstfree->next == NULL) { mp->val = val; _usednodes++; return true; /* OK; table still has a free place */ } else if (_firstfree == _nodes) break; /* cannot decrement from here */ else (_firstfree)--; } Rehash(true); return NewSlot(key, val); }
void CryptTask::_PrepareJob(CryptJob* job) { size_t bytes = min_c(fJobBlocks * BLOCK_SIZE, fLength); job->SetTo(this, _Get(), fData, bytes, fBlockIndex); fData += bytes; fLength -= bytes; fBlockIndex += fJobBlocks; }
ItemAttributeMgr::real_t ItemAttributeMgr::GetReal(Attr attr) const { real_t v; if(!_Get(attr, v)) if(!m_item.type().attributes._Get(attr, v)) // try the type attributes v = GetDefault(attr); _CalcTauCap(attr, v); return v; }
void SQTable::Remove(const SQObjectPtr &key) { _HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1)); if (n) { n->val = n->key = _null_; _usednodes--; Rehash(false); } }
// Runs at contruction of component void ScoreEvaluator::Start() { // Add a font renderer GetGameObject()._Get()->AddComponent<FontRendererComponent>(); _fontRenderer = GetGameObject()._Get()->GetComponent<FontRendererComponent>()._Get()->GetRenderer(); // Get the ScoreKeeper auto scoreKeeperObj = GameObjectContainer::GetByName("ScoreKeeper"); auto scoreKeeper = scoreKeeperObj._Get()->GetCustomComponent<component::ScoreKeeper>(); int finalScore = scoreKeeper._Get()->GetScore(); int finalGems = scoreKeeper._Get()->GetGemsCollected(); int finalLevel = scoreKeeper._Get()->GetLevel(); // Write final results hudOut.str(std::string()); hudOut << "Score: " << finalScore << " Gems: " << finalGems << " Level: " << finalLevel; _fontRenderer._Get()->SetTextString(hudOut.str()); }
bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val) { if(sqi_type(key) == OT_NULL) return false; _HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1)); if (n) { _getrealval(n->val, NULL, val); return true; } return false; }
// Runs at contruction of component void FpsUpdaterCmpt::Start() { // Add a font render component and retrieve the font renderer GetGameObject()._Get()->AddComponent<FontRendererComponent>(); auto fontRendererComponent = GetGameObject()._Get()->GetComponent<FontRendererComponent>(); _fontRenderer = fontRendererComponent._Get()->GetRenderer(); // Setup font rendering properties _fontRenderer._Get()->SetFontSize(48); _fontRenderer._Get()->SetColor(0.0f, 0.5f, 0.7f, 1.0f); _fontRenderer._Get()->SetPosition(10, 10); }
// Runs at contruction of component void DrawHUD::Start() { // Get the player data retrievePlayer(); // Retrieve the score keeper auto scoreKeeperObj = GameObjectContainer::GetByName("ScoreKeeper"); _scoreKeeper = scoreKeeperObj._Get()->GetCustomComponent<component::ScoreKeeper>(); // Get the font renderer _fontRendering = GetGameObject()._Get()->GetComponent<FontRendererComponent>()._Get()->GetRenderer(); }
std::weak_ptr<GameObject> GridCubePrefab::MakeObject() { // Create GameObject and name it std::weak_ptr<GameObject> go = GameObjectContainer::Create(); go._Get()->SetName("GridCube"); // Setup other properties here // Add components go._Get()->AddComponent<ObjectRendererComponent>(); // Setup renderer auto renderer = go._Get()->GetComponent<ObjectRendererComponent>()._Get()->GetRenderer(); renderer._Get()->SetMesh(MeshRegistry::GetByName("CubeMesh")); renderer._Get()->SetMaterial(MaterialRegistry::GetByName("CubeGrid")); // Setup transform auto transform = go._Get()->GetTransform(); transform._Get()->SetPosition(Vector3(0.0f, 0.0f, 0.0f)); transform._Get()->SetScale(Vector3(0.02f, 0.02f, 0.02f)); // Return weak pointer return go; }
// ---------------------------------------------------- // Keys::Compare // ---------------------------------------------------- bool Keys::Compare(const Keys &KeyList) const { // もしサイズが違うなら if(_Size() != KeyList._Size()){ // false return false; } // ループを回す for(int i = 0; i < _Size(); i++){ // もし一致しない要素が存在するなら if(KeyList && _Get(i) == false){ // false return false; } } return true; }
QSize GlobalSettings::GetMainWindowSize() { return _Get(Key_MainWindowSize, QSize()).toSize(); }
QString GlobalSettings::GetUnitBrackets() const { return _Get(Key_UnitBrackets, "()").toString(); }
QString GlobalSettings::GetLanguage(QString const &defaut) const { return _Get(Key_GuiLanguage, defaut).toString(); //I'm sure there was stored language }
QString GlobalSettings::GetLastSerialPortId() const { return _Get(Key_LastSerialPortId, "").toString(); }
bool GlobalSettings::GetHideAllChannels() { return _Get(Key_HideAllChannels, false).toBool(); }
QString GlobalSettings::GetLastDir() { return _Get(Key_LastDir, "./").toString(); }
void GlobalSettings::_FillRecentFilePaths() { if (m_recentPaths.size() == 0) m_recentPaths = _Get(Key_RecentFilePaths, "").toString().split(RECENT_FILE_SEPARATOR, QString::SkipEmptyParts); }
int GlobalSettings::GetChannelSizeFactor() { return _Get(Key_ChannelSizeFactor, 100).toInt(); }
bool GlobalSettings::GetMenuIsShown() { return _Get(Key_MenuIsShown, true).toBool(); }
bool GlobalSettings::GetMenuOnDemand() { return _Get(Key_MenuOnDemand, false).toBool(); }
QVariant GlobalSettings::GetLastSerialPortType() const { return _Get(Key_LastSerialPortType, 0); }
QString GlobalSettings::GetLimitDir() const { return _Get(Key_LimitDir, "").toString(); }