Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
A ket torony
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sabvente
A ket torony
Commits
cdfab349
Commit
cdfab349
authored
May 11, 2014
by
karthurg
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://git.sch.bme.hu/sabvente/akettorony
parents
9fce9b74
4b371a98
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/view/Sounds.java
+1
-0
1 addition, 0 deletions
src/view/Sounds.java
src/world/Enemy.java
+33
-27
33 additions, 27 deletions
src/world/Enemy.java
src/world/SpawnManager.java
+2
-21
2 additions, 21 deletions
src/world/SpawnManager.java
with
36 additions
and
48 deletions
src/view/Sounds.java
+
1
−
0
View file @
cdfab349
...
@@ -26,6 +26,7 @@ public class Sounds {
...
@@ -26,6 +26,7 @@ public class Sounds {
clip
=
AudioSystem
.
getClip
();
clip
=
AudioSystem
.
getClip
();
clip
.
open
(
aStream
);
clip
.
open
(
aStream
);
clip
.
loop
(
Clip
.
LOOP_CONTINUOUSLY
);
clip
.
loop
(
Clip
.
LOOP_CONTINUOUSLY
);
clips
.
add
(
clip
);
}
catch
(
LineUnavailableException
|
IOException
e1
)
{
}
catch
(
LineUnavailableException
|
IOException
e1
)
{
e1
.
printStackTrace
();
e1
.
printStackTrace
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/world/Enemy.java
+
33
−
27
View file @
cdfab349
...
@@ -16,8 +16,7 @@ public class Enemy extends Placeable implements ITickable {
...
@@ -16,8 +16,7 @@ public class Enemy extends Placeable implements ITickable {
private
Field
prevField
;
private
Field
prevField
;
private
int
moveTries
;
private
int
moveTries
;
private
static
HashMap
<
EnemyType
,
Integer
>
moveTimes
=
new
HashMap
<
EnemyType
,
Integer
>();
private
static
HashMap
<
EnemyType
,
Integer
>
moveTimes
=
new
HashMap
<
EnemyType
,
Integer
>();
static
static
{
{
moveTimes
.
put
(
EnemyType
.
HUMAN
,
4
);
moveTimes
.
put
(
EnemyType
.
HUMAN
,
4
);
moveTimes
.
put
(
EnemyType
.
DWARF
,
5
);
moveTimes
.
put
(
EnemyType
.
DWARF
,
5
);
moveTimes
.
put
(
EnemyType
.
ELF
,
3
);
moveTimes
.
put
(
EnemyType
.
ELF
,
3
);
...
@@ -41,8 +40,7 @@ public class Enemy extends Placeable implements ITickable {
...
@@ -41,8 +40,7 @@ public class Enemy extends Placeable implements ITickable {
split
();
split
();
}
}
private
void
Die
()
private
void
Die
()
{
{
field
.
getWorld
().
notifyEnemyDied
(
this
);
field
.
getWorld
().
notifyEnemyDied
(
this
);
field
.
stepOff
(
this
);
field
.
stepOff
(
this
);
if
(
this
.
type
==
EnemyType
.
HUMAN
)
if
(
this
.
type
==
EnemyType
.
HUMAN
)
...
@@ -80,6 +78,13 @@ public class Enemy extends Placeable implements ITickable {
...
@@ -80,6 +78,13 @@ public class Enemy extends Placeable implements ITickable {
reset
();
reset
();
potentials
.
get
(
index
).
stepOn
(
this
);
potentials
.
get
(
index
).
stepOn
(
this
);
}
}
else
{
field
.
stepOff
(
this
);
prevField
=
field
;
reset
();
prevField
.
stepOn
(
this
);
}
}
else
{
}
else
{
moveTries
++;
moveTries
++;
}
}
...
@@ -91,7 +96,8 @@ public class Enemy extends Placeable implements ITickable {
...
@@ -91,7 +96,8 @@ public class Enemy extends Placeable implements ITickable {
Die
();
Die
();
return
;
return
;
}
}
field
.
getWorld
().
getSpawnManager
().
spawnEnemy
(
field
,
type
,
hp
,
prevField
);
field
.
getWorld
().
getSpawnManager
()
.
spawnEnemy
(
field
,
type
,
hp
,
prevField
);
}
}
private
void
reset
()
{
private
void
reset
()
{
...
...
This diff is collapsed.
Click to expand it.
src/world/SpawnManager.java
+
2
−
21
View file @
cdfab349
...
@@ -16,9 +16,6 @@ public class SpawnManager implements ITickable, IEnemyObserver
...
@@ -16,9 +16,6 @@ public class SpawnManager implements ITickable, IEnemyObserver
private
int
spawnTimeLeft
;
private
int
spawnTimeLeft
;
private
int
currentTime
;
private
int
currentTime
;
private
int
enemiesAlive
;
private
int
enemiesAlive
;
public
static
boolean
randomEnemySpawnPos
=
false
;
public
static
EnemyType
fixedSpawnType
;
public
static
boolean
isFixedSpawnType
;
public
SpawnManager
(
Engine
engine
,
World
world
,
ArrayList
<
Field
>
spawns
)
public
SpawnManager
(
Engine
engine
,
World
world
,
ArrayList
<
Field
>
spawns
)
{
{
...
@@ -48,27 +45,11 @@ public class SpawnManager implements ITickable, IEnemyObserver
...
@@ -48,27 +45,11 @@ public class SpawnManager implements ITickable, IEnemyObserver
private
void
spawnEnemies
()
private
void
spawnEnemies
()
{
{
Field
spawnField
=
null
;
Field
spawnField
=
spawns
.
get
(
new
Random
().
nextInt
(
spawns
.
size
()));
if
(!
randomEnemySpawnPos
)
{
spawnField
=
spawns
.
get
(
0
);
}
else
{
spawnField
=
spawns
.
get
(
new
Random
().
nextInt
(
spawns
.
size
()));
}
int
num
=
nextSpawnNum
();
int
num
=
nextSpawnNum
();
for
(
int
i
=
0
;
i
<
num
;
i
++)
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
{
EnemyType
t
;
EnemyType
t
=
EnemyType
.
values
()[
new
Random
().
nextInt
(
EnemyType
.
values
().
length
)];
if
(
isFixedSpawnType
)
{
t
=
fixedSpawnType
;
}
else
{
t
=
EnemyType
.
values
()[
new
Random
().
nextInt
(
EnemyType
.
values
().
length
)];
}
Enemy
e
=
new
Enemy
(
t
);
Enemy
e
=
new
Enemy
(
t
);
e
.
setField
(
spawnField
);
e
.
setField
(
spawnField
);
spawnField
.
stepOn
(
e
);
spawnField
.
stepOn
(
e
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment