Re-coded everything
1
.gitignore
vendored
@@ -3,7 +3,6 @@
|
|||||||
*.class
|
*.class
|
||||||
*.war
|
*.war
|
||||||
*.ear
|
*.ear
|
||||||
*.gif
|
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
## Robovm
|
## Robovm
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ allprojects {
|
|||||||
|
|
||||||
version = '1.0'
|
version = '1.0'
|
||||||
ext {
|
ext {
|
||||||
appName = "Moment"
|
appName = "Mindustry"
|
||||||
gdxVersion = '1.9.6'
|
gdxVersion = '1.9.6'
|
||||||
|
aiVersion = '1.8.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -36,7 +37,6 @@ project(":desktop") {
|
|||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +59,12 @@ project(":core") {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compile fileTree(dir: '../core/lib', include: '*.jar')
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||||
compile fileTree(dir: '../core/lib', include: '*.jar')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.eclipse.doLast {
|
tasks.eclipse.doLast {
|
||||||
delete ".project"
|
delete ".project"
|
||||||
}
|
}
|
||||||
BIN
core/assets/maps/canyon.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
core/assets/maps/delta.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/maps/pit.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
moment.png
|
mindsutry.png
|
||||||
size: 256,32
|
size: 256,32
|
||||||
format: RGBA8888
|
format: RGBA8888
|
||||||
filter: Nearest,Nearest
|
filter: Nearest,Nearest
|
||||||
BIN
core/assets/ui/out/button-map-down.9.png
Normal file
|
After Width: | Height: | Size: 212 B |
BIN
core/assets/ui/out/button-map-over.9.png
Normal file
|
After Width: | Height: | Size: 212 B |
BIN
core/assets/ui/out/button-map.9.png
Normal file
|
After Width: | Height: | Size: 205 B |
|
Before Width: | Height: | Size: 70 B |
|
Before Width: | Height: | Size: 99 B |
|
Before Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 692 B |
|
Before Width: | Height: | Size: 647 B |
|
Before Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 70 B |
@@ -6,14 +6,14 @@ filter: Nearest,Nearest
|
|||||||
repeat: none
|
repeat: none
|
||||||
blank
|
blank
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 164, 2
|
xy: 898, 76
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
border
|
border
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 292, 42
|
xy: 134, 2
|
||||||
size: 12, 12
|
size: 12, 12
|
||||||
split: 4, 4, 4, 4
|
split: 4, 4, 4, 4
|
||||||
orig: 12, 12
|
orig: 12, 12
|
||||||
@@ -21,21 +21,21 @@ border
|
|||||||
index: -1
|
index: -1
|
||||||
border-circle
|
border-circle
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 939, 98
|
xy: 498, 64
|
||||||
size: 28, 28
|
size: 28, 28
|
||||||
orig: 28, 28
|
orig: 28, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
border-circle-error
|
border-circle-error
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 969, 98
|
xy: 528, 64
|
||||||
size: 28, 28
|
size: 28, 28
|
||||||
orig: 28, 28
|
orig: 28, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
border-dark-blue
|
border-dark-blue
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 133, 21
|
xy: 648, 87
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
@@ -43,7 +43,7 @@ border-dark-blue
|
|||||||
index: -1
|
index: -1
|
||||||
border-error
|
border-error
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 133, 16
|
xy: 241, 41
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
@@ -51,7 +51,7 @@ border-error
|
|||||||
index: -1
|
index: -1
|
||||||
border-white
|
border-white
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 118, 2
|
xy: 120, 2
|
||||||
size: 12, 12
|
size: 12, 12
|
||||||
split: 4, 4, 4, 4
|
split: 4, 4, 4, 4
|
||||||
orig: 12, 12
|
orig: 12, 12
|
||||||
@@ -67,7 +67,7 @@ bump
|
|||||||
index: -1
|
index: -1
|
||||||
button
|
button
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 913, 86
|
xy: 991, 86
|
||||||
size: 24, 40
|
size: 24, 40
|
||||||
split: 10, 10, 8, 8
|
split: 10, 10, 8, 8
|
||||||
orig: 24, 40
|
orig: 24, 40
|
||||||
@@ -126,7 +126,15 @@ button-gray-over
|
|||||||
orig: 24, 40
|
orig: 24, 40
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
button-over
|
button-map
|
||||||
|
rotate: false
|
||||||
|
xy: 861, 86
|
||||||
|
size: 24, 40
|
||||||
|
split: 10, 10, 8, 8
|
||||||
|
orig: 24, 40
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
button-map-down
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 809, 86
|
xy: 809, 86
|
||||||
size: 24, 40
|
size: 24, 40
|
||||||
@@ -134,10 +142,26 @@ button-over
|
|||||||
orig: 24, 40
|
orig: 24, 40
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
button-red
|
button-map-over
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 835, 86
|
xy: 835, 86
|
||||||
size: 24, 40
|
size: 24, 40
|
||||||
|
split: 10, 10, 8, 8
|
||||||
|
orig: 24, 40
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
button-over
|
||||||
|
rotate: false
|
||||||
|
xy: 887, 86
|
||||||
|
size: 24, 40
|
||||||
|
split: 10, 10, 8, 8
|
||||||
|
orig: 24, 40
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
button-red
|
||||||
|
rotate: false
|
||||||
|
xy: 913, 86
|
||||||
|
size: 24, 40
|
||||||
split: 10, 10, 10, 8
|
split: 10, 10, 10, 8
|
||||||
pad: 8, 8, 2, 2
|
pad: 8, 8, 2, 2
|
||||||
orig: 24, 40
|
orig: 24, 40
|
||||||
@@ -145,7 +169,7 @@ button-red
|
|||||||
index: -1
|
index: -1
|
||||||
button-select
|
button-select
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 219, 28
|
xy: 138, 16
|
||||||
size: 24, 24
|
size: 24, 24
|
||||||
split: 4, 4, 4, 4
|
split: 4, 4, 4, 4
|
||||||
orig: 24, 24
|
orig: 24, 24
|
||||||
@@ -153,7 +177,7 @@ button-select
|
|||||||
index: -1
|
index: -1
|
||||||
button-window-bg
|
button-window-bg
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 861, 86
|
xy: 939, 86
|
||||||
size: 24, 40
|
size: 24, 40
|
||||||
split: 10, 10, 10, 8
|
split: 10, 10, 10, 8
|
||||||
pad: 8, 8, 2, 2
|
pad: 8, 8, 2, 2
|
||||||
@@ -162,7 +186,7 @@ button-window-bg
|
|||||||
index: -1
|
index: -1
|
||||||
button-window-over
|
button-window-over
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 887, 86
|
xy: 965, 86
|
||||||
size: 24, 40
|
size: 24, 40
|
||||||
split: 10, 10, 10, 8
|
split: 10, 10, 10, 8
|
||||||
pad: 8, 8, 2, 2
|
pad: 8, 8, 2, 2
|
||||||
@@ -192,35 +216,35 @@ check-over
|
|||||||
index: -1
|
index: -1
|
||||||
clear
|
clear
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 306, 44
|
xy: 634, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
color-picker-bar-selector
|
color-picker-bar-selector
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 999, 98
|
xy: 618, 60
|
||||||
size: 14, 28
|
size: 14, 28
|
||||||
orig: 14, 28
|
orig: 14, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
color-picker-cross
|
color-picker-cross
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 318, 44
|
xy: 648, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
color-picker-selector-horizontal
|
color-picker-selector-horizontal
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 92, 5
|
xy: 335, 83
|
||||||
size: 6, 1
|
size: 6, 1
|
||||||
orig: 6, 1
|
orig: 6, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
color-picker-selector-vertical
|
color-picker-selector-vertical
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 168, 34
|
xy: 1017, 86
|
||||||
size: 1, 6
|
size: 1, 6
|
||||||
orig: 1, 6
|
orig: 1, 6
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -234,14 +258,14 @@ cursor
|
|||||||
index: -1
|
index: -1
|
||||||
cursor-normal
|
cursor-normal
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 245, 21
|
xy: 646, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
default-pane
|
default-pane
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 266, 33
|
xy: 164, 37
|
||||||
size: 5, 3
|
size: 5, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 5, 3
|
orig: 5, 3
|
||||||
@@ -265,7 +289,7 @@ default-select
|
|||||||
index: -1
|
index: -1
|
||||||
default-select-selection
|
default-select-selection
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 171, 38
|
xy: 898, 71
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
@@ -273,42 +297,42 @@ default-select-selection
|
|||||||
index: -1
|
index: -1
|
||||||
grey
|
grey
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 645, 71
|
xy: 340, 80
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
menu-bg
|
menu-bg
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 645, 71
|
xy: 340, 80
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-arrow-down
|
icon-arrow-down
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 257, 21
|
xy: 660, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-arrow-left
|
icon-arrow-left
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 640, 59
|
xy: 658, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-arrow-right
|
icon-arrow-right
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 330, 44
|
xy: 672, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-arrow-up
|
icon-arrow-up
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 977, 78
|
xy: 670, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -336,63 +360,63 @@ icon-close-over
|
|||||||
index: -1
|
index: -1
|
||||||
icon-copy
|
icon-copy
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 989, 78
|
xy: 684, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-cursor
|
icon-cursor
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 1001, 78
|
xy: 682, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-defense
|
icon-defense
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 640, 47
|
xy: 696, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-distribution
|
icon-distribution
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 645, 74
|
xy: 694, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-dots
|
icon-dots
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 657, 74
|
xy: 708, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-dots-down
|
icon-dots-down
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 669, 74
|
xy: 706, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-down
|
icon-down
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 681, 74
|
xy: 720, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-drive
|
icon-drive
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 939, 86
|
xy: 82, 4
|
||||||
size: 36, 10
|
size: 36, 10
|
||||||
orig: 36, 10
|
orig: 36, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-eraser
|
icon-eraser
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 693, 74
|
xy: 718, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -420,21 +444,21 @@ icon-file-pdf
|
|||||||
index: -1
|
index: -1
|
||||||
icon-file-text
|
icon-file-text
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 705, 74
|
xy: 732, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-fill
|
icon-fill
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 717, 74
|
xy: 730, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-folder
|
icon-folder
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 729, 74
|
xy: 744, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -448,7 +472,7 @@ icon-folder-new
|
|||||||
index: -1
|
index: -1
|
||||||
icon-folder-parent
|
icon-folder-parent
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 741, 74
|
xy: 742, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -462,14 +486,14 @@ icon-folder-star
|
|||||||
index: -1
|
index: -1
|
||||||
icon-grid
|
icon-grid
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 753, 74
|
xy: 756, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-home
|
icon-home
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 765, 74
|
xy: 754, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -483,91 +507,91 @@ icon-list-settings
|
|||||||
index: -1
|
index: -1
|
||||||
icon-load-1
|
icon-load-1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 777, 74
|
xy: 768, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-load-2
|
icon-load-2
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 789, 74
|
xy: 766, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-load-3
|
icon-load-3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 801, 74
|
xy: 780, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-lock
|
icon-lock
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 813, 74
|
xy: 778, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-lock-open
|
icon-lock-open
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 825, 74
|
xy: 792, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-minus
|
icon-minus
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 837, 74
|
xy: 790, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-open
|
icon-open
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 849, 74
|
xy: 804, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-open-gray
|
icon-open-gray
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 861, 74
|
xy: 802, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-pencil
|
icon-pencil
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 873, 74
|
xy: 816, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-pick
|
icon-pick
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 885, 74
|
xy: 814, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-plus
|
icon-plus
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 897, 74
|
xy: 828, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-production
|
icon-production
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 909, 74
|
xy: 826, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-redo
|
icon-redo
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 921, 74
|
xy: 840, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -581,7 +605,7 @@ icon-refresh
|
|||||||
index: -1
|
index: -1
|
||||||
icon-rename
|
icon-rename
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 933, 74
|
xy: 838, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -602,56 +626,49 @@ icon-star-outline
|
|||||||
index: -1
|
index: -1
|
||||||
icon-tap
|
icon-tap
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 945, 74
|
xy: 852, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-trash
|
icon-trash
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 957, 74
|
xy: 850, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-undo
|
icon-undo
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 652, 62
|
xy: 864, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-up
|
icon-up
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 652, 50
|
xy: 862, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
icon-zoom
|
icon-zoom
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 664, 62
|
xy: 876, 74
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
list-selection
|
list-selection
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 340, 83
|
xy: 78, 2
|
||||||
size: 1, 1
|
|
||||||
orig: 1, 1
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-blue
|
|
||||||
rotate: false
|
|
||||||
xy: 340, 83
|
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
padded-list-selection
|
padded-list-selection
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 58, 2
|
xy: 58, 5
|
||||||
size: 10, 1
|
size: 10, 1
|
||||||
split: 4, 4, 0, 1
|
split: 4, 4, 0, 1
|
||||||
orig: 10, 1
|
orig: 10, 1
|
||||||
@@ -659,56 +676,49 @@ padded-list-selection
|
|||||||
index: -1
|
index: -1
|
||||||
progressbar
|
progressbar
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 618, 56
|
xy: 1017, 94
|
||||||
size: 1, 32
|
size: 1, 32
|
||||||
orig: 1, 32
|
orig: 1, 32
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
progressbar-filled
|
progressbar-filled
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 621, 56
|
xy: 1020, 94
|
||||||
size: 1, 32
|
size: 1, 32
|
||||||
orig: 1, 32
|
orig: 1, 32
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
progressbar-filled-vertical
|
progressbar-filled-vertical
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 171, 43
|
xy: 207, 43
|
||||||
size: 32, 1
|
size: 32, 1
|
||||||
orig: 32, 1
|
orig: 32, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
progressbar-vertical
|
progressbar-vertical
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 58, 5
|
xy: 207, 40
|
||||||
size: 32, 1
|
size: 32, 1
|
||||||
orig: 32, 1
|
orig: 32, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
radio-off
|
radio-off
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 498, 64
|
xy: 558, 64
|
||||||
size: 28, 28
|
|
||||||
orig: 28, 28
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-radio
|
|
||||||
rotate: false
|
|
||||||
xy: 498, 64
|
|
||||||
size: 28, 28
|
size: 28, 28
|
||||||
orig: 28, 28
|
orig: 28, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
radio-on
|
radio-on
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 528, 64
|
xy: 588, 60
|
||||||
size: 28, 28
|
size: 28, 28
|
||||||
orig: 28, 28
|
orig: 28, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
scroll
|
scroll
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 977, 90
|
xy: 171, 38
|
||||||
size: 34, 6
|
size: 34, 6
|
||||||
split: 4, 4, 2, 2
|
split: 4, 4, 2, 2
|
||||||
orig: 34, 6
|
orig: 34, 6
|
||||||
@@ -734,7 +744,7 @@ scroll-knob-horizontal
|
|||||||
index: -1
|
index: -1
|
||||||
scroll-knob-vertical
|
scroll-knob-vertical
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 82, 8
|
xy: 219, 46
|
||||||
size: 34, 6
|
size: 34, 6
|
||||||
split: 12, 12, 2, 2
|
split: 12, 12, 2, 2
|
||||||
orig: 34, 6
|
orig: 34, 6
|
||||||
@@ -742,56 +752,56 @@ scroll-knob-vertical
|
|||||||
index: -1
|
index: -1
|
||||||
select-box-list-bg
|
select-box-list-bg
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 650, 89
|
xy: 340, 77
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
window-bg
|
window-bg
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 650, 89
|
xy: 340, 77
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
select-down
|
select-down
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 132, 2
|
xy: 148, 6
|
||||||
size: 14, 8
|
size: 14, 8
|
||||||
orig: 14, 8
|
orig: 14, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
select-up
|
select-up
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 148, 2
|
xy: 255, 44
|
||||||
size: 14, 8
|
size: 14, 8
|
||||||
orig: 14, 8
|
orig: 14, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
selection
|
selection
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 650, 86
|
xy: 588, 91
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
separator
|
separator
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 974, 83
|
xy: 148, 3
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
tree-over
|
tree-over
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 974, 83
|
xy: 148, 3
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
separator-menu
|
separator-menu
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 648, 71
|
xy: 271, 51
|
||||||
size: 1, 1
|
size: 1, 1
|
||||||
orig: 1, 1
|
orig: 1, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -833,7 +843,7 @@ slider-knob-over
|
|||||||
index: -1
|
index: -1
|
||||||
slider-vertical
|
slider-vertical
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 70, 2
|
xy: 58, 2
|
||||||
size: 8, 1
|
size: 8, 1
|
||||||
orig: 8, 1
|
orig: 8, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -848,21 +858,21 @@ slot
|
|||||||
index: -1
|
index: -1
|
||||||
splitpane
|
splitpane
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 80, 2
|
xy: 68, 2
|
||||||
size: 8, 1
|
size: 8, 1
|
||||||
orig: 8, 1
|
orig: 8, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
splitpane-over
|
splitpane-over
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 90, 2
|
xy: 70, 5
|
||||||
size: 8, 1
|
size: 8, 1
|
||||||
orig: 8, 1
|
orig: 8, 1
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
splitpane-vertical
|
splitpane-vertical
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 1015, 118
|
xy: 133, 16
|
||||||
size: 1, 8
|
size: 1, 8
|
||||||
orig: 1, 8
|
orig: 1, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -876,44 +886,30 @@ splitpane-vertical-over
|
|||||||
index: -1
|
index: -1
|
||||||
sub-menu
|
sub-menu
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 266, 38
|
xy: 888, 70
|
||||||
size: 8, 14
|
size: 8, 14
|
||||||
orig: 8, 14
|
orig: 8, 14
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
textfield
|
textfield
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 588, 60
|
xy: 305, 56
|
||||||
size: 28, 28
|
size: 28, 28
|
||||||
split: 6, 6, 6, 6
|
split: 6, 6, 6, 6
|
||||||
orig: 28, 28
|
orig: 28, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
vis-check
|
|
||||||
rotate: false
|
|
||||||
xy: 588, 60
|
|
||||||
size: 28, 28
|
|
||||||
orig: 28, 28
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
textfield-over
|
textfield-over
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 558, 64
|
xy: 275, 56
|
||||||
size: 28, 28
|
size: 28, 28
|
||||||
split: 2, 2, 2, 2
|
split: 2, 2, 2, 2
|
||||||
orig: 28, 28
|
orig: 28, 28
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
vis-check-over
|
|
||||||
rotate: false
|
|
||||||
xy: 558, 64
|
|
||||||
size: 28, 28
|
|
||||||
orig: 28, 28
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
tooltip-bg
|
tooltip-bg
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 335, 81
|
xy: 908, 81
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
@@ -928,85 +924,29 @@ touchpad-knob
|
|||||||
index: -1
|
index: -1
|
||||||
tree-minus
|
tree-minus
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 664, 50
|
xy: 874, 62
|
||||||
size: 10, 10
|
size: 10, 10
|
||||||
orig: 10, 10
|
orig: 10, 10
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
tree-plus
|
tree-plus
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 205, 28
|
xy: 634, 74
|
||||||
size: 12, 16
|
size: 12, 16
|
||||||
orig: 12, 16
|
orig: 12, 16
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
tree-selection
|
tree-selection
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 645, 87
|
xy: 164, 32
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
vis-check-down
|
|
||||||
rotate: false
|
|
||||||
xy: 275, 56
|
|
||||||
size: 28, 28
|
|
||||||
orig: 28, 28
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-check-tick
|
|
||||||
rotate: false
|
|
||||||
xy: 245, 33
|
|
||||||
size: 19, 19
|
|
||||||
orig: 19, 19
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-check-tick-disabled
|
|
||||||
rotate: false
|
|
||||||
xy: 624, 71
|
|
||||||
size: 19, 19
|
|
||||||
orig: 19, 19
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-radio-down
|
|
||||||
rotate: false
|
|
||||||
xy: 305, 56
|
|
||||||
size: 28, 28
|
|
||||||
orig: 28, 28
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-radio-over
|
|
||||||
rotate: false
|
|
||||||
xy: 138, 12
|
|
||||||
size: 28, 28
|
|
||||||
orig: 28, 28
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-radio-tick
|
|
||||||
rotate: false
|
|
||||||
xy: 624, 55
|
|
||||||
size: 14, 14
|
|
||||||
orig: 14, 14
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-radio-tick-disabled
|
|
||||||
rotate: false
|
|
||||||
xy: 276, 40
|
|
||||||
size: 14, 14
|
|
||||||
orig: 14, 14
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
vis-red
|
|
||||||
rotate: false
|
|
||||||
xy: 340, 80
|
|
||||||
size: 1, 1
|
|
||||||
orig: 1, 1
|
|
||||||
offset: 0, 0
|
|
||||||
index: -1
|
|
||||||
white
|
white
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 969, 81
|
xy: 335, 78
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -1021,7 +961,7 @@ window
|
|||||||
index: -1
|
index: -1
|
||||||
window-border-bg
|
window-border-bg
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 676, 69
|
xy: 246, 41
|
||||||
size: 3, 3
|
size: 3, 3
|
||||||
split: 1, 1, 1, 1
|
split: 1, 1, 1, 1
|
||||||
orig: 3, 3
|
orig: 3, 3
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
|
|||||||
default: {down: button-down, up: button },
|
default: {down: button-down, up: button },
|
||||||
blue: {down: button-blue-down, up: button-blue },
|
blue: {down: button-blue-down, up: button-blue },
|
||||||
toggle: {checked: button-down, down: button-down, up: button },
|
toggle: {checked: button-down, down: button-down, up: button },
|
||||||
|
togglemap: {checked: button-map-down, down: button-map-down, up: button-map },
|
||||||
select: {checked: button-select, up: clear },
|
select: {checked: button-select, up: clear },
|
||||||
gray: {down: button-down, up: button-gray, over: button-gray-over, disabled: button},
|
gray: {down: button-down, up: button-gray, over: button-gray-over, disabled: button},
|
||||||
close-window: {up: button, imageUp: icon-close, imageOver: icon-close-over, imageDown: icon-close-down, disabled: button }
|
close-window: {up: button, imageUp: icon-close, imageOver: icon-close-over, imageDown: icon-close-down, disabled: button }
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 19 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
||||||
<module>
|
<module>
|
||||||
<source path="io/anuke/moment" />
|
<source path="io/anuke/mindustry" />
|
||||||
</module>
|
</module>
|
||||||
@@ -1,425 +1,134 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import static io.anuke.mindustry.world.TileType.tilesize;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.Application.ApplicationType;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
|
||||||
import com.badlogic.gdx.math.Vector2;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.gif.GifRecorder;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.world.Generator;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
import io.anuke.mindustry.world.TileType;
|
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.*;
|
import io.anuke.ucore.entities.Entities;
|
||||||
import io.anuke.ucore.graphics.Atlas;
|
import io.anuke.ucore.graphics.Atlas;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
|
||||||
import io.anuke.ucore.modules.RendererModule;
|
import io.anuke.ucore.modules.RendererModule;
|
||||||
import io.anuke.ucore.scene.style.Styles;
|
|
||||||
import io.anuke.ucore.scene.utils.Cursors;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
|
||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class Control extends RendererModule<Moment>{
|
public class Control extends RendererModule{
|
||||||
//GifRecorder recorder = new GifRecorder(batch);
|
public int rangex = 10, rangey = 10;
|
||||||
int rangex = 10, rangey = 10;
|
GifRecorder recoder = new GifRecorder(batch);
|
||||||
float breaktime = 0;
|
|
||||||
float breakdur = 50;
|
public Control(){
|
||||||
|
|
||||||
public Control() {
|
|
||||||
atlas = new Atlas("moment.atlas");
|
|
||||||
cameraScale = 4f;
|
cameraScale = 4f;
|
||||||
setPixelation();
|
setPixelation();
|
||||||
buffers.add("shadow", (int) (Gdx.graphics.getWidth() / cameraScale), (int) (Gdx.graphics.getHeight() / cameraScale));
|
buffers.add("shadow", (int) (Gdx.graphics.getWidth() / cameraScale), (int) (Gdx.graphics.getHeight() / cameraScale));
|
||||||
|
|
||||||
|
atlas = new Atlas("mindustry.atlas");
|
||||||
|
|
||||||
Sounds.load("shoot.wav", "place.wav", "explosion.wav", "enemyshoot.wav", "corexplode.wav", "break.wav", "spawn.wav", "flame.wav");
|
Sounds.load("shoot.wav", "place.wav", "explosion.wav", "enemyshoot.wav", "corexplode.wav", "break.wav", "spawn.wav", "flame.wav");
|
||||||
Musics.load("1.mp3", "2.mp3", "3.mp3");
|
Musics.load("1.mp3", "2.mp3", "3.mp3");
|
||||||
|
|
||||||
|
Generator.loadMaps();
|
||||||
|
|
||||||
|
KeyBinds.defaults(
|
||||||
|
"up", Keys.W,
|
||||||
|
"left", Keys.A,
|
||||||
|
"down", Keys.S,
|
||||||
|
"right", Keys.D,
|
||||||
|
"rotate", Keys.R,
|
||||||
|
"menu", Keys.ESCAPE
|
||||||
|
);
|
||||||
|
|
||||||
|
Settings.loadAll("io.anuke.moment");
|
||||||
|
|
||||||
|
Sounds.setFalloff(9000f);
|
||||||
|
|
||||||
|
player = new Player();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
Musics.shuffleAll();
|
Musics.shuffleAll();
|
||||||
DrawContext.font = Styles.styles.font();
|
|
||||||
|
|
||||||
Entities.initPhysics(0, 0, main.pixsize, main.pixsize);
|
|
||||||
|
|
||||||
Effect.create("place", 16, e -> {
|
|
||||||
Draw.thickness(3f - e.ifract() * 2f);
|
|
||||||
Draw.square(e.x, e.y, TileType.tilesize / 2 + e.ifract() * 3f);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("spark", 10, e -> {
|
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.color(Hue.mix(Color.WHITE, Color.GRAY, e.ifract()));
|
|
||||||
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 8);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("smelt", 10, e -> {
|
Entities.initPhysics(0, 0, pixsize, pixsize);
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.color(Hue.mix(Color.YELLOW, Color.RED, e.ifract()));
|
|
||||||
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 8);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("break", 12, e -> {
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.color(Color.WHITE, Color.GRAY, e.ifract());
|
|
||||||
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 5);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("hit", 10, e -> {
|
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.color(Hue.mix(Color.WHITE, Color.ORANGE, e.ifract()));
|
|
||||||
Draw.spikes(e.x, e.y, e.ifract() * 3f, 2, 8);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("explosion", 15, e -> {
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.color(Hue.mix(Color.ORANGE, Color.GRAY, e.ifract()));
|
|
||||||
Draw.spikes(e.x, e.y, 2f + e.ifract() * 3f, 4, 6);
|
|
||||||
Draw.circle(e.x, e.y, 3f + e.ifract() * 3f);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("coreexplosion", 13, e -> {
|
Entities.setCollider(tilesize, (x, y)->{
|
||||||
Draw.thickness(3f-e.ifract()*2f);
|
return World.solid(x, y);
|
||||||
Draw.color(Hue.mix(Color.ORANGE, Color.WHITE, e.ifract()));
|
|
||||||
Draw.spikes(e.x, e.y, 5f + e.ifract() * 40f, 6, 6);
|
|
||||||
Draw.circle(e.x, e.y, 4f + e.ifract() * 40f);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("spawn", 23, e -> {
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.color(Hue.mix(Color.DARK_GRAY, Color.SCARLET, e.ifract()));
|
|
||||||
Draw.circle(e.x, e.y, 7f - e.ifract() * 6f);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect.create("ind", 100, e -> {
|
EffectLoader.create();
|
||||||
Draw.thickness(3f);
|
|
||||||
Draw.color("royal");
|
|
||||||
Draw.circle(e.x, e.y, 3);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Effect.create("respawn", main.respawntime, e -> {
|
|
||||||
Draw.tcolor(Color.SCARLET);
|
|
||||||
Draw.tscl(0.25f);
|
|
||||||
Draw.text("Respawning in " + (int)((e.lifetime-e.time)/60), e.x, e.y);
|
|
||||||
Draw.tscl(0.5f);
|
|
||||||
Draw.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
Pathfind.updatePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryMove(SolidEntity e, float x, float y){
|
|
||||||
e.getBoundingBox(Rectangle.tmp);
|
|
||||||
Rectangle.tmp.setSize(4);
|
|
||||||
|
|
||||||
if(!overlaps(Rectangle.tmp, e.x + x, e.y)){
|
|
||||||
e.x += x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!overlaps(Rectangle.tmp, e.x, e.y + y)){
|
|
||||||
e.y += y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean overlaps(Rectangle rect, float x, float y){
|
|
||||||
int r = 1;
|
|
||||||
rect.setCenter(x, y);
|
|
||||||
int tilex = Mathf.scl2(x, tilesize);
|
|
||||||
int tiley = Mathf.scl2(y, tilesize);
|
|
||||||
|
|
||||||
for(int dx = -r; dx <= r; dx++){
|
|
||||||
for(int dy = -r; dy <= r; dy++){
|
|
||||||
Tile tile = main.tile(tilex + dx, tiley + dy);
|
|
||||||
if(tile != null && tile.block().solid && Rectangle.tmp2.setSize(tilesize).setCenter(tile.worldx(), tile.worldy()).overlaps(rect)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle getRect(int x, int y){
|
|
||||||
return Rectangle.tmp2.setSize(tilesize).setCenter(x * tilesize, y * tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void input(){
|
|
||||||
|
|
||||||
if(Inputs.keyUp("rotate"))
|
|
||||||
main.rotation++;
|
|
||||||
|
|
||||||
main.rotation %= 4;
|
|
||||||
|
|
||||||
if(main.recipe != null && !main.hasItems(main.recipe.requirements)){
|
|
||||||
main.recipe = null;
|
|
||||||
Cursors.restoreCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Inputs.buttonUp(Buttons.LEFT) && main.recipe != null && validPlace(tilex(), tiley(), main.recipe.result) && !get(UI.class).hasMouse()){
|
|
||||||
Tile tile = main.tile(tilex(), tiley());
|
|
||||||
if(tile == null)
|
|
||||||
return; //just in ase
|
|
||||||
|
|
||||||
tile.setBlock(main.recipe.result);
|
|
||||||
tile.rotation = main.rotation;
|
|
||||||
|
|
||||||
Pathfind.updatePath();
|
|
||||||
|
|
||||||
Effects.effect("place", roundx(), roundy());
|
|
||||||
Effects.shake(2f, 2f);
|
|
||||||
Sounds.play("place");
|
|
||||||
|
|
||||||
for(ItemStack stack : main.recipe.requirements){
|
|
||||||
main.removeItem(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!main.hasItems(main.recipe.requirements)){
|
|
||||||
main.recipe = null;
|
|
||||||
Cursors.restoreCursor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(main.recipe != null && Inputs.buttonUp(Buttons.RIGHT)){
|
|
||||||
main.recipe = null;
|
|
||||||
Cursors.restoreCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
//block breaking
|
|
||||||
if(Inputs.buttonDown(Buttons.RIGHT) && cursorNear() && main.tile(tilex(), tiley()).artifical()
|
|
||||||
&& main.tile(tilex(), tiley()).block() != TileType.core){
|
|
||||||
Tile tile = main.tile(tilex(), tiley());
|
|
||||||
breaktime += delta();
|
|
||||||
if(breaktime >= breakdur){
|
|
||||||
Effects.effect("break", tile.entity);
|
|
||||||
Effects.shake(3f, 1f);
|
|
||||||
tile.setBlock(TileType.air);
|
|
||||||
Pathfind.updatePath();
|
|
||||||
breaktime = 0f;
|
|
||||||
Sounds.play("break");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
breaktime = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
float roundx(){
|
|
||||||
return Mathf.round2(Graphics.mouseWorld().x, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
float roundy(){
|
|
||||||
return Mathf.round2(Graphics.mouseWorld().y, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tilex(){
|
|
||||||
return Mathf.scl2(Graphics.mouseWorld().x, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tiley(){
|
|
||||||
return Mathf.scl2(Graphics.mouseWorld().y, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean validPlace(int x, int y, TileType type){
|
|
||||||
|
|
||||||
if(!cursorNear())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(Tile spawn : main.spawnpoints){
|
|
||||||
if(Vector2.dst(x * tilesize, y * tilesize, spawn.worldx(), spawn.worldy()) < main.spawnspace){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(SolidEntity e : Entities.getNearby(x * tilesize, y * tilesize, tilesize * 2f)){
|
|
||||||
Rectangle.tmp.setSize(e.hitsize);
|
|
||||||
Rectangle.tmp.setCenter(e.x, e.y);
|
|
||||||
|
|
||||||
if(getRect(x, y).overlaps(Rectangle.tmp)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return main.tile(x, y).block() == TileType.air;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean cursorNear(){
|
|
||||||
return Vector2.dst(main.player.x, main.player.y, tilex() * tilesize, tiley() * tilesize) <= main.placerange;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(Gdx.input.isKeyJustPressed(Keys.ESCAPE) && Gdx.app.getType() == ApplicationType.Desktop)
|
if(Inputs.keyUp(Keys.ESCAPE) && debug)
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
|
|
||||||
if(!main.playing){
|
if(Inputs.keyUp(Keys.SPACE) && debug)
|
||||||
|
Effects.sound("shoot", core.worldx(), core.worldy());
|
||||||
|
|
||||||
|
if(!playing){
|
||||||
clearScreen();
|
clearScreen();
|
||||||
return;
|
}else{
|
||||||
|
|
||||||
|
if(Inputs.keyUp("menu")){
|
||||||
|
if(paused){
|
||||||
|
ui.hideMenu();
|
||||||
|
paused = false;
|
||||||
|
}else{
|
||||||
|
ui.showMenu();
|
||||||
|
paused = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!paused){
|
||||||
|
|
||||||
|
if(enemies <= 0)
|
||||||
|
wavetime -= delta();
|
||||||
|
|
||||||
|
if(wavetime <= 0){
|
||||||
|
GameState.runWave();
|
||||||
|
}
|
||||||
|
|
||||||
|
Entities.update();
|
||||||
|
|
||||||
|
Input.doInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(core.block() == ProductionBlocks.core)
|
||||||
|
camera.position.set(player.x, player.y, 0f);
|
||||||
|
else
|
||||||
|
camera.position.set(core.worldx(), core.worldy(), 0f);
|
||||||
|
|
||||||
|
updateShake();
|
||||||
|
clampCamera(-tilesize / 2f, -tilesize / 2f, pixsize - tilesize / 2f, pixsize - tilesize / 2f);
|
||||||
|
|
||||||
|
drawDefault();
|
||||||
|
|
||||||
|
batch.setProjectionMatrix(control.camera.combined);
|
||||||
|
batch.begin();
|
||||||
|
Renderer.renderOverlay();
|
||||||
|
batch.end();
|
||||||
|
|
||||||
|
recoder.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!main.paused)
|
if(!paused){
|
||||||
Entities.update();
|
Inputs.update();
|
||||||
|
Timers.update(Gdx.graphics.getDeltaTime()*60f);
|
||||||
input();
|
}
|
||||||
|
|
||||||
if(main.core.block() == TileType.core)
|
|
||||||
camera.position.set(main.player.x, main.player.y, 0f);
|
|
||||||
else
|
|
||||||
camera.position.set(main.core.worldx(), main.core.worldy(), 0f);
|
|
||||||
|
|
||||||
clampCamera(-tilesize / 2f, -tilesize / 2f, main.pixsize - tilesize / 2f, main.pixsize - tilesize / 2f);
|
|
||||||
|
|
||||||
drawDefault();
|
|
||||||
|
|
||||||
//recorder.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.clear();
|
Renderer.renderTiles();
|
||||||
|
|
||||||
for(int l = 0; l < 4; l++){
|
|
||||||
if(l == 1){
|
|
||||||
batch.end();
|
|
||||||
buffers.end("pixel");
|
|
||||||
|
|
||||||
buffers.begin("shadow");
|
|
||||||
|
|
||||||
batch.begin();
|
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 0);
|
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
||||||
}
|
|
||||||
for(int x = -rangex; x <= rangex; x++){
|
|
||||||
for(int y = -rangey; y <= rangey; y++){
|
|
||||||
int worldx = Mathf.scl(camera.position.x, tilesize) + x;
|
|
||||||
int worldy = Mathf.scl(camera.position.y, tilesize) + y;
|
|
||||||
|
|
||||||
if(Mathf.inBounds(worldx, worldy, main.tiles)){
|
|
||||||
Tile tile = main.tiles[worldx][worldy];
|
|
||||||
if(l == 1){
|
|
||||||
if(tile.block() != TileType.air)
|
|
||||||
Draw.rect("shadow", worldx * tilesize, worldy * tilesize);
|
|
||||||
}else if(l == 0 || l == 2){
|
|
||||||
(l == 0 ? tile.floor() : tile.block()).draw(tile);
|
|
||||||
}else{
|
|
||||||
tile.block().drawOver(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(l == 1){
|
|
||||||
batch.end();
|
|
||||||
buffers.end("shadow");
|
|
||||||
batch.setColor(0, 0, 0, 0.15f);
|
|
||||||
|
|
||||||
buffers.begin("pixel");
|
|
||||||
|
|
||||||
drawFull("shadow");
|
|
||||||
batch.setColor(Color.WHITE);
|
|
||||||
batch.setProjectionMatrix(camera.combined);
|
|
||||||
|
|
||||||
batch.begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Entities.draw();
|
Entities.draw();
|
||||||
|
Renderer.renderPixelOverlay();
|
||||||
if(main.recipe != null && !get(UI.class).hasMouse()){
|
|
||||||
float x = Mathf.round2(Graphics.mouseWorld().x, tilesize);
|
|
||||||
float y = Mathf.round2(Graphics.mouseWorld().y, tilesize);
|
|
||||||
|
|
||||||
boolean valid = validPlace(tilex(), tiley(), main.recipe.result);
|
|
||||||
|
|
||||||
Draw.color(valid ? Color.PURPLE : Color.SCARLET);
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.square(x, y, TileType.tilesize / 2 + MathUtils.sin(Timers.time() / 6f) + 1);
|
|
||||||
|
|
||||||
if(main.recipe.result.rotate){
|
|
||||||
Draw.color("orange");
|
|
||||||
vector.set(7, 0).rotate(main.rotation * 90);
|
|
||||||
Draw.line(x, y, x + vector.x, y + vector.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.color("scarlet");
|
|
||||||
for(Tile spawn : main.spawnpoints){
|
|
||||||
Draw.dashcircle(spawn.worldx(), spawn.worldy(), main.spawnspace);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(valid)
|
|
||||||
Cursors.setHand();
|
|
||||||
else
|
|
||||||
Cursors.restoreCursor();
|
|
||||||
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//block breaking
|
|
||||||
if(Inputs.buttonDown(Buttons.RIGHT) && cursorNear()){
|
|
||||||
Tile tile = main.tile(tilex(), tiley());
|
|
||||||
if(tile.artifical() && tile.block() != TileType.core){
|
|
||||||
Draw.color(Color.YELLOW, Color.SCARLET, breaktime / breakdur);
|
|
||||||
Draw.square(tile.worldx(), tile.worldy(), 4);
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(main.recipe == null && !get(UI.class).hasMouse()){
|
|
||||||
Tile tile = main.tiles[tilex()][tiley()];
|
|
||||||
|
|
||||||
if(tile.block() != TileType.air){
|
|
||||||
if(tile.block().name().contains("turret")){
|
|
||||||
Draw.color("green");
|
|
||||||
Draw.dashcircle(tile.worldx(), tile.worldy(), tile.block().range);
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
if(tile.entity != null)
|
|
||||||
drawHealth(tile.entity.x, tile.entity.y, tile.entity.health, tile.entity.maxhealth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Entity entity : Entities.all()){
|
|
||||||
if(entity instanceof DestructibleEntity && !(entity instanceof TileEntity)){
|
|
||||||
DestructibleEntity dest = ((DestructibleEntity) entity);
|
|
||||||
|
|
||||||
drawHealth(dest.x, dest.y, dest.health, dest.maxhealth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Draw.text(Gdx.graphics.getFramesPerSecond() + " FPS", main.player.x, main.player.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawHealth(float x, float y, float health, float maxhealth){
|
|
||||||
float len = 3;
|
|
||||||
float offset = 7;
|
|
||||||
|
|
||||||
Draw.thickness(3f);
|
|
||||||
Draw.color(Color.GRAY);
|
|
||||||
Draw.line(x - len + 1, y - offset, x + len + 1, y - offset);
|
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.color(Color.BLACK);
|
|
||||||
Draw.line(x - len + 1, y - offset, x + len, y - offset);
|
|
||||||
Draw.color(Color.RED);
|
|
||||||
Draw.line(x - len + 1, y - offset, x - len + (int)(len * 2 * ((float) health / maxhealth)), y - offset);
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height){
|
public void resize(int width, int height){
|
||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
|
|||||||
87
core/src/io/anuke/mindustry/EffectLoader.java
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.entities.Effect;
|
||||||
|
import io.anuke.ucore.graphics.Hue;
|
||||||
|
|
||||||
|
public class EffectLoader{
|
||||||
|
|
||||||
|
public static void create(){
|
||||||
|
|
||||||
|
Effect.create("place", 16, e -> {
|
||||||
|
Draw.thickness(3f - e.ifract() * 2f);
|
||||||
|
Draw.square(e.x, e.y, tilesize / 2f + e.ifract() * 3f);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("spark", 10, e -> {
|
||||||
|
Draw.thickness(1f);
|
||||||
|
Draw.color(Hue.mix(Color.WHITE, Color.GRAY, e.ifract()));
|
||||||
|
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 8);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("smelt", 10, e -> {
|
||||||
|
Draw.thickness(1f);
|
||||||
|
Draw.color(Hue.mix(Color.YELLOW, Color.RED, e.ifract()));
|
||||||
|
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 8);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("break", 12, e -> {
|
||||||
|
Draw.thickness(2f);
|
||||||
|
Draw.color(Color.WHITE, Color.GRAY, e.ifract());
|
||||||
|
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 5);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("hit", 10, e -> {
|
||||||
|
Draw.thickness(1f);
|
||||||
|
Draw.color(Hue.mix(Color.WHITE, Color.ORANGE, e.ifract()));
|
||||||
|
Draw.spikes(e.x, e.y, e.ifract() * 3f, 2, 8);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("explosion", 15, e -> {
|
||||||
|
Draw.thickness(2f);
|
||||||
|
Draw.color(Hue.mix(Color.ORANGE, Color.GRAY, e.ifract()));
|
||||||
|
Draw.spikes(e.x, e.y, 2f + e.ifract() * 3f, 4, 6);
|
||||||
|
Draw.circle(e.x, e.y, 3f + e.ifract() * 3f);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("coreexplosion", 13, e -> {
|
||||||
|
Draw.thickness(3f-e.ifract()*2f);
|
||||||
|
Draw.color(Hue.mix(Color.ORANGE, Color.WHITE, e.ifract()));
|
||||||
|
Draw.spikes(e.x, e.y, 5f + e.ifract() * 40f, 6, 6);
|
||||||
|
Draw.circle(e.x, e.y, 4f + e.ifract() * 40f);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("spawn", 23, e -> {
|
||||||
|
Draw.thickness(2f);
|
||||||
|
Draw.color(Hue.mix(Color.DARK_GRAY, Color.SCARLET, e.ifract()));
|
||||||
|
Draw.circle(e.x, e.y, 7f - e.ifract() * 6f);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("ind", 100, e -> {
|
||||||
|
Draw.thickness(3f);
|
||||||
|
Draw.color("royal");
|
||||||
|
Draw.circle(e.x, e.y, 3);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
Effect.create("respawn", respawntime, e -> {
|
||||||
|
Draw.tcolor(Color.SCARLET);
|
||||||
|
Draw.tscl(0.25f);
|
||||||
|
Draw.text("Respawning in " + (int)((e.lifetime-e.time)/60), e.x, e.y);
|
||||||
|
Draw.tscl(0.5f);
|
||||||
|
Draw.clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
106
core/src/io/anuke/mindustry/GameState.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.*;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.core.Settings;
|
||||||
|
import io.anuke.ucore.core.Sounds;
|
||||||
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class GameState{
|
||||||
|
|
||||||
|
public static void reset(){
|
||||||
|
wave = 1;
|
||||||
|
wavetime = waveSpacing();
|
||||||
|
Entities.clear();
|
||||||
|
enemies = 0;
|
||||||
|
player.add();
|
||||||
|
player.heal();
|
||||||
|
Inventory.clearItems();
|
||||||
|
spawnpoints.clear();
|
||||||
|
|
||||||
|
ui.updateItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void play(){
|
||||||
|
player.x = core.worldx();
|
||||||
|
player.y = core.worldy()-8;
|
||||||
|
|
||||||
|
wavetime = waveSpacing();
|
||||||
|
|
||||||
|
if(showedTutorial || !Settings.getBool("tutorial")){
|
||||||
|
playing = true;
|
||||||
|
paused = false;
|
||||||
|
}else{
|
||||||
|
playing = true;
|
||||||
|
paused = true;
|
||||||
|
ui.showTutorial();
|
||||||
|
showedTutorial = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runWave(){
|
||||||
|
int amount = wave;
|
||||||
|
Sounds.play("spawn");
|
||||||
|
|
||||||
|
for(int i = 0; i < amount; i ++){
|
||||||
|
int pos = i;
|
||||||
|
|
||||||
|
for(int w = 0; w < spawnpoints.size; w ++){
|
||||||
|
int point = w;
|
||||||
|
Tile tile = spawnpoints.get(w);
|
||||||
|
|
||||||
|
Timers.run(i*30f, ()->{
|
||||||
|
|
||||||
|
Enemy enemy = null;
|
||||||
|
|
||||||
|
if(wave%5 == 0 /*&& point == 1 */&& pos == 0){
|
||||||
|
enemy = new BossEnemy(point);
|
||||||
|
}else if(wave > 3 && pos < amount/2){
|
||||||
|
enemy = new FastEnemy(point);
|
||||||
|
}else if(wave > 8 && pos % 3 == 0 && wave%2==1){
|
||||||
|
enemy = new FlameEnemy(point);
|
||||||
|
}else{
|
||||||
|
enemy = new Enemy(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
enemy.set(tile.worldx(), tile.worldy());
|
||||||
|
Effects.effect("spawn", enemy);
|
||||||
|
enemy.add();
|
||||||
|
});
|
||||||
|
|
||||||
|
enemies ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wave ++;
|
||||||
|
|
||||||
|
wavetime = waveSpacing();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void coreDestroyed(){
|
||||||
|
Effects.shake(5, 6);
|
||||||
|
Sounds.play("corexplode");
|
||||||
|
for(int i = 0; i < 16; i ++){
|
||||||
|
Timers.run(i*2, ()->{
|
||||||
|
Effects.effect("explosion", core.worldx()+Mathf.range(40), core.worldy()+Mathf.range(40));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
Effects.effect("coreexplosion", core.worldx(), core.worldy());
|
||||||
|
|
||||||
|
Timers.run(60, ()->{
|
||||||
|
ui.showRestart();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float waveSpacing(){
|
||||||
|
int scale = Settings.getInt("difficulty");
|
||||||
|
float out = (scale == 0 ? 2f : scale == 1f ? 1f : 0.5f);
|
||||||
|
return wavespace*out;
|
||||||
|
}
|
||||||
|
}
|
||||||
87
core/src/io/anuke/mindustry/Input.java
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.core.Inputs;
|
||||||
|
import io.anuke.ucore.core.Sounds;
|
||||||
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
public class Input{
|
||||||
|
|
||||||
|
public static void doInput(){
|
||||||
|
|
||||||
|
//player is dead
|
||||||
|
if(player.health <= 0) return;
|
||||||
|
|
||||||
|
if(Inputs.keyUp("rotate"))
|
||||||
|
rotation++;
|
||||||
|
|
||||||
|
rotation %= 4;
|
||||||
|
|
||||||
|
if(recipe != null && !Inventory.hasItems(recipe.requirements)){
|
||||||
|
recipe = null;
|
||||||
|
Cursors.restoreCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(Inputs.buttonUp(Buttons.LEFT) && recipe != null &&
|
||||||
|
World.validPlace(World.tilex(), World.tiley(), recipe.result) && !ui.hasMouse()){
|
||||||
|
Tile tile = World.tile(World.tilex(), World.tiley());
|
||||||
|
|
||||||
|
if(tile == null)
|
||||||
|
return; //just in case
|
||||||
|
|
||||||
|
tile.setBlock(recipe.result);
|
||||||
|
tile.rotation = rotation;
|
||||||
|
|
||||||
|
Pathfind.updatePath();
|
||||||
|
|
||||||
|
Effects.effect("place", World.roundx(), World.roundy());
|
||||||
|
Effects.shake(2f, 2f);
|
||||||
|
Sounds.play("place");
|
||||||
|
|
||||||
|
for(ItemStack stack : recipe.requirements){
|
||||||
|
Inventory.removeItem(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Inventory.hasItems(recipe.requirements)){
|
||||||
|
recipe = null;
|
||||||
|
Cursors.restoreCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(recipe != null && Inputs.buttonUp(Buttons.RIGHT)){
|
||||||
|
recipe = null;
|
||||||
|
Cursors.restoreCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
Tile cursor = World.cursorTile();
|
||||||
|
|
||||||
|
//block breaking
|
||||||
|
if(Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear() && cursor.artifical()
|
||||||
|
&& cursor.block() != ProductionBlocks.core){
|
||||||
|
Tile tile = cursor;
|
||||||
|
breaktime += Mathf.delta();
|
||||||
|
if(breaktime >= breakduration){
|
||||||
|
Effects.effect("break", tile.entity);
|
||||||
|
Effects.shake(3f, 1f);
|
||||||
|
tile.setBlock(Blocks.air);
|
||||||
|
Pathfind.updatePath();
|
||||||
|
breaktime = 0f;
|
||||||
|
Sounds.play("break");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
breaktime = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
42
core/src/io/anuke/mindustry/Inventory.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
|
|
||||||
|
public class Inventory{
|
||||||
|
|
||||||
|
public static void clearItems(){
|
||||||
|
items.clear();
|
||||||
|
//TODO make this not hardcoded
|
||||||
|
items.put(Item.stone, 40);
|
||||||
|
|
||||||
|
if(debug){
|
||||||
|
items.put(Item.stone, 2000);
|
||||||
|
items.put(Item.iron, 2000);
|
||||||
|
items.put(Item.steel, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addItem(Item item, int amount){
|
||||||
|
items.put(item, items.get(item, 0)+amount);
|
||||||
|
ui.updateItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasItems(ItemStack[] items){
|
||||||
|
for(ItemStack stack : items)
|
||||||
|
if(!hasItem(stack))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasItem(ItemStack req){
|
||||||
|
return items.get(req.item, 0) >= req.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeItem(ItemStack req){
|
||||||
|
items.put(req.item, items.get(req.item, 0)-req.amount);
|
||||||
|
ui.updateItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
core/src/io/anuke/mindustry/Mindustry.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import io.anuke.ucore.modules.Core;
|
||||||
|
|
||||||
|
public class Mindustry extends Core {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(){
|
||||||
|
add(Vars.control = new Control());
|
||||||
|
add(Vars.ui = new UI());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postInit(){
|
||||||
|
GameState.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,252 +0,0 @@
|
|||||||
package io.anuke.mindustry;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
|
||||||
import io.anuke.mindustry.entities.*;
|
|
||||||
import io.anuke.mindustry.resource.Item;
|
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
|
||||||
import io.anuke.mindustry.world.Generator;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.mindustry.world.TileType;
|
|
||||||
import io.anuke.ucore.core.*;
|
|
||||||
import io.anuke.ucore.entities.Entities;
|
|
||||||
import io.anuke.ucore.modules.ModuleController;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
|
||||||
import io.anuke.ucore.util.Timers;
|
|
||||||
|
|
||||||
public class Moment extends ModuleController<Moment>{
|
|
||||||
public static Moment i;
|
|
||||||
public Player player;
|
|
||||||
public int size = 128;
|
|
||||||
public int pixsize = size*TileType.tilesize;
|
|
||||||
public Tile[][] tiles = new Tile[size][size];
|
|
||||||
public ObjectMap<Item, Integer> items = new ObjectMap<>();
|
|
||||||
public Recipe recipe;
|
|
||||||
public int rotation;
|
|
||||||
public float placerange = 60;
|
|
||||||
public float respawntime = 60*5;
|
|
||||||
|
|
||||||
public int wave = 1;
|
|
||||||
public float wavespace = 35*60;
|
|
||||||
public float wavetime;
|
|
||||||
public float spawnspace = 65;
|
|
||||||
public Tile core;
|
|
||||||
public Array<Tile> spawnpoints = new Array<Tile>();
|
|
||||||
|
|
||||||
public boolean playing = false;
|
|
||||||
public boolean paused = false;
|
|
||||||
public boolean showedTutorial = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(){
|
|
||||||
i = this;
|
|
||||||
|
|
||||||
addModule(new Control());
|
|
||||||
addModule(new UI());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void preInit(){
|
|
||||||
KeyBinds.defaults(
|
|
||||||
"up", Keys.W,
|
|
||||||
"left", Keys.A,
|
|
||||||
"down", Keys.S,
|
|
||||||
"right", Keys.D,
|
|
||||||
"rotate", Keys.R,
|
|
||||||
"menu", Keys.ESCAPE
|
|
||||||
);
|
|
||||||
|
|
||||||
Settings.loadAll("io.anuke.moment");
|
|
||||||
|
|
||||||
for(int x = 0; x < size; x ++){
|
|
||||||
for(int y = 0; y < size; y ++){
|
|
||||||
tiles[x][y] = new Tile(x, y, TileType.grass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player = new Player();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postInit(){
|
|
||||||
restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(){
|
|
||||||
if(!paused)
|
|
||||||
super.update();
|
|
||||||
|
|
||||||
if(!playing || paused) return;
|
|
||||||
|
|
||||||
//if(UInput.keyUp(Keys.Q))
|
|
||||||
// System.out.println("Enemies: " + Enemy.amount + " Wavetime: " + wavetime + " Wave: " + wave + " Wavespace: " + wavespace);
|
|
||||||
|
|
||||||
//System.out.println(Enemy.amount);
|
|
||||||
if(Enemy.amount <= 0)
|
|
||||||
wavetime -= delta();
|
|
||||||
|
|
||||||
if(wavetime <= 0/* || UInput.keyUp(Keys.Q)*/){
|
|
||||||
runWave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void play(){
|
|
||||||
wavetime = waveSpacing();
|
|
||||||
|
|
||||||
if(showedTutorial){
|
|
||||||
playing = true;
|
|
||||||
paused = false;
|
|
||||||
}else{
|
|
||||||
playing = true;
|
|
||||||
paused = true;
|
|
||||||
get(UI.class).tutorial.show(get(UI.class).scene);
|
|
||||||
showedTutorial = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restart(){
|
|
||||||
wave = 1;
|
|
||||||
wavetime = waveSpacing();
|
|
||||||
Entities.clear();
|
|
||||||
Enemy.amount = 0;
|
|
||||||
player.add();
|
|
||||||
player.heal();
|
|
||||||
items.clear();
|
|
||||||
generate();
|
|
||||||
|
|
||||||
player.x = core.worldx();
|
|
||||||
player.y = core.worldy()-8;
|
|
||||||
|
|
||||||
items.put(Item.stone, 20);
|
|
||||||
|
|
||||||
//items.put(Item.stone, 2000);
|
|
||||||
//items.put(Item.iron, 2000);
|
|
||||||
//items.put(Item.steel, 2000);
|
|
||||||
|
|
||||||
if(get(UI.class).about != null)
|
|
||||||
get(UI.class).updateItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void coreDestroyed(){
|
|
||||||
Effects.shake(5, 6);
|
|
||||||
Sounds.play("corexplode");
|
|
||||||
for(int i = 0; i < 16; i ++){
|
|
||||||
Timers.run(i*2, ()->{
|
|
||||||
Effects.effect("explosion", core.worldx()+Mathf.range(40), core.worldy()+Mathf.range(40));
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
Effects.effect("coreexplosion", core.worldx(), core.worldy());
|
|
||||||
|
|
||||||
Timers.run(60, ()->{
|
|
||||||
getModule(UI.class).showRestart();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate(){
|
|
||||||
spawnpoints.clear();
|
|
||||||
Pathfind.reset();
|
|
||||||
Generator.generate(tiles, "map");
|
|
||||||
Pathfind.updatePath();
|
|
||||||
core.setBlock(TileType.core);
|
|
||||||
int x = core.x, y = core.y;
|
|
||||||
|
|
||||||
set(x, y-1, TileType.conveyor, 1);
|
|
||||||
set(x, y-2, TileType.conveyor, 1);
|
|
||||||
set(x, y-3, TileType.conveyor, 1);
|
|
||||||
set(x, y-4, TileType.stonedrill, 0);
|
|
||||||
//just in case
|
|
||||||
tiles[x][y-4].setFloor(TileType.stone);
|
|
||||||
|
|
||||||
|
|
||||||
tiles[x+2][y-2].setFloor(TileType.stone);
|
|
||||||
set(x+2, y-2, TileType.stonedrill, 0);
|
|
||||||
set(x+2, y-1, TileType.conveyor, 1);
|
|
||||||
set(x+2, y, TileType.turret, 0);
|
|
||||||
|
|
||||||
tiles[x-2][y-2].setFloor(TileType.stone);
|
|
||||||
set(x-2, y-2, TileType.stonedrill, 0);
|
|
||||||
set(x-2, y-1, TileType.conveyor, 1);
|
|
||||||
set(x-2, y, TileType.turret, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(int x, int y, TileType type, int rot){
|
|
||||||
tiles[x][y].setBlock(type);
|
|
||||||
tiles[x][y].rotation = rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runWave(){
|
|
||||||
int amount = wave;
|
|
||||||
Sounds.play("spawn");
|
|
||||||
|
|
||||||
for(int i = 0; i < amount; i ++){
|
|
||||||
int pos = i;
|
|
||||||
|
|
||||||
for(int w = 0; w < spawnpoints.size; w ++){
|
|
||||||
int point = w;
|
|
||||||
Tile tile = spawnpoints.get(w);
|
|
||||||
|
|
||||||
Timers.run(i*30f, ()->{
|
|
||||||
|
|
||||||
Enemy enemy = null;
|
|
||||||
|
|
||||||
if(wave%5 == 0 /*&& point == 1 */&& pos == 0){
|
|
||||||
enemy = new BossEnemy(point);
|
|
||||||
}else if(wave > 3 && pos < amount/2){
|
|
||||||
enemy = new FastEnemy(point);
|
|
||||||
}else if(wave > 8 && pos % 3 == 0 && wave%2==1){
|
|
||||||
enemy = new FlameEnemy(point);
|
|
||||||
}else{
|
|
||||||
enemy = new Enemy(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
enemy.set(tile.worldx(), tile.worldy());
|
|
||||||
Effects.effect("spawn", enemy);
|
|
||||||
enemy.add();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wave ++;
|
|
||||||
|
|
||||||
wavetime = waveSpacing();
|
|
||||||
}
|
|
||||||
|
|
||||||
public float waveSpacing(){
|
|
||||||
int scale = Settings.getInt("difficulty");
|
|
||||||
float out = (scale == 0 ? 2f : scale == 1f ? 1f : 0.5f);
|
|
||||||
return wavespace*out;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tile tile(int x, int y){
|
|
||||||
if(!Mathf.inBounds(x, y, tiles)) return null;
|
|
||||||
return tiles[x][y];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addItem(Item item, int amount){
|
|
||||||
items.put(item, items.get(item, 0)+amount);
|
|
||||||
get(UI.class).updateItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasItems(ItemStack[] items){
|
|
||||||
for(ItemStack stack : items)
|
|
||||||
if(!hasItem(stack))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasItem(ItemStack req){
|
|
||||||
return items.get(req.item, 0) >= req.amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeItem(ItemStack req){
|
|
||||||
items.put(req.item, items.get(req.item, 0)-req.amount);
|
|
||||||
get(UI.class).updateItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
172
core/src/io/anuke/mindustry/Renderer.java
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.core.Inputs;
|
||||||
|
import io.anuke.ucore.entities.DestructibleEntity;
|
||||||
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.entities.Entity;
|
||||||
|
import io.anuke.ucore.graphics.FrameBufferMap;
|
||||||
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class Renderer{
|
||||||
|
|
||||||
|
public static void renderTiles(){
|
||||||
|
Draw.clear();
|
||||||
|
Batch batch = control.batch;
|
||||||
|
FrameBufferMap buffers = control.buffers;
|
||||||
|
OrthographicCamera camera = control.camera;
|
||||||
|
int rangex = control.rangex, rangey = control.rangey;
|
||||||
|
|
||||||
|
for(int l = 0; l < 4; l++){
|
||||||
|
if(l == 1){
|
||||||
|
batch.end();
|
||||||
|
buffers.end("pixel");
|
||||||
|
|
||||||
|
buffers.begin("shadow");
|
||||||
|
|
||||||
|
batch.begin();
|
||||||
|
Gdx.gl.glClearColor(0, 0, 0, 0);
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int x = -rangex; x <= rangex; x++){
|
||||||
|
for(int y = -rangey; y <= rangey; y++){
|
||||||
|
int worldx = Mathf.scl(camera.position.x, tilesize) + x;
|
||||||
|
int worldy = Mathf.scl(camera.position.y, tilesize) + y;
|
||||||
|
|
||||||
|
if(Mathf.inBounds(worldx, worldy, tiles)){
|
||||||
|
Tile tile = tiles[worldx][worldy];
|
||||||
|
if(l == 1){
|
||||||
|
if(tile.block() != Blocks.air)
|
||||||
|
Draw.rect("shadow", worldx * tilesize, worldy * tilesize);
|
||||||
|
}else if(l == 0 || l == 2){
|
||||||
|
(l == 0 ? tile.floor() : tile.block()).draw(tile);
|
||||||
|
}else{
|
||||||
|
tile.block().drawOver(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l == 1){
|
||||||
|
batch.end();
|
||||||
|
buffers.end("shadow");
|
||||||
|
batch.setColor(0, 0, 0, 0.15f);
|
||||||
|
|
||||||
|
buffers.begin("pixel");
|
||||||
|
|
||||||
|
control.drawFull("shadow");
|
||||||
|
batch.setColor(Color.WHITE);
|
||||||
|
batch.setProjectionMatrix(camera.combined);
|
||||||
|
|
||||||
|
batch.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderPixelOverlay(){
|
||||||
|
|
||||||
|
if(recipe != null && !ui.hasMouse()){
|
||||||
|
float x = Mathf.round2(Graphics.mouseWorld().x, tilesize);
|
||||||
|
float y = Mathf.round2(Graphics.mouseWorld().y, tilesize);
|
||||||
|
|
||||||
|
boolean valid = World.validPlace(World.tilex(), World.tiley(), recipe.result);
|
||||||
|
|
||||||
|
Draw.color(valid ? Color.PURPLE : Color.SCARLET);
|
||||||
|
Draw.thickness(2f);
|
||||||
|
Draw.square(x, y, tilesize / 2 + MathUtils.sin(Timers.time() / 6f) + 1);
|
||||||
|
|
||||||
|
if(recipe.result.rotate){
|
||||||
|
Draw.color("orange");
|
||||||
|
vector.set(7, 0).rotate(rotation * 90);
|
||||||
|
Draw.line(x, y, x + vector.x, y + vector.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.thickness(1f);
|
||||||
|
Draw.color("scarlet");
|
||||||
|
for(Tile spawn : spawnpoints){
|
||||||
|
Draw.dashcircle(spawn.worldx(), spawn.worldy(), enemyspawnspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(valid)
|
||||||
|
Cursors.setHand();
|
||||||
|
else
|
||||||
|
Cursors.restoreCursor();
|
||||||
|
|
||||||
|
Draw.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//block breaking
|
||||||
|
if(Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear()){
|
||||||
|
Tile tile = World.cursorTile();
|
||||||
|
if(tile.artifical() && tile.block() != ProductionBlocks.core){
|
||||||
|
Draw.color(Color.YELLOW, Color.SCARLET, breaktime / breakduration);
|
||||||
|
Draw.square(tile.worldx(), tile.worldy(), 4);
|
||||||
|
Draw.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(recipe == null && !ui.hasMouse()){
|
||||||
|
Tile tile = World.cursorTile();
|
||||||
|
|
||||||
|
if(tile.block() != Blocks.air){
|
||||||
|
if(tile.entity != null)
|
||||||
|
drawHealth(tile.entity.x, tile.entity.y, tile.entity.health, tile.entity.maxhealth);
|
||||||
|
|
||||||
|
tile.block().drawPixelOverlay(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Entity entity : Entities.all()){
|
||||||
|
if(entity instanceof DestructibleEntity && !(entity instanceof TileEntity)){
|
||||||
|
DestructibleEntity dest = ((DestructibleEntity) entity);
|
||||||
|
|
||||||
|
drawHealth(dest.x, dest.y, dest.health, dest.maxhealth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderOverlay(){
|
||||||
|
|
||||||
|
Tile tile = World.cursorTile();
|
||||||
|
|
||||||
|
if(tile != null && tile.block() != Blocks.air){
|
||||||
|
tile.block().drawOverlay(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawHealth(float x, float y, float health, float maxhealth){
|
||||||
|
float len = 3;
|
||||||
|
float offset = 7;
|
||||||
|
|
||||||
|
float fraction = Mathf.clamp((float) health / maxhealth);
|
||||||
|
|
||||||
|
Draw.thickness(3f);
|
||||||
|
Draw.color(Color.GRAY);
|
||||||
|
Draw.line(x - len + 1, y - offset, x + len + 1, y - offset);
|
||||||
|
Draw.thickness(1f);
|
||||||
|
Draw.color(Color.BLACK);
|
||||||
|
Draw.line(x - len + 1, y - offset, x + len, y - offset);
|
||||||
|
Draw.color(Color.RED);
|
||||||
|
Draw.line(x - len + 1, y - offset, x - len + (int)(len * 2 * fraction), y - offset);
|
||||||
|
Draw.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
import static io.anuke.mindustry.world.TileType.tilesize;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
@@ -9,13 +9,12 @@ import com.badlogic.gdx.graphics.Color;
|
|||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.Texture.TextureWrap;
|
import com.badlogic.gdx.graphics.Texture.TextureWrap;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.Enemy;
|
|
||||||
import io.anuke.mindustry.resource.*;
|
import io.anuke.mindustry.resource.*;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.mindustry.world.TileType;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.core.*;
|
|
||||||
import io.anuke.ucore.modules.SceneModule;
|
import io.anuke.ucore.modules.SceneModule;
|
||||||
import io.anuke.ucore.scene.Scene;
|
import io.anuke.ucore.scene.Scene;
|
||||||
import io.anuke.ucore.scene.builders.*;
|
import io.anuke.ucore.scene.builders.*;
|
||||||
@@ -23,22 +22,22 @@ import io.anuke.ucore.scene.style.Styles;
|
|||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Mathf;
|
|
||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class UI extends SceneModule<Moment>{
|
public class UI extends SceneModule{
|
||||||
Table itemtable;
|
Table itemtable;
|
||||||
SettingsDialog prefs;
|
SettingsDialog prefs;
|
||||||
KeybindDialog keys;
|
KeybindDialog keys;
|
||||||
Dialog about, menu, restart, tutorial;
|
Dialog about, menu, restart, tutorial, levels;
|
||||||
Texture conveyor = new Texture("sprites/conveyor.png"), conveyort = new Texture("sprites/conveyort.png");
|
Texture conveyor = new Texture("sprites/conveyor.png"), conveyort = new Texture("sprites/conveyort.png");
|
||||||
|
int selectedMap = 0;
|
||||||
|
|
||||||
BooleanSupplier play = () -> {
|
BooleanSupplier play = () -> {
|
||||||
return main.playing;
|
return playing;
|
||||||
};
|
};
|
||||||
|
|
||||||
BooleanSupplier nplay = () -> {
|
BooleanSupplier nplay = () -> {
|
||||||
return !main.playing;
|
return !playing;
|
||||||
};
|
};
|
||||||
|
|
||||||
public UI() {
|
public UI() {
|
||||||
@@ -58,6 +57,8 @@ public class UI extends SceneModule<Moment>{
|
|||||||
int w = gwidth();
|
int w = gwidth();
|
||||||
int h = gheight();
|
int h = gheight();
|
||||||
|
|
||||||
|
Draw.color("gray");
|
||||||
|
|
||||||
batch.draw(conveyor, 0, 0, (int)Timers.time(), 0, w, h);
|
batch.draw(conveyor, 0, 0, (int)Timers.time(), 0, w, h);
|
||||||
|
|
||||||
int tw = w/64+1;//, th = h/64+1;
|
int tw = w/64+1;//, th = h/64+1;
|
||||||
@@ -66,8 +67,9 @@ public class UI extends SceneModule<Moment>{
|
|||||||
batch.draw(conveyort, x*64, 0, 0, (int)Timers.time(), 32, h);
|
batch.draw(conveyort, x*64, 0, 0, (int)Timers.time(), 32, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.tscl(1.5f);
|
Draw.color();
|
||||||
|
|
||||||
|
Draw.tscl(1.5f);
|
||||||
|
|
||||||
Draw.text("[DARK_GRAY]-( Mindustry )-", w/2, h-16);
|
Draw.text("[DARK_GRAY]-( Mindustry )-", w/2, h-16);
|
||||||
Draw.text("[#f1de60]-( Mindustry )-", w/2, h-10);
|
Draw.text("[#f1de60]-( Mindustry )-", w/2, h-10);
|
||||||
@@ -78,39 +80,7 @@ public class UI extends SceneModule<Moment>{
|
|||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
if(main.playing){
|
if(!playing){
|
||||||
scene.getBatch().setProjectionMatrix(get(Control.class).camera.combined);
|
|
||||||
scene.getBatch().begin();
|
|
||||||
Tile tile = main.tiles[tilex()][tiley()];
|
|
||||||
if(tile.block() != TileType.air){
|
|
||||||
String error = tile.block().error(tile);
|
|
||||||
if(error != null){
|
|
||||||
Draw.tcolor(Color.SCARLET);
|
|
||||||
Draw.tscl(1 / 8f);
|
|
||||||
Draw.text(error, tile.worldx(), tile.worldy() + tilesize);
|
|
||||||
|
|
||||||
}else if(tile.block().ammo != null){
|
|
||||||
Draw.tscl(1 / 8f);
|
|
||||||
Draw.tcolor(Color.GREEN);
|
|
||||||
Draw.text("Ammo: " + tile.entity.shots, tile.worldx(), tile.worldy() - tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.tscl(0.5f);
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
scene.getBatch().end();
|
|
||||||
|
|
||||||
if(Inputs.keyUp("menu")){
|
|
||||||
if(menu.getScene() != null){
|
|
||||||
menu.hide();
|
|
||||||
main.paused = false;
|
|
||||||
}else{
|
|
||||||
main.paused = true;
|
|
||||||
menu.show(scene);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
scene.getBatch().begin();
|
scene.getBatch().begin();
|
||||||
|
|
||||||
@@ -124,18 +94,43 @@ public class UI extends SceneModule<Moment>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
|
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
||||||
prefs = new SettingsDialog();
|
|
||||||
|
levels = new Dialog("Level Select");
|
||||||
prefs.sliderPref("screenshake", "Screen Shake", 4, 0, 12, i -> {
|
levels.addCloseButton();
|
||||||
return (i / 4f) + "x";
|
levels.getButtonTable().addButton("Play", ()->{
|
||||||
|
levels.hide();
|
||||||
|
World.loadMap(selectedMap);
|
||||||
|
GameState.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for(int i = 0; i < maps.length; i ++){
|
||||||
|
levels.content().add(maps[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
levels.content().row();
|
||||||
|
|
||||||
|
for(int i = 0; i < maps.length; i ++){
|
||||||
|
int index = i;
|
||||||
|
ImageButton image = new ImageButton(new TextureRegion(mapTextures[i]), "togglemap");
|
||||||
|
mapgroup.add(image);
|
||||||
|
image.clicked(()->{
|
||||||
|
selectedMap = index;
|
||||||
|
});
|
||||||
|
image.getImageCell().size(150, 150);
|
||||||
|
levels.content().add(image).size(180);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs = new SettingsDialog();
|
||||||
|
|
||||||
prefs.sliderPref("difficulty", "Difficulty", 1, 0, 2, i -> {
|
prefs.sliderPref("difficulty", "Difficulty", 1, 0, 2, i -> {
|
||||||
return i == 0 ? "Easy" : i == 1 ? "Normal" : "Hard";
|
return i == 0 ? "Easy" : i == 1 ? "Normal" : "Hard";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
prefs.screenshakePref();
|
||||||
|
prefs.volumePrefs();
|
||||||
|
|
||||||
|
prefs.checkPref("tutorial", "Show tutorial Window", true);
|
||||||
prefs.checkPref("fps", "Show FPS", false);
|
prefs.checkPref("fps", "Show FPS", false);
|
||||||
|
|
||||||
keys = new KeybindDialog();
|
keys = new KeybindDialog();
|
||||||
@@ -153,10 +148,11 @@ public class UI extends SceneModule<Moment>{
|
|||||||
@Override
|
@Override
|
||||||
public void hide(){
|
public void hide(){
|
||||||
super.hide();
|
super.hide();
|
||||||
main.playing = true;
|
playing = true;
|
||||||
main.paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tutorial.addCloseButton();
|
tutorial.addCloseButton();
|
||||||
tutorial.getButtonTable().addButton("OK", ()->{
|
tutorial.getButtonTable().addButton("OK", ()->{
|
||||||
tutorial.hide();
|
tutorial.hide();
|
||||||
@@ -176,11 +172,16 @@ public class UI extends SceneModule<Moment>{
|
|||||||
|
|
||||||
tutorial.content().pad(8);
|
tutorial.content().pad(8);
|
||||||
|
|
||||||
|
tutorial.content().row();
|
||||||
|
tutorial.content().addCheck("Don't show again", b->{
|
||||||
|
Settings.putBool("tutorial", !b);
|
||||||
|
}).padTop(4);
|
||||||
|
|
||||||
restart = new Dialog("The core was destroyed.", "dialog"){
|
restart = new Dialog("The core was destroyed.", "dialog"){
|
||||||
public Dialog show(Scene scene){
|
public Dialog show(Scene scene){
|
||||||
super.show(scene);
|
super.show(scene);
|
||||||
restart.content().clearChildren();
|
restart.content().clearChildren();
|
||||||
restart.content().add("You lasted until wave [GREEN]" + main.wave + "[].").pad(6);
|
restart.content().add("You lasted until wave [GREEN]" + wave + "[].").pad(6);
|
||||||
restart.pack();
|
restart.pack();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -188,14 +189,24 @@ public class UI extends SceneModule<Moment>{
|
|||||||
|
|
||||||
restart.getButtonTable().addButton("Back to menu", ()->{
|
restart.getButtonTable().addButton("Back to menu", ()->{
|
||||||
restart.hide();
|
restart.hide();
|
||||||
main.playing = false;
|
playing = false;
|
||||||
main.restart();
|
GameState.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
menu = new Dialog("Paused", "dialog");
|
menu = new Dialog("Paused", "dialog");
|
||||||
menu.content().addButton("Back", ()->{
|
menu.content().addButton("Back", ()->{
|
||||||
menu.hide();
|
menu.hide();
|
||||||
main.paused = false;
|
paused = false;
|
||||||
|
}).width(200);
|
||||||
|
|
||||||
|
menu.content().row();
|
||||||
|
menu.content().addButton("Settings", ()->{
|
||||||
|
prefs.show();
|
||||||
|
}).width(200);
|
||||||
|
|
||||||
|
menu.content().row();
|
||||||
|
menu.content().addButton("Controls", ()->{
|
||||||
|
keys.show();
|
||||||
}).width(200);
|
}).width(200);
|
||||||
|
|
||||||
menu.content().row();
|
menu.content().row();
|
||||||
@@ -210,8 +221,8 @@ public class UI extends SceneModule<Moment>{
|
|||||||
protected void result(Object object){
|
protected void result(Object object){
|
||||||
if(object == Boolean.TRUE){
|
if(object == Boolean.TRUE){
|
||||||
menu.hide();
|
menu.hide();
|
||||||
main.paused = false;
|
paused = false;
|
||||||
main.playing = false;
|
playing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.show(scene);
|
}.show(scene);
|
||||||
@@ -260,8 +271,8 @@ public class UI extends SceneModule<Moment>{
|
|||||||
ImageButton image = new ImageButton(Draw.region(r.result.name()), "select");
|
ImageButton image = new ImageButton(Draw.region(r.result.name()), "select");
|
||||||
|
|
||||||
image.clicked(()->{
|
image.clicked(()->{
|
||||||
if(main.hasItems(r.requirements))
|
if(Inventory.hasItems(r.requirements))
|
||||||
main.recipe = r;
|
recipe = r;
|
||||||
});
|
});
|
||||||
|
|
||||||
table.add(image).size(size+8).pad(4);
|
table.add(image).size(size+8).pad(4);
|
||||||
@@ -269,9 +280,9 @@ public class UI extends SceneModule<Moment>{
|
|||||||
|
|
||||||
image.update(()->{
|
image.update(()->{
|
||||||
|
|
||||||
boolean has = main.hasItems(r.requirements);
|
boolean has = Inventory.hasItems(r.requirements);
|
||||||
image.setDisabled(!has);
|
image.setDisabled(!has);
|
||||||
image.setChecked(main.recipe == r && has);
|
image.setChecked(recipe == r && has);
|
||||||
//image.setTouchable(has ? Touchable.enabled : Touchable.disabled);
|
//image.setTouchable(has ? Touchable.enabled : Touchable.disabled);
|
||||||
image.getImage().setColor(has ? Color.WHITE : Color.GRAY);
|
image.getImage().setColor(has ? Color.WHITE : Color.GRAY);
|
||||||
});
|
});
|
||||||
@@ -287,10 +298,6 @@ public class UI extends SceneModule<Moment>{
|
|||||||
tiptable.clearChildren();
|
tiptable.clearChildren();
|
||||||
|
|
||||||
String description = r.result.description();
|
String description = r.result.description();
|
||||||
if(r.result.ammo != null){
|
|
||||||
description += "\n[SALMON]Ammo: " + r.result.ammo.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tiptable.background("button");
|
tiptable.background("button");
|
||||||
tiptable.add("[PURPLE]" + r.result.name(), 0.75f).left().padBottom(2f);
|
tiptable.add("[PURPLE]" + r.result.name(), 0.75f).left().padBottom(2f);
|
||||||
@@ -298,7 +305,7 @@ public class UI extends SceneModule<Moment>{
|
|||||||
ItemStack[] req = r.requirements;
|
ItemStack[] req = r.requirements;
|
||||||
for(ItemStack s : req){
|
for(ItemStack s : req){
|
||||||
tiptable.row();
|
tiptable.row();
|
||||||
int amount = Math.min(main.items.get(s.item, 0), s.amount);
|
int amount = Math.min(items.get(s.item, 0), s.amount);
|
||||||
tiptable.add(
|
tiptable.add(
|
||||||
(amount >= s.amount ? "[YELLOW]" : "[RED]")
|
(amount >= s.amount ? "[YELLOW]" : "[RED]")
|
||||||
+s.item + ": " + amount + " / " +s.amount, 0.5f).left();
|
+s.item + ": " + amount + " / " +s.amount, 0.5f).left();
|
||||||
@@ -378,7 +385,7 @@ public class UI extends SceneModule<Moment>{
|
|||||||
new label("Wave 1"){{
|
new label("Wave 1"){{
|
||||||
get().setFontScale(1f);
|
get().setFontScale(1f);
|
||||||
get().update(() -> {
|
get().update(() -> {
|
||||||
get().setText("[YELLOW]Wave " + Moment.i.wave);
|
get().setText("[YELLOW]Wave " + wave);
|
||||||
});
|
});
|
||||||
}}.left();
|
}}.left();
|
||||||
|
|
||||||
@@ -386,7 +393,8 @@ public class UI extends SceneModule<Moment>{
|
|||||||
|
|
||||||
new label("Time"){{
|
new label("Time"){{
|
||||||
get().update(() -> {
|
get().update(() -> {
|
||||||
get().setText(Enemy.amount > 0 ? Enemy.amount + " Enemies remaining" : "New wave in " + (int) (main.wavetime / 60f));
|
get().setText(enemies > 0 ?
|
||||||
|
enemies + " Enemies remaining" : "New wave in " + (int) (wavetime / 60f));
|
||||||
});
|
});
|
||||||
}}.minWidth(150);
|
}}.minWidth(150);
|
||||||
|
|
||||||
@@ -401,18 +409,17 @@ public class UI extends SceneModule<Moment>{
|
|||||||
new table(){{
|
new table(){{
|
||||||
aleft();
|
aleft();
|
||||||
abottom();
|
abottom();
|
||||||
Control c = main.get(Control.class);
|
|
||||||
new button("+", ()->{
|
new button("+", ()->{
|
||||||
if(c.cameraScale < 4f){
|
if(control.cameraScale < 4f){
|
||||||
c.cameraScale = 4f;
|
control.cameraScale = 4f;
|
||||||
c.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
control.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
}).size(40);
|
}).size(40);
|
||||||
|
|
||||||
new button("-", ()->{
|
new button("-", ()->{
|
||||||
if(c.cameraScale > 3f){
|
if(control.cameraScale > 3f){
|
||||||
c.cameraScale = 3f;
|
control.cameraScale = 3f;
|
||||||
c.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
control.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
}).size(40);
|
}).size(40);
|
||||||
|
|
||||||
@@ -424,7 +431,7 @@ public class UI extends SceneModule<Moment>{
|
|||||||
float w = 200;
|
float w = 200;
|
||||||
|
|
||||||
new button("Play", () -> {
|
new button("Play", () -> {
|
||||||
main.play();
|
levels.show();
|
||||||
}).width(w);
|
}).width(w);
|
||||||
|
|
||||||
row();
|
row();
|
||||||
@@ -453,36 +460,33 @@ public class UI extends SceneModule<Moment>{
|
|||||||
build.end();
|
build.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showMenu(){
|
||||||
|
menu.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideMenu(){
|
||||||
|
menu.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showTutorial(){
|
||||||
|
tutorial.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void showRestart(){
|
public void showRestart(){
|
||||||
restart.show(scene);
|
restart.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItems(){
|
public void updateItems(){
|
||||||
itemtable.clear();
|
itemtable.clear();
|
||||||
|
|
||||||
for(Item stack : main.items.keys()){
|
for(Item stack : items.keys()){
|
||||||
Image image = new Image(Draw.region("icon-" + stack.name()));
|
Image image = new Image(Draw.region("icon-" + stack.name()));
|
||||||
Label label = new Label("" + main.items.get(stack));
|
Label label = new Label("" + items.get(stack));
|
||||||
label.setFontScale(1f);
|
label.setFontScale(1f);
|
||||||
itemtable.add(image).size(32);
|
itemtable.add(image).size(32);
|
||||||
itemtable.add(label);
|
itemtable.add(label);
|
||||||
itemtable.row();
|
itemtable.row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float roundx(){
|
|
||||||
return Mathf.round2(Graphics.mouseWorld().x, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
float roundy(){
|
|
||||||
return Mathf.round2(Graphics.mouseWorld().y, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tilex(){
|
|
||||||
return Mathf.scl2(Graphics.mouseWorld().x, TileType.tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tiley(){
|
|
||||||
return Mathf.scl2(Graphics.mouseWorld().y, TileType.tilesize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
55
core/src/io/anuke/mindustry/Vars.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.Player;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
|
/**ick, global state*/
|
||||||
|
public class Vars{
|
||||||
|
public static final float placerange = 66;
|
||||||
|
public static final float respawntime = 60*4;
|
||||||
|
public static final float wavespace = 20*60;
|
||||||
|
public static final float enemyspawnspace = 65;
|
||||||
|
public static final float breakduration = 40;
|
||||||
|
public static boolean debug = true;
|
||||||
|
|
||||||
|
public static final Vector2 vector = new Vector2();
|
||||||
|
|
||||||
|
public static final int tilesize = 8;
|
||||||
|
|
||||||
|
public static Control control;
|
||||||
|
public static UI ui;
|
||||||
|
|
||||||
|
public static final ObjectMap<Item, Integer> items = new ObjectMap<>();
|
||||||
|
|
||||||
|
public static Player player;
|
||||||
|
|
||||||
|
public static float breaktime = 0;
|
||||||
|
|
||||||
|
public static final String[] maps = {"delta", "canyon", "pit"};
|
||||||
|
public static Pixmap[] mapPixmaps;
|
||||||
|
public static Texture[] mapTextures;
|
||||||
|
public static int worldsize = 128;
|
||||||
|
public static int pixsize = worldsize*tilesize;
|
||||||
|
public static Tile[][] tiles = new Tile[worldsize][worldsize];
|
||||||
|
public static Recipe recipe;
|
||||||
|
public static int rotation;
|
||||||
|
|
||||||
|
public static int wave = 1;
|
||||||
|
public static float wavetime;
|
||||||
|
public static int enemies = 0;
|
||||||
|
|
||||||
|
public static Tile core;
|
||||||
|
public static Array<Tile> spawnpoints = new Array<Tile>();
|
||||||
|
|
||||||
|
public static boolean playing = false;
|
||||||
|
public static boolean paused = false;
|
||||||
|
public static boolean showedTutorial = false;
|
||||||
|
}
|
||||||
170
core/src/io/anuke/mindustry/World.java
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Generator;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.WeaponBlocks;
|
||||||
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.entities.Entity;
|
||||||
|
import io.anuke.ucore.entities.SolidEntity;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
public class World{
|
||||||
|
private static Tile[] temptiles = new Tile[4];
|
||||||
|
|
||||||
|
public static boolean solid(int x, int y){
|
||||||
|
Tile tile = tile(x, y);
|
||||||
|
|
||||||
|
return tile == null || tile.block().solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Tile tile(int x, int y){
|
||||||
|
if(!Mathf.inBounds(x, y, tiles)) return null;
|
||||||
|
return tiles[x][y];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Tile cursorTile(){
|
||||||
|
return tile(tilex(), tiley());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Tile[] getNearby(int x, int y){
|
||||||
|
temptiles[0] = tile(x+1, y);
|
||||||
|
temptiles[1] = tile(x, y+1);
|
||||||
|
temptiles[2] = tile(x-1, y);
|
||||||
|
temptiles[3] = tile(x, y-1);
|
||||||
|
return temptiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadMap(int id){
|
||||||
|
spawnpoints.clear();
|
||||||
|
|
||||||
|
int size = mapPixmaps[id].getWidth();
|
||||||
|
worldsize = size;
|
||||||
|
pixsize = worldsize*tilesize;
|
||||||
|
tiles = new Tile[worldsize][worldsize];
|
||||||
|
|
||||||
|
for(int x = 0; x < worldsize; x ++){
|
||||||
|
for(int y = 0; y < worldsize; y ++){
|
||||||
|
tiles[x][y] = new Tile(x, y, Blocks.stone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Generator.generate(id);
|
||||||
|
|
||||||
|
Pathfind.reset();
|
||||||
|
|
||||||
|
core.setBlock(ProductionBlocks.core);
|
||||||
|
int x = core.x, y = core.y;
|
||||||
|
|
||||||
|
set(x, y-1, ProductionBlocks.conveyor, 1);
|
||||||
|
set(x, y-2, ProductionBlocks.conveyor, 1);
|
||||||
|
set(x, y-3, ProductionBlocks.conveyor, 1);
|
||||||
|
set(x, y-4, ProductionBlocks.stonedrill, 0);
|
||||||
|
//just in case
|
||||||
|
tiles[x][y-4].setFloor(Blocks.stone);
|
||||||
|
|
||||||
|
|
||||||
|
tiles[x+2][y-2].setFloor(Blocks.stone);
|
||||||
|
set(x+2, y-2, ProductionBlocks.stonedrill, 0);
|
||||||
|
set(x+2, y-1, ProductionBlocks.conveyor, 1);
|
||||||
|
set(x+2, y, WeaponBlocks.turret, 0);
|
||||||
|
|
||||||
|
tiles[x-2][y-2].setFloor(Blocks.stone);
|
||||||
|
set(x-2, y-2, ProductionBlocks.stonedrill, 0);
|
||||||
|
set(x-2, y-1, ProductionBlocks.conveyor, 1);
|
||||||
|
set(x-2, y, WeaponBlocks.turret, 0);
|
||||||
|
|
||||||
|
Pathfind.updatePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set(int x, int y, Block type, int rot){
|
||||||
|
tiles[x][y].setBlock(type);
|
||||||
|
tiles[x][y].rotation = rot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean validPlace(int x, int y, Block type){
|
||||||
|
|
||||||
|
if(!cursorNear())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(Tile spawn : spawnpoints){
|
||||||
|
if(Vector2.dst(x * tilesize, y * tilesize, spawn.worldx(), spawn.worldy()) < enemyspawnspace){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(SolidEntity e : Entities.getNearby(x * tilesize, y * tilesize, tilesize * 2f)){
|
||||||
|
Rectangle.tmp.setSize(e.hitsize);
|
||||||
|
Rectangle.tmp.setCenter(e.x, e.y);
|
||||||
|
|
||||||
|
if(getCollider(x, y).overlaps(Rectangle.tmp)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tile(x, y).block() == Blocks.air;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean cursorNear(){
|
||||||
|
return Vector2.dst(player.x, player.y, tilex() * tilesize, tiley() * tilesize) <= placerange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Rectangle getCollider(int x, int y){
|
||||||
|
return Rectangle.tmp2.setSize(tilesize).setCenter(x * tilesize, y * tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){
|
||||||
|
Entity closest = null;
|
||||||
|
float dst = 0;
|
||||||
|
|
||||||
|
int rad = (int)(range/tilesize)+1;
|
||||||
|
int tilex = Mathf.scl2(x, tilesize);
|
||||||
|
int tiley = Mathf.scl2(y, tilesize);
|
||||||
|
|
||||||
|
for(int rx = -rad; rx <= rad; rx ++){
|
||||||
|
for(int ry = -rad; ry <= rad; ry ++){
|
||||||
|
Tile other = tile(rx+tilex, ry+tiley);
|
||||||
|
|
||||||
|
if(other == null || other.entity == null ||(tile != null && other.entity == tile.entity)) continue;
|
||||||
|
|
||||||
|
TileEntity e = other.entity;
|
||||||
|
|
||||||
|
if(damaged && ((TileEntity) e).health >= ((TileEntity) e).tile.block().health)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float ndst = Vector2.dst(x, y, e.x, e.y);
|
||||||
|
if(ndst < range && (closest == null || ndst < dst)){
|
||||||
|
dst = ndst;
|
||||||
|
closest = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (TileEntity) closest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float roundx(){
|
||||||
|
return Mathf.round2(Graphics.mouseWorld().x, tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float roundy(){
|
||||||
|
return Mathf.round2(Graphics.mouseWorld().y, tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int tilex(){
|
||||||
|
return Mathf.scl2(Graphics.mouseWorld().x, tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int tiley(){
|
||||||
|
return Mathf.scl2(Graphics.mouseWorld().y, tilesize);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,8 @@ package io.anuke.mindustry.ai;
|
|||||||
|
|
||||||
import com.badlogic.gdx.ai.pfa.Heuristic;
|
import com.badlogic.gdx.ai.pfa.Heuristic;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.TileType;
|
|
||||||
|
|
||||||
public class MHueristic implements Heuristic<Tile>{
|
public class MHueristic implements Heuristic<Tile>{
|
||||||
//so this means that the cost of going through solids is 10x going through non solids
|
//so this means that the cost of going through solids is 10x going through non solids
|
||||||
@@ -14,8 +14,8 @@ public class MHueristic implements Heuristic<Tile>{
|
|||||||
float cost = Math.abs(node.worldx() - other.worldx()) + Math.abs(node.worldy() - other.worldy());
|
float cost = Math.abs(node.worldx() - other.worldx()) + Math.abs(node.worldy() - other.worldy());
|
||||||
|
|
||||||
//TODO balance multiplier
|
//TODO balance multiplier
|
||||||
if(node.artifical() && node.block().solid) cost += TileType.tilesize*multiplier;
|
if(node.artifical() && node.block().solid) cost += Vars.tilesize*multiplier;
|
||||||
if(other.artifical() && other.block().solid) cost += TileType.tilesize*multiplier;
|
if(other.artifical() && other.block().solid) cost += Vars.tilesize*multiplier;
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package io.anuke.mindustry.ai;
|
package io.anuke.mindustry.ai;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.worldsize;
|
||||||
|
|
||||||
import com.badlogic.gdx.ai.pfa.Connection;
|
import com.badlogic.gdx.ai.pfa.Connection;
|
||||||
import com.badlogic.gdx.ai.pfa.indexed.IndexedGraph;
|
import com.badlogic.gdx.ai.pfa.indexed.IndexedGraph;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
/**Tilegraph that ignores player-made tiles.*/
|
/**Tilegraph that ignores player-made tiles.*/
|
||||||
public class PassTileGraph implements IndexedGraph<Tile>{
|
public class PassTileGraph implements IndexedGraph<Tile>{
|
||||||
private Array<Connection<Tile>> tempConnections = new Array<Connection<Tile>>();
|
private Array<Connection<Tile>> tempConnections = new Array<Connection<Tile>>();
|
||||||
@@ -28,11 +28,11 @@ public class PassTileGraph implements IndexedGraph<Tile>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIndex(Tile node){
|
public int getIndex(Tile node){
|
||||||
return node.x+node.y*Moment.i.size;
|
return node.x+node.y*worldsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNodeCount(){
|
public int getNodeCount(){
|
||||||
return Moment.i.size*Moment.i.size;
|
return worldsize*worldsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
package io.anuke.mindustry.ai;
|
package io.anuke.mindustry.ai;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.ai.pfa.DefaultGraphPath;
|
import com.badlogic.gdx.ai.pfa.DefaultGraphPath;
|
||||||
import com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder;
|
import com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
import io.anuke.mindustry.entities.Enemy;
|
import io.anuke.mindustry.entities.Enemy;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
|
|
||||||
public class Pathfind{
|
public class Pathfind{
|
||||||
static MHueristic heuristic = new MHueristic();
|
static MHueristic heuristic = new MHueristic();
|
||||||
static TileGraph graph = new TileGraph();
|
|
||||||
static PassTileGraph passgraph = new PassTileGraph();
|
static PassTileGraph passgraph = new PassTileGraph();
|
||||||
static IndexedAStarPathFinder<Tile> pathfinder = new IndexedAStarPathFinder<Tile>(graph);
|
static IndexedAStarPathFinder<Tile> passpathfinder;
|
||||||
static IndexedAStarPathFinder<Tile> passpathfinder = new IndexedAStarPathFinder<Tile>(passgraph);
|
|
||||||
static Array<DefaultGraphPath<Tile>> paths = new Array<>();
|
static Array<DefaultGraphPath<Tile>> paths = new Array<>();
|
||||||
static Vector2 vector = new Vector2();
|
static Vector2 vector = new Vector2();
|
||||||
|
|
||||||
@@ -48,11 +46,12 @@ public class Pathfind{
|
|||||||
|
|
||||||
static public void reset(){
|
static public void reset(){
|
||||||
paths.clear();
|
paths.clear();
|
||||||
|
passpathfinder = new IndexedAStarPathFinder<Tile>(passgraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void updatePath(){
|
static public void updatePath(){
|
||||||
if(paths.size == 0){
|
if(paths.size == 0){
|
||||||
for(int i = 0; i < Moment.i.spawnpoints.size; i ++){
|
for(int i = 0; i < spawnpoints.size; i ++){
|
||||||
DefaultGraphPath<Tile> path = new DefaultGraphPath<>();
|
DefaultGraphPath<Tile> path = new DefaultGraphPath<>();
|
||||||
paths.add(path);
|
paths.add(path);
|
||||||
}
|
}
|
||||||
@@ -62,8 +61,8 @@ public class Pathfind{
|
|||||||
for(DefaultGraphPath<Tile> path : paths){
|
for(DefaultGraphPath<Tile> path : paths){
|
||||||
path.clear();
|
path.clear();
|
||||||
passpathfinder.searchNodePath(
|
passpathfinder.searchNodePath(
|
||||||
Moment.i.spawnpoints.get(i),
|
spawnpoints.get(i),
|
||||||
Moment.i.core, heuristic, path);
|
core, heuristic, path);
|
||||||
|
|
||||||
//for(Tile tile : path){
|
//for(Tile tile : path){
|
||||||
// Effects.effect("ind", tile.worldx(), tile.worldy());
|
// Effects.effect("ind", tile.worldx(), tile.worldy());
|
||||||
@@ -80,7 +79,6 @@ public class Pathfind{
|
|||||||
|
|
||||||
static void findNode(Enemy enemy){
|
static void findNode(Enemy enemy){
|
||||||
DefaultGraphPath<Tile> path = paths.get(enemy.spawn);
|
DefaultGraphPath<Tile> path = paths.get(enemy.spawn);
|
||||||
|
|
||||||
Tile closest = null;
|
Tile closest = null;
|
||||||
float ldst = 0f;
|
float ldst = 0f;
|
||||||
int cindex = -1;
|
int cindex = -1;
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package io.anuke.mindustry.ai;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.ai.pfa.Connection;
|
|
||||||
import com.badlogic.gdx.ai.pfa.indexed.IndexedGraph;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
|
|
||||||
public class TileGraph implements IndexedGraph<Tile>{
|
|
||||||
private Array<Connection<Tile>> tempConnections = new Array<Connection<Tile>>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Array<Connection<Tile>> getConnections(Tile fromNode){
|
|
||||||
tempConnections.clear();
|
|
||||||
|
|
||||||
if(fromNode.block().solid && fromNode != Moment.i.core)
|
|
||||||
return tempConnections;
|
|
||||||
|
|
||||||
for(Tile tile : fromNode.getNearby()){
|
|
||||||
if(tile != null && (!tile.block().solid || tile == Moment.i.core))
|
|
||||||
tempConnections.add(new TileConnection(fromNode, tile));
|
|
||||||
}
|
|
||||||
return tempConnections;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIndex(Tile node){
|
|
||||||
return node.x+node.y*Moment.i.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNodeCount(){
|
|
||||||
return Moment.i.size*Moment.i.size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.World;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.TileType;
|
|
||||||
import io.anuke.ucore.entities.BulletEntity;
|
import io.anuke.ucore.entities.BulletEntity;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
import io.anuke.ucore.entities.SolidEntity;
|
import io.anuke.ucore.entities.SolidEntity;
|
||||||
@@ -24,9 +25,9 @@ public class Bullet extends BulletEntity{
|
|||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
int tilex = Mathf.scl2(x, TileType.tilesize);
|
int tilex = Mathf.scl2(x, tilesize);
|
||||||
int tiley = Mathf.scl2(y, TileType.tilesize);
|
int tiley = Mathf.scl2(y, tilesize);
|
||||||
Tile tile = Moment.i.tile(tilex, tiley);
|
Tile tile = World.tile(tilex, tiley);
|
||||||
|
|
||||||
if(tile != null && tile.entity != null &&
|
if(tile != null && tile.entity != null &&
|
||||||
tile.entity.collide(this) && !tile.entity.dead){
|
tile.entity.collide(this) && !tile.entity.dead){
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
|||||||
},
|
},
|
||||||
sniper = new BulletType(3f, 17){
|
sniper = new BulletType(3f, 17){
|
||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
Draw.color("light gray");
|
Draw.color("lightgray");
|
||||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||||
Draw.clear();
|
Draw.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,15 @@ package io.anuke.mindustry.entities;
|
|||||||
|
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Control;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.Moment;
|
import io.anuke.mindustry.World;
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
import io.anuke.mindustry.world.TileType;
|
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Sounds;
|
|
||||||
import io.anuke.ucore.entities.*;
|
import io.anuke.ucore.entities.*;
|
||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class Enemy extends DestructibleEntity{
|
public class Enemy extends DestructibleEntity{
|
||||||
public static int amount = 0;
|
|
||||||
|
|
||||||
public Vector2 direction = new Vector2();
|
public Vector2 direction = new Vector2();
|
||||||
public float xvelocity, yvelocity;
|
public float xvelocity, yvelocity;
|
||||||
public float speed = 0.3f;
|
public float speed = 0.3f;
|
||||||
@@ -27,6 +23,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
public float length = 4;
|
public float length = 4;
|
||||||
public float rotatespeed = 8f;
|
public float rotatespeed = 8f;
|
||||||
public String shootsound = "enemyshoot";
|
public String shootsound = "enemyshoot";
|
||||||
|
public boolean dead = false;
|
||||||
|
|
||||||
public Enemy(int spawn){
|
public Enemy(int spawn){
|
||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
@@ -35,18 +32,16 @@ public class Enemy extends DestructibleEntity{
|
|||||||
|
|
||||||
maxhealth = 30;
|
maxhealth = 30;
|
||||||
heal();
|
heal();
|
||||||
|
|
||||||
amount ++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void move(){
|
void move(){
|
||||||
Vector2 vec = Pathfind.find(this);
|
Vector2 vec = Pathfind.find(this);
|
||||||
vec.sub(x, y).setLength(speed);
|
vec.sub(x, y).setLength(speed);
|
||||||
|
|
||||||
Moment.module(Control.class).tryMove(this, vec.x*delta, vec.y*delta);
|
move(vec.x*delta, vec.y*delta);
|
||||||
|
|
||||||
//if(Timers.get(this, 10))
|
//if(Timers.get(this, 10))
|
||||||
target = TileType.findTileTarget(x, y, null, range, false);
|
target = World.findTileTarget(x, y, null, range, false);
|
||||||
|
|
||||||
//no tile found
|
//no tile found
|
||||||
if(target == null)
|
if(target == null)
|
||||||
@@ -57,7 +52,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
if(target != null){
|
if(target != null){
|
||||||
if(Timers.get(this, reload)){
|
if(Timers.get(this, reload)){
|
||||||
shoot();
|
shoot();
|
||||||
Sounds.play(shootsound);
|
Effects.sound(shootsound, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -78,13 +73,15 @@ public class Enemy extends DestructibleEntity{
|
|||||||
public void onDeath(){
|
public void onDeath(){
|
||||||
Effects.effect("explosion", this);
|
Effects.effect("explosion", this);
|
||||||
Effects.shake(3f, 4f);
|
Effects.shake(3f, 4f);
|
||||||
Sounds.play("explosion");
|
Effects.sound("explosion", this);
|
||||||
remove();
|
remove();
|
||||||
|
dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(){
|
public void removed(){
|
||||||
amount --;
|
if(!dead)
|
||||||
|
Vars.enemies --;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Control;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
import io.anuke.mindustry.UI;
|
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.DestructibleEntity;
|
import io.anuke.ucore.entities.DestructibleEntity;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
@@ -32,8 +32,8 @@ public class Player extends DestructibleEntity{
|
|||||||
Effects.shake(4f, 5f);
|
Effects.shake(4f, 5f);
|
||||||
Effects.effect("respawn", this);
|
Effects.effect("respawn", this);
|
||||||
|
|
||||||
Timers.run(Moment.i.respawntime, ()->{
|
Timers.run(respawntime, ()->{
|
||||||
set(Moment.i.core.worldx(), Moment.i.core.worldy()-8);
|
set(core.worldx(), core.worldy()-8);
|
||||||
heal();
|
heal();
|
||||||
add();
|
add();
|
||||||
});
|
});
|
||||||
@@ -50,6 +50,11 @@ public class Player extends DestructibleEntity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
float speed = this.speed;
|
||||||
|
|
||||||
|
if(Vars.debug)
|
||||||
|
speed = 3f;
|
||||||
|
|
||||||
if(health < maxhealth && Timers.get(this, 50))
|
if(health < maxhealth && Timers.get(this, 50))
|
||||||
health ++;
|
health ++;
|
||||||
|
|
||||||
@@ -66,7 +71,7 @@ public class Player extends DestructibleEntity{
|
|||||||
|
|
||||||
reload -= delta;
|
reload -= delta;
|
||||||
|
|
||||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && Moment.i.recipe == null && !Moment.module(UI.class).hasMouse();
|
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse();
|
||||||
|
|
||||||
if(shooting && reload <= 0){
|
if(shooting && reload <= 0){
|
||||||
weapon.shoot(this);
|
weapon.shoot(this);
|
||||||
@@ -76,7 +81,7 @@ public class Player extends DestructibleEntity{
|
|||||||
|
|
||||||
vector.limit(speed);
|
vector.limit(speed);
|
||||||
|
|
||||||
Moment.module(Control.class).tryMove(this, vector.x*delta, vector.y*delta);
|
move(vector.x*delta, vector.y*delta);
|
||||||
|
|
||||||
if(!shooting){
|
if(!shooting){
|
||||||
direction.add(vector.scl(delta));
|
direction.add(vector.scl(delta));
|
||||||
|
|||||||
@@ -1,48 +1,47 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.DelayedRemovalArray;
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
import io.anuke.mindustry.GameState;
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.TileType;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Sounds;
|
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
|
|
||||||
public class TileEntity extends Entity{
|
public class TileEntity extends Entity{
|
||||||
public final Tile tile;
|
public Tile tile;
|
||||||
public DelayedRemovalArray<ItemPos> convey = new DelayedRemovalArray<>();
|
|
||||||
public ObjectMap<Item, Integer> items = new ObjectMap<>();
|
public ObjectMap<Item, Integer> items = new ObjectMap<>();
|
||||||
public int shots;
|
|
||||||
public TileEntity link;
|
|
||||||
public float rotation;
|
|
||||||
public int maxhealth, health;
|
public int maxhealth, health;
|
||||||
public boolean dead = false;
|
public boolean dead = false;
|
||||||
|
|
||||||
public TileEntity(Tile tile){
|
|
||||||
|
public TileEntity init(Tile tile){
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
x = tile.worldx();
|
x = tile.worldx();
|
||||||
y = tile.worldy();
|
y = tile.worldy();
|
||||||
|
|
||||||
maxhealth = tile.block().health;
|
maxhealth = tile.block().health;
|
||||||
health = maxhealth;
|
health = maxhealth;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDeath(){
|
public void onDeath(){
|
||||||
dead = true;
|
dead = true;
|
||||||
|
|
||||||
if(tile.block() == TileType.core){
|
if(tile.block() == ProductionBlocks.core){
|
||||||
Moment.i.coreDestroyed();
|
GameState.coreDestroyed();
|
||||||
}
|
}
|
||||||
tile.setBlock(TileType.air);
|
|
||||||
|
tile.setBlock(Blocks.air);
|
||||||
Pathfind.updatePath();
|
Pathfind.updatePath();
|
||||||
Effects.shake(4f, 4f);
|
Effects.shake(4f, 4f);
|
||||||
Effects.effect("explosion", this);
|
Effects.effect("explosion", this);
|
||||||
|
|
||||||
Sounds.play("break");
|
Effects.sound("break", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collision(Bullet other){
|
public void collision(Bullet other){
|
||||||
@@ -79,27 +78,4 @@ public class TileEntity extends Entity{
|
|||||||
public void removeItem(Item item, int amount){
|
public void removeItem(Item item, int amount){
|
||||||
items.put(item, items.get(item, 0) - amount);
|
items.put(item, items.get(item, 0) - amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConvey(Item item){
|
|
||||||
addConvey(item, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addConvey(Item item, float pos){
|
|
||||||
ItemPos posa = new ItemPos(item);
|
|
||||||
posa.pos = pos;
|
|
||||||
convey.add(posa);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeConvey(ItemPos pos){
|
|
||||||
convey.removeValue(pos, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public class ItemPos{
|
|
||||||
public Item item;
|
|
||||||
public float pos;
|
|
||||||
|
|
||||||
public ItemPos(Item item){
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,37 +4,39 @@ import static io.anuke.mindustry.resource.Section.*;
|
|||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.world.TileType;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
|
import io.anuke.mindustry.world.blocks.WeaponBlocks;
|
||||||
|
|
||||||
public enum Recipe{
|
public enum Recipe{
|
||||||
stonewall(distribution, TileType.stonewall, stack(Item.stone, 5)),
|
stonewall(distribution, Blocks.stonewall, stack(Item.stone, 5)),
|
||||||
ironwall(distribution, TileType.ironwall, stack(Item.iron, 5)),
|
ironwall(distribution, Blocks.ironwall, stack(Item.iron, 5)),
|
||||||
steelwall(distribution, TileType.steelwall, stack(Item.steel, 5)),
|
steelwall(distribution, Blocks.steelwall, stack(Item.steel, 5)),
|
||||||
conveyor(distribution, TileType.conveyor, stack(Item.stone, 1)),
|
conveyor(distribution, ProductionBlocks.conveyor, stack(Item.stone, 1)),
|
||||||
fastconveyor(distribution, TileType.steelconveyor, stack(Item.steel, 1)),
|
fastconveyor(distribution, ProductionBlocks.steelconveyor, stack(Item.steel, 1)),
|
||||||
router(distribution, TileType.router, stack(Item.stone, 3)),
|
router(distribution, ProductionBlocks.router, stack(Item.stone, 3)),
|
||||||
|
|
||||||
|
turret(defense, WeaponBlocks.turret, stack(Item.stone, 6)),
|
||||||
|
dturret(defense, WeaponBlocks.doubleturret, stack(Item.stone, 12)),
|
||||||
|
machineturret(defense, WeaponBlocks.machineturret, stack(Item.iron, 15), stack(Item.stone, 20)),
|
||||||
|
shotgunturret(defense, WeaponBlocks.shotgunturret, stack(Item.iron, 15), stack(Item.iron, 20)),
|
||||||
|
flameturret(defense, WeaponBlocks.flameturret, stack(Item.iron, 25), stack(Item.steel, 18)),
|
||||||
|
sniperturret(defense, WeaponBlocks.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)),
|
||||||
|
|
||||||
turret(defense, TileType.turret, stack(Item.stone, 8)),
|
healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 40)),
|
||||||
dturret(defense, TileType.doubleturret, stack(Item.stone, 12)),
|
megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 40)),
|
||||||
machineturret(defense, TileType.machineturret, stack(Item.iron, 15), stack(Item.stone, 20)),
|
|
||||||
shotgunturret(defense, TileType.shotgunturret, stack(Item.iron, 15), stack(Item.steel, 24)),
|
|
||||||
flameturret(defense, TileType.flameturret, stack(Item.iron, 25), stack(Item.steel, 18)),
|
|
||||||
sniperturret(defense, TileType.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)),
|
|
||||||
|
|
||||||
healturret(defense, TileType.repairturret, stack(Item.iron, 40)),
|
drill(production, ProductionBlocks.stonedrill, stack(Item.stone, 6)),
|
||||||
megahealturret(defense, TileType.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 40)),
|
irondrill(production, ProductionBlocks.irondrill, stack(Item.stone, 40)),
|
||||||
|
coaldrill(production, ProductionBlocks.coaldrill, stack(Item.stone, 40), stack(Item.iron, 40)),
|
||||||
|
smelter(production, ProductionBlocks.smelter, stack(Item.stone, 80), stack(Item.iron, 80));
|
||||||
|
|
||||||
drill(production, TileType.stonedrill, stack(Item.stone, 6)),
|
public Block result;
|
||||||
irondrill(production, TileType.irondrill, stack(Item.stone, 40)),
|
|
||||||
coaldrill(production, TileType.coaldrill, stack(Item.stone, 40), stack(Item.iron, 40)),
|
|
||||||
smelter(production, TileType.smelter, stack(Item.stone, 80), stack(Item.iron, 80));
|
|
||||||
|
|
||||||
public TileType result;
|
|
||||||
public ItemStack[] requirements;
|
public ItemStack[] requirements;
|
||||||
public Section section;
|
public Section section;
|
||||||
|
|
||||||
private Recipe(Section section, TileType result, ItemStack... requirements){
|
private Recipe(Section section, Block result, ItemStack... requirements){
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.requirements = requirements;
|
this.requirements = requirements;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
|
|||||||
139
core/src/io/anuke/mindustry/world/Block.java
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
|
||||||
|
public class Block{
|
||||||
|
protected static Vector2 vector = new Vector2();
|
||||||
|
protected static Vector2 vector2 = new Vector2();
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public boolean solid, update, rotate;
|
||||||
|
public int health = 40;
|
||||||
|
|
||||||
|
public Block(String name) {
|
||||||
|
this.name = name;
|
||||||
|
solid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawOver(Tile tile){}
|
||||||
|
public void drawPixelOverlay(Tile tile){}
|
||||||
|
public void drawOverlay(Tile tile){}
|
||||||
|
|
||||||
|
public String name(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String description(){
|
||||||
|
return "[no description]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String errorMessage(Tile tile){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleItem(Tile tile, Item item, Tile source){
|
||||||
|
tile.entity.addItem(item, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean accept(Item item){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Tile tile){}
|
||||||
|
|
||||||
|
public TileEntity getEntity(){
|
||||||
|
return new TileEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to put this item into a nearby container, if there are no available
|
||||||
|
* containers, it gets added to the block's inventory.
|
||||||
|
*/
|
||||||
|
protected void offloadNear(Tile tile, Item item){
|
||||||
|
int i = tile.dump;
|
||||||
|
int pdump = tile.dump;
|
||||||
|
|
||||||
|
Tile[] tiles = tile.getNearby();
|
||||||
|
|
||||||
|
for(int j = 0; j < 4; j ++){
|
||||||
|
Tile other = tiles[i];
|
||||||
|
if(other != null && other.block().accept(item)
|
||||||
|
//don't output to things facing this thing
|
||||||
|
&& !(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
||||||
|
|
||||||
|
other.block().handleItem(other, item, tile);
|
||||||
|
tile.dump = (i+1)%4;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
i %= 4;
|
||||||
|
}
|
||||||
|
tile.dump = pdump;
|
||||||
|
handleItem(tile, item, tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Try dumping any item near the tile. */
|
||||||
|
protected boolean tryDump(Tile tile){
|
||||||
|
return tryDump(tile, -1, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try dumping any item near the tile. -1 = any direction
|
||||||
|
*/
|
||||||
|
protected boolean tryDump(Tile tile, int direction, Item todump){
|
||||||
|
int i = tile.dump;
|
||||||
|
|
||||||
|
Tile[] tiles = tile.getNearby();
|
||||||
|
|
||||||
|
for(int j = 0; j < 4; j ++){
|
||||||
|
Tile other = tiles[i];
|
||||||
|
|
||||||
|
if(i == direction || direction == -1)
|
||||||
|
for(Item item : Item.values()){
|
||||||
|
|
||||||
|
if(todump != null && item != todump) continue;
|
||||||
|
|
||||||
|
if(tile.entity.hasItem(item) && other != null && other.block().accept(item) &&
|
||||||
|
//don't output to things facing this thing
|
||||||
|
!(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
||||||
|
other.block().handleItem(other, item, tile);
|
||||||
|
tile.entity.removeItem(item, 1);
|
||||||
|
tile.dump = (i+1)%4;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
i %= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try offloading an item to a nearby container. Returns true if success.
|
||||||
|
*/
|
||||||
|
protected boolean offloadDir(Tile tile, Item item){
|
||||||
|
Tile other = tile.getNearby()[tile.rotation];
|
||||||
|
if(other != null && other.block().accept(item)){
|
||||||
|
other.block().handleItem(other, item, tile);
|
||||||
|
//other.entity.addCovey(item, ch == 1 ? 0.5f : ch ==2 ? 1f : 0f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Tile tile){
|
||||||
|
if(tile.floor() == this){
|
||||||
|
MathUtils.random.setSeed(tile.id());
|
||||||
|
Draw.rect(name() + MathUtils.random(1, 3), tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0);
|
||||||
|
}else{
|
||||||
|
Draw.rect(name(), tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,53 +1,66 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
import io.anuke.ucore.graphics.Hue;
|
||||||
import io.anuke.ucore.noise.Noise;
|
import io.anuke.ucore.noise.Noise;
|
||||||
|
|
||||||
public class Generator{
|
public class Generator{
|
||||||
static final int black = Color.rgba8888(Color.BLACK);
|
static final int stonefloor = Color.rgba8888(Hue.rgb(54, 54, 54));
|
||||||
static final int white = Color.rgba8888(Color.WHITE);
|
static final int stone = Color.rgba8888(Hue.rgb(128, 128, 128));
|
||||||
static final int red = Color.rgba8888(Color.RED);
|
static final int spawn = Color.rgba8888(Color.RED);
|
||||||
static final int blue = Color.rgba8888(Color.BLUE);
|
static final int start = Color.rgba8888(Color.GREEN);
|
||||||
|
|
||||||
public static void generate(Tile[][] tiles, String mapname){
|
/**Returns world size.*/
|
||||||
Pixmap pix = new Pixmap(Gdx.files.internal("maps/"+mapname+".png"));
|
public static void generate(int map){
|
||||||
|
Pixmap pix = mapPixmaps[map];
|
||||||
|
|
||||||
Noise.setSeed(MathUtils.random(0, 99999));
|
Noise.setSeed(MathUtils.random(0, 99999));
|
||||||
for(int x = 0; x < tiles.length; x ++){
|
for(int x = 0; x < tiles.length; x ++){
|
||||||
for(int y = 0; y < tiles.length; y ++){
|
for(int y = 0; y < tiles.length; y ++){
|
||||||
TileType floor = TileType.stone;
|
Block floor = Blocks.stone;
|
||||||
TileType block = TileType.air;
|
Block block = Blocks.air;
|
||||||
|
|
||||||
int color = pix.getPixel(x, pix.getHeight()-1-y);
|
int color = pix.getPixel(x, pix.getHeight()-1-y);
|
||||||
|
|
||||||
if(Noise.nnoise(x, y, 8, 1) > 0.22){
|
if(Noise.nnoise(x, y, 8, 1) > 0.22){
|
||||||
floor = TileType.iron;
|
floor = Blocks.iron;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Noise.nnoise(x, y, 6, 1) > 0.245){
|
if(Noise.nnoise(x, y, 6, 1) > 0.245){
|
||||||
floor = TileType.coal;
|
floor = Blocks.coal;
|
||||||
}
|
}
|
||||||
|
if(color == stone && map == 1){
|
||||||
|
block = Blocks.dirtblock;
|
||||||
|
}else if(color == stone){
|
||||||
if(color == white){
|
block = Blocks.stoneblock;
|
||||||
block = TileType.stoneblock;
|
}else if(color == start){
|
||||||
|
core = tiles[x][y];
|
||||||
}else if(color == blue){
|
}else if(color == spawn){
|
||||||
Moment.i.core = tiles[x][y];
|
spawnpoints.add(tiles[x][y]);
|
||||||
}else if(color == red){
|
|
||||||
Moment.i.spawnpoints.add(tiles[x][y]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles[x][y].setBlock(block);
|
tiles[x][y].setBlock(block);
|
||||||
tiles[x][y].setFloor(floor);
|
tiles[x][y].setFloor(floor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadMaps(){
|
||||||
|
mapPixmaps = new Pixmap[maps.length];
|
||||||
|
mapTextures = new Texture[maps.length];
|
||||||
|
|
||||||
pix.dispose();
|
for(int i = 0; i < maps.length; i ++){
|
||||||
|
Pixmap pix = new Pixmap(Gdx.files.internal("maps/"+maps[i]+".png"));
|
||||||
|
mapPixmaps[i] = pix;
|
||||||
|
mapTextures[i] = new Texture(pix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,66 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.World;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
|
|
||||||
|
|
||||||
public class Tile{
|
public class Tile{
|
||||||
private static Tile[] tiles = new Tile[4];
|
private Block floor = Blocks.air;
|
||||||
private TileType floor = TileType.air;
|
private Block block = Blocks.air;
|
||||||
private TileType block = TileType.air;
|
|
||||||
public TileEntity entity;
|
public TileEntity entity;
|
||||||
public int x, y, rotation;
|
public int x, y, rotation, dump;
|
||||||
|
|
||||||
public Tile(int x, int y){
|
public Tile(int x, int y){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(int x, int y, TileType floor){
|
public Tile(int x, int y, Block floor){
|
||||||
this(x, y);
|
this(x, y);
|
||||||
this.floor = floor;
|
this.floor = floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int relativeTo(int cx, int cy){
|
||||||
|
if(x == cx && y == cy - 1) return 1;
|
||||||
|
if(x == cx && y == cy + 1) return 3;
|
||||||
|
if(x == cx - 1 && y == cy) return 0;
|
||||||
|
if(x == cx + 1 && y == cy) return 2;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends TileEntity> T entity(){
|
||||||
|
return (T)entity;
|
||||||
|
}
|
||||||
|
|
||||||
public int id(){
|
public int id(){
|
||||||
return x + y * Moment.i.size;
|
return x + y * worldsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float worldx(){
|
public float worldx(){
|
||||||
return x * TileType.tilesize;
|
return x * tilesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float worldy(){
|
public float worldy(){
|
||||||
return y * TileType.tilesize;
|
return y * tilesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileType floor(){
|
public Block floor(){
|
||||||
return floor;
|
return floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileType block(){
|
public Block block(){
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(TileType type){
|
public void setBlock(Block type){
|
||||||
this.block = type;
|
this.block = type;
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFloor(TileType type){
|
public void setFloor(Block type){
|
||||||
this.floor = type;
|
this.floor = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,15 +69,9 @@ public class Tile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Tile[] getNearby(){
|
public Tile[] getNearby(){
|
||||||
tiles[0] = Moment.i.tile(x+1, y);
|
return World.getNearby(x, y);
|
||||||
tiles[1] = Moment.i.tile(x, y+1);
|
|
||||||
tiles[2] = Moment.i.tile(x-1, y);
|
|
||||||
tiles[3] = Moment.i.tile(x, y-1);
|
|
||||||
|
|
||||||
return tiles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void changed(){
|
public void changed(){
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@@ -70,6 +79,11 @@ public class Tile{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(block.update)
|
if(block.update)
|
||||||
entity = new TileEntity(this).add();
|
entity = block.getEntity().init(this).add();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return floor.name() + ":" + block.name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,735 +0,0 @@
|
|||||||
package io.anuke.mindustry.world;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
|
||||||
import com.badlogic.gdx.math.Vector2;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
import io.anuke.mindustry.entities.*;
|
|
||||||
import io.anuke.mindustry.entities.TileEntity.ItemPos;
|
|
||||||
import io.anuke.mindustry.resource.Item;
|
|
||||||
import io.anuke.ucore.core.Draw;
|
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
import io.anuke.ucore.core.Sounds;
|
|
||||||
import io.anuke.ucore.entities.*;
|
|
||||||
import io.anuke.ucore.graphics.Hue;
|
|
||||||
import io.anuke.ucore.util.Angles;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
|
||||||
import io.anuke.ucore.util.Timers;
|
|
||||||
|
|
||||||
public enum TileType{
|
|
||||||
air{
|
|
||||||
//nothing gets drawn
|
|
||||||
public void draw(Tile tile){
|
|
||||||
}
|
|
||||||
},
|
|
||||||
grass,
|
|
||||||
stone,
|
|
||||||
dirt,
|
|
||||||
iron,
|
|
||||||
coal,
|
|
||||||
dirtblock(true),
|
|
||||||
stoneblock(true),
|
|
||||||
stonewall(true, true){{health = 50;}},
|
|
||||||
ironwall(true, true){{health = 80;}},
|
|
||||||
steelwall(true, true){{health = 110;}},
|
|
||||||
stonedrill(true, true){
|
|
||||||
public void update(Tile tile){
|
|
||||||
|
|
||||||
if(tile.floor() == TileType.stone && Timers.get(tile, 60 * 6)){
|
|
||||||
offloadNear(tile, Item.stone);
|
|
||||||
Effects.effect("spark", tile.x * tilesize, tile.y * tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Timers.get(tile.hashCode() + "dump", 30)){
|
|
||||||
tryDump(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Mines 1 stone every 6 seconds.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String error(Tile tile){
|
|
||||||
if(tile.floor() != TileType.stone)
|
|
||||||
return "Not on stone block!";
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
irondrill(true, true){
|
|
||||||
public void update(Tile tile){
|
|
||||||
|
|
||||||
if(tile.floor() == TileType.iron && Timers.get(tile, 60 * 6)){
|
|
||||||
offloadNear(tile, Item.iron);
|
|
||||||
Effects.effect("spark", tile.x * tilesize, tile.y * tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Timers.get(tile.hashCode() + "dump", 30)){
|
|
||||||
tryDump(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Mines 1 iron every 6 seconds.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String error(Tile tile){
|
|
||||||
if(tile.floor() != TileType.iron)
|
|
||||||
return "Not on iron ore block!";
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
coaldrill(true, true){
|
|
||||||
public void update(Tile tile){
|
|
||||||
|
|
||||||
if(tile.floor() == TileType.coal && Timers.get(tile, 60 * 6)){
|
|
||||||
offloadNear(tile, Item.coal);
|
|
||||||
Effects.effect("spark", tile.x * tilesize, tile.y * tilesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Timers.get(tile.hashCode() + "dump", 30)){
|
|
||||||
tryDump(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Mines 1 coal every 6 seconds.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String error(Tile tile){
|
|
||||||
if(tile.floor() != TileType.coal)
|
|
||||||
return "Not on coal block!";
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
conveyor(false, true, true){
|
|
||||||
float speed = 0.02f;
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect(name() + (Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90);
|
|
||||||
|
|
||||||
vector.set(tilesize, 0).rotate(tile.rotation * 90);
|
|
||||||
vector2.set(-tilesize / 2, 0).rotate(tile.rotation * 90);
|
|
||||||
|
|
||||||
for(ItemPos pos : tile.entity.convey){
|
|
||||||
Draw.rect("icon-" + pos.item.name(), tile.x * tilesize + vector.x * pos.pos + vector2.x, tile.y * tilesize + vector.y * pos.pos + vector2.y, 4, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
tile.entity.convey.begin();
|
|
||||||
|
|
||||||
for(ItemPos pos : tile.entity.convey){
|
|
||||||
pos.pos += speed * Gdx.graphics.getDeltaTime() * 60f;
|
|
||||||
if(pos.pos >= 1f && offloadDir(tile, pos.item)){
|
|
||||||
tile.entity.removeConvey(pos);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pos.pos = Mathf.clamp(pos.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
tile.entity.convey.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accepts(Item item){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Moves Items";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void handleItem(Tile tile, Item item, float f){
|
|
||||||
tile.entity.addConvey(item, f);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
steelconveyor(false, true, true){
|
|
||||||
float speed = 0.03f;
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect(name() + (Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90);
|
|
||||||
|
|
||||||
vector.set(tilesize, 0).rotate(tile.rotation * 90);
|
|
||||||
vector2.set(-tilesize / 2, 0).rotate(tile.rotation * 90);
|
|
||||||
|
|
||||||
for(ItemPos pos : tile.entity.convey){
|
|
||||||
Draw.rect("icon-" + pos.item.name(), tile.x * tilesize + vector.x * pos.pos + vector2.x, tile.y * tilesize + vector.y * pos.pos + vector2.y, 4, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
tile.entity.convey.begin();
|
|
||||||
|
|
||||||
for(ItemPos pos : tile.entity.convey){
|
|
||||||
pos.pos += speed * Gdx.graphics.getDeltaTime() * 60f;
|
|
||||||
if(pos.pos >= 1f && offloadDir(tile, pos.item)){
|
|
||||||
tile.entity.removeConvey(pos);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pos.pos = Mathf.clamp(pos.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
tile.entity.convey.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accepts(Item item){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Moves Items\nFaster than a normal conveyor";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void handleItem(Tile tile, Item item, float f){
|
|
||||||
tile.entity.addConvey(item, f);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
router(true, true, false){
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
if(Timers.get(tile, 10) && tile.entity.totalItems() > 0){
|
|
||||||
tryDump(tile, tile.rotation++);
|
|
||||||
tile.rotation %= 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accepts(Item item){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Splits conveyor belt input";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
smelter(true, true, false){
|
|
||||||
{health=70;}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
|
|
||||||
if(tile.entity.hasItem(Item.coal) && tile.entity.hasItem(Item.iron)){
|
|
||||||
tile.entity.removeItem(Item.coal, 1);
|
|
||||||
tile.entity.removeItem(Item.iron, 1);
|
|
||||||
offloadNear(tile, Item.steel);
|
|
||||||
Effects.effect("smelt", tile.entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Timers.get(tile, 20) && tile.entity.hasItem(Item.steel)){
|
|
||||||
tryDump(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accepts(Item item){
|
|
||||||
return item == Item.iron || item == Item.coal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Smelts iron and coal into steel";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
core(true, true, false){
|
|
||||||
{
|
|
||||||
health = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void handleItem(Tile tile, Item item, float f){
|
|
||||||
Moment.i.addItem(item, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accepts(Item item){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
turret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 40;
|
|
||||||
reload = 10f;
|
|
||||||
bullet = BulletType.stone;
|
|
||||||
ammo = Item.stone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
updateTurret(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Shoots things.";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doubleturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 40;
|
|
||||||
reload = 13f;
|
|
||||||
bullet = BulletType.stone;
|
|
||||||
ammo = Item.stone;
|
|
||||||
health = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
updateTurret(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Shoots things.";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void shoot(Tile tile){
|
|
||||||
vector.set(4, -2).rotate(tile.entity.rotation);
|
|
||||||
bullet(tile, tile.entity.rotation);
|
|
||||||
vector.set(4, 2).rotate(tile.entity.rotation);
|
|
||||||
bullet(tile, tile.entity.rotation);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
machineturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 65;
|
|
||||||
reload = 7f;
|
|
||||||
bullet = BulletType.iron;
|
|
||||||
ammo = Item.iron;
|
|
||||||
health = 65;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
updateTurret(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Shoots things.";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
flameturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 35f;
|
|
||||||
reload = 5f;
|
|
||||||
bullet = BulletType.flame;
|
|
||||||
ammo = Item.coal;
|
|
||||||
health = 85;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
updateTurret(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Burns things.";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sniperturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 100;
|
|
||||||
reload = 60f;
|
|
||||||
bullet = BulletType.sniper;
|
|
||||||
ammo = Item.steel;
|
|
||||||
health = 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
updateTurret(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Shoots things.";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shotgunturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 50;
|
|
||||||
reload = 40f;
|
|
||||||
bullet = BulletType.iron;
|
|
||||||
ammo = Item.iron;
|
|
||||||
health = 70;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
updateTurret(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Shoots things.";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void shoot(Tile tile){
|
|
||||||
|
|
||||||
for(int i = 0; i < 6; i ++)
|
|
||||||
Timers.run(i/1.5f, ()->{
|
|
||||||
vector.set(4, 0).setAngle(tile.entity.rotation);
|
|
||||||
bullet(tile, tile.entity.rotation + Mathf.range(16));
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
repairturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 30;
|
|
||||||
reload = 40f;
|
|
||||||
health = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
/*
|
|
||||||
* if(tile.entity.hasItem(ammo)){ tile.entity.shots += 20;
|
|
||||||
* tile.entity.removeItem(ammo, 1); }
|
|
||||||
*/
|
|
||||||
//if(tile.entity.shots > 0){
|
|
||||||
tile.entity.link = findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
|
|
||||||
|
|
||||||
if(tile.entity.link != null){
|
|
||||||
tile.entity.rotation = tile.entity.angleTo(tile.entity.link);
|
|
||||||
|
|
||||||
if(Timers.get(tile, reload)){
|
|
||||||
tile.entity.link.health++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
if(tile.entity.link != null){
|
|
||||||
float x = tile.worldx(), y = tile.worldy();
|
|
||||||
float x2 = tile.entity.link.x, y2 = tile.entity.link.y;
|
|
||||||
|
|
||||||
Draw.color(Hue.rgb(138, 244, 138, (MathUtils.sin(Timers.time()) + 1f) / 14f));
|
|
||||||
Draw.alpha(0.3f);
|
|
||||||
Draw.thickness(4f);
|
|
||||||
Draw.line(x, y, x2, y2);
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.rect("circle", x2, y2, 7f, 7f);
|
|
||||||
Draw.alpha(1f);
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.line(x, y, x2, y2);
|
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.rect("circle", x2, y2, 5f, 5f);
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Heals nearby tiles.";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
megarepairturret(true, true, false){
|
|
||||||
{
|
|
||||||
range = 30;
|
|
||||||
reload = 20f;
|
|
||||||
health = 80;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
tile.entity.link = findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
|
|
||||||
|
|
||||||
if(tile.entity.link != null){
|
|
||||||
tile.entity.rotation = tile.entity.angleTo(tile.entity.link);
|
|
||||||
|
|
||||||
if(Timers.get(tile, reload)){
|
|
||||||
tile.entity.link.health++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect("block", tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
if(tile.entity.link != null){
|
|
||||||
float x = tile.worldx(), y = tile.worldy();
|
|
||||||
float x2 = tile.entity.link.x, y2 = tile.entity.link.y;
|
|
||||||
|
|
||||||
Draw.color(Hue.rgb(132, 242, 242, (MathUtils.sin(Timers.time()) + 1f) / 13f));
|
|
||||||
Draw.alpha(0.3f);
|
|
||||||
Draw.thickness(4f);
|
|
||||||
Draw.line(x, y, x2, y2);
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.rect("circle", x2, y2, 7f, 7f);
|
|
||||||
Draw.alpha(1f);
|
|
||||||
Draw.thickness(2f);
|
|
||||||
Draw.line(x, y, x2, y2);
|
|
||||||
Draw.thickness(1f);
|
|
||||||
Draw.rect("circle", x2, y2, 5f, 5f);
|
|
||||||
Draw.clear();
|
|
||||||
}
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), tile.entity.rotation - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "Heals nearby tiles.";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static Vector2 vector = new Vector2();
|
|
||||||
static Vector2 vector2 = new Vector2();
|
|
||||||
|
|
||||||
public boolean solid, update, rotate;
|
|
||||||
public static final int tilesize = 8;
|
|
||||||
public int health = 40;
|
|
||||||
|
|
||||||
//turrets
|
|
||||||
public float range = 50f;
|
|
||||||
public float reload = 10f;
|
|
||||||
public BulletType bullet;
|
|
||||||
public Item ammo;
|
|
||||||
|
|
||||||
private TileType() {
|
|
||||||
solid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TileType(boolean solid) {
|
|
||||||
this.solid = solid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TileType(boolean solid, boolean update) {
|
|
||||||
this.solid = solid;
|
|
||||||
this.update = update;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TileType(boolean solid, boolean update, boolean rotate) {
|
|
||||||
this.solid = solid;
|
|
||||||
this.update = update;
|
|
||||||
this.rotate = rotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(TileEntity entity){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateTurret(Tile tile){
|
|
||||||
if(tile.entity.hasItem(ammo)){
|
|
||||||
tile.entity.shots += 20;
|
|
||||||
tile.entity.removeItem(ammo, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tile.entity.shots > 0){
|
|
||||||
Enemy enemy = findTarget(tile, range);
|
|
||||||
if(enemy != null){
|
|
||||||
tile.entity.rotation = MathUtils.lerpAngleDeg(tile.entity.rotation, Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f), 0.2f);
|
|
||||||
if(Timers.get(tile, reload)){
|
|
||||||
Sounds.play("shoot");
|
|
||||||
shoot(tile);
|
|
||||||
tile.entity.shots--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void shoot(Tile tile){
|
|
||||||
vector.set(0, 4).setAngle(tile.entity.rotation);
|
|
||||||
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, tile.entity.rotation).add();
|
|
||||||
}
|
|
||||||
|
|
||||||
void bullet(Tile tile, float angle){
|
|
||||||
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
|
|
||||||
}
|
|
||||||
|
|
||||||
Enemy findTarget(Tile tile, float range){
|
|
||||||
Entity closest = null;
|
|
||||||
float dst = 0;
|
|
||||||
|
|
||||||
Array<SolidEntity> array = Entities.getNearby(tile.worldx(), tile.worldy(), range*2);
|
|
||||||
|
|
||||||
for(Entity e : array){
|
|
||||||
|
|
||||||
if(e instanceof Enemy){
|
|
||||||
float ndst = Vector2.dst(tile.worldx(), tile.worldy(), e.x, e.y);
|
|
||||||
if(ndst < range && (closest == null || ndst < dst)){
|
|
||||||
dst = ndst;
|
|
||||||
closest = e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Enemy) closest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){
|
|
||||||
Entity closest = null;
|
|
||||||
float dst = 0;
|
|
||||||
|
|
||||||
int rad = (int)(range/tilesize)+1;
|
|
||||||
int tilex = Mathf.scl2(x, tilesize);
|
|
||||||
int tiley = Mathf.scl2(y, tilesize);
|
|
||||||
|
|
||||||
for(int rx = -rad; rx <= rad; rx ++){
|
|
||||||
for(int ry = -rad; ry <= rad; ry ++){
|
|
||||||
Tile other = Moment.i.tile(rx+tilex, ry+tiley);
|
|
||||||
|
|
||||||
if(other == null || other.entity == null ||(tile != null && other.entity == tile.entity)) continue;
|
|
||||||
|
|
||||||
TileEntity e = other.entity;
|
|
||||||
|
|
||||||
if(damaged && ((TileEntity) e).health >= ((TileEntity) e).tile.block().health)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
float ndst = Vector2.dst(x, y, e.x, e.y);
|
|
||||||
if(ndst < range && (closest == null || ndst < dst)){
|
|
||||||
dst = ndst;
|
|
||||||
closest = e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (TileEntity) closest;
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleItem(Tile tile, Item item, float f){
|
|
||||||
tile.entity.addItem(item, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries to put this item into a nearby container, if there are no available
|
|
||||||
* containers, it gets added to the block's inventory.
|
|
||||||
*/
|
|
||||||
void offloadNear(Tile tile, Item item){
|
|
||||||
int i = 0;
|
|
||||||
for(Tile other : tile.getNearby()){
|
|
||||||
if(other != null && other.block().accepts(item)
|
|
||||||
//don't output to things facing this thing
|
|
||||||
&& !(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
|
||||||
|
|
||||||
other.block().handleItem(other, item, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
handleItem(tile, item, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Try dumping any item near the tile. */
|
|
||||||
boolean tryDump(Tile tile){
|
|
||||||
return tryDump(tile, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try dumping any item near the tile. -1 = any direction
|
|
||||||
*/
|
|
||||||
boolean tryDump(Tile tile, int direction){
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for(Tile other : tile.getNearby()){
|
|
||||||
if(i == direction || direction == -1)
|
|
||||||
for(Item item : Item.values()){
|
|
||||||
|
|
||||||
if(tile.entity.hasItem(item) && other != null && other.block().accepts(item) &&
|
|
||||||
//don't output to things facing this thing
|
|
||||||
!(other.block().rotate && (other.rotation + 2) % 4 == i)){
|
|
||||||
other.block().handleItem(other, item, 0);
|
|
||||||
tile.entity.removeItem(item, 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try offloading an item to a nearby container. Returns true if success.
|
|
||||||
*/
|
|
||||||
boolean offloadDir(Tile tile, Item item){
|
|
||||||
Tile other = tile.getNearby()[tile.rotation];
|
|
||||||
if(other != null && other.block().accepts(item)){
|
|
||||||
int ch = Math.abs(other.rotation - tile.rotation);
|
|
||||||
other.block().handleItem(other, item, ch == 1 ? 0.5f : ch == 2 ? 1f : 0f);
|
|
||||||
//other.entity.addCovey(item, ch == 1 ? 0.5f : ch ==2 ? 1f : 0f);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean accepts(Item item){
|
|
||||||
return item == ammo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String description(){
|
|
||||||
return "[no description]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Tile tile){
|
|
||||||
if(tile.floor() == this){
|
|
||||||
MathUtils.random.setSeed(tile.id());
|
|
||||||
Draw.rect(name() + MathUtils.random(1, 3), tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0);
|
|
||||||
}else{
|
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String error(Tile tile){
|
|
||||||
if(ammo != null && !tile.entity.hasItem(ammo) && tile.entity.shots <= 0)
|
|
||||||
return "No ammo!";
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawOver(Tile tile){
|
|
||||||
/*
|
|
||||||
* String error = error(tile); if(error != null){ Draw.color("scarlet");
|
|
||||||
* Draw.square(tile.worldx(), tile.worldy(), 6); Draw.clear(); }
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(Tile tile){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
49
core/src/io/anuke/mindustry/world/blocks/Blocks.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
|
public class Blocks{
|
||||||
|
public static final Block
|
||||||
|
|
||||||
|
air = new Block("air"){
|
||||||
|
//no drawing here
|
||||||
|
public void draw(Tile tile){}
|
||||||
|
},
|
||||||
|
|
||||||
|
stone = new Block("stone"),
|
||||||
|
|
||||||
|
dirt = new Block("dirt"),
|
||||||
|
|
||||||
|
iron = new Block("iron"),
|
||||||
|
|
||||||
|
coal = new Block("coal"),
|
||||||
|
|
||||||
|
grass = new Block("grass"),
|
||||||
|
|
||||||
|
stoneblock = new Block("stoneblock"){{
|
||||||
|
solid = true;
|
||||||
|
}},
|
||||||
|
|
||||||
|
dirtblock = new Block("dirtblock"){{
|
||||||
|
solid = true;
|
||||||
|
}},
|
||||||
|
|
||||||
|
stonewall = new Block("stonewall"){{
|
||||||
|
solid = true;
|
||||||
|
update = true;
|
||||||
|
health = 50;
|
||||||
|
}},
|
||||||
|
|
||||||
|
ironwall = new Block("ironwall"){{
|
||||||
|
solid = true;
|
||||||
|
update = true;
|
||||||
|
health = 80;
|
||||||
|
}},
|
||||||
|
|
||||||
|
steelwall = new Block("steelwall"){{
|
||||||
|
solid = true;
|
||||||
|
update = true;
|
||||||
|
health = 100;
|
||||||
|
}};
|
||||||
|
}
|
||||||
103
core/src/io/anuke/mindustry/world/blocks/Conveyor.java
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
import com.badlogic.gdx.utils.DelayedRemovalArray;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class Conveyor extends Block{
|
||||||
|
float speed = 0.02f;
|
||||||
|
|
||||||
|
protected Conveyor(String name) {
|
||||||
|
super(name);
|
||||||
|
rotate = true;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile){
|
||||||
|
ConveyorEntity entity = tile.entity();
|
||||||
|
|
||||||
|
Draw.rect(name() + (Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90);
|
||||||
|
|
||||||
|
for(ItemPos pos : entity.convey){
|
||||||
|
vector.set(tilesize, 0).rotate(tile.rotation * 90);
|
||||||
|
vector2.set(-tilesize / 2, pos.y*tilesize/2).rotate(tile.rotation * 90);
|
||||||
|
|
||||||
|
Draw.rect("icon-" + pos.item.name(),
|
||||||
|
tile.x * tilesize + vector.x * pos.pos + vector2.x,
|
||||||
|
tile.y * tilesize + vector.y * pos.pos + vector2.y, 4, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
ConveyorEntity entity = tile.entity();
|
||||||
|
|
||||||
|
entity.convey.begin();
|
||||||
|
|
||||||
|
for(ItemPos pos : entity.convey){
|
||||||
|
pos.pos += speed * Mathf.delta();
|
||||||
|
pos.y = MathUtils.lerp(pos.y, 0, 0.14f * Mathf.delta());
|
||||||
|
|
||||||
|
if(pos.pos >= 1f && offloadDir(tile, pos.item)){
|
||||||
|
entity.convey.removeValue(pos, true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pos.pos = Mathf.clamp(pos.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.convey.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity(){
|
||||||
|
return new ConveyorEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item item){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description(){
|
||||||
|
return "Moves Items";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleItem(Tile tile, Item item, Tile source){
|
||||||
|
int ch = Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation);
|
||||||
|
int ang = ((source.relativeTo(tile.x, tile.y) - tile.rotation));
|
||||||
|
|
||||||
|
|
||||||
|
float pos = ch == 0 ? 0 : ch%2 == 1 ? 0.5f : 1f;
|
||||||
|
float y = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
||||||
|
|
||||||
|
ConveyorEntity entity = tile.entity();
|
||||||
|
entity.convey.add(new ItemPos(item, pos, y*0.9f));
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ConveyorEntity extends TileEntity{
|
||||||
|
DelayedRemovalArray<ItemPos> convey = new DelayedRemovalArray<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ItemPos{
|
||||||
|
public Item item;
|
||||||
|
public float pos, y;
|
||||||
|
|
||||||
|
public ItemPos(Item item, float pos, float y){
|
||||||
|
this.item = item;
|
||||||
|
this.pos = pos;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
core/src/io/anuke/mindustry/world/blocks/Crafter.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class Crafter extends Block{
|
||||||
|
protected Item[] requirements;
|
||||||
|
protected Item result;
|
||||||
|
|
||||||
|
public Crafter(String name) {
|
||||||
|
super(name);
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
|
||||||
|
if(Timers.get(tile, 20) && tile.entity.hasItem(result)){
|
||||||
|
tryDump(tile, -1, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Item item : requirements){
|
||||||
|
if(!tile.entity.hasItem(item)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Item item : requirements){
|
||||||
|
tile.entity.removeItem(item, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
offloadNear(tile, result);
|
||||||
|
Effects.effect("smelt", tile.entity);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item item){
|
||||||
|
return item == Item.iron || item == Item.coal;
|
||||||
|
}
|
||||||
|
}
|
||||||
62
core/src/io/anuke/mindustry/world/blocks/Drill.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class Drill extends Block{
|
||||||
|
protected Block resource;
|
||||||
|
protected Item result;
|
||||||
|
protected int time = 6;
|
||||||
|
|
||||||
|
public Drill(String name) {
|
||||||
|
super(name);
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
|
||||||
|
if(tile.floor() == resource && Timers.get(tile, 60 * time)){
|
||||||
|
offloadNear(tile, result);
|
||||||
|
Effects.effect("spark", tile.worldx(), tile.worldy());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Timers.get(tile.hashCode() + "dump", 30)){
|
||||||
|
tryDump(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description(){
|
||||||
|
return "Mines 1 "+resource.name+" every "+time+" seconds.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOverlay(Tile tile){
|
||||||
|
|
||||||
|
if(tile.floor() != resource){
|
||||||
|
Draw.tcolor(Color.SCARLET);
|
||||||
|
Draw.tscl(1 / 8f);
|
||||||
|
Draw.text("Not on " + resource.name + " block!", tile.worldx(), tile.worldy() + tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.tscl(0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
//@Override
|
||||||
|
public String error(Tile tile){
|
||||||
|
if(tile.floor() != resource)
|
||||||
|
return "Not on iron ore block!";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Inventory;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class ProductionBlocks{
|
||||||
|
public static final Block
|
||||||
|
|
||||||
|
core = new Block("core"){
|
||||||
|
{
|
||||||
|
health = 300;
|
||||||
|
solid = true;
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleItem(Tile tile, Item item, Tile source){
|
||||||
|
Inventory.addItem(item, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item item){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
conveyor = new Conveyor("conveyor"){{
|
||||||
|
update = true;
|
||||||
|
}},
|
||||||
|
|
||||||
|
steelconveyor = new Conveyor("steelconveyor"){{
|
||||||
|
update = true;
|
||||||
|
speed = 0.04f;
|
||||||
|
}},
|
||||||
|
|
||||||
|
router = new Block("router"){
|
||||||
|
{
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
if(Timers.get(tile, 10) && tile.entity.totalItems() > 0){
|
||||||
|
tryDump(tile, tile.rotation++, null);
|
||||||
|
tile.rotation %= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item item){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description(){
|
||||||
|
return "Split input materials into 3 directions.";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
smelter = new Crafter("smelter"){{
|
||||||
|
health = 70;
|
||||||
|
requirements = new Item[]{Item.coal, Item.iron};
|
||||||
|
result = Item.steel;
|
||||||
|
}},
|
||||||
|
|
||||||
|
stonedrill = new Drill("stonedrill"){{
|
||||||
|
resource = Blocks.stone;
|
||||||
|
result = Item.stone;
|
||||||
|
}},
|
||||||
|
|
||||||
|
irondrill = new Drill("irondrill"){{
|
||||||
|
resource = Blocks.iron;
|
||||||
|
result = Item.iron;
|
||||||
|
}},
|
||||||
|
|
||||||
|
coaldrill = new Drill("coaldrill"){{
|
||||||
|
resource = Blocks.coal;
|
||||||
|
result = Item.coal;
|
||||||
|
}},
|
||||||
|
|
||||||
|
end = null;
|
||||||
|
}
|
||||||
61
core/src/io/anuke/mindustry/world/blocks/RepairTurret.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.World;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.graphics.Hue;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class RepairTurret extends Turret{
|
||||||
|
|
||||||
|
public RepairTurret(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
entity.target = World.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
|
||||||
|
|
||||||
|
if(entity.target != null){
|
||||||
|
entity.rotation = entity.angleTo(entity.target);
|
||||||
|
|
||||||
|
if(Timers.get(tile, reload)){
|
||||||
|
entity.target.health++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOver(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
if(entity.target != null){
|
||||||
|
float x = tile.worldx(), y = tile.worldy();
|
||||||
|
float x2 = entity.target.x, y2 = entity.target.y;
|
||||||
|
|
||||||
|
Draw.color(Hue.rgb(138, 244, 138, (MathUtils.sin(Timers.time()) + 1f) / 14f));
|
||||||
|
Draw.alpha(0.3f);
|
||||||
|
Draw.thickness(4f);
|
||||||
|
Draw.line(x, y, x2, y2);
|
||||||
|
Draw.thickness(2f);
|
||||||
|
Draw.rect("circle", x2, y2, 7f, 7f);
|
||||||
|
Draw.alpha(1f);
|
||||||
|
Draw.thickness(2f);
|
||||||
|
Draw.line(x, y, x2, y2);
|
||||||
|
Draw.thickness(1f);
|
||||||
|
Draw.rect("circle", x2, y2, 5f, 5f);
|
||||||
|
Draw.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.rect(name(), tile.worldx(), tile.worldy(), entity.rotation - 90);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description(){
|
||||||
|
return "Heals nearby tiles.";
|
||||||
|
}
|
||||||
|
}
|
||||||
122
core/src/io/anuke/mindustry/world/blocks/Turret.java
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.*;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.util.Angles;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class Turret extends Block{
|
||||||
|
protected float range = 50f;
|
||||||
|
protected float reload = 10f;
|
||||||
|
protected String shootsound = "shoot";
|
||||||
|
protected BulletType bullet;
|
||||||
|
protected Item ammo;
|
||||||
|
|
||||||
|
public Turret(String name) {
|
||||||
|
super(name);
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile){
|
||||||
|
Draw.rect("block", tile.worldx(), tile.worldy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOver(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
Draw.rect(name(), tile.worldx(), tile.worldy(), entity.rotation - 90);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawPixelOverlay(Tile tile){
|
||||||
|
Draw.color("green");
|
||||||
|
Draw.dashcircle(tile.worldx(), tile.worldy(), range);
|
||||||
|
Draw.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOverlay(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
if(entity.ammo <= 0 && ammo != null){
|
||||||
|
Draw.tcolor(Color.SCARLET);
|
||||||
|
Draw.tscl(1 / 8f);
|
||||||
|
Draw.text("No ammo!", tile.worldx(), tile.worldy() + tilesize);
|
||||||
|
|
||||||
|
}else if(ammo != null){
|
||||||
|
Draw.tscl(1 / 8f);
|
||||||
|
Draw.tcolor(Color.GREEN);
|
||||||
|
Draw.text("Ammo: " + entity.ammo, tile.worldx(), tile.worldy() - tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.tscl(0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Item item){
|
||||||
|
return item == ammo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description(){
|
||||||
|
return "Shoots things.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
if(entity.hasItem(ammo)){
|
||||||
|
entity.ammo += 20;
|
||||||
|
entity.removeItem(ammo, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity.ammo > 0){
|
||||||
|
Enemy enemy = (Enemy)Entities.getClosest(tile.worldx(), tile.worldy(), range, e->{
|
||||||
|
return e instanceof Enemy;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(enemy != null){
|
||||||
|
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f), 0.2f);
|
||||||
|
if(Timers.get(tile, reload)){
|
||||||
|
Effects.sound(shootsound, entity);
|
||||||
|
shoot(tile);
|
||||||
|
entity.ammo --;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity(){
|
||||||
|
return new TurretEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void shoot(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
vector.set(0, 4).setAngle(entity.rotation);
|
||||||
|
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, entity.rotation).add();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void bullet(Tile tile, float angle){
|
||||||
|
new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class TurretEntity extends TileEntity{
|
||||||
|
public TileEntity target;
|
||||||
|
public int ammo;
|
||||||
|
public float rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
109
core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.BulletType;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
|
public class WeaponBlocks{
|
||||||
|
public static Block
|
||||||
|
|
||||||
|
turret = new Turret("turret"){
|
||||||
|
{
|
||||||
|
range = 50;
|
||||||
|
reload = 10f;
|
||||||
|
bullet = BulletType.stone;
|
||||||
|
ammo = Item.stone;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
doubleturret = new Turret("doubleturret"){
|
||||||
|
{
|
||||||
|
range = 40;
|
||||||
|
reload = 13f;
|
||||||
|
bullet = BulletType.stone;
|
||||||
|
ammo = Item.stone;
|
||||||
|
health = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shoot(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
vector.set(4, -2).rotate(entity.rotation);
|
||||||
|
bullet(tile, entity.rotation);
|
||||||
|
|
||||||
|
vector.set(4, 2).rotate(entity.rotation);
|
||||||
|
bullet(tile, entity.rotation);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
machineturret = new Turret("machineturret"){
|
||||||
|
{
|
||||||
|
range = 65;
|
||||||
|
reload = 7f;
|
||||||
|
bullet = BulletType.iron;
|
||||||
|
ammo = Item.iron;
|
||||||
|
health = 65;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
shotgunturret = new Turret("shotgunturret"){
|
||||||
|
{
|
||||||
|
range = 50;
|
||||||
|
reload = 40f;
|
||||||
|
bullet = BulletType.iron;
|
||||||
|
ammo = Item.iron;
|
||||||
|
health = 70;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shoot(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
for(int i = 0; i < 6; i ++)
|
||||||
|
Timers.run(i/1.5f, ()->{
|
||||||
|
vector.set(4, 0).setAngle(entity.rotation);
|
||||||
|
bullet(tile, entity.rotation + Mathf.range(16));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
flameturret = new Turret("flameturret"){
|
||||||
|
{
|
||||||
|
range = 35f;
|
||||||
|
reload = 5f;
|
||||||
|
bullet = BulletType.flame;
|
||||||
|
ammo = Item.coal;
|
||||||
|
health = 85;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
sniperturret = new Turret("sniperturret"){
|
||||||
|
{
|
||||||
|
range = 100;
|
||||||
|
reload = 60f;
|
||||||
|
bullet = BulletType.sniper;
|
||||||
|
ammo = Item.steel;
|
||||||
|
health = 60;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
repairturret = new RepairTurret("repairturret"){
|
||||||
|
{
|
||||||
|
range = 30;
|
||||||
|
reload = 40f;
|
||||||
|
health = 60;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
megarepairturret = new RepairTurret("megarepairturret"){
|
||||||
|
{
|
||||||
|
range = 50;
|
||||||
|
reload = 20f;
|
||||||
|
health = 90;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
|
||||||
<module>
|
|
||||||
<source path="io/anuke/ucore" />
|
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.ucore.scene" />
|
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.ucore.scene.ui" />
|
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.ucore.scene.style.Styles" />
|
|
||||||
</module>
|
|
||||||
@@ -3,7 +3,7 @@ apply plugin: "java"
|
|||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||||
|
|
||||||
project.ext.mainClassName = "io.anuke.moment.desktop.DesktopLauncher"
|
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
|
||||||
project.ext.assetsDir = new File("../core/assets");
|
project.ext.assetsDir = new File("../core/assets");
|
||||||
|
|
||||||
task run(dependsOn: classes, type: JavaExec) {
|
task run(dependsOn: classes, type: JavaExec) {
|
||||||
|
|||||||
BIN
desktop/gifexport/recording1493769807.gif
Normal file
|
After Width: | Height: | Size: 568 KiB |
BIN
desktop/gifexport/recording1493777288.gif
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
desktop/gifexport/recording1493777471.gif
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
desktop/gifexport/recording1493777483.gif
Normal file
|
After Width: | Height: | Size: 887 KiB |
BIN
desktop/gifexport/recording1493777703.gif
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
@@ -1,17 +1,14 @@
|
|||||||
package io.anuke.moment.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||||
|
import io.anuke.mindustry.Mindustry;
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
|
|
||||||
public class DesktopLauncher {
|
public class DesktopLauncher {
|
||||||
public static void main (String[] arg) {
|
public static void main (String[] arg) {
|
||||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||||
config.setTitle("Moment");
|
config.setTitle("Mindustry");
|
||||||
config.setMaximized(true);
|
config.setMaximized(true);
|
||||||
config.useVsync(false);
|
new Lwjgl3Application(new Mindustry(), config);
|
||||||
config.setWindowedMode(800, 600);
|
|
||||||
new Lwjgl3Application(new Moment(), config);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ gwt {
|
|||||||
minHeapSize="1G"
|
minHeapSize="1G"
|
||||||
|
|
||||||
src = files(file("src/")) // Needs to be in front of "modules" below.
|
src = files(file("src/")) // Needs to be in front of "modules" below.
|
||||||
modules 'io.anuke.moment.GdxDefinition'
|
modules 'io.anuke.mindustry.GdxDefinition'
|
||||||
devModules 'io.anuke.moment.GdxDefinitionSuperdev'
|
devModules 'io.anuke.mindustry.GdxDefinitionSuperdev'
|
||||||
project.webAppDirName = 'webapp'
|
project.webAppDirName = 'webapp'
|
||||||
|
|
||||||
compiler {
|
compiler {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
||||||
<module rename-to="html">
|
<module rename-to="html">
|
||||||
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
|
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
|
||||||
|
<inherits name='com.badlogic.gdx.physics.box2d.box2d-gwt' />
|
||||||
|
|
||||||
<inherits name='Moment' />
|
<inherits name='Mindustry' />
|
||||||
<inherits name='uCore' />
|
<inherits name='uCore' />
|
||||||
<inherits name='com.badlogic.gdx.ai' />
|
<entry-point class='io.anuke.mindustry.client.HtmlLauncher' />
|
||||||
<entry-point class='io.anuke.moment.client.HtmlLauncher' />
|
|
||||||
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
|
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
|
||||||
<set-configuration-property name="gdx.assetpath" value="../core/assets" />
|
<set-configuration-property name="gdx.assetpath" value="../core/assets" />
|
||||||
</module>
|
</module>
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
|
||||||
<module rename-to="html">
|
<module rename-to="html">
|
||||||
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
|
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
|
||||||
|
<inherits name='com.badlogic.gdx.physics.box2d.box2d-gwt' />
|
||||||
|
|
||||||
<inherits name='io.anuke.moment.GdxDefinition' />
|
<inherits name='io.anuke.mindustry.GdxDefinition' />
|
||||||
|
|
||||||
<collapse-all-properties />
|
<collapse-all-properties />
|
||||||
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
package io.anuke.moment.client;
|
package io.anuke.mindustry.client;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationListener;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
import com.badlogic.gdx.backends.gwt.GwtApplication;
|
import com.badlogic.gdx.backends.gwt.GwtApplication;
|
||||||
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
|
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
|
||||||
|
import io.anuke.mindustry.Mindustry;
|
||||||
import com.google.gwt.dom.client.*;
|
import com.google.gwt.dom.client.*;
|
||||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
import io.anuke.mindustry.Moment;
|
|
||||||
|
|
||||||
public class HtmlLauncher extends GwtApplication {
|
public class HtmlLauncher extends GwtApplication {
|
||||||
static final int WIDTH = 800;
|
static final int WIDTH = 800;
|
||||||
static final int HEIGHT = 600;
|
static final int HEIGHT = 600;
|
||||||
@@ -49,7 +48,7 @@ public class HtmlLauncher extends GwtApplication {
|
|||||||
setupResizeHook();
|
setupResizeHook();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new Moment();
|
return new Mindustry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scaleCanvas() {
|
void scaleCanvas() {
|
||||||
@@ -90,11 +89,11 @@ public class HtmlLauncher extends GwtApplication {
|
|||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
native void setupResizeHook() /*-{
|
native void setupResizeHook() /*-{
|
||||||
var htmlLauncher_onWindowResize = $entry(@io.anuke.moment.client.HtmlLauncher::handleResize());
|
var htmlLauncher_onWindowResize = $entry(@io.anuke.mindustry.client.HtmlLauncher::handleResize());
|
||||||
$wnd.addEventListener('resize', htmlLauncher_onWindowResize, false);
|
$wnd.addEventListener('resize', htmlLauncher_onWindowResize, false);
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
public static void handleResize() {
|
public static void handleResize() {
|
||||||
instance.scaleCanvas();
|
instance.scaleCanvas();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Moment</title>
|
<title>Mindustry</title>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
<link href="styles.css" rel="stylesheet" type="text/css">
|
<link href="styles.css" rel="stylesheet" type="text/css">
|
||||||
<script src="soundmanager2-setup.js"></script>
|
<script src="soundmanager2-setup.js"></script>
|
||||||
<script src="soundmanager2-jsmin.js"></script>
|
<script src="soundmanager2-jsmin.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onkeydown="preventUseOfDefaultKeys(event);" oncontextmenu="return false;">
|
<body onkeydown="preventUseOfDefaultKeys(event);">
|
||||||
<div align="center" id="embed-html"></div>
|
<div align="center" id="embed-html"></div>
|
||||||
<script type="text/javascript" src="html/html.nocache.js"></script>
|
<script type="text/javascript" src="html/html.nocache.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||