Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Quentin DRUAULT-AUBIN
lo23-project
Commits
c9c7089d
Commit
c9c7089d
authored
Dec 16, 2017
by
Quentin DRUAULT-AUBIN
Committed by
Paul Jeannot
Dec 17, 2017
Browse files
[Table] Reset timer
parent
c34fbf09
Changes
4
Hide whitespace changes
Inline
Side-by-side
.classpath
0 → 100644
View file @
c9c7089d
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER"
/>
<classpathentry
kind=
"src"
path=
"Battleship/src/main/resources"
/>
<classpathentry
kind=
"src"
path=
"Battleship/src/test/java"
/>
<classpathentry
kind=
"src"
path=
"Battleship/src/main/java"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
.project
0 → 100644
View file @
c9c7089d
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
lo23-project
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
Battleship/src/main/java/com/utclo23/ihmtable/IHMTableFacade.java
View file @
c9c7089d
...
...
@@ -172,6 +172,7 @@ public class IHMTableFacade implements IIHMTableToIHMMain, IIHMTableToData {
*/
@Override
public
void
notifyGameReady
()
{
System
.
out
.
println
(
"notifygameready"
);
gameReady
=
true
;
// Notify the controller the game has started.
controller
.
startGame
();
...
...
Battleship/src/main/java/com/utclo23/ihmtable/controller/InGameGUIController.java
View file @
c9c7089d
...
...
@@ -248,6 +248,11 @@ public class InGameGUIController {
* Frame for reloading a game
*/
private
Timeline
reloadTimeline
=
null
;
/**
* Timer
*/
private
Timeline
timer
;
/**
* Set the IHM Table facade.
...
...
@@ -381,6 +386,7 @@ public class InGameGUIController {
buttonImage5
.
setOnMouseClicked
(
new
SelectShipEvent
(
ShipType
.
SUBMARINE
));
// Start chrono.
initTimer
();
chronoTimeInit
();
// Init the number of turns passed.
...
...
@@ -590,6 +596,7 @@ public class InGameGUIController {
// Reinitialize chrono for the next turn.
chronoTimeInit
();
cellToAttack
=
null
;
// End of my turn.
switchOpponnentPane
();
}
catch
(
Exception
e
)
{
...
...
@@ -833,6 +840,10 @@ public class InGameGUIController {
* Function for initialize chrono
*/
private
void
chronoTimeInit
()
{
// Stop the timer.
if
(
timer
!=
null
)
{
timer
.
stop
();
}
switch
(
nbPassedTurns
)
{
case
0
:
countdown
=
30
;
...
...
@@ -856,16 +867,17 @@ public class InGameGUIController {
* Function for initialize chrono
*/
private
void
restartChronoTime
()
{
System
.
out
.
println
(
"restartcronotime"
);
chronoTimeInit
();
time
Pass
();
time
r
.
playFromStart
();
}
/**
* Function for simulate chrono, using Timeline and KeyFrame import and set the label
*/
private
void
timePass
()
{
final
Timeline
time
=
new
Timeline
();
time
.
setCycleCount
(
Timeline
.
INDEFINITE
);
private
void
initTimer
()
{
time
r
=
new
Timeline
();
time
r
.
setCycleCount
(
Timeline
.
INDEFINITE
);
KeyFrame
frame
=
new
KeyFrame
(
Duration
.
seconds
(
1.1
),
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
...
...
@@ -874,7 +886,7 @@ public class InGameGUIController {
countdown
--;
// Time's up!
if
(
countdown
<=
0
)
{
time
.
stop
();
time
r
.
stop
();
chronoLabel
.
setText
(
"00:00"
);
// Leave the game if te player has not played for the 3rd time.
...
...
@@ -905,8 +917,7 @@ public class InGameGUIController {
}
});
time
.
getKeyFrames
().
add
(
frame
);
time
.
playFromStart
();
timer
.
getKeyFrames
().
add
(
frame
);
}
/**
...
...
@@ -1230,6 +1241,7 @@ public class InGameGUIController {
* @param destroyedShip : the destroyed ship or null.
*/
public
void
displayOpponentAttack
(
Coordinate
coord
,
boolean
touched
,
Ship
destroyedShip
)
{
System
.
out
.
println
(
"displayOpponentAttack"
);
// Get the cell.
Node
cell
=
getNodeByRowColumnIndex
(
coord
.
getY
(),
coord
.
getX
(),
playerGrid
);
// The opponent has touched my ship.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment