Vector PerlinGenerator::at( const Vector& pos ) { //return sky( pos.x,pos.y,pos.z, SKY_BLUE, CLOUD_WHITE ) ; Vector n = pos/worldNormalizer ; switch( noiseType ) { case PerlinNoiseType::Sky: return sky( n.x, n.y, n.z, SKY_BLUE, CLOUD_WHITE ) ; case PerlinNoiseType::Wood: return wood( n.x, n.y, n.z ) ; case PerlinNoiseType::Marble: default: return marble( n.x,n.y,n.z, n.x ) ; case PerlinNoiseType::CustomLinear: return linearSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ; case PerlinNoiseType::CustomQuadratic: return quadraticSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ; case PerlinNoiseType::CustomCubic: return cubicSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ; case PerlinNoiseType::CustomQuartic: return quarticSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ; case PerlinNoiseType::CustomQuintic: return quinticSpline( PerlinNoise3D( n.x,n.y,n.z, persistence, lacunarity, octaves ) ) ; } }
bool GatherState::canGather() { int canMine = 0; if (_amount > 0) { Item gold("gold", true); if (_target->getInventory().contains(gold)) { canMine++; } Item iron("iron", true); if (_target->getInventory().contains(iron)) { canMine++; } Item coal("coal", true); if (_target->getInventory().contains(coal)) { canMine++; } Item wood("wood", true); if (_target->getInventory().contains(wood)) { canMine++; } Item fish("fish", true); if (_target->getInventory().contains(fish)) { canMine++; } } return !!canMine; }
void GatherState::tick(float deltaTime) { string success; string start; if (canGather()) { if (_actor->getBAC() > .4) { cout << _actor->getName() << " drunkenly swings the tool, hits himself in the foot, and decides not to do that anymore." << "\n"; switchState("null"); } else { bool canPickup = true; string typeName = _target->getName(); Item* removedItem; if (typeName.find("gold") != string::npos) { Item gold("gold", _target->getColor(), true); removedItem = _target->getInventory().removeItem(gold); start = " lifts his pickaxe, and swings it at the rock."; success = " successfully mines some "; } else if (typeName.find("iron") != string::npos) { Item iron("iron", _target->getColor(), true); removedItem = _target->getInventory().removeItem(iron); start = " lifts his pickaxe, and swings it at the rock."; success = " successfully mines some "; } else if (typeName.find("coal") != string::npos) { Item coal("coal", _target->getColor(), true); removedItem = _target->getInventory().removeItem(coal); start = " lifts his pickaxe, and swings it at the rock."; success = " successfully mines some "; } else if (typeName.find("redwood") != string::npos || typeName.find("oak") != string::npos || typeName.find("birch") != string::npos || typeName.find("cedar") != string::npos) { Item wood("wood", _target->getColor(), true); removedItem = _target->getInventory().removeItem(wood); start = " takes out his hatchet, and swings it at the tree."; success = " successfully chops some "; } else if (typeName.find("dock") != string::npos) { Item fish("fish", _target->getColor(), true); removedItem = _target->getInventory().removeItem(fish); start = " pulls out his harpoon, and jabs it at the water."; success = " successfully catches some "; } _actor->reduceStamina(1); string coloredName = Color::colorText(removedItem->getName(), removedItem->getColor()); canPickup = _actor->getInventory().addItem(removedItem); cout << _actor->getName() << start << "\n"; cout << _actor->getName() << success << coloredName << "\n"; if (!canPickup) { delete removedItem; cout << _actor->getName() << " has a full inventory, and drops " << coloredName << " on the ground.\n"; _amount = 0; switchState("null"); } _amount--; } } else { _amount = 0; switchState("null"); } }