Class DayNightCycleComponent

java.lang.Object
com.deco2800.game.rendering.DayNightCycleComponent

public class DayNightCycleComponent extends Object
This class is responsible for shading the game screen when invoked in RendererService
  • Field Details

    • BLACK_IMAGE

      public static final com.badlogic.gdx.graphics.g2d.TextureRegion BLACK_IMAGE
    • NIGHT_INTENSITY

      public static final float NIGHT_INTENSITY
      See Also:
    • DUSK_INTENSITY

      public static final float DUSK_INTENSITY
      See Also:
    • DAWN_INTENSITY

      public static final float DAWN_INTENSITY
      See Also:
    • DAY_INTENSITY

      public static final float DAY_INTENSITY
      See Also:
    • bright

      public static final com.badlogic.gdx.math.Vector3 bright
    • dark

      public static final com.badlogic.gdx.math.Vector3 dark
  • Constructor Details

    • DayNightCycleComponent

      public DayNightCycleComponent()
      Creates a new DayNightCycleComponent. Making sure to compile shader files
  • Method Details

    • render

      public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Called to apply the shader Should be frequently called as ambientColor and intensity might changed.
      Parameters:
      batch - the sprite batch to apply the filter to
    • getCurrentCycleIntensityStep

      public float getCurrentCycleIntensityStep()
      Give steps values according to number of seconds in each part of day. Used for gradually fading to the next part of day
      Returns:
      the amount to step up by
    • getCurrentPartOfDayIntensity

      public float getCurrentPartOfDayIntensity()
      Gets the current part of day intensity
      Returns:
      the intensity for current part of day
    • getIntensityDifference

      public float getIntensityDifference(DayNightCycleStatus partOfDay)
      Computes the intensity between the part of day and next
      Parameters:
      partOfDay - the part of day to get next part of day difference from
      Returns:
      the intensity difference
    • onPartOfDayChange

      public void onPartOfDayChange(DayNightCycleStatus partOfDay)
      Invoked when the part of day has changed
      Parameters:
      partOfDay - the new part of day
    • setPartOfDay

      public void setPartOfDay(DayNightCycleStatus partOfDay)
    • fade

      public void fade()
      Gradually fades to the next part of the day. Night overrides its own light fading and replaces light shader with dark one
    • shouldFade

      public boolean shouldFade()
      Signals whether we need to fade to next part of day. It's based on the number of milliseconds set per fade step some parts of day fade faster and others slower. Add bounds so it doesn't get too bright or too dark
      Returns:
      true if fade is needed false otherwise
    • getAmbientColour

      public com.badlogic.gdx.math.Vector3 getAmbientColour()