Package fr.formiko.kokcinelo
Class Controller
java.lang.Object
fr.formiko.kokcinelo.Controller
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanLet acid drops hit.voidvoidaddZoom(float amountY) Update zoom of camera.Iterable<com.badlogic.gdx.scenes.scene2d.Actor>booleanLet ants collect honeydew.booleanantsHit()Let ants hit ladybug.voidLet an ant shoot.booleanLet ants shoot ladybug.voidUpdate the visibility of the honeydew of the aphids.voidCreate a new Menu Screen & start music.voiddispose()voidEnd the current screen.voidEnd the current screen.voidexitApp()voidgameOver()End game by launching sound & end game menu.intgetBestScore(String levelId) Return the best score of a level.static ControllerReturn a Map of, how much insect there is.intgetLastScore(String levelId) Return the last score of a level.getLevel()Return a list of ligth sources that may be empty.intfloatfloatintcom.badlogic.gdx.Screenstatic floatgetSoundPan(MapItem soundSource, Creature soundTarget) Return the pan of a sound to emit.static floatgetSoundVolume(MapItem soundSource, Creature soundTarget) Return the volume of a sound to emit.com.badlogic.gdx.math.Vector2getVectorStageCoordinates(float x, float y) Return a vector of coordinate from screen x, y to stage x, y.voidvoidinteract()Let Creature interact with each other.booleanbooleanstatic booleanisDebug()static booleanbooleanbooleanLet ladybugs eat aphids.loadData()Load all important data.static KOptionsMapLoad all options.static voidLoad the unlocked levels.static voidloadUnlockedLevels(String scores) Load the unlocked levels.voidMove all AI Creature.voidmovePlayer(int playerId) Move the player Creature & synchonize Camera and masks.voidPause game or resume depening of current state.voidCall every function that need to be call every frame.voidPlay the end game sound.voidPlay a sound that soundSource have emit.static StringreadStringInFile(String fileName) Read a string from a file.voidvoidRestart all the app.voidRestart the current Game.voidsaveData()Save all important data.voidvoidSave the score of the current game.voidsaveStringInFile(String fileName, String contentToWrite, boolean append) Save a string in a file.static voidsetController(Controller controller) static voidsetDebug(boolean isDebug) voidstatic voidsetGraphicsTest(boolean graphicsTest) voidsetScreen(com.badlogic.gdx.Screen screen) voidsetSpectatorMode(boolean spectatorMode) voidstartApp()voidSynchronize the camera with the given Creature.voidupdateActorVisibility(int playerId)
-
Constructor Details
-
Controller
Main constructor.- Parameters:
app- app to send action to
-
-
Method Details
-
getController
-
setController
-
getGameScreen
-
getScreen
public com.badlogic.gdx.Screen getScreen() -
setScreen
public void setScreen(com.badlogic.gdx.Screen screen) -
getMenuScreen
-
getLocalPlayerId
public int getLocalPlayerId() -
isSpectatorMode
public boolean isSpectatorMode() -
setSpectatorMode
public void setSpectatorMode(boolean spectatorMode) -
getNumberOfAphids
public int getNumberOfAphids() -
getLevel
-
getLevelId
-
getPlayerCreature
-
getLocalPlayer
-
getAssets
-
addToRemove
-
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
-
setGameState
-
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
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
-
allMapItems
-
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
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
Save a string in a file.- Parameters:
fileName- name of the filecontentToWrite- content to write into the fileappend- if true, append the content to the file, else overwrite the content of the file
-
readStringInFile
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
Load all important data. It create it if it doesn't exist. -
saveOptions
public void saveOptions() -
loadOptions
Load all options. It create it if it doesn't exist. -
getBestScore
Return the best score of a level.- Parameters:
levelId- id of the level- Returns:
- best score of the level
-
getLastScore
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
Load the unlocked levels. Unlocked levels are 1K + the one with a score + the next levels of a at least 1 star level. -
playSound
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 filesoundSource- source of the sound
-
getSoundVolume
Return the volume of a sound to emit.- Parameters:
soundSource- source of the soundsoundTarget- target of the sound- Returns:
- the volume of a sound to emit
-
getSoundPan
Return the pan of a sound to emit.- Parameters:
soundSource- source of the soundsoundTarget- 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 coordinatey- y screen coordinate- Returns:
- Vector of coordinate from screen x, y to stage x, y
-
getLightSources
Return a list of ligth sources that may be empty. -
getInsectList
Return a Map of, how much insect there is.
-