Example #1
0
bool Buffer::fetch(CursorId cursor, char &c)
{
	return fetchCharacter(cursor, c, false);
}
Example #2
0
void SceneBase::UpdateCharacters(double dt)
{
	TRS = player.getProperties();
	TRS.rotation.SetToRotation(player.camera.rotationY, 0, 1, 0);
	player.setTRS(TRS);
	player.setPosition(player.camera.getPosition());
	player.updateHitbox();
	ResetTRS(TRS);

	if (player.m_iHealth <= 0)
	{
		player.m_iHealth = 0;
		gameOver = true;
	}

	// update more enemies if wave clear

	if (timer >= startTimer)
	{
		if(enemyCount == 0)
		{
			wave += 1;
			maxEnemy = wave * 3;

			for(unsigned i = enemyCount; i < maxEnemy; ++i)
			{
				float xCoord = Math::RandFloatMinMax(-TERRAIN_SCALE.x * 0.5f, TERRAIN_SCALE.x * 0.5f);
				float zCoord = Math::RandFloatMinMax(-TERRAIN_SCALE.z * 0.5f, TERRAIN_SCALE.z * 0.5f);
				Character* alien = fetchCharacter();
				alien->setMesh(meshList[GEO_ALIEN]);
				alien->setHitBox(threeDhitbox(Vector3(0, 0, 0), 13.8f, 27.8f, 19.f, "alien"));
				alien->setPosition(Vector3(xCoord, TERRAIN_SCALE.y * ReadHeightMap(m_heightMap, xCoord/TERRAIN_SCALE.x, zCoord/TERRAIN_SCALE.z) - 5.f, zCoord));
				alien->enemyTarget = &player;
				alien->m_iHealth = 10 * wave;
				alien->m_iID = 1;
				alien->camera.Init(alien->getPosition(), player.getPosition(), Vector3(0, 1, 0));

				++enemyCount;

				newAvatar.setAvatar(MeshBuilder::GenerateQuad("MinimapAvatar", Color(1, 1, 1), 1.f));
				newAvatar.setPosition(alien->getPosition().x / TERRAIN_SCALE.x * MINIMAP_SCALE, alien->getPosition().z / TERRAIN_SCALE.z * MINIMAP_SCALE);
				newAvatar.getAvatar()->textureID[0] = LoadTGA("Image//enemyAvatar.tga");
				m_Minimap->enemyList.push_back(newAvatar);
			}
		}

		for(std::vector<Character *>::iterator it = characterList.begin(); it != characterList.end(); ++it)
		{
			Character *go = (Character *)*it;
			if(go->getRender())
			{
				// chase after target
				TRS = go->getProperties();
				float theta = Math::RadianToDegree(atan2(go->camera.getView().x, go->camera.getView().z));
				TRS.rotation.SetToRotation(theta, 0, 1, 0);
				go->setTRS(TRS);
				if (go->camera.getTarget() != go->camera.getPosition())
				{
					go->camera.moveForward(dt, TERRAIN_SCALE.y * ReadHeightMap(m_heightMap, go->camera.getPosition().x/TERRAIN_SCALE.x, go->camera.getPosition().z/TERRAIN_SCALE.z) - 5.f);
				}
				go->camera.setTarget(player.getPosition());
				go->setPosition(go->camera.getPosition());

				go->updateHitbox();

				if(go->m_iHealth <= 0)
				{
					go->setRender(false);

					int dropBonus = Math::RandIntMinMax(1, 3);

					if (dropBonus == 3)
					{
						itemBonus = Math::RandIntMinMax(1, 3);

						// increase pistol ammo
						if (itemBonus == 1)
						{
							player.bagpack.pistol.setAmmo(player.bagpack.pistol.getAmmo() + 30);
						}

						// increase rifle ammo
						else if (itemBonus == 2)
						{
							player.bagpack.rifle.setAmmo(player.bagpack.rifle.getAmmo() + 30);
						}

						else if(player.m_iHealth < 100)
						{
							// increase health by 30 if health less than 70
							if (player.m_iHealth < 70)
							{
								player.m_iHealth += 10;
							}

							// recover health to full health
							else
							{
								player.m_iHealth = 100;
							}
						}

						UpdateSoundStatus('p');
					}

					else
					{
						itemBonus = 0;
					}

					//remove enemy from minimap
					int pos = it - characterList.begin();

					m_Minimap->enemyList[pos].setRender(false);

					--enemyCount;
				}
			}
		}
	}
}
Example #3
0
bool Buffer::read(Buffer::CursorId cursor, char &c)
{
	return fetchCharacter(cursor, c, true);
}