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 TypeMethodDescriptionboolean
Let acid drops hit.void
void
addZoom
(float amountY) Update zoom of camera.Iterable<com.badlogic.gdx.scenes.scene2d.Actor>
boolean
Let ants collect honeydew.boolean
antsHit()
Let ants hit ladybug.void
Let an ant shoot.boolean
Let ants shoot ladybug.void
Update the visibility of the honeydew of the aphids.void
Create a new Menu Screen & start music.void
dispose()
void
End the current screen.void
End the current screen.void
exitApp()
void
gameOver()
End game by launching sound & end game menu.int
getBestScore
(String levelId) Return the best score of a level.static Controller
Return a Map of, how much insect there is.int
getLastScore
(String levelId) Return the last score of a level.getLevel()
Return a list of ligth sources that may be empty.int
float
float
int
com.badlogic.gdx.Screen
static float
getSoundPan
(MapItem soundSource, Creature soundTarget) Return the pan of a sound to emit.static float
getSoundVolume
(MapItem soundSource, Creature soundTarget) Return the volume of a sound to emit.com.badlogic.gdx.math.Vector2
getVectorStageCoordinates
(float x, float y) Return a vector of coordinate from screen x, y to stage x, y.void
void
interact()
Let Creature interact with each other.boolean
boolean
static boolean
isDebug()
static boolean
boolean
boolean
Let ladybugs eat aphids.loadData()
Load all important data.static KOptionsMap
Load all options.static void
Load the unlocked levels.static void
loadUnlockedLevels
(String scores) Load the unlocked levels.void
Move all AI Creature.void
movePlayer
(int playerId) Move the player Creature & synchonize Camera and masks.void
Pause game or resume depening of current state.void
Call every function that need to be call every frame.void
Play the end game sound.void
Play a sound that soundSource have emit.static String
readStringInFile
(String fileName) Read a string from a file.void
void
Restart all the app.void
Restart the current Game.void
saveData()
Save all important data.void
void
Save the score of the current game.void
saveStringInFile
(String fileName, String contentToWrite, boolean append) Save a string in a file.static void
setController
(Controller controller) static void
setDebug
(boolean isDebug) void
static void
setGraphicsTest
(boolean graphicsTest) void
setScreen
(com.badlogic.gdx.Screen screen) void
setSpectatorMode
(boolean spectatorMode) void
startApp()
void
Synchronize the camera with the given Creature.void
updateActorVisibility
(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.
-