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
genie_logiciel_2015
the_dungeon_project
Commits
97b39e13
Commit
97b39e13
authored
Jan 06, 2016
by
Lucas Delcros
Browse files
Merge branch 'master' of
https://gitlab.crans.org/genie_logiciel_2015/the_dungeon_project
parents
d1b73d7f
76db9885
Changes
22
Hide whitespace changes
Inline
Side-by-side
src/artificial_intelligence/AIEntities/AbstractEntity.java
View file @
97b39e13
...
...
@@ -261,6 +261,17 @@ public abstract class AbstractEntity extends Thread {
}
}
public
void
waiting_move
(){
Direction
dir
=
this
.
relayer
.
getCharacter
().
getDirection
();
double
r
=
random
();
if
(
r
<
0.8
){
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
this
.
relayer
.
move
(
dir
);
}
}
else
{
this
.
random_move
();}
}
public
void
act
()
{
}
...
...
src/artificial_intelligence/AIEntities/BossEntity.java
View file @
97b39e13
...
...
@@ -39,7 +39,7 @@ public class BossEntity extends AbstractEntity {
Entity
victim
=
this
.
gameState
.
getAllEntities
().
get
(
victim_i
);
/* d_min minimum distance to not run away
* dmax maximum distance to not get closer*/
double
d_min
=
32
*
3
;
// tiles of length 32 : so
3
and
7
tiles
double
d_min
=
32
*
5
;
// tiles of length 32 : so
5
and
14
tiles
double
d_max
=
32
*
14
;
double
d
=
Distance_to_victim
(
victim
);
if
(
d
<
d_min
){
...
...
@@ -56,14 +56,7 @@ public class BossEntity extends AbstractEntity {
}
else
{
Direction
dir
=
this
.
relayer
.
getCharacter
().
getDirection
();
double
r
=
random
();
if
(
r
<
0.8
){
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
this
.
relayer
.
move
(
Direction
.
NONE
);
}
}
else
{
this
.
random_move
();}
this
.
waiting_move
();
}
...
...
src/artificial_intelligence/AIEntities/StraightEntity.java
View file @
97b39e13
...
...
@@ -52,17 +52,8 @@ public class StraightEntity extends AbstractEntity {
}
}
else
{
Direction
d
=
this
.
relayer
.
getCharacter
().
getDirection
();
double
r
=
random
();
if
(
r
<
0.8
){
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
this
.
relayer
.
move
(
d
);
}
}
else
{
this
.
random_move
();}
this
.
waiting_move
();
}
// attack
}
}
src/artificial_intelligence/AlphaStar/AITile.java
View file @
97b39e13
...
...
@@ -40,8 +40,7 @@ public class AITile {
}
public
boolean
isObstacle
(
Map
map
){
//Map map=AbstractEntity.GetMap();
//Relayer relayer=AbstractEntity.GetRelay();
Tile
tile
=
map
.
getTileAt
(
x
/
32
,
y
/
32
);
TilePropertyVector
tpv
=
tile
.
getTilePropertyVector
();
List
list
=
new
ArrayList
<
TilePropertyVector
.
TileProperty
>();
...
...
@@ -91,7 +90,4 @@ public class AITile {
return
Direction
.
NONE
;
}
}
// others information could be here and be handled by Case Comparator if u want.
}
\ No newline at end of file
src/artificial_intelligence/AlphaStar/AITileComparator.java
View file @
97b39e13
package
artificial_intelligence.AlphaStar
;
import
artificial_intelligence.AlphaStar.AITile
;
import
java.util.Comparator
;
...
...
@@ -21,12 +20,11 @@ public class AITileComparator implements Comparator<AITile> {
* Allows to compare two tiles with respect to their distances to the obj tile.
* @param c1
* @param c2
* @return
* @return
heuristic distance between both element
*/
@Override
public
int
compare
(
AITile
c1
,
AITile
c2
)
{
// juste pour tester, mais il faudra changer car la conversion est trop violente
return
heuristique
(
c1
)-
heuristique
(
c2
);
}
...
...
src/artificial_intelligence/AlphaStar/AITileQueueElement.java
View file @
97b39e13
...
...
@@ -5,14 +5,14 @@ import java.util.Objects;
/**
* @author Yann RAMUSAT and Remy GARNIER
*
*
Specific
queue for
the
A*
a
lgorithm
.
*
Implement a
queue for A*
A
lgorithm
s
*/
public
class
AITileQueueElement
implements
Comparable
<
AITileQueueElement
>{
private
AITile
caseElement
;
private
double
value
;
/**
*
En
queue.
*
Add an eleement to the
queue.
* @param element
* @param d
*/
...
...
@@ -29,7 +29,7 @@ public class AITileQueueElement implements Comparable<AITileQueueElement>{
return
caseElement
;
}
@Override
public
int
compareTo
(
AITileQueueElement
cqe
)
{
return
(
value
>
cqe
.
value
)?
1
:-
1
;
...
...
src/assets/species/species.txt
View file @
97b39e13
# Fichier contenant l'ensemble des species du jeu.
# Nombre de species total
8
9
#Ronflex - Character
C
...
...
@@ -308,4 +308,32 @@ TRIGGER_DEGAT_LP
#abilityList
1
TEST_SUICIDE
#--------------------------------------------------------------------
#Gold - Entity
E
#name
Gold
#tilePropertyVector
2
SOLID
LIQUID
#collisionBox
R
15
15
#visilibity
R
200
200
#entityDisplayerType
FIREBOLT
#triggers
1
#trigger function
DEFAULT_TRIGGER
#effect descriptor
1
TRAP_TRIGGER
#abilityList
0
src/core/abilities/effects/EffectBuilder.java
View file @
97b39e13
...
...
@@ -269,6 +269,29 @@ public class EffectBuilder implements Serializable{
}
};
}
Effect
trigger_gold
()
{
return
new
Effect
()
{
private
static
final
long
serialVersionUID
=
1L
;
@Override
public
void
effect
(
List
<
Integer
>
targetCharacterIDList
,
GameContent
gameContent
,
int
casterCharacterID
)
throws
InterruptedException
{
boolean
hit
=
false
;
for
(
Integer
targetID
:
targetCharacterIDList
)
{
try
{
if
(
gameContent
.
getGameState
().
getEntity
(
casterCharacterID
).
getOwned_character
()
!=
targetID
)
{
gameContent
.
getGameState
().
getCharacter
(
targetID
).
takeDamage
(
Math
.
max
(
1
,
0
));
hit
=
true
;
}
}
catch
(
EntityNotFoundExeption
entityNotFoundExeption
)
{
}
}
if
(
hit
){
Event
event
=
new
AbilityEvent
(
casterCharacterID
,
0
);
DummyLocalGameLoop
.
getInstance
().
getNetworkConnection
().
sendEvent
(
event
);
}
}
};
}
/** Methods to be applied on an Effect to transform it into another one **/
...
...
src/core/abilities/effects/EffectGeneratorRoster.java
View file @
97b39e13
...
...
@@ -96,6 +96,15 @@ public final class EffectGeneratorRoster {
eb
.
trigger_degat_lp
()));
};
effectFactory
.
registerEffectGenerator
(
EffectKey
.
TRIGGER_DEGAT_LP
,
effectGenerator
);
effectGenerator
=
(
casterCharacterID
,
parameters
)
->
{
return
eb
.
affectZone
((
character
->
character
.
getHitbox
()),
eb
.
filter
(
CommonCharacterIDListFilter
.
allExceptOne
(
casterCharacterID
),
eb
.
trigger_gold
()));
};
effectFactory
.
registerEffectGenerator
(
EffectKey
.
TRIGGER_GOLD
,
effectGenerator
);
}
}
src/core/abilities/effects/EffectKey.java
View file @
97b39e13
...
...
@@ -16,7 +16,9 @@ public enum EffectKey {
TRAP_TRIGGER
(
0
),
TRIGGER_DEGAT
(
0
),
TRIGGER_DEGAT_LP
(
0
),
MENTALI_ATTACK_DAMAGE
(
2
);
MENTALI_ATTACK_DAMAGE
(
2
),
TRIGGER_GOLD
(
0
),
SPAWN_GOLD
(
1
);
private
EffectKey
(
int
parameterNb
)
{
this
.
parameterNb
=
parameterNb
;
...
...
src/core/event/SpawnGold.java
0 → 100644
View file @
97b39e13
package
core.event
;
import
core.abilities.effects.Effect
;
import
core.gamestate.*
;
import
core.gamestate.Character
;
import
core.relayer.RelayerEntity
;
import
core.zone.Direction
;
import
core.zone.Point
;
import
core.zone.Translation
;
import
gameloop.DummyLocalGameLoop
;
import
java.util.List
;
/**
* Created by hilaire on 06/01/16.
*
* this event is used when some Gold is created
*/
public
class
SpawnGold
implements
ClientEvent
,
ServerEvent
{
private
static
final
long
serialVersionUID
=
1L
;
private
int
targetID
;
public
SpawnGold
(
int
targetID
){
this
.
targetID
=
targetID
;
}
@Override
public
boolean
execute
(
GameContent
gameContent
)
throws
InterruptedException
{
Entity
target
=
null
;
try
{
target
=
gameContent
.
getGameState
().
getEntity
(
targetID
);
Character
charac
=
null
;
try
{
charac
=
gameContent
.
getGameState
().
getCharacter
(
targetID
);
}
catch
(
EntityNotFoundExeption
entityNotFoundExeption
)
{
return
false
;
}
Entity
entity
=
SpeciesArray
.
create
(
charac
.
getX
(),
charac
.
getY
(),
0
,
"Gold"
,
"Gold"
);
entity
.
setOrientation
(
charac
.
getOrientation
());
entity
.
setSpeed
(
0
);
entity
.
setOwned_character
(
targetID
);
gameContent
.
getGameState
().
addEntity
(
entity
);
gameContent
.
addTriggerToCheck
(
entity
);
RelayerEntity
relayer
=
new
RelayerEntity
(
entity
.
getID
(),
entity
,
gameContent
);
entity
.
setRelayer
(
relayer
);
if
(
DummyLocalGameLoop
.
getInstance
().
getFollowedRelayer
().
getDirection
()
!=
Direction
.
NONE
)
{
relayer
.
move
(
DummyLocalGameLoop
.
getInstance
().
getFollowedRelayer
().
getDirection
());
}
else
{
relayer
.
move
(
charac
.
getDirection
());
}
relayer
.
start
();
return
true
;
}
catch
(
EntityNotFoundExeption
entityNotFoundExeption
)
{
return
true
;
}
}
@Override
public
Event
resolve
(
GameContent
gameContent
)
{
return
this
;
}
}
\ No newline at end of file
src/core/gamestate/Being.java
View file @
97b39e13
...
...
@@ -6,7 +6,9 @@ import java.util.Objects;
import
java.util.logging.Logger
;
import
core.abilities.Ability
;
import
core.abilities.effects.EffectBuilder
;
import
core.event.Event
;
import
core.event.SpawnGold
;
import
core.event.ToServerDeathEvent
;
import
core.zone.Zone
;
import
gameloop.DummyLocalGameLoop
;
...
...
@@ -153,6 +155,14 @@ public class Being extends Entity {
}
else
{
LOGGER
.
info
(
"Death of "
+
this
.
getID
()+
" is send"
);
network
.
sendEvent
(
event
);
}
Event
event2
=
new
SpawnGold
(
this
.
getID
());
if
(
network
==
null
){
LOGGER
.
severe
(
"NetworkConnection null, GOld"
+
this
.
getID
()+
" can't be created"
);
}
else
{
LOGGER
.
info
(
"Gold creation by "
+
this
.
getID
()
+
" is send"
);
network
.
sendEvent
(
event2
);
}
}
...
...
src/core/gamestate/Character.java
View file @
97b39e13
...
...
@@ -29,6 +29,8 @@ public final class Character extends Being {
*/
private
int
intel
;
private
int
gold
;
/**
* ????
*/
...
...
@@ -82,6 +84,23 @@ public final class Character extends Being {
return
intel
;
}
/**
* Returns the character's gold value.
* @return the character's gold value.
*/
public
int
getGold
()
{
return
gold
;
}
/**
* Returns the character's gold value.
* @return the character's gold value.
*/
public
void
setGold
(
int
gold2
)
{
this
.
gold
=
gold2
;
}
/**
* ????
* @return
...
...
src/core/gamestate/GameContent.java
View file @
97b39e13
...
...
@@ -43,7 +43,13 @@ public class GameContent implements Serializable{
for
(
Entity
e:
map
.
getEntities
()){
gameState
.
addEntity
(
e
);
Relayer
dmr
=
Relayers
.
addNewRelayer
(
e
);
AIControler
.
add
(
this
,
dmr
,
EnumBehaviourType
.
Boss
);
String
name
=
dmr
.
getCharacter
().
getSpeciesName
();
if
(
name
.
equals
(
"Ronflex"
)){
AIControler
.
add
(
this
,
dmr
,
EnumBehaviourType
.
Boss
);
}
else
{
AIControler
.
add
(
this
,
dmr
,
EnumBehaviourType
.
Straight
);
}
}
}
int
posX
=(
map
.
getPositionPlayerStart
().
getI
())*
Point
.
TileScale
;
...
...
src/gameloop/DummyLocalGameLoop.java
View file @
97b39e13
package
gameloop
;
import
core.event.Event
;
import
core.event.MapChangeEvent
;
import
core.event.MapInit
;
import
core.event.ToClientDeathEvent
;
import
core.gamestate.GameContent
;
...
...
@@ -149,6 +150,9 @@ public class DummyLocalGameLoop extends Thread{
setFollowedRelayer
(
firstEntityRelayer
);
relayerSemaphore
.
release
();
}
if
(
eventToReceive
instanceof
MapChangeEvent
){
GraphicsMasterAbstraction
.
getInstance
().
changeGUIStateTo
(
GraphicsMasterAbstraction
.
GUIStates
.
GAME_WIN
);
}
if
(
eventToReceive
instanceof
ToClientDeathEvent
&&
((
ToClientDeathEvent
)
eventToReceive
).
getEntityID
()==
followedRelayer
.
getCharacter
().
getID
())
{
GraphicsMasterAbstraction
.
getInstance
().
changeGUIStateTo
(
GraphicsMasterAbstraction
.
GUIStates
.
GAME_OVER
);
...
...
src/graphics/graphical_abstraction/GraphicsMasterAbstraction.java
View file @
97b39e13
...
...
@@ -39,7 +39,8 @@ public abstract class GraphicsMasterAbstraction {
LOST_CONNECTION
,
PLEASE_WAIT
,
SERVER_ADDRESS_PANEL
,
SERVER_CREATED_PANEL
SERVER_CREATED_PANEL
,
GAME_WIN
;
}
//This map indicates to graphicsMaster which guiPanel is associated to each GUIState, it is filled in Graphicsmaster's constructor
protected
HashMap
<
GUIStates
,
PanelAbstraction
>
mapGUIStatesToGUIPanel
=
new
HashMap
<>();
...
...
src/graphics/guiSkeleton/GraphicsMaster.java
View file @
97b39e13
...
...
@@ -58,6 +58,7 @@ public class GraphicsMaster extends GraphicsMasterAbstraction {
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
SERVER_ADDRESS_PANEL
,
new
ServerAddressPanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
GAME_OVER
,
new
GameOverPanel
(
this
));
mapGUIStatesToGUIPanel
.
put
(
GUIStates
.
GAME_WIN
,
new
GameWinPanel
(
this
));
}
public
static
void
build
()
{
...
...
src/graphics/guiSkeleton/guiPanel/GUIPanel.java
View file @
97b39e13
...
...
@@ -11,8 +11,6 @@ import javax.swing.*;
* The gui changes what it displays by swapping GUIPanels in the mainFrame.
*/
public
abstract
class
GUIPanel
extends
JPanel
implements
PanelAbstraction
{
//The following line is commented because KeyListener does not seem to work in a JPanel
//Private KeyListenerForGUIPanel associatedKeyHandler;
//Store the graphicsMaster that created the guiPanel (there should be only one GraphicsMaster instanciation per application,
// this variable is just there to give the guiPanel the right to call the method changeGUIStateTo de graphicsMaster)
...
...
@@ -24,66 +22,6 @@ public abstract class GUIPanel extends JPanel implements PanelAbstraction{
public
GUIPanel
(
GraphicsMaster
graphicsMaster
)
{
this
.
graphicsMaster
=
graphicsMaster
;
//The following 2 lines are commented because KeyListener does not seem to work in a JPanel
//associatedKeyHandler = new KeyListenerForGUIPanel(this);
setFocusable
(
true
);
}
/**
* This method is called by the gui before displaying the panel
*/
//abstract void initialise();
/**
* This method is called by the gui after this panel is no more displayed
*/
//abstract void finalise();
/**
* Define here what should happen if a key is pressed while this panel has the focus
* @param e
*/
//abstract void keyPressedHandler(KeyEvent e);
//Example of a body one could give to the keyPressedHandler method when implementing a guiPanel
//if(e.getKeyCode() == 27) { // 27 -> Escape
// System.out.println("Escape has been pressed");
//}
/**
* Define here what should happen if a key is released while this panel has the focus
* @param e
*/
//abstract void keyReleasedHandler(KeyEvent e);
/**
* Define here what should happen if a key is typed while this panel has the focus
* @param e
*/
//abstract void keyTypedHandler(KeyEvent e);
}
// The following code is commented because KeyListener does not seem to work on a JPanel
///**
// * This class detects the KeyEvents coming from the keyboard (KeyPressed, KeyReleased and KeyTyped) when the guiPanel
// * it is associated with has the focus, and call the corresponding KeyEvent handler of the associated guiPanel
// */
//class KeyListenerForGUIPanel implements KeyListener {
//
// private guiPanel associatedGUIPanel;
//
// KeyListenerForGUIPanel(guiPanel associatedGUIPanel) {
// this.associatedGUIPanel = associatedGUIPanel;
// }
//
// public final void keyPressed(KeyEvent e) {
// associatedGUIPanel.keyPressedHandler(e);
// }
//
// public final void keyReleased(KeyEvent e) {
// associatedGUIPanel.keyReleasedHandler(e);
// }
//
// public final void keyTyped(KeyEvent e) {
// associatedGUIPanel.keyTypedHandler(e);
// }
//}
}
\ No newline at end of file
src/graphics/guiSkeleton/guiPanel/menuPanel/GameWinPanel.java
0 → 100644
View file @
97b39e13
package
graphics.guiSkeleton.guiPanel.menuPanel
;
import
graphics.graphical_abstraction.GraphicsMasterAbstraction
;
import
graphics.graphical_abstraction.panel.menu.GameOverPanelAbstraction
;
import
graphics.graphical_abstraction.panel.menu.GameOverPanelAbstractionController
;
import
graphics.graphical_abstraction.panel.menu.MainMenuPanelAbstraction
;
import
graphics.guiSkeleton.GUIColorsAndFonts
;
import
graphics.guiSkeleton.GraphicsMaster
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker
;
import
graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel
;
import
graphics.ingame_input_listener.Input
;
import
javax.swing.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
/**
* Created by dupriez on 01/01/16.
*/
public
class
GameWinPanel
extends
MenuPanel
implements
GameOverPanelAbstraction
{
GameOverPanelAbstractionController
controller
=
new
GameOverPanelAbstractionController
(
this
);
public
GameWinPanel
(
GraphicsMaster
graphicsMaster
)
{
super
(
graphicsMaster
);
JLabel
winLabel
=
new
JLabel
(
"Congratulation, you have reached the stairs !"
);
winLabel
.
setFont
(
GUIColorsAndFonts
.
smallFont1
);
winLabel
.
setForeground
(
GUIColorsAndFonts
.
fontColor1
);
setTitlePanel
(
"Game Over"
);
addToCentralColumn
(
winLabel
,
1
,
1
);
addToCentralColumn
(
ButtonMaker
.
makeButton
(
"Return to main menu"
,
returnButtonActionListener
),
1
,
1
);
}
private
ActionListener
returnButtonActionListener
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
controller
.
returnButtonPressed
();
}
};
@Override
public
void
initialise
()
{
}
@Override
public
void
finalise
()
{
}
@Override
public
void
keyPressedHandler
(
Input
e
)
{
}
@Override
public
void
keyReleasedHandler
(
Input
e
)
{
}
@Override
public
void
keyTypedHandler
(
Input
e
)
{
}
@Override
public
void
returnButtonAction
()
{
getGraphicsMaster
().
changeGUIStateTo
(
GraphicsMaster
.
GUIStates
.
MAIN_MENU
);
}
}
src/graphics/guiSkeleton/mapManagement/GamePanelMapPoint.java
View file @
97b39e13
...
...
@@ -32,8 +32,4 @@ public class GamePanelMapPoint {
public
int
getY
()
{
return
Y
;
}
//TODO: Useful?
public
GraphicsMapPoint
getGraphicsMapPoint
()
{
return
graphicsMapPoint
;
}
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
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