Arrow::Arrow(Game & game) : Actor(game){ //Create a mesh component mMeshComponent = MeshComponent::Create(*this); auto & assetCache = game.GetAssetCache(); auto mesh = assetCache.Load<Mesh>("Meshes/Arrow.itpmesh2"); mMeshComponent->SetMesh(mesh); }
Asteroid::Asteroid(Game& game) : Actor(game) { auto meshComponent = MeshComponent::Create(*this); auto mesh = game.GetAssetCache().Load<Mesh>("Meshes/AsteroidMesh.itpmesh2"); auto texture = game.GetAssetCache().Load<Texture>("Textures/Asteroid.png"); meshComponent->SetMesh(mesh); SetRotation(Random::GetFloatRange(0.0f, Math::TwoPi)); auto move = MoveComponent::Create(*this, Component::PreTick); move -> SetLinearSpeed(150.0f); move -> SetLinearAxis(1.0f); auto col = SphereCollision::Create(*this); col->SetScale(0.9f); col->RadiusFromTexture(texture); }
Tower::Tower(Game & game) : Actor (game){ //Get Asset Cache auto& assetCache = game.GetAssetCache(); //Create a mesh component auto meshComponent = MeshComponent::Create(*this); auto mesh = assetCache.Load<Mesh>("Meshes/TowerBase.itpmesh2"); meshComponent->SetMesh(mesh); }
FrostTower::FrostTower(Game & game) : Tower(game){ //Get Asset Cache auto& assetCache = game.GetAssetCache(); //Create a mesh component auto meshComponent = MeshComponent::Create(*this); auto mesh = assetCache.Load<Mesh>("Meshes/Frost.itpmesh2"); meshComponent->SetMesh(mesh); //Set Frost timer TimerHandle handle; mGame.GetTime().SetTimer(handle, this, &FrostTower::FrostEnemies, 2.0f, true); }
Asteroid::Asteroid(Game& game) : Super(game) { auto mesh = MeshComponent::Create(*this); auto meshPtr = game.GetAssetCache().Load<Mesh>("Meshes/AsteroidMesh.itpmesh2"); mesh->SetMesh(meshPtr); auto movement = MoveComponent::Create(*this, Component::PreTick); movement->SetLinearSpeed(150.0f); movement->SetLinearAxis(1.0f); SetRotation(Random::GetRotation()); SetScale( 0.1f ); }
Laser::Laser(Game & game) :Actor(game) { //Create a sprite component auto sprite = SpriteComponent::Create(*this); auto assetCache = game.GetAssetCache(); auto texture = assetCache.Load<Texture>("Textures/Laser.png"); sprite->SetTexture(texture); //Set Movement auto move = MoveComponent::Create(*this, Component::PreTick); move->SetLinearSpeed(600.0f); move->SetLinearAxis(1.0f); //Set SphereCollision auto coll = SphereCollision::Create(*this); coll->RadiusFromTexture(texture); coll->SetScale(0.9f); }
CannonTower::CannonTower(Game & game) : Tower(game){ //Get Asset Cache auto& assetCache = game.GetAssetCache(); //Create the child mCannon = Actor::SpawnAttached(*this); //Create a mesh component auto meshComponent = MeshComponent::Create(*mCannon); auto mesh = assetCache.Load<Mesh>("Meshes/Cannon.itpmesh2"); meshComponent->SetMesh(mesh); //Set the fire timer TimerHandle handle; mGame.GetTime().SetTimer(handle, this, &CannonTower::Fire, 1.0f, true); //Set shotting sound mAudio = AudioComponent::Create(*this); mShottingSound = assetCache.Load<Sound>("Sounds/CannonFire.wav"); }
Enemy::Enemy(Game & game) : Actor(game){ //Create the mesh mMeshComponent = MeshComponent::Create(*this); auto& assetCache = game.GetAssetCache(); auto mesh = assetCache.Load<Mesh>("Meshes/Peasant.itpmesh2"); mMeshComponent->SetMesh(mesh); //Create a Move component mNavComponent = NavComponent::Create(*this, Component::PreTick); mNavComponent->SetLinearSpeed(60.0f); mNavComponent->SetLinearAxis(1.0f); //Create a Sphere collision mColl = SphereCollision::Create(*this); mColl->RadiusFromMesh(mesh); mColl->SetScale(0.2f); //Audio stuff mAudio = AudioComponent::Create(*this); mFreezeSound = assetCache.Load<Sound>("Sounds/Freeze.wav"); mDeathSound = assetCache.Load<Sound>("Sounds/WilhelmScream.wav"); }
CannonBall::CannonBall(Game & game) : Actor(game){ //Create the mesh mMeshComponent = MeshComponent::Create(*this); auto& assetCache = game.GetAssetCache(); auto mesh = assetCache.Load<Mesh>("Meshes/Cannonball.itpmesh2"); mMeshComponent->SetMesh(mesh); //Create a Move component mMoveComponent = MoveComponent::Create(*this, Component::PreTick); mMoveComponent->SetLinearSpeed(300.0f); mMoveComponent->SetLinearAxis(1.0f); //Create a Sphere collision mColl = SphereCollision::Create(*this); mColl->RadiusFromMesh(mesh); //mColl->SetScale(0.2f); //Set Frost timer TimerHandle handle; mGame.GetTime().SetTimer(handle, this, &CannonBall::deSpawn, 3.0f); }