//! called during the initialization of the entity void Boss2::Init() { m_pFSM = snew Boss2FSM(this); super::Init(); m_LeftHook = DYNAMIC_CAST(GetChildByName("LeftHook"), Actor); m_RightHook = DYNAMIC_CAST(GetChildByName("RightHook"), Actor); }
//! called during the initialization of the entity void HQ::Init() { super::Init(); m_HealthBG = DYNAMIC_CAST(GetChildByName("HealthBG"), Entity3D); m_HealthBar = DYNAMIC_CAST(GetChildByName("HealthBar"), ProgressBar); m_fHitPoints = m_fMaxHitPoints; if(Entity* pMesh = GetChildByName("HQMesh")) m_Collision = pMesh->GetComponent<RigidBodyComponent>(); }
//! called during the initialization of the entity void VKButton::Init() { super::Init(); if(Text* pLetter = static_cast<Text*>(GetChildByName("Letter"))) { pLetter->SetText(m_Letter.c_str()); } }
//! called during the initialization of the entity void TightPassage::Init() { super::Init(); EventManager::Instance()->RegisterListener<TriggerEvent>(this, &HandleTriggerEvent); m_aCannons.clear(); for(u32 i=0; i<m_sNumCannons; ++i) { m_aCannons.push_back(static_cast<Entity3D*>(GetChildByName(std::string("Cannon") + Utils::ToString(i+1)))); } }
//! called during the initialization of the entity void Button::Init() { super::Init(); m_Icon = static_cast<Sprite*>(GetChildByName("Icon")); // Init bounding box if(!m_bCustomBBox) { if(Entity2D* pBG = static_cast<Entity2D*>(GetChildByName("BG"))) { m_BoundingBox = pBG->GetBoundingBox(); } else if(m_Icon.IsValid()) { m_BoundingBox = m_Icon->GetBoundingBox(); } } m_vOriginalPosition = m_vPosition; }
//! called during the initialization of the entity void BasicFighter::Init() { super::Init(); EventManager::Instance()->RegisterListener<TriggerEvent>(this, &HandleTriggerEvent); m_ShootingPoint = static_cast<Entity3D*>(GetChildByName("ShootingPoint")); m_LeftCannon = static_cast<Entity3D*>(GetChildByName("LeftCannon")); m_RightCannon = static_cast<Entity3D*>(GetChildByName("RightCannon")); s32 path = (m_ForcePath < 0) ? Random::GetInt(0, 1) : m_ForcePath; if(Path* pPath = static_cast<Path*>(GetChildByName(path ? "Path" : "Path2"))) { if(Player* pPlayer = Player::Instance()) { if(m_ForcePath < 0) { Vector3 vPosition = pPlayer->GetPosition() + GetSpawningPoint(); SetAbsolutePosition(vPosition); } if(BasicFighterSettings* pSettings = static_cast<BasicFighterSettings*>(m_Settings.Get())) { // orient path towards player Vector3 vToPlayer = (pPlayer->GetMeshEntity()->GetTransformationMatrix().GetTranslation()-pPath->GetTransformationMatrix().GetTranslation()).Normalize(); m_vDirection = Math::Lerp(Vector3::Create(0.0f, -1.0f, 0.0f), vToPlayer, pSettings->m_fHomingFactor); f32 fAngle = Math::ATan2(-m_vDirection.X, -m_vDirection.Y)*Math::RadToDegFactor; pPath->SetRotation(Vector3::Create(0.0f, 0.0f, fAngle)); } if(SequenceVisitor* pSequence = m_Mesh->GetComponent<SequenceVisitor>()) { FollowPathVisitor* pFollow = static_cast<FollowPathVisitor*>(pSequence->GetVisitor(0)); pFollow->SetPath(pPath); pFollow->Visit(m_Mesh); } } } }
//! called during the initialization of the entity void SFXManager::Init() { super::Init(); m_Root = GetRoot(); m_PlayerPulseManager = static_cast<PulseManager*>(GetChildByName("PlayerPulseManager")); m_PlayerLaserManager = static_cast<LaserManager*>(GetChildByName("PlayerLaserManager")); m_PlayerPelletManager = static_cast<PelletManager*>(GetChildByName("PlayerPelletManager")); m_PlayerSidePulseManager = static_cast<PulseManager*>(GetChildByName("PlayerSidePulseManager")); m_PlayerSideLaserManager = static_cast<LaserManager*>(GetChildByName("PlayerSideLaserManager")); m_PlayerSidePelletManager = static_cast<PelletManager*>(GetChildByName("PlayerSidePelletManager")); m_EnemyPulseManager = static_cast<PulseManager*>(GetChildByName("EnemyPulseManager")); m_BossPulseManager = static_cast<PulseManager*>(GetChildByName("BossPulseManager")); m_EnemyLaserManager = static_cast<LaserManager*>(GetChildByName("EnemyLaserManager")); m_EnemyPelletManager = static_cast<PelletManager*>(GetChildByName("EnemyPelletManager")); if(Entity* pSkyBox = m_Root->GetChildByType("SkyBoxEntity")) { m_SkyBoxMaterial = pSkyBox->GetComponent<GraphicComponent>()->GetMaterial(); } }
//! called during the initialization of the entity void BlackHole::Init() { super::Init(); if(Entity* pHoles = GetChildByName("Holes")) { for (auto &hole : pHoles->GetChildren()) { HoleInfo info = { Handle<Entity3D>(static_cast<Entity3D*>(hole.Get())), Random::GetFloat(0.0f, 360.0f) }; m_aHoles.push_back(info); info.m_Hole->SetUseRotationMatrix(true); } } }
wxTreeItemId DirectoryTree::GetItemFromPath(const wxString& sPath, bool bReturnBestFit) { wxString sRemainingPath = sPath; wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s')"), sPath.c_str()); // Ensure path finishes in '/' wxString sSeparator = wxFileName::GetPathSeparator(); wxChar chSeparator = sSeparator.GetChar(0); if(sRemainingPath.Right(1) != sSeparator) sRemainingPath += sSeparator; // Start from root path wxTreeItemId tid = GetRootItem(sPath); if(!tid.IsOk()) { wxLogDebug(wxT("GetItemFromPath(): invalid wxTreeItemId root %u"), (int) tid); return wxTreeItemId(); } sRemainingPath = sRemainingPath.AfterFirst(chSeparator); while(sRemainingPath != wxT("")) { wxString sDir = sRemainingPath.BeforeFirst(chSeparator); //wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tGetChildByName('%s')"), sDir.c_str()); wxTreeItemId tidChild = GetChildByName(tid, sDir); if(!tidChild.IsOk()) { wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s'): Failed to find directory '%s'"), sPath.c_str(), sDir.c_str()); if(bReturnBestFit) { // Allow selection of 'best fit' path return tid; } else { wxTreeItemId tidBad; return tidBad; } } sRemainingPath = sRemainingPath.AfterFirst(chSeparator); tid = tidChild; wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tFound child '%s'"), GetItemText(tid).c_str()); } return tid; }
wxTreeItemId DirectoryTree::PopulatePath(const wxString& sPath) { wxString sSeparator = wxFileName::GetPathSeparator(); wxChar chSeparator = sSeparator.GetChar(0); // Ensure path finishes in path separator wxString sTerminatedPath = sPath; if(sTerminatedPath.Right(1) != sSeparator) sTerminatedPath += sSeparator; // Start from root path wxTreeItemId tid = GetRootItem(sPath); if(!tid.IsOk()) { wxLogDebug(wxT("DirectoryTree::PopulatePath(): GetRootItem(sPath) failed;"), (int) tid); return wxTreeItemId(); } sTerminatedPath = sTerminatedPath.AfterFirst(chSeparator); while(sTerminatedPath != wxT("")) { // Ensure all children exist AddChildren(tid); // Select the sub-directory wxString sDir = sTerminatedPath.BeforeFirst(chSeparator); wxLogTrace(DIRECTORYTREE_EVENTS, wxT("CreatePath(): Directory '%s'"), sDir.c_str()); wxTreeItemId tidChild = GetChildByName(tid, sDir); // Fail if we can't find the sub-directory if(!tidChild.IsOk()) { wxLogTrace(DIRECTORYTREE_EVENTS, wxT("CreatePath(): GetChildByName(%u, '%s') failed"), (int) tid, sDir.c_str()); break; } sTerminatedPath = sTerminatedPath.AfterFirst(chSeparator); tid = tidChild; } // Return the item return tid; }
//! called when the HQ has taken damage bool HQ::OnDamage(float fDamage) { if (m_fExplosionTimer > 0.0f) return true; m_fHitPoints -= fDamage; m_HealthBG->SetVisible(true); m_HealthBar->SetProgress(m_fHitPoints / m_fMaxHitPoints); if(m_fHitPoints < 0.0f) { auto explosionVisitor = static_cast<ExplosionVisitor*>(m_ExplosionVisitor->Copy()); auto explosionEntity = static_cast<Entity3D*>(m_ExplosionEntity->Copy()); explosionEntity->SetScale(Vector3::One * 2.0f); // add explosion visitor explosionVisitor->SetDefaultIntensity(m_fExplosionIntensity); explosionVisitor->SetDefaultDuration(m_fExplosionDuration); auto mesh = static_cast<Entity3D*>(GetChildByName("HQMesh")); mesh->AddComponent(explosionVisitor); // add explosion entity AddChild(explosionEntity); explosionEntity->SetPosition(mesh->GetPosition()); AUDIOMGR->Play(AudioManager::S_ExplosionNuclear); m_fExplosionTimer = m_fExplosionDuration; m_HealthBG->SetVisible(false); GAMECAM->Shake(.5f, .02f, m_fExplosionDuration / 2.0f); return true; } return false; }
const String JsonReader::GetChildStringByName( const char * childName, const String & defaultValue ) const { const JSON * c = GetChildByName( childName ); return String( ( c != NULL ) ? c->GetStringValue() : defaultValue ); }
double JsonReader::GetChildDoubleByName( const char * childName, const double defaultValue ) const { const JSON * c = GetChildByName( childName ); return ( c != NULL ) ? c->GetDoubleValue() : defaultValue; }
float JsonReader::GetChildFloatByName( const char * childName, const float defaultValue ) const { const JSON * c = GetChildByName( childName ); return ( c != NULL ) ? c->GetFloatValue() : defaultValue; }
SInt64 JsonReader::GetChildInt64ByName( const char * childName, const SInt64 defaultValue ) const { const JSON * c = GetChildByName( childName ); return ( c != NULL ) ? c->GetInt64Value() : defaultValue; }
bool JsonReader::GetChildBoolByName( const char * childName, const bool defaultValue ) const { const JSON * c = GetChildByName( childName ); return ( c != NULL ) ? c->GetBoolValue() : defaultValue; }