Class Controller

java.lang.Object
fr.formiko.kokcinelo.Controller

public class Controller extends Object
Controller is the link between View & model. Because of Seen2D Actor, there is some view item in the model.
Since:
0.1
Version:
2.5
  • Constructor Details

    • Controller

      public Controller(App app)
      Main constructor.
      Parameters:
      app - app to send action to
  • Method Details

    • getController

      public static Controller getController()
    • setController

      public static void setController(Controller controller)
    • getGameScreen

      public GameScreen getGameScreen()
    • getScreen

      public com.badlogic.gdx.Screen getScreen()
    • setScreen

      public void setScreen(com.badlogic.gdx.Screen screen)
    • getMenuScreen

      @Null public MenuScreen getMenuScreen()
    • getLocalPlayerId

      public int getLocalPlayerId()
    • isSpectatorMode

      public boolean isSpectatorMode()
    • setSpectatorMode

      public void setSpectatorMode(boolean spectatorMode)
    • getNumberOfAphids

      public int getNumberOfAphids()
    • getLevel

      public Level getLevel()
    • getLevelId

      public String getLevelId()
    • getPlayerCreature

      @Null public Creature getPlayerCreature()
    • getLocalPlayer

      public Player getLocalPlayer()
    • getAssets

      public Assets getAssets()
    • addToRemove

      public void addToRemove(Creature c)
    • iniAssets

      public void iniAssets()
    • isDebug

      public static boolean isDebug()
    • setDebug

      public static void setDebug(boolean isDebug)
    • isGraphicsTest

      public static boolean isGraphicsTest()
    • setGraphicsTest

      public static void setGraphicsTest(boolean graphicsTest)
    • getGameState

      public GameState getGameState()
    • setGameState

      public void setGameState(GameState gs)
    • getMapWidth

      public float getMapWidth()
    • getMapHeight

      public float getMapHeight()
    • playAFrame

      public void playAFrame()
      Call every function that need to be call every frame. Some function may do nothing if they are not needed.
    • startApp

      public void startApp()
    • createNewMenuScreen

      public void createNewMenuScreen()
      Create a new Menu Screen & start music.
    • endMenuScreen

      public void endMenuScreen()
      End the current screen. Current screen is supposed to be a MenuScreen. Other wise it will do nothing.
    • endGameScreen

      public void endGameScreen()
      End the current screen. Current screen is supposed to be a GameScreen. Other wise it will do nothing.
    • addZoom

      public void addZoom(float amountY)
      Update zoom of camera.
      Parameters:
      amountY - zoom amount
    • movePlayer

      public void movePlayer(int playerId)
      Move the player Creature & synchonize Camera and masks.
      Parameters:
      playerId - id of the player to move
    • moveAICreature

      public void moveAICreature()
      Move all AI Creature.
    • synchronizeCamera

      public void synchronizeCamera(Creature c)
      Synchronize the camera with the given Creature.
      Parameters:
      c - creature to synchronize with
    • restartGame

      public void restartGame()
      Restart the current Game.
    • restartFullGame

      public void restartFullGame()
      Restart all the app.
    • updateActorVisibility

      public void updateActorVisibility(int playerId)
    • allCreatures

      public Collection<Creature> allCreatures()
    • allMapItems

      public Collection<MapItem> allMapItems()
    • allActors

      public Iterable<com.badlogic.gdx.scenes.scene2d.Actor> allActors()
    • isAllAphidGone

      public boolean isAllAphidGone()
    • isAllLadybugGone

      public boolean isAllLadybugGone()
    • interact

      public void interact()
      Let Creature interact with each other. It let ladybugs eat aphids and if they do, update player score, play matching sound etc.
    • ladybugsEat

      public boolean ladybugsEat()
      Let ladybugs eat aphids.
      Returns:
      true if a ladybug have interact
    • aphidHonewdewUpdate

      public void aphidHonewdewUpdate()
      Update the visibility of the honeydew of the aphids.
    • antsCollectHoneydew

      public boolean antsCollectHoneydew()
      Let ants collect honeydew.
      Returns:
      true if an ant have interact with an aphid
    • antsHit

      public boolean antsHit()
      Let ants hit ladybug.
      Returns:
      true if a ladybug have interact
    • antsShoot

      public boolean antsShoot()
      Let ants shoot ladybug.
      Returns:
      true if a ladybug have interact
    • antShoot

      public void antShoot(Ant ant)
      Let an ant shoot.
    • acidDropsHit

      public boolean acidDropsHit()
      Let acid drops hit.
      Returns:
      true if an acide drops have interact
    • gameOver

      public void gameOver()
      End game by launching sound & end game menu.
    • playEndGameSound

      public void playEndGameSound()
      Play the end game sound.
    • pauseResume

      public void pauseResume()
      Pause game or resume depening of current state. It pause move of creature & music.
    • removeEscapeMenu

      public void removeEscapeMenu()
    • exitApp

      public void exitApp()
    • dispose

      public void dispose()
    • saveStringInFile

      public void saveStringInFile(String fileName, String contentToWrite, boolean append)
      Save a string in a file.
      Parameters:
      fileName - name of the file
      contentToWrite - content to write into the file
      append - if true, append the content to the file, else overwrite the content of the file
    • readStringInFile

      public static String readStringInFile(String fileName)
      Read a string from a file.
      Parameters:
      fileName - name of the file
      Returns:
      content of the file
    • saveScoreInFile

      public void saveScoreInFile()
      Save the score of the current game. It save the levelId, the score and the time of the game.
    • saveData

      public void saveData()
      Save all important data. It will update the lastDatePlayed and add the time played since the last time the game was played.
    • loadData

      public Map<String,String> loadData()
      Load all important data. It create it if it doesn't exist.
    • saveOptions

      public void saveOptions()
    • loadOptions

      public static KOptionsMap loadOptions()
      Load all options. It create it if it doesn't exist.
    • getBestScore

      public int getBestScore(String levelId)
      Return the best score of a level.
      Parameters:
      levelId - id of the level
      Returns:
      best score of the level
    • getLastScore

      public int getLastScore(String levelId)
      Return the last score of a level.
      Parameters:
      levelId - id of the level
      Returns:
      last score of the level
    • loadUnlockedLevels

      public static void loadUnlockedLevels()
      Load the unlocked levels. Unlocked levels are 1K + the one with a score + the next levels of a 50% score level.
    • loadUnlockedLevels

      public static void loadUnlockedLevels(String scores)
      Load the unlocked levels. Unlocked levels are 1K + the one with a score + the next levels of a at least 1 star level.
    • playSound

      public void playSound(String fileName, MapItem soundSource)
      Play a sound that soundSource have emit. soundSource is used to calculate the volume and the pan of the sound from distance and angle data between soundSource and player Creature.
      Parameters:
      fileName - name of the sound file
      soundSource - source of the sound
    • getSoundVolume

      public static float getSoundVolume(MapItem soundSource, Creature soundTarget)
      Return the volume of a sound to emit.
      Parameters:
      soundSource - source of the sound
      soundTarget - target of the sound
      Returns:
      the volume of a sound to emit
    • getSoundPan

      public static float getSoundPan(MapItem soundSource, Creature soundTarget)
      Return the pan of a sound to emit.
      Parameters:
      soundSource - source of the sound
      soundTarget - target of the sound
      Returns:
      the volume of a sound to emit
    • getVectorStageCoordinates

      public com.badlogic.gdx.math.Vector2 getVectorStageCoordinates(float x, float y)
      Return a vector of coordinate from screen x, y to stage x, y.
      Parameters:
      x - x screen coordinate
      y - y screen coordinate
      Returns:
      Vector of coordinate from screen x, y to stage x, y
    • getLightSources

      public Collection<Creature> getLightSources()
      Return a list of ligth sources that may be empty.
    • getInsectList

      public Map<Class<? extends Creature>,Integer> getInsectList()
      Return a Map of, how much insect there is.