Esempio n. 1
0
void Pet::Update(uint32 time)
{
	if(m_Owner == NULL)
		return;

	Creature::Update(time); // passthrough

	if(!bExpires)
	{
		// Happiness
		if(m_HappinessTimer == 0)
		{
			int32 val = GetHappiness();
			// amount of burned happiness is loyalty_lvl depended
			int32 burn = 1042;
			if( CombatStatus.IsInCombat() )
				burn = burn >> 1; // in combat reduce burn by half (guessed)
			if((val - burn)<0)
				val = 0;
			else
				val -= burn;
			SetHappiness(val); // Set the value
			m_HappinessTimer = PET_HAPPINESS_UPDATE_TIMER; // reset timer
		}
		else
		{
			if( time > m_HappinessTimer )
Esempio n. 2
0
void ImGuiImpl::UpdateGuiButtons(void)
{
#pragma region Model

    char fileNameBuffer[140] = { '\0' };
    std::strcat(fileNameBuffer, filename.c_str());
    if (ImGui::InputText("Model", fileNameBuffer, sizeof(fileNameBuffer)))
    {
      // text was changed; copy back over to C++ string
      filename = fileNameBuffer;
    }

    if (ImGui::Button("Load Model"))
    {
      if (filename != prevfilename)
      {
        Object* myObj = ObjectManager::CreateObject(glm::linearRand(glm::vec3(-5.0f, -5.0f, -6.0f), glm::vec3(5.0f, 5.0f, 6.0f)),
          glm::vec3(-2.0f, 0.0f, -3.0f),
          glm::linearRand(0.0f, 360.0f),
          glm::linearRand(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f)), filename.c_str());
        prevfilename = filename;
      }

      // TODO(student): implement loading models from a file; you can use the
      // string 'modelFile' which should store the updated file name from ImGui
    }


    //std::vector<char const *> shadertypeStrings = {
    //  "Fragment Phong", "Vertex Phong", "Frag Blinn" };
    //ImGui::Combo("Light Model", &ShaderType, shadertypeStrings.data(), 3);
#pragma endregion

#pragma region Camera
  ImGui::Separator();
  // model options
  {
    if (ImGui::CollapsingHeader("CameraPos"))
    {
      ImGui::PushID("Camera");

      ImGui::SliderFloat3("Camera Position", (float*)&pos, -10.0f, 10.0f);
      ImGui::SliderFloat3("Lookat Vector", (float*)&lookat, -2.0f, 2.0f);

      if (pos != prevpos)
      {
        glm::vec3 vect = pos - prevpos;
        g_GraphicsSys->GetCurrentCamera().position += vect;
        prevpos = pos;
      }

      if (lookat != prevlookat)
      {
        glm::vec3 vect = lookat - prevlookat;
        glm::normalize(vect);
        g_GraphicsSys->GetCurrentCamera().viewDirection += vect;
        glm::normalize(g_GraphicsSys->GetCurrentCamera().viewDirection);
        prevlookat = lookat;
      }

      ImGui::PopID();
    }
  }
#pragma endregion



  ImGui::Separator();
  {
    if (ImGui::Button("Particles"))
    {
      g_GraphicsSys->Particle_Draw();
    }
  }

  ImGui::Separator();
  {
    if (ImGui::CollapsingHeader("Note"))
    {
      ImGui::PushID("Notes");

      if (ImGui::Button("Play"))
      {
        Music_State = PLAY;
      }

      if (ImGui::Button("Stop"))
      {
        Music_State = STOP;
      }

      if (ImGui::Button("Pause"))
      {
        Music_State = PAUSE;
      }

      if (ImGui::Button("Reset Default"))
      {
        shoft_loud = 0.5f;
        major_minor = 0;
        staccato_legato = 0.5f;
        phrase_length = 12;
        voice_melody = 0;
        time_signature = 1;
        bpm = 80;
        happiness = 0.5f;
        peacefulness = 0.5f;
        heart = 0.5f;
        relax = 0.5f;
      }

      if (ImGui::CollapsingHeader("Constraints"))
      {
        ImGui::SliderFloat("Soft | Loud", GetSoftness(), 0, 1);
        ImGui::SliderInt("Major | Minor", GetMajor(), 0, 1);
        ImGui::SliderFloat("Staccato | Legato", GetStaccato(), 0, 1);
        ImGui::SliderInt("Phrase Length", GetPhraseLength(), 4, 16);

        std::vector<char const *> Voices = {
          "None", "Bass", "Tenor", "Alto", "Soprano" };
        ImGui::Combo("Voice Melody", GetVoiceMelody(), Voices.data(), 5);

        std::vector<char const *> Time = {
          "3/4", "4/4", "6/8" };
        ImGui::Combo("Time Signature", GetTimeSignature(), Time.data(), 3);

        ImGui::SliderInt("BPM", GetBPM(), 40, 208);
      }

      if (ImGui::CollapsingHeader("Emotion"))
      {
        ImGui::SliderFloat("Happy | Sad", GetHappiness(), 0, 1);
        ImGui::SliderFloat("Peaceful | Angry", GetPeacefulness(), 0, 1);
        ImGui::SliderFloat("Light-Hearted | Heavy", GetHeartness(), 0, 1);
        ImGui::SliderFloat("Relaxed | Frantic", GetRelax(), 0, 1);
      }
    }
  }

}