Multiplayer: added mobile devies support
|
@ -0,0 +1,127 @@
|
|||
## Java
|
||||
|
||||
*.class
|
||||
*.war
|
||||
*.ear
|
||||
hs_err_pid*
|
||||
|
||||
## Robovm
|
||||
/ios/robovm-build/
|
||||
|
||||
## GWT
|
||||
/html/war/
|
||||
/html/gwt-unitCache/
|
||||
.apt_generated/
|
||||
.gwt/
|
||||
gwt-unitCache/
|
||||
www-test/
|
||||
.gwt-tmp/
|
||||
|
||||
## Android Studio and Intellij and Android in general
|
||||
/android/libs/armeabi/
|
||||
/android/libs/armeabi-v7a/
|
||||
/android/libs/arm64-v8a/
|
||||
/android/libs/x86/
|
||||
/android/libs/x86_64/
|
||||
/android/gen/
|
||||
.idea/
|
||||
*.ipr
|
||||
*.iws
|
||||
*.iml
|
||||
/android/out/
|
||||
com_crashlytics_export_strings.xml
|
||||
|
||||
## Eclipse
|
||||
|
||||
.classpath
|
||||
.project
|
||||
.metadata/
|
||||
/android/bin/
|
||||
/core/bin/
|
||||
/desktop/bin/
|
||||
/html/bin/
|
||||
/ios/bin/
|
||||
/ios-moe/bin/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
.settings/
|
||||
.loadpath
|
||||
.externalToolBuilders/
|
||||
*.launch
|
||||
|
||||
## NetBeans
|
||||
|
||||
/nbproject/private/
|
||||
/android/nbproject/private/
|
||||
/core/nbproject/private/
|
||||
/desktop/nbproject/private/
|
||||
/html/nbproject/private/
|
||||
/ios/nbproject/private/
|
||||
/ios-moe/nbproject/private/
|
||||
|
||||
/build/
|
||||
/android/build/
|
||||
/core/build/
|
||||
/desktop/build/
|
||||
/html/build/
|
||||
/ios/build/
|
||||
/ios-moe/build/
|
||||
|
||||
/nbbuild/
|
||||
/android/nbbuild/
|
||||
/core/nbbuild/
|
||||
/desktop/nbbuild/
|
||||
/html/nbbuild/
|
||||
/ios/nbbuild/
|
||||
/ios-moe/nbbuild/
|
||||
|
||||
/dist/
|
||||
/android/dist/
|
||||
/core/dist/
|
||||
/desktop/dist/
|
||||
/html/dist/
|
||||
/ios/dist/
|
||||
/ios-moe/dist/
|
||||
|
||||
/nbdist/
|
||||
/android/nbdist/
|
||||
/core/nbdist/
|
||||
/desktop/nbdist/
|
||||
/html/nbdist/
|
||||
/ios/nbdist/
|
||||
/ios-moe/nbdist/
|
||||
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
|
||||
## Gradle
|
||||
|
||||
/local.properties
|
||||
.gradle/
|
||||
gradle-app.setting
|
||||
/build/
|
||||
/android/build/
|
||||
/core/build/
|
||||
/desktop/build/
|
||||
/html/build/
|
||||
/ios/build/
|
||||
/ios-moe/build/
|
||||
|
||||
## OS Specific
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
## iOS
|
||||
/ios/xcode/*.xcodeproj/*
|
||||
!/ios/xcode/*.xcodeproj/xcshareddata
|
||||
!/ios/xcode/*.xcodeproj/project.pbxproj
|
||||
/ios/xcode/native/
|
||||
/ios/IOSLauncher.app
|
||||
/ios/IOSLauncher.app.dSYM
|
||||
|
||||
/ios-moe/xcode/*.xcodeproj/*
|
||||
!/ios-moe/xcode/*.xcodeproj/xcshareddata
|
||||
!/ios-moe/xcode/*.xcodeproj/project.pbxproj
|
||||
/ios-moe/xcode/native/
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.emamaker.amazeing" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:isGame="true"
|
||||
android:appCategory="game"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/GdxTheme" >
|
||||
<activity
|
||||
android:name="com.emamaker.amazeing.AndroidLauncher"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="landscape"
|
||||
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
After Width: | Height: | Size: 67 KiB |
|
@ -0,0 +1,101 @@
|
|||
info face="Droid Sans" size=17 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
|
||||
common lineHeight=20 base=18 scaleW=256 scaleH=128 pages=1 packed=0
|
||||
page id=0 file="default.png"
|
||||
chars count=96
|
||||
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=16 xadvance=4 page=0 chnl=0
|
||||
char id=124 x=0 y=0 width=6 height=20 xoffset=1 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=106 x=6 y=0 width=9 height=20 xoffset=-4 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=81 x=15 y=0 width=15 height=19 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0
|
||||
char id=74 x=30 y=0 width=11 height=19 xoffset=-5 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=125 x=41 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=123 x=51 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=93 x=61 y=0 width=8 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=91 x=69 y=0 width=8 height=18 xoffset=-2 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=41 x=77 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=40 x=86 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=64 x=95 y=0 width=18 height=17 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0
|
||||
char id=121 x=113 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=113 x=126 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=112 x=139 y=0 width=13 height=17 xoffset=-2 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=103 x=152 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=38 x=165 y=0 width=16 height=16 xoffset=-3 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=37 x=181 y=0 width=18 height=16 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0
|
||||
char id=36 x=199 y=0 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=63 x=211 y=0 width=11 height=16 xoffset=-3 yoffset=3 xadvance=7 page=0 chnl=0
|
||||
char id=33 x=222 y=0 width=7 height=16 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=48 x=229 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=57 x=242 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=56 x=0 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=54 x=13 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=53 x=26 y=20 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=51 x=38 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=100 x=51 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=98 x=64 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=85 x=77 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=83 x=91 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=79 x=104 y=20 width=15 height=16 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0
|
||||
char id=71 x=119 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=67 x=133 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=127 x=146 y=20 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=35 x=158 y=20 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=92 x=173 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=47 x=184 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=59 x=195 y=20 width=8 height=15 xoffset=-3 yoffset=6 xadvance=4 page=0 chnl=0
|
||||
char id=55 x=203 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=52 x=216 y=20 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=50 x=230 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=49 x=243 y=20 width=9 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=116 x=0 y=36 width=10 height=15 xoffset=-3 yoffset=4 xadvance=5 page=0 chnl=0
|
||||
char id=108 x=10 y=36 width=6 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=107 x=16 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=105 x=28 y=36 width=7 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=104 x=35 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=102 x=47 y=36 width=11 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=90 x=58 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=89 x=71 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=88 x=84 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=87 x=98 y=36 width=19 height=15 xoffset=-3 yoffset=3 xadvance=15 page=0 chnl=0
|
||||
char id=86 x=117 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=84 x=131 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=82 x=144 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=80 x=157 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=78 x=169 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0
|
||||
char id=77 x=183 y=36 width=17 height=15 xoffset=-2 yoffset=3 xadvance=14 page=0 chnl=0
|
||||
char id=76 x=200 y=36 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=75 x=211 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=73 x=224 y=36 width=10 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=72 x=234 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=70 x=0 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=69 x=11 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=68 x=22 y=51 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=66 x=36 y=51 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=65 x=49 y=51 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=58 x=64 y=51 width=7 height=13 xoffset=-2 yoffset=6 xadvance=4 page=0 chnl=0
|
||||
char id=117 x=71 y=51 width=12 height=13 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0
|
||||
char id=115 x=83 y=51 width=11 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0
|
||||
char id=111 x=94 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=101 x=107 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=99 x=120 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0
|
||||
char id=97 x=132 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=60 x=144 y=51 width=13 height=12 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0
|
||||
char id=122 x=157 y=51 width=11 height=12 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0
|
||||
char id=120 x=168 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=119 x=181 y=51 width=17 height=12 xoffset=-3 yoffset=6 xadvance=12 page=0 chnl=0
|
||||
char id=118 x=198 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=114 x=211 y=51 width=10 height=12 xoffset=-2 yoffset=6 xadvance=6 page=0 chnl=0
|
||||
char id=110 x=221 y=51 width=12 height=12 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0
|
||||
char id=109 x=233 y=51 width=17 height=12 xoffset=-2 yoffset=6 xadvance=15 page=0 chnl=0
|
||||
char id=94 x=0 y=66 width=13 height=11 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=62 x=13 y=66 width=13 height=11 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0
|
||||
char id=42 x=26 y=66 width=13 height=10 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=43 x=39 y=66 width=13 height=10 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=61 x=52 y=66 width=13 height=8 xoffset=-3 yoffset=7 xadvance=9 page=0 chnl=0
|
||||
char id=39 x=65 y=66 width=6 height=8 xoffset=-2 yoffset=3 xadvance=3 page=0 chnl=0
|
||||
char id=34 x=71 y=66 width=9 height=8 xoffset=-2 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=44 x=80 y=66 width=8 height=7 xoffset=-3 yoffset=14 xadvance=4 page=0 chnl=0
|
||||
char id=126 x=88 y=66 width=13 height=6 xoffset=-3 yoffset=8 xadvance=9 page=0 chnl=0
|
||||
char id=46 x=101 y=66 width=7 height=6 xoffset=-2 yoffset=13 xadvance=4 page=0 chnl=0
|
||||
char id=96 x=108 y=66 width=8 height=6 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0
|
||||
char id=45 x=116 y=66 width=9 height=5 xoffset=-3 yoffset=10 xadvance=5 page=0 chnl=0
|
||||
char id=95 x=125 y=66 width=13 height=4 xoffset=-4 yoffset=17 xadvance=6 page=0 chnl=0
|
||||
kernings count=-1
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec2 v_texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(v_texCoord0, 0.0, 1.0);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
attribute vec3 a_position;
|
||||
attribute vec3 a_normal;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_worldTrans;
|
||||
uniform mat4 u_projViewTrans;
|
||||
|
||||
varying vec2 v_texCoord0;
|
||||
|
||||
void main() {
|
||||
v_texCoord0 = a_texCoord0;
|
||||
gl_Position = u_projViewTrans * u_worldTrans * vec4(a_position, 1.0);
|
||||
}
|
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
|
@ -0,0 +1,200 @@
|
|||
|
||||
uiskin.png
|
||||
size: 256,128
|
||||
format: RGBA8888
|
||||
filter: Linear,Linear
|
||||
repeat: none
|
||||
check-off
|
||||
rotate: false
|
||||
xy: 11, 5
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
textfield
|
||||
rotate: false
|
||||
xy: 11, 5
|
||||
size: 14, 14
|
||||
split: 3, 3, 3, 3
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
check-on
|
||||
rotate: false
|
||||
xy: 125, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
cursor
|
||||
rotate: false
|
||||
xy: 23, 1
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default
|
||||
rotate: false
|
||||
xy: 1, 50
|
||||
size: 254, 77
|
||||
orig: 254, 77
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-pane
|
||||
rotate: false
|
||||
xy: 11, 1
|
||||
size: 5, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect-pad
|
||||
rotate: false
|
||||
xy: 11, 1
|
||||
size: 5, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-pane-noborder
|
||||
rotate: false
|
||||
xy: 170, 44
|
||||
size: 1, 1
|
||||
split: 0, 0, 0, 0
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect
|
||||
rotate: false
|
||||
xy: 38, 25
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect-down
|
||||
rotate: false
|
||||
xy: 170, 46
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round
|
||||
rotate: false
|
||||
xy: 112, 29
|
||||
size: 12, 20
|
||||
split: 5, 5, 5, 4
|
||||
pad: 4, 4, 1, 1
|
||||
orig: 12, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round-down
|
||||
rotate: false
|
||||
xy: 99, 29
|
||||
size: 12, 20
|
||||
split: 5, 5, 5, 4
|
||||
pad: 4, 4, 1, 1
|
||||
orig: 12, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round-large
|
||||
rotate: false
|
||||
xy: 57, 29
|
||||
size: 20, 20
|
||||
split: 5, 5, 5, 4
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-scroll
|
||||
rotate: false
|
||||
xy: 78, 29
|
||||
size: 20, 20
|
||||
split: 2, 2, 2, 2
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-select
|
||||
rotate: false
|
||||
xy: 29, 29
|
||||
size: 27, 20
|
||||
split: 4, 14, 4, 4
|
||||
orig: 27, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-select-selection
|
||||
rotate: false
|
||||
xy: 26, 16
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-slider
|
||||
rotate: false
|
||||
xy: 29, 20
|
||||
size: 8, 8
|
||||
split: 2, 2, 2, 2
|
||||
orig: 8, 8
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-slider-knob
|
||||
rotate: false
|
||||
xy: 1, 1
|
||||
size: 9, 18
|
||||
orig: 9, 18
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-splitpane
|
||||
rotate: false
|
||||
xy: 17, 1
|
||||
size: 5, 3
|
||||
split: 0, 5, 0, 0
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-splitpane-vertical
|
||||
rotate: false
|
||||
xy: 125, 29
|
||||
size: 3, 5
|
||||
split: 0, 0, 0, 5
|
||||
orig: 3, 5
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-window
|
||||
rotate: false
|
||||
xy: 1, 20
|
||||
size: 27, 29
|
||||
split: 4, 3, 20, 3
|
||||
orig: 27, 29
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
selection
|
||||
rotate: false
|
||||
xy: 174, 48
|
||||
size: 1, 1
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-minus
|
||||
rotate: false
|
||||
xy: 140, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-plus
|
||||
rotate: false
|
||||
xy: 155, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
white
|
||||
rotate: false
|
||||
xy: 129, 31
|
||||
size: 3, 3
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
BitmapFont: { default-font: { file: default.fnt } },
|
||||
Color: {
|
||||
green: { a: 1, b: 0, g: 1, r: 0 },
|
||||
white: { a: 1, b: 1, g: 1, r: 1 },
|
||||
red: { a: 1, b: 0, g: 0, r: 1 },
|
||||
black: { a: 1, b: 0, g: 0, r: 0 },
|
||||
},
|
||||
TintedDrawable: {
|
||||
dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } },
|
||||
},
|
||||
ButtonStyle: {
|
||||
default: { down: default-round-down, up: default-round },
|
||||
toggle: { parent: default, checked: default-round-down }
|
||||
},
|
||||
TextButtonStyle: {
|
||||
default: { parent: default, font: default-font, fontColor: white },
|
||||
toggle: { parent: default, checked: default-round-down, downFontColor: red }
|
||||
},
|
||||
ScrollPaneStyle: {
|
||||
default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }
|
||||
},
|
||||
SelectBoxStyle: {
|
||||
default: {
|
||||
font: default-font, fontColor: white, background: default-select,
|
||||
scrollStyle: default,
|
||||
listStyle: { font: default-font, selection: default-select-selection }
|
||||
}
|
||||
},
|
||||
SplitPaneStyle: {
|
||||
default-vertical: { handle: default-splitpane-vertical },
|
||||
default-horizontal: { handle: default-splitpane }
|
||||
},
|
||||
WindowStyle: {
|
||||
default: { titleFont: default-font, background: default-window, titleFontColor: white },
|
||||
dialog: { parent: default, stageBackground: dialogDim }
|
||||
},
|
||||
ProgressBarStyle: {
|
||||
default-horizontal: { background: default-slider, knob: default-slider-knob },
|
||||
default-vertical: { background: default-slider, knob: default-round-large }
|
||||
},
|
||||
SliderStyle: {
|
||||
default-horizontal: { parent: default-horizontal },
|
||||
default-vertical: { parent: default-vertical }
|
||||
},
|
||||
LabelStyle: {
|
||||
default: { font: default-font, fontColor: white }
|
||||
},
|
||||
TextFieldStyle: {
|
||||
default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }
|
||||
},
|
||||
CheckBoxStyle: {
|
||||
default: { checkboxOn: check-on, checkboxOff: check-off, font: default-font, fontColor: white }
|
||||
},
|
||||
ListStyle: {
|
||||
default: { fontColorUnselected: white, selection: selection, fontColorSelected: white, font: default-font }
|
||||
},
|
||||
TouchpadStyle: {
|
||||
default: { background: default-pane, knob: default-round-large }
|
||||
},
|
||||
TreeStyle: {
|
||||
default: { minus: tree-minus, plus: tree-plus, selection: default-select-selection }
|
||||
},
|
||||
TextTooltipStyle: {
|
||||
default: {
|
||||
label: { font: default-font, fontColor: white },
|
||||
background: default-pane, wrapWidth: 150
|
||||
}
|
||||
},
|
||||
}
|
After Width: | Height: | Size: 28 KiB |
|
@ -0,0 +1,97 @@
|
|||
android {
|
||||
buildToolsVersion "29.0.2"
|
||||
compileSdkVersion 29
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java.srcDirs = ['src']
|
||||
aidl.srcDirs = ['src']
|
||||
renderscript.srcDirs = ['src']
|
||||
res.srcDirs = ['res']
|
||||
assets.srcDirs = ['assets']
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/robovm/ios/robovm.xml'
|
||||
}
|
||||
defaultConfig {
|
||||
applicationId "com.emamaker.amazeing"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// called every time gradle gets executed, takes the native dependencies of
|
||||
// the natives configuration, and extracts them to the proper libs/ folders
|
||||
// so they get packed with the APK.
|
||||
task copyAndroidNatives {
|
||||
doFirst {
|
||||
file("libs/armeabi/").mkdirs()
|
||||
file("libs/armeabi-v7a/").mkdirs()
|
||||
file("libs/arm64-v8a/").mkdirs()
|
||||
file("libs/x86_64/").mkdirs()
|
||||
file("libs/x86/").mkdirs()
|
||||
|
||||
configurations.natives.files.each { jar ->
|
||||
def outputDir = null
|
||||
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
|
||||
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
|
||||
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
|
||||
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
|
||||
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
|
||||
if(outputDir != null) {
|
||||
copy {
|
||||
from zipTree(jar)
|
||||
into outputDir
|
||||
include "*.so"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.whenTaskAdded { packageTask ->
|
||||
if (packageTask.name.contains("package")) {
|
||||
packageTask.dependsOn 'copyAndroidNatives'
|
||||
}
|
||||
}
|
||||
|
||||
task run(type: Exec) {
|
||||
def path
|
||||
def localProperties = project.file("../local.properties")
|
||||
if (localProperties.exists()) {
|
||||
Properties properties = new Properties()
|
||||
localProperties.withInputStream { instr ->
|
||||
properties.load(instr)
|
||||
}
|
||||
def sdkDir = properties.getProperty('sdk.dir')
|
||||
if (sdkDir) {
|
||||
path = sdkDir
|
||||
} else {
|
||||
path = "$System.env.ANDROID_HOME"
|
||||
}
|
||||
} else {
|
||||
path = "$System.env.ANDROID_HOME"
|
||||
}
|
||||
|
||||
def adb = path + "/platform-tools/adb"
|
||||
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.emamaker.amazeing/com.emamaker.amazeing.AndroidLauncher'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation files('/home/emamaker/github/amazeing/gdx/lib/kryonet-2.21-all.jar')
|
||||
}
|
||||
|
||||
|
||||
eclipse.project.name = appName + "-android"
|
After Width: | Height: | Size: 22 KiB |
|
@ -0,0 +1,45 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
-verbose
|
||||
|
||||
-dontwarn android.support.**
|
||||
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
|
||||
-dontwarn com.badlogic.gdx.utils.GdxBuild
|
||||
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
|
||||
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
|
||||
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
|
||||
|
||||
-keep class com.badlogic.gdx.controllers.android.AndroidControllers
|
||||
|
||||
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
|
||||
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
|
||||
}
|
||||
|
||||
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
|
||||
boolean contactFilter(long, long);
|
||||
void beginContact(long);
|
||||
void endContact(long);
|
||||
void preSolve(long, long);
|
||||
void postSolve(long, long);
|
||||
boolean reportFixture(long);
|
||||
float reportRayFixture(long, float, float, float, float, float);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
# This file is used by the Eclipse ADT plugin. It is unnecessary for IDEA and Android Studio projects, which
|
||||
# configure Proguard and the Android target via the build.gradle file.
|
||||
|
||||
# To enable ProGuard to work with Eclipse ADT, uncomment this (available properties: sdk.dir, user.home)
|
||||
# and ensure proguard.jar in the Android SDK is up to date (or alternately reduce the android target to 23 or lower):
|
||||
# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-rules.pro
|
||||
|
||||
# Project target.
|
||||
target=android-19
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_background_color"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
|
@ -0,0 +1,40 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:pathData="M22,48.667l2.987,0l0,10.667l-2.987,0z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="1"/>
|
||||
<path
|
||||
android:pathData="M26.907,52.72l2.987,0l0,6.613l-2.987,0z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="1"/>
|
||||
<path
|
||||
android:pathData="M26.907,48.667l2.987,0l0,2.56l-2.987,0z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="1"/>
|
||||
<path
|
||||
android:pathData="M31.813,48.667L31.813,52.72 31.813,55.067 31.813,56.767 31.813,59.333l2.992,0 2.117,0c1.654,0 2.998,-1.481 2.998,-3.307 0,-1.826 -1.344,-3.307 -2.998,-3.307l-2.117,0L34.805,48.667ZM34.805,55.067l1.269,0c0.469,0 0.848,0.384 0.848,0.853 0,0.469 -0.379,0.847 -0.848,0.847l-1.269,0z"
|
||||
android:fillColor="#000000"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="1"/>
|
||||
<path
|
||||
android:pathData="m44.192,48.667c-1.65,0 -2.992,1.481 -2.992,3.307 0,0.023 -0,0.044 0,0.067 0,0.004 -0,0.009 0,0.013l0,3.893c-0.001,0.027 0,0.053 0,0.08 0,1.826 1.341,3.307 2.992,3.307l2.112,0 0.247,0 2.739,0 0.247,0 2.112,0c1.651,0 2.992,-1.481 2.992,-3.307 0,-1.826 -1.341,-3.307 -2.992,-3.307l-1.199,0 -0.48,0 -2.372,0l0,2.347l2.372,0 0.48,0 0.353,0c0.468,0 0.846,0.384 0.846,0.853 0,0.469 -0.378,0.847 -0.846,0.847l-0.833,0 -0.433,0 -0.247,0 -2.739,0 -0.247,0 -0.433,0 -0.833,0c-0.459,0 -0.832,-0.363 -0.846,-0.82l0,-3.893 0,-0.013c0.021,-0.45 0.391,-0.807 0.846,-0.807l0.833,0 0.433,0 1.293,0l0,0.007L54.207,51.24L54.207,48.667l-4.917,0 -1.692,0 -1.293,0 -2.112,0z"
|
||||
android:fillColor="#e74a45"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="1"/>
|
||||
<path
|
||||
android:pathData="M56.133,48.667L56.133,51.238l5.406,0 1.859,0 1.105,0 0.43,0 0.827,0c0.452,0 0.82,0.356 0.84,0.806l0,0.013 0,3.891c-0.014,0.456 -0.384,0.819 -0.84,0.819l-0.827,0 -0.43,0 -1.899,0 -1.065,0 -2.442,0L59.098,52.724L56.133,52.724l0,4.044 0,1.752 0,0.813l5.406,0 1.065,0 1.899,0 2.098,0c1.639,0 2.971,-1.48 2.971,-3.305 0,-0.027 0.001,-0.053 0,-0.08L69.573,52.058c0,-0.004 -0,-0.009 0,-0.013 0,-0.022 0,-0.044 0,-0.067 0,-1.825 -1.332,-3.305 -2.971,-3.305l-2.098,0 -1.105,0l0,-0.007L56.133,48.667Z"
|
||||
android:fillColor="#e74a45"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="1"/>
|
||||
<path
|
||||
android:pathData="M69.572,48.667L73.72,48.667L77.787,52.733 81.853,48.667l4.147,0l-5.333,5.333 5.333,5.333L81.853,59.333L77.787,55.267 73.72,59.333l-4.147,0l5.333,-5.333z"
|
||||
android:fillColor="#e74a45"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_background_color">#FFFFFFFF</color>
|
||||
</resources>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">AMazeIng</string>
|
||||
|
||||
</resources>
|
|
@ -0,0 +1,12 @@
|
|||
<resources>
|
||||
|
||||
<style name="GdxTheme" parent="android:Theme">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -0,0 +1,17 @@
|
|||
package com.emamaker.amazeing;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
|
||||
public class AndroidLauncher extends AndroidApplication {
|
||||
@Override
|
||||
protected void onCreate (Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
||||
config.useImmersiveMode = true;
|
||||
initialize(new AMazeIng(AMazeIng.Platform.ANDROID), config);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
buildscript {
|
||||
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.8'
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: "eclipse"
|
||||
|
||||
version = '1.0'
|
||||
ext {
|
||||
appName = "AMazeIng"
|
||||
gdxVersion = '1.9.10'
|
||||
roboVMVersion = '2.3.8'
|
||||
box2DLightsVersion = '1.4'
|
||||
ashleyVersion = '1.7.0'
|
||||
aiVersion = '1.8.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
google()
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
|
||||
}
|
||||
}
|
||||
|
||||
project(":desktop") {
|
||||
apply plugin: "java-library"
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation project(":core")
|
||||
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||
api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
|
||||
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
||||
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
|
||||
api "de.tomgrill.gdxdialogs:gdx-dialogs-desktop:1.2.5"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
project(":android") {
|
||||
apply plugin: "android"
|
||||
|
||||
configurations { natives }
|
||||
|
||||
dependencies {
|
||||
implementation project(":core")
|
||||
api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
|
||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
|
||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
|
||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
|
||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
|
||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
|
||||
api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
|
||||
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
|
||||
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
|
||||
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a"
|
||||
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
|
||||
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"
|
||||
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
|
||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
|
||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
|
||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
|
||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
|
||||
api "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
|
||||
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
api "de.tomgrill.gdxdialogs:gdx-dialogs-android:1.2.5"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
project(":ios") {
|
||||
apply plugin: "java-library"
|
||||
apply plugin: "robovm"
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation project(":core")
|
||||
api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
||||
api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
||||
api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
|
||||
api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"
|
||||
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
|
||||
api "de.tomgrill.gdxdialogs:gdx-dialogs-ios:1.2.5"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
project(":core") {
|
||||
apply plugin: "java-library"
|
||||
|
||||
|
||||
dependencies {
|
||||
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
|
||||
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
api "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
|
||||
api "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.2.5"
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
info face="Droid Sans" size=17 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
|
||||
common lineHeight=20 base=18 scaleW=256 scaleH=128 pages=1 packed=0
|
||||
page id=0 file="default.png"
|
||||
chars count=96
|
||||
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=16 xadvance=4 page=0 chnl=0
|
||||
char id=124 x=0 y=0 width=6 height=20 xoffset=1 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=106 x=6 y=0 width=9 height=20 xoffset=-4 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=81 x=15 y=0 width=15 height=19 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0
|
||||
char id=74 x=30 y=0 width=11 height=19 xoffset=-5 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=125 x=41 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=123 x=51 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=93 x=61 y=0 width=8 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=91 x=69 y=0 width=8 height=18 xoffset=-2 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=41 x=77 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=40 x=86 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=64 x=95 y=0 width=18 height=17 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0
|
||||
char id=121 x=113 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=113 x=126 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=112 x=139 y=0 width=13 height=17 xoffset=-2 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=103 x=152 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=38 x=165 y=0 width=16 height=16 xoffset=-3 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=37 x=181 y=0 width=18 height=16 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0
|
||||
char id=36 x=199 y=0 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=63 x=211 y=0 width=11 height=16 xoffset=-3 yoffset=3 xadvance=7 page=0 chnl=0
|
||||
char id=33 x=222 y=0 width=7 height=16 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=48 x=229 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=57 x=242 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=56 x=0 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=54 x=13 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=53 x=26 y=20 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=51 x=38 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=100 x=51 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=98 x=64 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=85 x=77 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=83 x=91 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=79 x=104 y=20 width=15 height=16 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0
|
||||
char id=71 x=119 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=67 x=133 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=127 x=146 y=20 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=35 x=158 y=20 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=92 x=173 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=47 x=184 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=59 x=195 y=20 width=8 height=15 xoffset=-3 yoffset=6 xadvance=4 page=0 chnl=0
|
||||
char id=55 x=203 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=52 x=216 y=20 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=50 x=230 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=49 x=243 y=20 width=9 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=116 x=0 y=36 width=10 height=15 xoffset=-3 yoffset=4 xadvance=5 page=0 chnl=0
|
||||
char id=108 x=10 y=36 width=6 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=107 x=16 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=105 x=28 y=36 width=7 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0
|
||||
char id=104 x=35 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=102 x=47 y=36 width=11 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=90 x=58 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=89 x=71 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=88 x=84 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=87 x=98 y=36 width=19 height=15 xoffset=-3 yoffset=3 xadvance=15 page=0 chnl=0
|
||||
char id=86 x=117 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=84 x=131 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=82 x=144 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=80 x=157 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=78 x=169 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0
|
||||
char id=77 x=183 y=36 width=17 height=15 xoffset=-2 yoffset=3 xadvance=14 page=0 chnl=0
|
||||
char id=76 x=200 y=36 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=75 x=211 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=73 x=224 y=36 width=10 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0
|
||||
char id=72 x=234 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=70 x=0 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=69 x=11 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0
|
||||
char id=68 x=22 y=51 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0
|
||||
char id=66 x=36 y=51 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=65 x=49 y=51 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0
|
||||
char id=58 x=64 y=51 width=7 height=13 xoffset=-2 yoffset=6 xadvance=4 page=0 chnl=0
|
||||
char id=117 x=71 y=51 width=12 height=13 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0
|
||||
char id=115 x=83 y=51 width=11 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0
|
||||
char id=111 x=94 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=101 x=107 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=99 x=120 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0
|
||||
char id=97 x=132 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=60 x=144 y=51 width=13 height=12 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0
|
||||
char id=122 x=157 y=51 width=11 height=12 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0
|
||||
char id=120 x=168 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=119 x=181 y=51 width=17 height=12 xoffset=-3 yoffset=6 xadvance=12 page=0 chnl=0
|
||||
char id=118 x=198 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0
|
||||
char id=114 x=211 y=51 width=10 height=12 xoffset=-2 yoffset=6 xadvance=6 page=0 chnl=0
|
||||
char id=110 x=221 y=51 width=12 height=12 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0
|
||||
char id=109 x=233 y=51 width=17 height=12 xoffset=-2 yoffset=6 xadvance=15 page=0 chnl=0
|
||||
char id=94 x=0 y=66 width=13 height=11 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=62 x=13 y=66 width=13 height=11 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0
|
||||
char id=42 x=26 y=66 width=13 height=10 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0
|
||||
char id=43 x=39 y=66 width=13 height=10 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0
|
||||
char id=61 x=52 y=66 width=13 height=8 xoffset=-3 yoffset=7 xadvance=9 page=0 chnl=0
|
||||
char id=39 x=65 y=66 width=6 height=8 xoffset=-2 yoffset=3 xadvance=3 page=0 chnl=0
|
||||
char id=34 x=71 y=66 width=9 height=8 xoffset=-2 yoffset=3 xadvance=6 page=0 chnl=0
|
||||
char id=44 x=80 y=66 width=8 height=7 xoffset=-3 yoffset=14 xadvance=4 page=0 chnl=0
|
||||
char id=126 x=88 y=66 width=13 height=6 xoffset=-3 yoffset=8 xadvance=9 page=0 chnl=0
|
||||
char id=46 x=101 y=66 width=7 height=6 xoffset=-2 yoffset=13 xadvance=4 page=0 chnl=0
|
||||
char id=96 x=108 y=66 width=8 height=6 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0
|
||||
char id=45 x=116 y=66 width=9 height=5 xoffset=-3 yoffset=10 xadvance=5 page=0 chnl=0
|
||||
char id=95 x=125 y=66 width=13 height=4 xoffset=-4 yoffset=17 xadvance=6 page=0 chnl=0
|
||||
kernings count=-1
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec2 v_texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(v_texCoord0, 0.0, 1.0);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
attribute vec3 a_position;
|
||||
attribute vec3 a_normal;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_worldTrans;
|
||||
uniform mat4 u_projViewTrans;
|
||||
|
||||
varying vec2 v_texCoord0;
|
||||
|
||||
void main() {
|
||||
v_texCoord0 = a_texCoord0;
|
||||
gl_Position = u_projViewTrans * u_worldTrans * vec4(a_position, 1.0);
|
||||
}
|
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 28 KiB |
|
@ -0,0 +1,200 @@
|
|||
|
||||
uiskin.png
|
||||
size: 256,128
|
||||
format: RGBA8888
|
||||
filter: Linear,Linear
|
||||
repeat: none
|
||||
check-off
|
||||
rotate: false
|
||||
xy: 11, 5
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
textfield
|
||||
rotate: false
|
||||
xy: 11, 5
|
||||
size: 14, 14
|
||||
split: 3, 3, 3, 3
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
check-on
|
||||
rotate: false
|
||||
xy: 125, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
cursor
|
||||
rotate: false
|
||||
xy: 23, 1
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default
|
||||
rotate: false
|
||||
xy: 1, 50
|
||||
size: 254, 77
|
||||
orig: 254, 77
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-pane
|
||||
rotate: false
|
||||
xy: 11, 1
|
||||
size: 5, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect-pad
|
||||
rotate: false
|
||||
xy: 11, 1
|
||||
size: 5, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-pane-noborder
|
||||
rotate: false
|
||||
xy: 170, 44
|
||||
size: 1, 1
|
||||
split: 0, 0, 0, 0
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect
|
||||
rotate: false
|
||||
xy: 38, 25
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect-down
|
||||
rotate: false
|
||||
xy: 170, 46
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round
|
||||
rotate: false
|
||||
xy: 112, 29
|
||||
size: 12, 20
|
||||
split: 5, 5, 5, 4
|
||||
pad: 4, 4, 1, 1
|
||||
orig: 12, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round-down
|
||||
rotate: false
|
||||
xy: 99, 29
|
||||
size: 12, 20
|
||||
split: 5, 5, 5, 4
|
||||
pad: 4, 4, 1, 1
|
||||
orig: 12, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round-large
|
||||
rotate: false
|
||||
xy: 57, 29
|
||||
size: 20, 20
|
||||
split: 5, 5, 5, 4
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-scroll
|
||||
rotate: false
|
||||
xy: 78, 29
|
||||
size: 20, 20
|
||||
split: 2, 2, 2, 2
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-select
|
||||
rotate: false
|
||||
xy: 29, 29
|
||||
size: 27, 20
|
||||
split: 4, 14, 4, 4
|
||||
orig: 27, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-select-selection
|
||||
rotate: false
|
||||
xy: 26, 16
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-slider
|
||||
rotate: false
|
||||
xy: 29, 20
|
||||
size: 8, 8
|
||||
split: 2, 2, 2, 2
|
||||
orig: 8, 8
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-slider-knob
|
||||
rotate: false
|
||||
xy: 1, 1
|
||||
size: 9, 18
|
||||
orig: 9, 18
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-splitpane
|
||||
rotate: false
|
||||
xy: 17, 1
|
||||
size: 5, 3
|
||||
split: 0, 5, 0, 0
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-splitpane-vertical
|
||||
rotate: false
|
||||
xy: 125, 29
|
||||
size: 3, 5
|
||||
split: 0, 0, 0, 5
|
||||
orig: 3, 5
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-window
|
||||
rotate: false
|
||||
xy: 1, 20
|
||||
size: 27, 29
|
||||
split: 4, 3, 20, 3
|
||||
orig: 27, 29
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
selection
|
||||
rotate: false
|
||||
xy: 174, 48
|
||||
size: 1, 1
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-minus
|
||||
rotate: false
|
||||
xy: 140, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-plus
|
||||
rotate: false
|
||||
xy: 155, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
white
|
||||
rotate: false
|
||||
xy: 129, 31
|
||||
size: 3, 3
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
BitmapFont: { default-font: { file: default.fnt } },
|
||||
Color: {
|
||||
green: { a: 1, b: 0, g: 1, r: 0 },
|
||||
white: { a: 1, b: 1, g: 1, r: 1 },
|
||||
red: { a: 1, b: 0, g: 0, r: 1 },
|
||||
black: { a: 1, b: 0, g: 0, r: 0 },
|
||||
},
|
||||
TintedDrawable: {
|
||||
dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } },
|
||||
},
|
||||
ButtonStyle: {
|
||||
default: { down: default-round-down, up: default-round },
|
||||
toggle: { parent: default, checked: default-round-down }
|
||||
},
|
||||
TextButtonStyle: {
|
||||
default: { parent: default, font: default-font, fontColor: white },
|
||||
toggle: { parent: default, checked: default-round-down, downFontColor: red }
|
||||
},
|
||||
ScrollPaneStyle: {
|
||||
default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }
|
||||
},
|
||||
SelectBoxStyle: {
|
||||
default: {
|
||||
font: default-font, fontColor: white, background: default-select,
|
||||
scrollStyle: default,
|
||||
listStyle: { font: default-font, selection: default-select-selection }
|
||||
}
|
||||
},
|
||||
SplitPaneStyle: {
|
||||
default-vertical: { handle: default-splitpane-vertical },
|
||||
default-horizontal: { handle: default-splitpane }
|
||||
},
|
||||
WindowStyle: {
|
||||
default: { titleFont: default-font, background: default-window, titleFontColor: white },
|
||||
dialog: { parent: default, stageBackground: dialogDim }
|
||||
},
|
||||
ProgressBarStyle: {
|
||||
default-horizontal: { background: default-slider, knob: default-slider-knob },
|
||||
default-vertical: { background: default-slider, knob: default-round-large }
|
||||
},
|
||||
SliderStyle: {
|
||||
default-horizontal: { parent: default-horizontal },
|
||||
default-vertical: { parent: default-vertical }
|
||||
},
|
||||
LabelStyle: {
|
||||
default: { font: default-font, fontColor: white }
|
||||
},
|
||||
TextFieldStyle: {
|
||||
default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }
|
||||
},
|
||||
CheckBoxStyle: {
|
||||
default: { checkboxOn: check-on, checkboxOff: check-off, font: default-font, fontColor: white }
|
||||
},
|
||||
ListStyle: {
|
||||
default: { fontColorUnselected: white, selection: selection, fontColorSelected: white, font: default-font }
|
||||
},
|
||||
TouchpadStyle: {
|
||||
default: { background: default-pane, knob: default-round-large }
|
||||
},
|
||||
TreeStyle: {
|
||||
default: { minus: tree-minus, plus: tree-plus, selection: default-select-selection }
|
||||
},
|
||||
TextTooltipStyle: {
|
||||
default: {
|
||||
label: { font: default-font, fontColor: white },
|
||||
background: default-pane, wrapWidth: 150
|
||||
}
|
||||
},
|
||||
}
|
After Width: | Height: | Size: 28 KiB |
|
@ -0,0 +1,11 @@
|
|||
apply plugin: "java"
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
dependencies {
|
||||
implementation files('/home/emamaker/github/amazeing/gdx/lib/kryonet-2.21-all.jar')
|
||||
}
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
|
||||
eclipse.project.name = appName + "-core"
|
|
@ -0,0 +1,137 @@
|
|||
package com.emamaker.amazeing;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputMultiplexer;
|
||||
import com.badlogic.gdx.graphics.FPSLogger;
|
||||
import com.badlogic.gdx.physics.bullet.Bullet;
|
||||
import com.emamaker.amazeing.manager.GameManager;
|
||||
import com.emamaker.amazeing.manager.GameType;
|
||||
import com.emamaker.amazeing.manager.network.GameClient;
|
||||
import com.emamaker.amazeing.manager.network.GameServer;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
import com.emamaker.voxelengine.VoxelWorld;
|
||||
|
||||
public class AMazeIng extends Game {
|
||||
|
||||
public VoxelWorld world = new VoxelWorld();
|
||||
FPSLogger fps = new FPSLogger();
|
||||
boolean generated = false;
|
||||
boolean gui = false;
|
||||
Random rand = new Random();
|
||||
|
||||
public UIManager uiManager;
|
||||
public GameManager gameManager;
|
||||
public MazeSettings settings;
|
||||
public InputMultiplexer multiplexer = new InputMultiplexer();
|
||||
|
||||
/* Local manager for local games and server host in multiplayer games */
|
||||
public GameServer server;
|
||||
public GameClient client;
|
||||
|
||||
static AMazeIng game;
|
||||
|
||||
public static Platform PLATFORM;
|
||||
|
||||
public AMazeIng(Platform p) {
|
||||
PLATFORM = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
game = this;
|
||||
|
||||
// Bullet init for physics
|
||||
Bullet.init();
|
||||
|
||||
// Set windowed resolution
|
||||
Gdx.graphics.setWindowedMode(1280, 720);
|
||||
|
||||
// Enable on-screen keyboard for mobile devices
|
||||
// Gdx.input.setOnscreenKeyboardVisible(true);
|
||||
|
||||
// Voxel engine init. Call everything after this
|
||||
world.init(this);
|
||||
world.worldManager.generateChunks = false;
|
||||
world.worldManager.updateChunks = true;
|
||||
|
||||
// Disable VoxelEngines's integrated camera input processor and enable our own
|
||||
Gdx.input.setInputProcessor(multiplexer);
|
||||
|
||||
generated = false;
|
||||
setupGUI();
|
||||
setupGameManager();
|
||||
}
|
||||
|
||||
public void setupGUI() {
|
||||
System.out.println("Setup UI Manager");
|
||||
uiManager = new UIManager(this);
|
||||
settings = new MazeSettings();
|
||||
uiManager.setupScreens();
|
||||
}
|
||||
|
||||
public void setupGameManager() {
|
||||
System.out.println("Setup Game Managers");
|
||||
gameManager = new GameManager(this, GameType.LOCAL);
|
||||
|
||||
server = new GameServer(this);
|
||||
client = new GameClient(this);
|
||||
}
|
||||
|
||||
float delta;
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
server.update();
|
||||
client.update();
|
||||
if (gameManager != null)
|
||||
gameManager.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
world.dispose();
|
||||
gameManager.dispose();
|
||||
client.stop();
|
||||
server.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
world.resize(width, height);
|
||||
if (this.getScreen() != null)
|
||||
this.getScreen().resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
world.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
world.resume();
|
||||
}
|
||||
|
||||
public static AMazeIng getMain() {
|
||||
return game;
|
||||
}
|
||||
|
||||
public static boolean isDesktop(){
|
||||
return PLATFORM == Platform.DESKTOP;
|
||||
}
|
||||
public static boolean isMobile(){
|
||||
return PLATFORM == Platform.ANDROID || PLATFORM == Platform.IOS;
|
||||
}
|
||||
public static boolean isIOS(){
|
||||
return PLATFORM == Platform.IOS;
|
||||
}
|
||||
|
||||
public static enum Platform {
|
||||
DESKTOP, ANDROID, IOS
|
||||
}
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
package com.emamaker.amazeing.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.AMazeIng.Platform;
|
||||
import com.emamaker.amazeing.maze.MazeGenerator;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.player.MazePlayer;
|
||||
import com.emamaker.amazeing.player.MazePlayerLocal;
|
||||
import com.emamaker.amazeing.ui.screens.PreGameScreen;
|
||||
import com.emamaker.voxelengine.block.CellId;
|
||||
import com.emamaker.voxelengine.player.Player;
|
||||
|
||||
public class GameManager {
|
||||
|
||||
AMazeIng main;
|
||||
public MazeGenerator mazeGen;
|
||||
|
||||
public boolean gameStarted = false;
|
||||
public boolean showGame = true;
|
||||
public boolean anyoneWon = false;
|
||||
|
||||
public Stage stage;
|
||||
|
||||
Random rand = new Random();
|
||||
|
||||
GameType type = GameType.LOCAL;
|
||||
|
||||
public ArrayList<MazePlayer> players = new ArrayList<MazePlayer>();
|
||||
|
||||
public GameManager(Game main_, GameType t) {
|
||||
main = (AMazeIng) main_;
|
||||
gameStarted = false;
|
||||
|
||||
type = t;
|
||||
setShowGame(type != GameType.SERVER);
|
||||
|
||||
mazeGen = new MazeGenerator(main, MazeSettings.MAZEX, MazeSettings.MAZEZ);
|
||||
stage = new Stage(new ScreenViewport());
|
||||
}
|
||||
|
||||
ArrayList<MazePlayer> toDelete = new ArrayList<MazePlayer>();
|
||||
|
||||
public void generateMaze(Set<MazePlayer> pl, int todraw[][]) {
|
||||
main.setScreen(null);
|
||||
|
||||
AMazeIng.getMain().multiplexer.removeProcessor(stage);
|
||||
|
||||
anyoneWon = false;
|
||||
|
||||
if(AMazeIng.PLATFORM == Platform.DESKTOP) {
|
||||
if (pl != null) {
|
||||
for (MazePlayer p : players)
|
||||
if (!pl.contains(p))
|
||||
toDelete.add(p);
|
||||
|
||||
// Check if new players have to be added
|
||||
for (MazePlayer p : pl)
|
||||
if (!players.contains(p))
|
||||
players.add(p);
|
||||
|
||||
// Fianlly delete players. A separated step is needed to remove the risk of a
|
||||
// ConcurrentModificationException
|
||||
for (MazePlayer p : toDelete) {
|
||||
p.dispose();
|
||||
players.remove(p);
|
||||
}
|
||||
toDelete.clear();
|
||||
}
|
||||
}else{
|
||||
for (MazePlayer p : players) {
|
||||
p.dispose();
|
||||
}
|
||||
players.clear();
|
||||
players.addAll(pl);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < MazeSettings.MAZEX; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int k = 0; k < MazeSettings.MAZEZ; k++) {
|
||||
main.world.worldManager.setCell(i, j, k, CellId.ID_AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mazeGen.setMazeSize(MazeSettings.MAZEX, MazeSettings.MAZEZ);
|
||||
mazeGen.generateMaze();
|
||||
|
||||
if (type != GameType.CLIENT) {
|
||||
mazeGen.setupEndPoint();
|
||||
spreadPlayers();
|
||||
}
|
||||
|
||||
if (todraw != null && showGame == true) {
|
||||
mazeGen.show(todraw);
|
||||
}
|
||||
|
||||
resetCamera();
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
stage.clear();
|
||||
if (AMazeIng.PLATFORM == Platform.ANDROID)
|
||||
for (MazePlayer p : players) {
|
||||
if (p instanceof MazePlayerLocal)
|
||||
stage.addActor(((MazePlayerLocal) p).tctrl);
|
||||
}
|
||||
|
||||
AMazeIng.getMain().multiplexer.addProcessor(stage);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
if (gameStarted && !anyoneWon) {
|
||||
|
||||
if (getShowGame()) {
|
||||
main.world.render();
|
||||
resetCamera();
|
||||
setCamera(new Vector3(mazeGen.w / 2, (MazeSettings.MAZEX + MazeSettings.MAZEZ) * 0.45f, mazeGen.h / 2),
|
||||
new Vector3(0, -90, 0));
|
||||
|
||||
stage.act();
|
||||
stage.draw();
|
||||
|
||||
}
|
||||
|
||||
main.world.modelBatch.begin(main.world.cam);
|
||||
if (players != null) {
|
||||
for (MazePlayer p : players) {
|
||||
if (getShowGame() && !p.isDisposed())
|
||||
p.render(main.world.modelBatch, main.world.environment);
|
||||
|
||||
anyoneWon = false;
|
||||
if (type != GameType.CLIENT) {
|
||||
if (checkWin(p)) {
|
||||
anyoneWon = true;
|
||||
gameStarted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (anyoneWon) {
|
||||
System.out.println("Game Finished! " + type);
|
||||
if (type == GameType.LOCAL) {
|
||||
main.setScreen(main.uiManager.playersScreen);
|
||||
} else if (type == GameType.SERVER) {
|
||||
|
||||
((PreGameScreen) main.uiManager.preGameScreen).setGameType(GameType.SERVER);
|
||||
main.setScreen(main.uiManager.preGameScreen);
|
||||
}
|
||||
}
|
||||
|
||||
main.world.modelBatch.end();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void spreadPlayers() {
|
||||
for (MazePlayer p : players) {
|
||||
int x = 1, z = 1;
|
||||
do {
|
||||
x = (Math.abs(rand.nextInt() - 1) % (mazeGen.w));
|
||||
z = (Math.abs(rand.nextInt() - 1) % (mazeGen.h));
|
||||
// System.out.println(
|
||||
// thereIsPlayerInPos(x, z) + " - " + mazeGen.occupiedSpot(x, z) + " --- " + x + ", " + z);
|
||||
} while (thereIsPlayerInPos(x, z) || mazeGen.occupiedSpot(x, z));
|
||||
p.setPlaying();
|
||||
p.setPos(x + 0.5f, 2f, z + 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Player generateNewPlayer(int kup, int kdown, int ksx, int kdx) {
|
||||
return generateNewPlayer(kup, kdown, ksx, kdx, "");
|
||||
}
|
||||
|
||||
Player generateNewPlayer(int kup, int kdown, int ksx, int kdx, String name) {
|
||||
int x, z;
|
||||
do {
|
||||
x = (Math.abs(rand.nextInt() - 1) % (mazeGen.w));
|
||||
z = (Math.abs(rand.nextInt() - 1) % (mazeGen.h));
|
||||
} while (thereIsPlayerInPos(x, z) || mazeGen.occupiedSpot(x, z));
|
||||
if (name.equalsIgnoreCase(""))
|
||||
return new Player(kup, kdown, ksx, kdx, x + 0.5f, 4f, z + 0.5f);
|
||||
else
|
||||
return new Player(kup, kdown, ksx, kdx, x + 0.5f, 4f, z + 0.5f, name);
|
||||
}
|
||||
|
||||
public boolean checkWin(MazePlayer p) {
|
||||
if ((int) p.getPos().x == mazeGen.WINX && (int) p.getPos().z == mazeGen.WINZ) {
|
||||
System.out.println(p.getName() + " won");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean thereIsPlayerInPos(int x, int z) {
|
||||
for (MazePlayer p : players) {
|
||||
if ((int) p.getPos().x == x || (int) p.getPos().z == z)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean areTherePlayersNearby(int x, int z, int range) {
|
||||
int i, k;
|
||||
for (MazePlayer p : players) {
|
||||
i = (int) p.getPos().x;
|
||||
k = (int) p.getPos().z;
|
||||
|
||||
if ((x - i) * (x - i) + (k - z) * (k - z) <= range * range)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetCamera() {
|
||||
main.world.cam.position.set(0f, 0f, 0.5f); // Set cam position at origin
|
||||
main.world.cam.lookAt(0, 0, 0); // Direction to look at, for setting direction (perhaps better to set manually)
|
||||
// main.world.cam.near = 1f; // Minimum distance visible
|
||||
// main.world.cam.far = 300f; // Maximum distance visible
|
||||
main.world.cam.up.set(0f, 1f, 0f); // Up is in y positive direction
|
||||
main.world.cam.view.idt(); // Reset rotation matrix
|
||||
main.world.cam.update();
|
||||
}
|
||||
|
||||
public void setCamera(Vector3 position, Vector3 rotation) {
|
||||
main.world.cam.translate(position); // set cam absolute position
|
||||
main.world.cam.rotate(rotation.x, 0f, 1f, 0f); // set cam absolute rotation on axis X
|
||||
main.world.cam.rotate(rotation.y, 1f, 0f, 0f); // set cam absolute rotation on axis Y
|
||||
main.world.cam.rotate(rotation.z, 0f, 0f, 1f); // set cam absolute rotation on axis Z
|
||||
main.world.cam.update();
|
||||
}
|
||||
|
||||
boolean getShowGame() {
|
||||
return showGame;
|
||||
}
|
||||
|
||||
void setShowGame(boolean g) {
|
||||
showGame = g;
|
||||
}
|
||||
|
||||
public void generateMaze() {
|
||||
generateMaze(null, null);
|
||||
}
|
||||
|
||||
public void generateMaze(int todraw[][]) {
|
||||
generateMaze(null, todraw);
|
||||
}
|
||||
|
||||
public void generateMaze(Set<MazePlayer> pl) {
|
||||
generateMaze(pl, null);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for (MazePlayer p : players)
|
||||
if (!p.isDisposed())
|
||||
p.dispose();
|
||||
players.clear();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.emamaker.amazeing.manager;
|
||||
|
||||
public enum GameType {
|
||||
LOCAL, CLIENT, SERVER
|
||||
}
|
|
@ -0,0 +1,343 @@
|
|||
package com.emamaker.amazeing.manager.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.math.Quaternion;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.manager.GameManager;
|
||||
import com.emamaker.amazeing.manager.GameType;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.AddNewPlayer;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.EndGame;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.JustConnected;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.LoginAO;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.LoginAO2;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.RemovePlayer;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.StartGame;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.UpdateMap;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.UpdatePlayerTransform;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.UpdateSettings;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.player.MazePlayer;
|
||||
import com.emamaker.amazeing.player.MazePlayerLocal;
|
||||
import com.emamaker.amazeing.player.MazePlayerRemote;
|
||||
import com.emamaker.amazeing.player.PlayerUtils;
|
||||
import com.emamaker.amazeing.ui.screens.PreGameScreen;
|
||||
import com.esotericsoftware.kryonet.Client;
|
||||
import com.esotericsoftware.kryonet.Connection;
|
||||
import com.esotericsoftware.kryonet.Listener;
|
||||
|
||||
public class GameClient {
|
||||
|
||||
public AMazeIng main;
|
||||
volatile boolean clientRunning = false;
|
||||
|
||||
public String addr;
|
||||
public int port;
|
||||
|
||||
boolean startGame = false;
|
||||
boolean showPreGame = false;
|
||||
boolean updateMobilePlayers = false;
|
||||
String map = "";
|
||||
|
||||
// Hashtable of players present in the match
|
||||
public Hashtable<String, MazePlayer> players = new Hashtable<>();
|
||||
ArrayList<MazePlayer> localPlrQueue = new ArrayList<MazePlayer>();
|
||||
|
||||
volatile HashSet<String> toAdd = new HashSet<>();
|
||||
volatile HashSet<String> toRemove = new HashSet<>();
|
||||
|
||||
public GameManager gameManager;
|
||||
Client client;
|
||||
|
||||
public GameClient(AMazeIng main_) {
|
||||
main = main_;
|
||||
}
|
||||
|
||||
public boolean start(String addr_, int port_) {
|
||||
port = port_;
|
||||
addr = addr_;
|
||||
|
||||
clientRunning = true;
|
||||
startGame = false;
|
||||
client = new Client();
|
||||
client.start();
|
||||
|
||||
NetworkCommon.register(client);
|
||||
|
||||
client.addListener(new Listener() {
|
||||
public void connected(Connection connection) {
|
||||
}
|
||||
|
||||
public void received(Connection connection, Object object) {
|
||||
if (object instanceof LoginAO2) {
|
||||
localPlrQueue.get(0).uuid = ((LoginAO2) object).uuid;
|
||||
toAdd.add("Local" + localPlrQueue.get(0).uuid);
|
||||
client.sendTCP(object);
|
||||
|
||||
System.out.println("Received UUID " + localPlrQueue.get(0).uuid + " for player "
|
||||
+ localPlrQueue.get(0) + " giving confirmation");
|
||||
|
||||
// When we receive the connection accept from the server, we can show the
|
||||
// pre-game screen listing the players' names, setting this flag to let the main
|
||||
// thread to it
|
||||
showPreGame = true;
|
||||
} else if (object instanceof AddNewPlayer) {
|
||||
AddNewPlayer msg = (AddNewPlayer) object;
|
||||
if (!players.containsKey(msg.uuid) && !toAdd.contains("Local" + msg.uuid)) {
|
||||
toAdd.add("Remote" + msg.uuid);
|
||||
System.out
|
||||
.println("Remote player with uuid " + msg.uuid.toString() + " has joined the game :)");
|
||||
}
|
||||
} else if (object instanceof RemovePlayer) {
|
||||
RemovePlayer msg = (RemovePlayer) object;
|
||||
if (players.containsKey(msg.uuid)) {
|
||||
toRemove.add(msg.uuid);
|
||||
System.out.println("Player with uuid " + msg.uuid.toString() + " is leaving the game :(");
|
||||
} else {
|
||||
System.out.println("Player remove received, but I don't know that player :/");
|
||||
}
|
||||
} else if (object instanceof NetworkCommon.UpdatePlayerTransformServer) {
|
||||
NetworkCommon.UpdatePlayerTransformServer s = (NetworkCommon.UpdatePlayerTransformServer) object;
|
||||
System.out.println("Received a forced position update for self!");
|
||||
if (players.containsKey(s.uuid)) {
|
||||
players.get(s.uuid).setPlaying();
|
||||
players.get(s.uuid).setTransform(s.tx, s.ty, s.tz, s.rx, s.ry, s.rz, s.rw);
|
||||
}
|
||||
} else if (object instanceof UpdatePlayerTransform) {
|
||||
UpdatePlayerTransform msg = (UpdatePlayerTransform) object;
|
||||
if (players.containsKey(msg.uuid) && players.get(msg.uuid) instanceof MazePlayerRemote) {
|
||||
players.get(msg.uuid).setPlaying();
|
||||
players.get(msg.uuid).setTransform(msg.tx, msg.ty, msg.tz, msg.rx, msg.ry, msg.rz, msg.rw);
|
||||
}
|
||||
} else if (object instanceof UpdateMap) {
|
||||
map = ((UpdateMap) object).map;
|
||||
System.out.println("Map update!");
|
||||
} else if (object instanceof StartGame) {
|
||||
startGame = true;
|
||||
map = ((StartGame) object).map;
|
||||
System.out.println("Starting the online game!");
|
||||
} else if (object instanceof EndGame) {
|
||||
System.out.println("EndGame Received!");
|
||||
if (gameManager != null) {
|
||||
gameManager.gameStarted = false;
|
||||
gameManager.anyoneWon = true;
|
||||
showPreGame = true;
|
||||
}
|
||||
} else if (object instanceof UpdateSettings) {
|
||||
System.out.println("Update received for setting n." + ((UpdateSettings) object).index);
|
||||
if (!main.server.isRunning()) {
|
||||
MazeSettings.settings.get(((UpdateSettings) object).index)
|
||||
.parseOptionString(((UpdateSettings) object).value);
|
||||
}else {
|
||||
System.out.println("Ignoring settings update since we are running on a server");
|
||||
}
|
||||
|
||||
//We don't mind if we are client or server, just set the flag to update pregamescreen
|
||||
showPreGame = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnected(Connection connection) {
|
||||
toRemove.addAll(players.keySet());
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
client.connect(5000, addr, port);
|
||||
System.out.println("Connecting to server...");
|
||||
// Tell the server you just connected, but still no players have to be add
|
||||
client.sendTCP(new JustConnected());
|
||||
return true;
|
||||
// Server communication after connection can go here, or in
|
||||
// Listener#connected().
|
||||
} catch (
|
||||
|
||||
IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update must be called from Main thread and used for applications on main
|
||||
// thread
|
||||
MazePlayerLocal p;
|
||||
|
||||
public void update() {
|
||||
if (clientRunning) {
|
||||
try {
|
||||
for (String s : toAdd) {
|
||||
if (!(players.containsKey(s.replace("Local", ""))
|
||||
|| players.containsKey(s.replace("Remote", "")))) {
|
||||
if (s.startsWith("Local")) {
|
||||
// System.out.println(s + " | " + s.replace("Local", "") + " | " + localPlrQueue.get(0).uuid);
|
||||
if (localPlrQueue.get(0) != null) {
|
||||
players.put(s.replace("Local", ""), localPlrQueue.get(0));
|
||||
System.out.println("Added local player " + localPlrQueue.get(0));
|
||||
localPlrQueue.remove(0);
|
||||
}
|
||||
} else if (s.startsWith("Remote")) {
|
||||
players.put(s.replace("Remote", ""), new MazePlayerRemote(s.replace("Remote", "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
toAdd.clear();
|
||||
for (String s : toRemove) {
|
||||
if (players.containsKey(s)) {
|
||||
players.get(s).dispose();
|
||||
players.remove(s);
|
||||
}
|
||||
}
|
||||
toRemove.clear();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if (showPreGame) {
|
||||
// We are taking care of specifying what type of game we are running. Server is
|
||||
// the server is running in the same instance, client if not
|
||||
// In this way server host is shown the start game button.
|
||||
if (!main.server.isRunning())
|
||||
((PreGameScreen) main.uiManager.preGameScreen).setGameType(GameType.CLIENT);
|
||||
main.setScreen(main.uiManager.preGameScreen);
|
||||
showPreGame = false;
|
||||
}
|
||||
|
||||
if (startGame) {
|
||||
gameManager = new GameManager(main, GameType.CLIENT);
|
||||
|
||||
if (main.getScreen() != null) {
|
||||
main.getScreen().hide();
|
||||
main.setScreen(null);
|
||||
}
|
||||
|
||||
for (MazePlayer p : players.values())
|
||||
p.setPlaying();
|
||||
|
||||
gameManager.generateMaze(new HashSet<MazePlayer>(players.values()));
|
||||
startGame = false;
|
||||
}
|
||||
|
||||
if (gameManager != null) {
|
||||
gameManager.update();
|
||||
|
||||
if (gameManager.gameStarted) {
|
||||
if (!map.equals("")) {
|
||||
System.out.println("Setting map");
|
||||
gameManager.mazeGen.show(gameManager.mazeGen.runLenghtDecode(map));
|
||||
map = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gameManager == null || (gameManager != null && !gameManager.gameStarted)) {
|
||||
// Consantly search for new players to be added
|
||||
if(AMazeIng.PLATFORM == AMazeIng.Platform.DESKTOP) {
|
||||
// Search for keyboard players (WASD and ARROWS) on Desktop
|
||||
if (Gdx.input.isKeyJustPressed(Keys.W) || Gdx.input.isKeyJustPressed(Keys.A)
|
||||
|| Gdx.input.isKeyJustPressed(Keys.S) || Gdx.input.isKeyJustPressed(Keys.D)) {
|
||||
p = PlayerUtils.getPlayerWithKeys(new HashSet<>(players.values()), Keys.W, Keys.S, Keys.A, Keys.D);
|
||||
if (p != null) {
|
||||
RemovePlayer msg = new RemovePlayer();
|
||||
msg.uuid = p.uuid;
|
||||
client.sendTCP(msg);
|
||||
} else {
|
||||
localPlrQueue.add(new MazePlayerLocal(Keys.W, Keys.S, Keys.A, Keys.D));
|
||||
client.sendTCP(new LoginAO());
|
||||
}
|
||||
}
|
||||
|
||||
if (Gdx.input.isKeyJustPressed(Keys.UP) || Gdx.input.isKeyJustPressed(Keys.LEFT)
|
||||
|| Gdx.input.isKeyJustPressed(Keys.DOWN) || Gdx.input.isKeyJustPressed(Keys.RIGHT)) {
|
||||
p = PlayerUtils.getPlayerWithKeys(new HashSet<>(players.values()), Keys.UP, Keys.DOWN, Keys.LEFT,
|
||||
Keys.RIGHT);
|
||||
if (p != null) {
|
||||
RemovePlayer msg = new RemovePlayer();
|
||||
msg.uuid = p.uuid;
|
||||
client.sendTCP(msg);
|
||||
} else {
|
||||
localPlrQueue.add(new MazePlayerLocal(Keys.UP, Keys.DOWN, Keys.LEFT, Keys.RIGHT));
|
||||
client.sendTCP(new LoginAO());
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(updateMobilePlayers){
|
||||
for(int i = 0; i < MazeSettings.MAXPLAYERS; i++) {
|
||||
p = PlayerUtils.getPlayerWithTouchCtrl(i, new HashSet<>(players.values()));
|
||||
if(i < MazeSettings.MAXPLAYERS_MOBILE){
|
||||
//if yhe player wasn't there before, but wants to join: add it
|
||||
if(p == null) {
|
||||
localPlrQueue.add(new MazePlayerLocal(new Touchpad(0f, main.uiManager.skin), i));
|
||||
client.sendTCP(new NetworkCommon.LoginAO());
|
||||
}
|
||||
}else {
|
||||
//The player was there before, but has left: remove it
|
||||
if (p != null && players.containsValue(p)) {
|
||||
NetworkCommon.RemovePlayer msg = new NetworkCommon.RemovePlayer();
|
||||
msg.uuid = p.uuid;
|
||||
client.sendTCP(msg);
|
||||
}
|
||||
//Otherwise just do nothing
|
||||
}
|
||||
}
|
||||
updateMobilePlayers = false;
|
||||
}
|
||||
}
|
||||
//Search for mobile players
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLocalPlayer(MazePlayerLocal p) {
|
||||
if (this.gameManager != null && this.gameManager.gameStarted && clientRunning && p.isPlaying()) {
|
||||
UpdatePlayerTransform pu = new UpdatePlayerTransform();
|
||||
Vector3 pos = p.ghostObject.getWorldTransform().getTranslation(new Vector3());
|
||||
Quaternion rot = p.ghostObject.getWorldTransform().getRotation(new Quaternion());
|
||||
pu.tx = pos.x;
|
||||
pu.ty = pos.y;
|
||||
pu.tz = pos.z;
|
||||
pu.rx = rot.x;
|
||||
pu.ry = rot.y;
|
||||
pu.rz = rot.z;
|
||||
pu.rw = rot.w;
|
||||
pu.uuid = p.uuid;
|
||||
|
||||
client.sendTCP(pu);
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpdateMobilePlayers(){
|
||||
updateMobilePlayers = true;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return clientRunning;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (clientRunning) {
|
||||
for (String s : players.keySet()) {
|
||||
if (players.get(s) instanceof MazePlayerLocal) {
|
||||
RemovePlayer request = new RemovePlayer();
|
||||
request.uuid = s;
|
||||
client.sendTCP(request);
|
||||
}
|
||||
|
||||
players.get(s).dispose();
|
||||
}
|
||||
|
||||
players.clear();
|
||||
|
||||
client.stop();
|
||||
clientRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
package com.emamaker.amazeing.manager.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.badlogic.gdx.math.Quaternion;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.manager.GameManager;
|
||||
import com.emamaker.amazeing.manager.GameType;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.AddNewPlayer;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.ConnectionRefused;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.EndGame;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.JustConnected;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.LoginAO;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.LoginAO2;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.RemovePlayer;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.StartGame;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.UpdatePlayerTransform;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon.UpdateSettings;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.player.MazePlayer;
|
||||
import com.emamaker.amazeing.player.MazePlayerRemote;
|
||||
import com.esotericsoftware.kryonet.Connection;
|
||||
import com.esotericsoftware.kryonet.Listener;
|
||||
import com.esotericsoftware.kryonet.Server;
|
||||
|
||||
public class GameServer {
|
||||
|
||||
public AMazeIng main;
|
||||
|
||||
volatile boolean serverRunning = false;
|
||||
boolean endGameCalled = false;
|
||||
public int port;
|
||||
UUID uuid;
|
||||
|
||||
public GameManager gameManager;
|
||||
Server server;
|
||||
|
||||
// Hashtable of remote players present in the match. This will be used to update
|
||||
// other players' transform when server reports about it
|
||||
public Hashtable<String, MazePlayerRemote> remotePlayers = new Hashtable<>();
|
||||
|
||||
public GameServer(AMazeIng main_) {
|
||||
main = main_;
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
// Returns true if the server started successfully
|
||||
public boolean startServer(int port_) {
|
||||
port = port_;
|
||||
serverRunning = true;
|
||||
try {
|
||||
server = new Server() {
|
||||
protected Connection newConnection() {
|
||||
// Notify connection about previously connected clients
|
||||
|
||||
AddNewPlayer response = new AddNewPlayer();
|
||||
for (String s : remotePlayers.keySet()) {
|
||||
response.uuid = s;
|
||||
server.sendToAllTCP(response);
|
||||
}
|
||||
|
||||
// By providing our own connection implementation, we can store per
|
||||
// connection state without a connection ID to state look up.
|
||||
return new ConnectionPlayer();
|
||||
}
|
||||
};
|
||||
|
||||
// For consistency, the classes to be sent over the network are
|
||||
// registered by the same method for both the client and server.
|
||||
NetworkCommon.register(server);
|
||||
|
||||
server.addListener(new Listener() {
|
||||
public void received(Connection c, Object object) {
|
||||
ConnectionPlayer connection = (ConnectionPlayer) c;
|
||||
|
||||
if (object instanceof JustConnected) {
|
||||
// Notify the newly connected client about all other clients already present
|
||||
// here
|
||||
System.out.println("New client just connected, updating it with info about other clients!");
|
||||
AddNewPlayer response = new AddNewPlayer();
|
||||
for (String s : remotePlayers.keySet()) {
|
||||
response.uuid = s;
|
||||
c.sendTCP(response);
|
||||
System.out.println("Updated about: " + s);
|
||||
}
|
||||
} else if (object instanceof LoginAO) {
|
||||
// Give player its UUID and wait for response. Once the LoginAO2 response is
|
||||
// received, move the
|
||||
// UUID to the list of players, create a new one and notify clients about it
|
||||
connection.uuid = UUID.randomUUID().toString();
|
||||
|
||||
LoginAO2 response = new LoginAO2();
|
||||
response.uuid = connection.uuid;
|
||||
System.out.println("Server received connection request! Giving client UUID " + connection.uuid);
|
||||
c.sendTCP(response);
|
||||
|
||||
} else if (object instanceof LoginAO2) {
|
||||
// Ignore is there's no uuid or it's different from the login message one
|
||||
// If there's still space left for players to join
|
||||
if (remotePlayers.values().size() < MazeSettings.MAXPLAYERS) {
|
||||
remotePlayers.put(((LoginAO2) object).uuid,
|
||||
new MazePlayerRemote(((LoginAO2) object).uuid, false));
|
||||
|
||||
updateSettingForClient(c);
|
||||
|
||||
System.out.println("Client with UUID " + ((LoginAO2) object).uuid
|
||||
+ " is connected and ready to play :)");
|
||||
|
||||
AddNewPlayer response = new AddNewPlayer();
|
||||
response.uuid = ((LoginAO2) object).uuid;
|
||||
server.sendToAllTCP(response);
|
||||
|
||||
} else {
|
||||
// Send connection refused
|
||||
c.sendTCP(new ConnectionRefused());
|
||||
}
|
||||
|
||||
} else if (object instanceof RemovePlayer) {
|
||||
// Otherwise remove the player and notify all clients about it
|
||||
if (remotePlayers.containsKey(((RemovePlayer) object).uuid.toString())) {
|
||||
remotePlayers.get(((RemovePlayer) object).uuid).dispose();
|
||||
remotePlayers.remove(((RemovePlayer) object).uuid);
|
||||
|
||||
System.out.println("Client with UUID " + connection.uuid + " is leaving the server :(");
|
||||
server.sendToAllTCP(object);
|
||||
} else {
|
||||
System.out.println("Server received delete message for player with UUID " + connection.uuid
|
||||
+ " but player wasn't playing");
|
||||
}
|
||||
} else if (object instanceof UpdatePlayerTransform) {
|
||||
UpdatePlayerTransform transform = (UpdatePlayerTransform) object;
|
||||
if (gameManager.gameStarted) {
|
||||
// Otherwise Update the transport and notify clients about it
|
||||
MazePlayerRemote player = remotePlayers.get((transform.uuid));
|
||||
player.setTransform(transform.tx, transform.ty, transform.tz, transform.rx, transform.ry,
|
||||
transform.rz, transform.rw);
|
||||
updatePlayer(transform.uuid, remotePlayers.get(transform.uuid), false);
|
||||
System.out.println("Updating client " + connection.uuid + " position!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnected(Connection c) {
|
||||
ConnectionPlayer connection = (ConnectionPlayer) c;
|
||||
if (connection.uuid != null) {
|
||||
if (remotePlayers.get(connection.uuid) != null) {
|
||||
remotePlayers.get(connection.uuid).dispose();
|
||||
}
|
||||
remotePlayers.remove(connection.uuid);
|
||||
RemovePlayer remove = new RemovePlayer();
|
||||
remove.uuid = connection.uuid;
|
||||
server.sendToAllTCP(remove);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.bind(port);
|
||||
server.start();
|
||||
System.out.println("Server registered and running on port " + port);
|
||||
|
||||
// Also launch the client to have a player play on host. We return the result of
|
||||
// starting, so server doesn't start if local client has problems
|
||||
if (main.client.start("localhost", port))
|
||||
return true;
|
||||
else {
|
||||
server.stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update must be called from Main thread and used for applications on main
|
||||
// thread, such as spawning new players
|
||||
public void update() {
|
||||
if (serverRunning) {
|
||||
if (gameManager != null) {
|
||||
gameManager.update();
|
||||
if (gameManager.anyoneWon && !endGameCalled) {
|
||||
server.sendToAllTCP(new EndGame());
|
||||
endGameCalled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Once the server has started accepting connections from other players, the
|
||||
// host should decide when to start the gmae
|
||||
// A proper ui should be added, but for now we can just start the game without
|
||||
// showing any players and just show the map across all the clients
|
||||
public boolean startGame() {
|
||||
if (serverRunning) {
|
||||
update();
|
||||
|
||||
if (!remotePlayers.isEmpty()) {
|
||||
// Start game stuff
|
||||
this.gameManager = new GameManager(main, GameType.SERVER);
|
||||
this.gameManager.generateMaze(new HashSet<MazePlayer>(remotePlayers.values()));
|
||||
endGameCalled = false;
|
||||
|
||||
StartGame request = new StartGame();
|
||||
request.map = this.gameManager.mazeGen.runLenghtEncode();
|
||||
server.sendToAllTCP(request);
|
||||
|
||||
if (gameManager.gameStarted)
|
||||
for (String p : remotePlayers.keySet())
|
||||
updatePlayer(p, remotePlayers.get(p), true);
|
||||
|
||||
if (main.getScreen() != null) {
|
||||
main.getScreen().hide();
|
||||
main.setScreen(null);
|
||||
}
|
||||
return true;
|
||||
} else System.out.println("No players have joined yet");
|
||||
} else {
|
||||
System.out.println("Server not started yet, game cannot start");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updatePlayer(String uuid, MazePlayerRemote p, boolean force) {
|
||||
if (serverRunning && this.gameManager != null && this.gameManager.gameStarted) {
|
||||
if (force) {
|
||||
NetworkCommon.UpdatePlayerTransformServer pu = new NetworkCommon.UpdatePlayerTransformServer();
|
||||
Vector3 pos = p.getPos();
|
||||
Quaternion rot = p.getRotation();
|
||||
pu.tx = pos.x;
|
||||
pu.ty = pos.y;
|
||||
pu.tz = pos.z;
|
||||
pu.rx = rot.x;
|
||||
pu.ry = rot.y;
|
||||
pu.rz = rot.z;
|
||||
pu.rw = rot.w;
|
||||
pu.uuid = uuid;
|
||||
System.out.println("Forcing position update to all clients for player " + uuid);
|
||||
server.sendToAllTCP(pu);
|
||||
} else {
|
||||
UpdatePlayerTransform pu = new UpdatePlayerTransform();
|
||||
Vector3 pos = p.getPos();
|
||||
Quaternion rot = p.getRotation();
|
||||
pu.tx = pos.x;
|
||||
pu.ty = pos.y;
|
||||
pu.tz = pos.z;
|
||||
pu.rx = rot.x;
|
||||
pu.ry = rot.y;
|
||||
pu.rz = rot.z;
|
||||
pu.rw = rot.w;
|
||||
pu.uuid = uuid;
|
||||
System.out.println("Sending position update to all clients for player " + uuid);
|
||||
server.sendToAllTCP(pu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
for (MazePlayerRemote p : remotePlayers.values())
|
||||
if (!p.isDisposed())
|
||||
p.dispose();
|
||||
remotePlayers.clear();
|
||||
if (serverRunning) {
|
||||
main.client.stop();
|
||||
server.stop();
|
||||
serverRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return serverRunning;
|
||||
}
|
||||
|
||||
UpdateSettings s = new UpdateSettings();
|
||||
|
||||
// Send updates about settings to the clients
|
||||
public void updateSettingForAll() {
|
||||
if (isRunning())
|
||||
for (int i = 0; i < MazeSettings.settings.size(); i++) {
|
||||
s.index = i;
|
||||
s.value = MazeSettings.settings.get(i).getOptionString();
|
||||
server.sendToAllTCP(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSettingForClient(Connection c) {
|
||||
if (isRunning())
|
||||
for (int i = 0; i < MazeSettings.settings.size(); i++) {
|
||||
s.index = i;
|
||||
s.value = MazeSettings.settings.get(i).getOptionString();
|
||||
c.sendTCP(s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ConnectionPlayer extends Connection {
|
||||
public String uuid;
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.emamaker.amazeing.manager.network;
|
||||
|
||||
import com.esotericsoftware.kryo.Kryo;
|
||||
import com.esotericsoftware.kryonet.EndPoint;
|
||||
|
||||
public class NetworkCommon {
|
||||
|
||||
|
||||
// This registers objects that are going to be sent over the network.
|
||||
public static void register(EndPoint endPoint) {
|
||||
Kryo kryo = endPoint.getKryo();
|
||||
kryo.register(JustConnected.class);
|
||||
kryo.register(LoginAO.class);
|
||||
kryo.register(LoginAO2.class);
|
||||
kryo.register(ConnectionRefused.class);
|
||||
kryo.register(LoginUUID.class);
|
||||
kryo.register(AddNewPlayer.class);
|
||||
kryo.register(RemovePlayer.class);
|
||||
kryo.register(UpdatePlayerTransform.class);
|
||||
kryo.register(UpdatePlayerTransformServer.class);
|
||||
kryo.register(StartGame.class);
|
||||
kryo.register(EndGame.class);
|
||||
kryo.register(UpdateMap.class);
|
||||
kryo.register(UpdateSettings.class);
|
||||
}
|
||||
|
||||
//Login stuff
|
||||
public static class JustConnected {
|
||||
}
|
||||
public static class LoginAO {
|
||||
}
|
||||
public static class LoginAO2 {
|
||||
String uuid;
|
||||
}
|
||||
public static class ConnectionRefused {
|
||||
String uuid;
|
||||
}
|
||||
public static class LoginUUID {
|
||||
String uuid;
|
||||
}
|
||||
|
||||
//Player stuff
|
||||
public static class AddNewPlayer {
|
||||
String uuid;
|
||||
}
|
||||
public static class RemovePlayer {
|
||||
String uuid;
|
||||
}
|
||||
public static class UpdatePlayerTransform {
|
||||
String uuid;
|
||||
float tx, ty, tz, rx, ry, rz, rw;
|
||||
}
|
||||
public static class UpdatePlayerTransformServer {
|
||||
String uuid;
|
||||
float tx, ty, tz, rx, ry, rz, rw;
|
||||
}
|
||||
|
||||
public static class StartGame{
|
||||
//Use this to notify clients of a newly started game
|
||||
//A Run-lenght-encoded representation of the map can be appended, this can be avoided but it's not recommended
|
||||
String map;
|
||||
}
|
||||
public static class EndGame{
|
||||
//Use this to notify clients when a game ends
|
||||
}
|
||||
public static class UpdateMap{
|
||||
//Use this to notify clients of a modification of the map
|
||||
//Run-lenght-encoded representation of the map
|
||||
String map;
|
||||
}
|
||||
|
||||
public static class UpdateSettings {
|
||||
int index;
|
||||
String value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,340 @@
|
|||
package com.emamaker.amazeing.maze;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSetting;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.voxelengine.block.CellId;
|
||||
|
||||
public class MazeGenerator {
|
||||
|
||||
AMazeIng main;
|
||||
Random rand = new Random();
|
||||
|
||||
Cell currentCell;
|
||||
Cell[][] cellsGrid;
|
||||
ArrayList<Cell> stack = new ArrayList<Cell>();
|
||||
public int[][] todraw;
|
||||
|
||||
public int w, h, W, H;
|
||||
public int WINX = Integer.MAX_VALUE, WINZ = Integer.MAX_VALUE;
|
||||
public int OLDMAZEX, OLDMAZEZ;
|
||||
|
||||
public MazeGenerator(AMazeIng game) {
|
||||
this(game, 20, 20);
|
||||
}
|
||||
|
||||
public MazeGenerator(AMazeIng game, int dimx, int dimy) {
|
||||
main = game;
|
||||
setMazeSize(dimx, dimy);
|
||||
}
|
||||
|
||||
public void setMazeSize(int w_, int h_) {
|
||||
w = w_ - 1;
|
||||
h = h_ - 1;
|
||||
W = w / 2;
|
||||
H = h / 2;
|
||||
|
||||
cellsGrid = new Cell[W][H];
|
||||
todraw = new int[w][h];
|
||||
// System.out.println(W + "*" + H + " --- " + w + "*" + h);
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of a recursive backtracker to generated the maze. Mazes
|
||||
* generated in this way can always be solved.
|
||||
* https://en.wikipedia.org/wiki/Maze_generation_algorithm#Recursive_backtracker
|
||||
*/
|
||||
public void generateMaze() {
|
||||
// init cells
|
||||
for (int i = 0; i < W; i++) {
|
||||
for (int j = 0; j < H; j++) {
|
||||
cellsGrid[i][j] = new Cell(i, j, this);
|
||||
}
|
||||
}
|
||||
|
||||
currentCell = cellsGrid[0][0];
|
||||
|
||||
// while there are unvisited cells
|
||||
while (!allCellsVisited()) {
|
||||
// mark current as visisted
|
||||
currentCell.visited = true;
|
||||
|
||||
// check for unvisited neighbours
|
||||
Cell[] neighbours = currentCell.unvisitedNeighbours();
|
||||
|
||||
// if the cell has unvisited neighbours
|
||||
if (neighbours.length > 0) {
|
||||
// Randomly choose one
|
||||
Cell n = neighbours[rand.nextInt(neighbours.length)];
|
||||
|
||||
// Push current cell to the stack
|
||||
stack.add(currentCell);
|
||||
|
||||
// Delete the walls
|
||||
if (n.x == currentCell.x + 1) {
|
||||
// right
|
||||
currentCell.walls[1] = false;
|
||||
n.walls[3] = false;
|
||||
}
|
||||
if (n.x == currentCell.x - 1) {
|
||||
// left
|
||||
currentCell.walls[3] = false;
|
||||
n.walls[1] = false;
|
||||
}
|
||||
if (n.y == currentCell.y + 1) {
|
||||
// up
|
||||
currentCell.walls[2] = false;
|
||||
n.walls[0] = false;
|
||||
}
|
||||
if (n.y == currentCell.y - 1) {
|
||||
// down
|
||||
currentCell.walls[0] = false;
|
||||
n.walls[2] = false;
|
||||
}
|
||||
currentCell.current = false;
|
||||
currentCell = n;
|
||||
currentCell.current = true;
|
||||
} else if (!stack.isEmpty()) {
|
||||
currentCell.current = false;
|
||||
// pop a cell from the custom and make it the current one
|
||||
currentCell = stack.get(stack.size() - 1);
|
||||
stack.remove(stack.size() - 1);
|
||||
currentCell.current = true;
|
||||
}
|
||||
}
|
||||
prepareShow();
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup end point in a random location. At a distance of EP_DIST from every
|
||||
* player
|
||||
*/
|
||||
public void setupEndPoint() {
|
||||
// Randomly places the end point
|
||||
int x = 0, y = 0;
|
||||
|
||||
do {
|
||||
x = (Math.abs(rand.nextInt()) % (w));
|
||||
y = (Math.abs(rand.nextInt()) % (h));
|
||||
// while there's a wall in current location pick new location
|
||||
} while (main.gameManager.areTherePlayersNearby(x, y, MazeSettings.EPDIST) || occupiedSpot(x, y));
|
||||
WINX = x;
|
||||
WINZ = y;
|
||||
todraw[x][y] = 2;
|
||||
show(todraw);
|
||||
}
|
||||
|
||||
/*
|
||||
* Run-lenght encodes ( https://en.wikipedia.org/wiki/Run-length_encoding) the
|
||||
* maze todraw configuration, so it can be easily passed to server clients. This
|
||||
* should be done once the game is been set up and the end point has been
|
||||
* placed. We'll normally use a number for the count of equal blocks next to
|
||||
* each other We'll use letters instead for the todraw[][] numbers to represent
|
||||
* the different block, starting from A (Ascii 65) and adding the todraw[x][y]
|
||||
* index to the ascii value of A. To even simplify decoding, the count number is
|
||||
* encoded in a letter too, starting from a (Ascii 97), so that every count
|
||||
* takes up just to characters.
|
||||
*
|
||||
*/
|
||||
public String runLenghtEncode() {
|
||||
// todraw[x][y], where row number is x and the index of the block in that row is
|
||||
// y
|
||||
int count = 0;
|
||||
String s = "";
|
||||
for (int i = 0; i < w; i++) {
|
||||
for (int j = 0; j < h; j++) {
|
||||
// https://www.geeksforgeeks.org/run-length-encoding/
|
||||
count = 1;
|
||||
while (j < h - 1 && todraw[i][j] == todraw[i][j + 1]) {
|
||||
count++;
|
||||
j++;
|
||||
}
|
||||
s += String.valueOf((char) (count + 97));
|
||||
s += String.valueOf((char) (todraw[i][j] + 65));
|
||||
}
|
||||
s += "-";
|
||||
}
|
||||
System.out.println(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run length decodes the maze received from the server. We know that the block
|
||||
* types start from A (Ascii 65), so we can simply subtract 65 We know that the
|
||||
* block count start from a (Ascii 97), so we can simply subtract 97 from the
|
||||
* current index and get the block type, repeated for how many times the count
|
||||
* number says
|
||||
*/
|
||||
public int[][] runLenghtDecode(String s) {
|
||||
int[][] todraw_ = null;
|
||||
int count, type, totalcount = 0, width = 0;
|
||||
|
||||
// Split the various rows
|
||||
String[] rows = s.split("-");
|
||||
|
||||
count = ((int) (rows[0].charAt(0))) - 97;
|
||||
width += count;
|
||||
|
||||
// Mazes are always squares
|
||||
setMazeSize(width + 1, rows.length + 1);
|
||||
// Temporarely patch to the calculation errors in setMazeSize
|
||||
todraw_ = new int[w][h];
|
||||
|
||||
for (int i = 0; i < width; i++) {
|
||||
totalcount = 0;
|
||||
for (int j = 0; j < rows[i].length(); j += 2) {
|
||||
count = ((int) (rows[i].charAt(j))) - 97;
|
||||
type = ((int) (rows[i].charAt(j + 1))) - 65;
|
||||
|
||||
for (int k = totalcount; k < totalcount + count; k++) {
|
||||
todraw_[i][k] = type;
|
||||
}
|
||||
totalcount += count;
|
||||
}
|
||||
}
|
||||
return todraw_;
|
||||
}
|
||||
|
||||
public void prepareShow() {
|
||||
for (int i = 0; i < w; i++) {
|
||||
for (int j = 0; j < h; j++) {
|
||||
todraw[i][j] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// constructs an array so that the walls of the cells are black tiles and the
|
||||
// free cells are white tiles
|
||||
for (int i = 0; i < W; i++) {
|
||||
for (int j = 0; j < H; j++) {
|
||||
int x = 2 * i + 1;
|
||||
int y = 2 * j + 1;
|
||||
|
||||
// current cell
|
||||
todraw[x][y] = 0;
|
||||
|
||||
// up wall
|
||||
if (!cellsGrid[i][j].walls[0])
|
||||
todraw[x][y - 1] = 0;
|
||||
// down wall
|
||||
if (!cellsGrid[i][j].walls[2])
|
||||
todraw[x][y + 1] = 0;
|
||||
// left wall
|
||||
if (!cellsGrid[i][j].walls[3])
|
||||
todraw[x - 1][y] = 0;
|
||||
// right all
|
||||
if (!cellsGrid[i][j].walls[1])
|
||||
todraw[x + 1][y] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
show(todraw);
|
||||
}
|
||||
|
||||
public void show(int[][] todraw_) {
|
||||
|
||||
for (int j = 0; j < OLDMAZEX+2; j++) {
|
||||
for (int i = 0; i < OLDMAZEZ+2; i++) {
|
||||
main.world.worldManager.setCell(i, 0, j, CellId.ID_AIR);
|
||||
main.world.worldManager.setCell(i, 1, j, CellId.ID_AIR);
|
||||
}
|
||||
}
|
||||
OLDMAZEX = MazeSettings.MAZEX;
|
||||
OLDMAZEZ = MazeSettings.MAZEZ;
|
||||
|
||||
for (int j = 0; j < h; j++) {
|
||||
for (int i = 0; i < w; i++) {
|
||||
todraw[i][j] = todraw_[i][j];
|
||||
main.world.worldManager.setCell(i, 0, j, CellId.ID_GRASS);
|
||||
|
||||
if (todraw[i][j] == 1)
|
||||
main.world.worldManager.setCell(i, 1, j, CellId.ID_LEAVES);
|
||||
if (todraw[i][j] == 2) {
|
||||
WINX = i;
|
||||
WINZ = j;
|
||||
|
||||
System.out.println("Win position in: " + i + ", " + j);
|
||||
main.world.worldManager.setCell(i, 0, j, CellId.ID_WOOD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean allCellsVisited() {
|
||||
for (int i = 0; i < W; i++) {
|
||||
for (int j = 0; j < H; j++) {
|
||||
if (!cellsGrid[i][j].visited)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int cellAt(int x, int y) {
|
||||
if (x < w && y < h)
|
||||
return todraw[x][y];
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean occupiedSpot(int x, int y) {
|
||||
return cellAt(x, y) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Cell {
|
||||
|
||||
public boolean visited = false;
|
||||
public boolean current = false;
|
||||
public boolean[] walls = { true, true, true, true };
|
||||
|
||||
// top, right, bottom, left,
|
||||
// true means wall present
|
||||
|
||||
int x, y;
|
||||
MazeGenerator gen;
|
||||
|
||||
public Cell(int x_, int y_, MazeGenerator generator_) {
|
||||
this.x = x_;
|
||||
this.y = y_;
|
||||
gen = generator_;
|
||||
}
|
||||
|
||||
// returning an array of unvisited neighbours, so that they can be easily
|
||||
// choosed later on
|
||||
Cell[] unvisitedNeighbours() {
|
||||
int un = 0;
|
||||
if (x - 1 >= 0 && !gen.cellsGrid[x - 1][y].visited)
|
||||
un++;
|
||||
if (x + 1 < gen.W && !gen.cellsGrid[x + 1][y].visited)
|
||||
un++;
|
||||
if (y - 1 >= 0 && !gen.cellsGrid[x][y - 1].visited)
|
||||
un++;
|
||||
if (y + 1 < gen.H && !gen.cellsGrid[x][y + 1].visited)
|
||||
un++;
|
||||
|
||||
Cell[] c = new Cell[un];
|
||||
|
||||
int tun = 0;
|
||||
if (x - 1 >= 0 && !gen.cellsGrid[x - 1][y].visited) {
|
||||
c[tun] = gen.cellsGrid[x - 1][y];
|
||||
tun++;
|
||||
}
|
||||
if (x + 1 < gen.W && !gen.cellsGrid[x + 1][y].visited) {
|
||||
c[tun] = gen.cellsGrid[x + 1][y];
|
||||
tun++;
|
||||
}
|
||||
if (y - 1 >= 0 && !gen.cellsGrid[x][y - 1].visited) {
|
||||
c[tun] = gen.cellsGrid[x][y - 1];
|
||||
tun++;
|
||||
}
|
||||
if (y + 1 < gen.H && !gen.cellsGrid[x][y + 1].visited) {
|
||||
c[tun] = gen.cellsGrid[x][y + 1];
|
||||
tun++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package com.emamaker.amazeing.maze.settings;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MazeSetting {
|
||||
|
||||
/*This object holds whatever is needed for a single setting to be changed, this includes:
|
||||
* A set of possible options
|
||||
* Thread buttons to go back and forth between the options and reset them
|
||||
* A label with the current option
|
||||
* A label with the name of the option
|
||||
* Methods to set the correct variables, this should be overwritten by every single class
|
||||
*/
|
||||
|
||||
protected UIManager uiManager;
|
||||
protected int currentOption = 0;
|
||||
protected String[] options;
|
||||
protected String name;
|
||||
protected Table table;
|
||||
private int defaultOption;
|
||||
private int prevState;
|
||||
|
||||
Label nameLabel, currentOptLabel;
|
||||
TextButton backBtn, forthBtn, resetBtn;
|
||||
|
||||
public MazeSetting(String name_, String[] options_, UIManager uiManager_) {
|
||||
this(name_, options_, 0, uiManager_);
|
||||
}
|
||||
|
||||
public MazeSetting(String name_, String[] options_, int defaultOption, UIManager uiManager_) {
|
||||
this.defaultOption = defaultOption;
|
||||
this.currentOption = defaultOption;
|
||||
this.name = name_;
|
||||
this.uiManager = uiManager_;
|
||||
setOptions(options_, defaultOption);
|
||||
|
||||
|
||||
//Build the Table which will be later used to add this to the screen
|
||||
table = new Table();
|
||||
nameLabel = new Label(this.name, uiManager.skin);
|
||||
currentOptLabel = new Label(this.options[currentOption], uiManager.skin);
|
||||
backBtn = new TextButton("<", uiManager.skin);
|
||||
forthBtn = new TextButton(">", uiManager.skin);
|
||||
resetBtn = new TextButton("R", uiManager.skin);
|
||||
|
||||
|
||||
|
||||
update();
|
||||
// Add actions to the buttons
|
||||
backBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
currentOption--;
|
||||
update();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
forthBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
currentOption++;
|
||||
update();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
resetBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
buildTable();
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
currentOption = defaultOption;
|
||||
update();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
currentOption = (currentOption+options.length)%options.length;
|
||||
if(currentOptLabel != null) currentOptLabel.setText(options[currentOption]);
|
||||
parseOptionString(options[currentOption]);
|
||||
}
|
||||
|
||||
public void saveState() {
|
||||
prevState = currentOption;
|
||||
}
|
||||
|
||||
public void restoreState() {
|
||||
currentOption = prevState;
|
||||
}
|
||||
|
||||
public void buildTable() {
|
||||
table.clear();
|
||||
float width = Gdx.graphics.getWidth();
|
||||
float height = Gdx.graphics.getHeight();
|
||||
|
||||
float d = (float) Math.sqrt(width*width + height*height);
|
||||
float labScale = d * .00080f;
|
||||
float buttonDim = d * 0.025f;
|
||||
float space = buttonDim * 0.5f;
|
||||
|
||||
nameLabel.setFontScale(labScale);
|
||||
currentOptLabel.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
forthBtn.getLabel().setFontScale(labScale);
|
||||
resetBtn.getLabel().setFontScale(labScale);
|
||||
|
||||
table.row().colspan(2);
|
||||
table.add(nameLabel);
|
||||
table.add(backBtn).width(buttonDim).height(buttonDim).space(space);
|
||||
table.add(currentOptLabel);
|
||||
table.add(forthBtn).width(buttonDim).height(buttonDim).space(space);
|
||||
table.add(resetBtn).width(buttonDim).height(buttonDim).space(space);
|
||||
}
|
||||
|
||||
public void setOptions(String[] opts){
|
||||
this.setOptions(opts, 0);
|
||||
}
|
||||
|
||||
public void setOptions(String[] opts, int defaultOption){
|
||||
this.options = Arrays.copyOf(opts, opts.length);
|
||||
this.defaultOption = defaultOption;
|
||||
reset();
|
||||
}
|
||||
|
||||
public void parseOptionString(String opt) {}
|
||||
public String getOptionString() {
|
||||
return options[currentOption];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.emamaker.amazeing.maze.settings;
|
||||
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MazeSettingDimension extends MazeSetting{
|
||||
|
||||
/* Maze dimension settings
|
||||
* Provide Options in the x*z format
|
||||
*/
|
||||
|
||||
public MazeSettingDimension(String name_, String[] options_, int defaultOption, UIManager uiManager_) {
|
||||
super(name_, options_, defaultOption, uiManager_);
|
||||
}
|
||||
|
||||
|
||||
public MazeSettingDimension(String name_, String[] options_, UIManager uiManager_) {
|
||||
super(name_, options_, uiManager_);
|
||||
}
|
||||
@Override
|
||||
public void parseOptionString(String opt) {
|
||||
super.parseOptionString(opt);
|
||||
String[] split = opt.split("x");
|
||||
MazeSettings.MAZEX = Integer.valueOf(split[0]);
|
||||
MazeSettings.MAZEZ = Integer.valueOf(split[1]);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.emamaker.amazeing.maze.settings;
|
||||
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MazeSettingEPDIST extends MazeSetting{
|
||||
|
||||
/* Game max. number of players settings*/
|
||||
|
||||
public MazeSettingEPDIST(String name_, String[] options_, UIManager uiManager_) {
|
||||
super(name_, options_, uiManager_);
|
||||
}
|
||||
public MazeSettingEPDIST(String name_, String[] options_, int defaultOption, UIManager uiManager_) {
|
||||
super(name_, options_, defaultOption, uiManager_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseOptionString(String opt) {
|
||||
if(Integer.valueOf(opt) <= MazeSettings.MAZEX * 0.75) {
|
||||
MazeSettings.EPDIST = Integer.valueOf(opt);
|
||||
}else{
|
||||
MazeSettings.EPDIST = 5;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.emamaker.amazeing.maze.settings;
|
||||
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MazeSettingMaxPlayers extends MazeSetting{
|
||||
|
||||
/* Game max. number of players settings*/
|
||||
|
||||
public MazeSettingMaxPlayers(String name_, String[] options_, UIManager uiManager_) {
|
||||
super(name_, options_, uiManager_);
|
||||
}
|
||||
public MazeSettingMaxPlayers(String name_, String[] options_, int defaultOption, UIManager uiManager_) {
|
||||
super(name_, options_, defaultOption, uiManager_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseOptionString(String opt) {
|
||||
MazeSettings.MAXPLAYERS = Integer.valueOf(opt);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.emamaker.amazeing.maze.settings;
|
||||
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MazeSettingMaxPlayersMobile extends MazeSetting{
|
||||
|
||||
/* Game max. number of players settings*/
|
||||
|
||||
public MazeSettingMaxPlayersMobile(String name_, String[] options_, UIManager uiManager_) {
|
||||
super(name_, options_, uiManager_);
|
||||
}
|
||||
public MazeSettingMaxPlayersMobile(String name_, String[] options_, int defaultOption, UIManager uiManager_) {
|
||||
super(name_, options_, defaultOption, uiManager_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseOptionString(String opt) {
|
||||
MazeSettings.MAXPLAYERS_MOBILE = Integer.valueOf(opt);
|
||||
//AMazeIng.getMain().uiManager.preGameScreen.buildTable();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.emamaker.amazeing.maze.settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
|
||||
public class MazeSettings {
|
||||
|
||||
//This must only hold public static variables to eventually their getters and setters
|
||||
public static int MAZEX = 20;
|
||||
public static int MAZEZ = 20;
|
||||
public static int MAXPLAYERS = 8;
|
||||
public static int MAXPLAYERS_MOBILE = 1;
|
||||
public static int EPDIST = 5;
|
||||
|
||||
public static ArrayList<MazeSetting> settings = new ArrayList<MazeSetting>();
|
||||
public static MazeSetting setDim;
|
||||
public static MazeSetting setPlayers;
|
||||
public static MazeSetting setPlayers_Mobile;
|
||||
public static MazeSetting setEpDist;
|
||||
|
||||
public static String[] maxPlayersDesktop = new String[] {
|
||||
"2", "4", "6", "8", "10", "15", "20"
|
||||
};
|
||||
public static String[] maxPlayersMobile = new String[] {
|
||||
"1", "2", "3", "4"
|
||||
};
|
||||
|
||||
public MazeSettings() {
|
||||
//Add various settings here
|
||||
setDim = new MazeSettingDimension("MAZE DIMENSIONS:", new String[] {
|
||||
"10x10", "20x20", "30x30"
|
||||
}, 1, AMazeIng.getMain().uiManager);
|
||||
|
||||
setPlayers = new MazeSettingMaxPlayers("MAX NUMBER OF PLAYERS: ", maxPlayersDesktop, AMazeIng.getMain().uiManager);
|
||||
setPlayers_Mobile = new MazeSettingMaxPlayersMobile("PLAYERS JOINING FROM THIS DEVICE: ", maxPlayersMobile, 0, AMazeIng.getMain().uiManager);
|
||||
|
||||
setEpDist = new MazeSettingEPDIST("END POINT DISTANCE:", new String[] {
|
||||
"1", "2", "5", "10", "20"
|
||||
}, 2, AMazeIng.getMain().uiManager);
|
||||
|
||||
settings.add(setDim);
|
||||
settings.add(setPlayers);
|
||||
settings.add(setEpDist);
|
||||
}
|
||||
|
||||
public static void saveStates() {
|
||||
for(MazeSetting m : settings) m.saveState();
|
||||
}
|
||||
public static void restoreStates() {
|
||||
for(MazeSetting m : settings) m.saveState();
|
||||
}
|
||||
public static void resetAll() {
|
||||
for(MazeSetting m : settings) m.reset();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package com.emamaker.amazeing.player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.VertexAttributes;
|
||||
import com.badlogic.gdx.graphics.g3d.Environment;
|
||||
import com.badlogic.gdx.graphics.g3d.Material;
|
||||
import com.badlogic.gdx.graphics.g3d.Model;
|
||||
import com.badlogic.gdx.graphics.g3d.ModelBatch;
|
||||
import com.badlogic.gdx.graphics.g3d.ModelInstance;
|
||||
import com.badlogic.gdx.graphics.g3d.model.Node;
|
||||
import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder;
|
||||
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
|
||||
import com.badlogic.gdx.math.Quaternion;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.voxelengine.physics.GameObject;
|
||||
|
||||
public abstract class MazePlayer implements Disposable {
|
||||
|
||||
AMazeIng main;
|
||||
|
||||
static Random rand = new Random();
|
||||
|
||||
// MazePlayer model building stuff
|
||||
public Model mazePlayerModel;
|
||||
public ModelInstance instance;
|
||||
ModelBuilder modelBuilder = new ModelBuilder();
|
||||
MeshPartBuilder meshBuilder;
|
||||
static int meshAttr = VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal;
|
||||
public GameObject obj;
|
||||
String name = "";
|
||||
boolean disposing = false;
|
||||
boolean disposed = false;
|
||||
boolean playing = false;
|
||||
boolean show = true;
|
||||
public String uuid;
|
||||
|
||||
Vector3 pos = new Vector3();
|
||||
Quaternion rot = new Quaternion();
|
||||
|
||||
MazePlayer(boolean s) {
|
||||
this(String.valueOf((char) (65 + rand.nextInt(26))), s);
|
||||
disposing = false;
|
||||
disposed = false;
|
||||
playing = false;
|
||||
}
|
||||
|
||||
MazePlayer(String name, boolean s) {
|
||||
main = AMazeIng.getMain();
|
||||
show = s;
|
||||
setName(name);
|
||||
if (show)
|
||||
buildModel();
|
||||
}
|
||||
|
||||
public Vector3 getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public Quaternion getRotation() {
|
||||
return rot;
|
||||
}
|
||||
|
||||
public void setPlaying() {
|
||||
disposing = false;
|
||||
playing = true;
|
||||
}
|
||||
|
||||
public void setPos(Vector3 v) {
|
||||
if (!disposing)
|
||||
setPos(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
public void setPos(float x, float y, float z) {
|
||||
if (!disposing)
|
||||
setTransform(x, y, z, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public void setTransform(float x, float y, float z, float i, float j, float k, float l) {
|
||||
if (!disposing && !disposed) {
|
||||
pos.set(x, y, z);
|
||||
rot.set(i, j, k, l);
|
||||
if (show)
|
||||
instance.transform.set(x, y, z, i, j, k, l);
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name_) {
|
||||
this.name = name_;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void render(ModelBatch b, Environment e) {
|
||||
if (!disposing && ! disposed && playing) {
|
||||
update();
|
||||
if (show)
|
||||
b.render(instance, e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void buildModel() {
|
||||
modelBuilder.begin();
|
||||
Node n = modelBuilder.node();
|
||||
n.id = "MazePlayer";
|
||||
modelBuilder.part("MazePlayer", GL20.GL_TRIANGLES, meshAttr, new Material()).box(0.6f, 0.6f, 0.6f);
|
||||
mazePlayerModel = modelBuilder.end();
|
||||
instance = new ModelInstance(mazePlayerModel);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
playing = false;
|
||||
if (!disposed) {
|
||||
disposing = true;
|
||||
if (show)
|
||||
mazePlayerModel.dispose();
|
||||
disposing = false;
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
public boolean isDisposed() {
|
||||
return disposed;
|
||||
}
|
||||
|
||||
public boolean isPlaying() {
|
||||
return playing;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,306 @@
|
|||
package com.emamaker.amazeing.player;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.controllers.Controller;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Matrix4;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.physics.bullet.collision.btBoxShape;
|
||||
import com.badlogic.gdx.physics.bullet.collision.btBroadphaseProxy;
|
||||
import com.badlogic.gdx.physics.bullet.collision.btCollisionObject;
|
||||
import com.badlogic.gdx.physics.bullet.collision.btConvexShape;
|
||||
import com.badlogic.gdx.physics.bullet.collision.btPairCachingGhostObject;
|
||||
import com.badlogic.gdx.physics.bullet.dynamics.btDiscreteDynamicsWorld;
|
||||
import com.badlogic.gdx.physics.bullet.dynamics.btKinematicCharacterController;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
|
||||
public class MazePlayerLocal extends MazePlayer {
|
||||
|
||||
/*
|
||||
* Player controlled on local machine with mouse and kbd, touch or controller
|
||||
* (in a remote future=
|
||||
*/
|
||||
|
||||
btConvexShape ghostShape;
|
||||
public btPairCachingGhostObject ghostObject;
|
||||
public btKinematicCharacterController characterController;
|
||||
Matrix4 characterTransform;
|
||||
Vector3 characterDirection = new Vector3();
|
||||
Vector3 walkDirection = new Vector3();
|
||||
public Controller ctrl;
|
||||
public Touchpad tctrl;
|
||||
public int tctrlPosition;
|
||||
|
||||
boolean touchpadPressed = false;
|
||||
float oldAngle = 0, angle;
|
||||
|
||||
// Physics using LibGDX's bullet wrapper
|
||||
public int kup, kdown, ksx, kdx;
|
||||
float startx, starty, startz;
|
||||
|
||||
// Give keys in up, down, left, right order
|
||||
public MazePlayerLocal(int... keys) {
|
||||
this(keys[0], keys[1], keys[2], keys[3]);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(int up_, int down_, int sx_, int dx_) {
|
||||
this(up_, down_, sx_, dx_, 0, 0, 0);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(int up_, int down_, int sx_, int dx_, String name) {
|
||||
this(up_, down_, sx_, dx_, 0, 0, 0, name);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(int up_, int down_, int sx_, int dx_, float startx, float starty, float startz) {
|
||||
this(up_, down_, sx_, dx_, startx, starty, startz, String.valueOf((char) (65 + rand.nextInt(26))));
|
||||
}
|
||||
|
||||
public MazePlayerLocal(int up_, int down_, int sx_, int dx_, float startx, float starty, float startz,
|
||||
String name) {
|
||||
super(name, true);
|
||||
this.kup = up_;
|
||||
this.kdown = down_;
|
||||
this.ksx = sx_;
|
||||
this.kdx = dx_;
|
||||
|
||||
this.startx = startx;
|
||||
this.starty = starty;
|
||||
this.startz = startz;
|
||||
|
||||
initPhysics();
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Controller ctrl_) {
|
||||
this(ctrl_, 0, 0, 0);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Controller ctrl_, String name) {
|
||||
this(ctrl_, 0, 0, 0, name);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Controller crtl_, float startx, float starty, float startz) {
|
||||
this(crtl_, startx, starty, startz, String.valueOf((char) (65 + rand.nextInt(26))));
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Controller ctrl_, float startx, float starty, float startz, String name) {
|
||||
super(true);
|
||||
this.ctrl = ctrl_;
|
||||
|
||||
this.startx = startx;
|
||||
this.starty = starty;
|
||||
this.startz = startz;
|
||||
|
||||
initPhysics();
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Touchpad ctrl_, int p) {
|
||||
this(ctrl_, p, 0, 0, 0);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Touchpad ctrl_, int p, String name) {
|
||||
this(ctrl_, p, 0, 0, 0, name);
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Touchpad crtl_, int p, float startx, float starty, float startz) {
|
||||
this(crtl_, p, startx, starty, startz, String.valueOf((char) (65 + rand.nextInt(26))));
|
||||
}
|
||||
|
||||
public MazePlayerLocal(Touchpad ctrl_, int p, float startx, float starty, float startz, String name) {
|
||||
super(true);
|
||||
this.tctrl = ctrl_;
|
||||
|
||||
this.startx = startx;
|
||||
this.starty = starty;
|
||||
this.startz = startz;
|
||||
this.tctrlPosition = p;
|
||||
|
||||
tctrl.setResetOnTouchUp(true);
|
||||
|
||||
oldAngle = 0;
|
||||
angle = 0;
|
||||
touchpadPressed = false;
|
||||
|
||||
tctrl.setSize(Gdx.graphics.getHeight() / 6f, Gdx.graphics.getHeight() / 6f);
|
||||
|
||||
tctrl.addListener(new InputListener() {
|
||||
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchDragged(InputEvent event, float x, float y, int pointer) {
|
||||
oldAngle = angle;
|
||||
angle = MathUtils.atan2(-tctrl.getKnobPercentY(), -tctrl.getKnobPercentX()) * 180f / MathUtils.PI;
|
||||
|
||||
touchpadPressed = true;
|
||||
//System.out.println(angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
||||
touchpadPressed = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (tctrlPosition == 0)
|
||||
tctrl.setPosition(tctrl.getWidth() / 2, tctrl.getHeight() / 2);
|
||||
else if (tctrlPosition == 1)
|
||||
tctrl.setPosition(Gdx.graphics.getWidth() - tctrl.getWidth() * 1.5f, tctrl.getHeight() / 2);
|
||||
else if (tctrlPosition == 2)
|
||||
tctrl.setPosition(Gdx.graphics.getWidth() - tctrl.getWidth() * 1.5f, Gdx.graphics.getHeight() - tctrl.getHeight() * 1.5f);
|
||||
else if (tctrlPosition == 3)
|
||||
tctrl.setPosition(tctrl.getWidth() / 2, Gdx.graphics.getHeight() - tctrl.getHeight() * 1.5f);
|
||||
|
||||
initPhysics();
|
||||
}
|
||||
|
||||
|
||||
public void initPhysics() {
|
||||
characterTransform = instance.transform; // Set by reference
|
||||
characterTransform.set(startx, starty, startz, 0, 0, 0, 0);
|
||||
|
||||
// Create the physics representation of the character
|
||||
ghostObject = new btPairCachingGhostObject();
|
||||
ghostObject.setWorldTransform(characterTransform);
|
||||
ghostShape = new btBoxShape(new Vector3(0.3f, 0.3f, 0.3f));
|
||||
ghostObject.setCollisionShape(ghostShape);
|
||||
ghostObject.setCollisionFlags(btCollisionObject.CollisionFlags.CF_CHARACTER_OBJECT);
|
||||
characterController = new btKinematicCharacterController(ghostObject, ghostShape, .05f, Vector3.Y);
|
||||
|
||||
// And add it to the physics world
|
||||
main.world.dynamicsWorld.addCollisionObject(ghostObject,
|
||||
(short) btBroadphaseProxy.CollisionFilterGroups.CharacterFilter,
|
||||
(short) (btBroadphaseProxy.CollisionFilterGroups.StaticFilter
|
||||
| btBroadphaseProxy.CollisionFilterGroups.DefaultFilter));
|
||||
((btDiscreteDynamicsWorld) (main.world.dynamicsWorld)).addAction(characterController);
|
||||
}
|
||||
|
||||
boolean pressed = false;
|
||||
|
||||
public void inputs() {
|
||||
//Update for touchscreen controller is done in touchpad listener
|
||||
if(AMazeIng.PLATFORM == AMazeIng.Platform.DESKTOP){
|
||||
if (ctrl != null) {
|
||||
|
||||
}else{
|
||||
|
||||
pressed = false;
|
||||
// If the left or right key is pressed, rotate the character and update its
|
||||
// physics update accordingly.
|
||||
if (Gdx.input.isKeyPressed(ksx)) {
|
||||
pressed = true;
|
||||
characterTransform.rotate(0, 1, 0, 2.5f);
|
||||
ghostObject.setWorldTransform(characterTransform);
|
||||
}
|
||||
if (Gdx.input.isKeyPressed(kdx)) {
|
||||
pressed = true;
|
||||
characterTransform.rotate(0, 1, 0, -2.5f);
|
||||
ghostObject.setWorldTransform(characterTransform);
|
||||
}
|
||||
// Fetch which direction the character is facing now
|
||||
characterDirection.set(-1, 0, 0).rot(characterTransform).nor();
|
||||
// Set the walking direction accordingly (either forward or backward)
|
||||
walkDirection.set(0, 0, 0);
|
||||
|
||||
if (Gdx.input.isKeyPressed(kup)) {
|
||||
pressed = true;
|
||||
walkDirection.add(characterDirection);
|
||||
}
|
||||
if (Gdx.input.isKeyPressed(kdown)) {
|
||||
pressed = false;
|
||||
walkDirection.add(-characterDirection.x, -characterDirection.y, -characterDirection.z);
|
||||
}
|
||||
walkDirection.scl(3f * Gdx.graphics.getDeltaTime());
|
||||
// And update the character controller
|
||||
characterController.setWalkDirection(walkDirection);
|
||||
// Now we can update the world as normally
|
||||
// And fetch the new transformation of the character (this will make the model
|
||||
// be rendered correctly)
|
||||
ghostObject.getWorldTransform(characterTransform);
|
||||
}
|
||||
}else{
|
||||
if(touchpadPressed) {
|
||||
|
||||
//characterTransform.rotate(0, 1, 0, angle-oldAngle);
|
||||
//ghostObject.setWorldTransform(characterTransform);
|
||||
|
||||
// Fetch which direction the character is facing now
|
||||
characterDirection.set(-1, 0, 0).rotate(angle, 0, 1, 0).nor();
|
||||
|
||||
// characterDirection.set(-1, 0, 0).rot(characterTransform).nor();
|
||||
|
||||
|
||||
// Set the walking direction accordingly (either forward or backward)
|
||||
walkDirection.set(0, 0, 0);
|
||||
walkDirection.add(characterDirection);
|
||||
walkDirection.scl(3f * Gdx.graphics.getDeltaTime());
|
||||
// And update the character controller
|
||||
characterController.setWalkDirection(walkDirection);
|
||||
// Now we can update the world as normally
|
||||
// And fetch the new transformation of the character (this will make the model
|
||||
// be rendered correctly)
|
||||
ghostObject.getWorldTransform(characterTransform);
|
||||
|
||||
oldAngle = angle;
|
||||
pressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pressed)
|
||||
main.client.updateLocalPlayer(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
inputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getPos() {
|
||||
if (!disposing) {
|
||||
return ghostObject.getWorldTransform().getTranslation(new Vector3());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(Vector3 v) {
|
||||
this.setPos(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(float x, float y, float z) {
|
||||
if (!disposing)
|
||||
setTransform(x, y, z, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransform(float x, float y, float z, float i, float j, float k, float l) {
|
||||
if (!disposing) {
|
||||
characterTransform.set(x, y, z, i, j, k, l);
|
||||
ghostObject.setWorldTransform(characterTransform);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
disposing = true;
|
||||
if (!isDisposed()) {
|
||||
main.world.dynamicsWorld.removeAction(characterController);
|
||||
main.world.dynamicsWorld.removeCollisionObject(ghostObject);
|
||||
characterController.dispose();
|
||||
ghostObject.dispose();
|
||||
ghostShape.dispose();
|
||||
disposed = true;
|
||||
}
|
||||
disposing = false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.emamaker.amazeing.player;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
|
||||
public class MazePlayerRemote extends MazePlayer{
|
||||
|
||||
/*Remote controlled player to show other players on the server*/
|
||||
|
||||
static Random rand = new Random();
|
||||
|
||||
AMazeIng main;
|
||||
//UUID is stored a string, for kryonet ease of use
|
||||
|
||||
boolean disposing = false;
|
||||
|
||||
public MazePlayerRemote(String u) {
|
||||
this(u, true);
|
||||
}
|
||||
|
||||
public MazePlayerRemote( String u, boolean b) {
|
||||
super(b);
|
||||
uuid = u;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.emamaker.amazeing.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.gdx.controllers.Controller;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
|
||||
public class PlayerUtils {
|
||||
|
||||
/*Utility function to add and remove players from arrays when organizing as game*/
|
||||
|
||||
public static boolean togglePlayer(MazePlayerLocal p, Set<MazePlayer> players) {
|
||||
if (alreadyAddedPlayer(p, players)) {
|
||||
p.dispose();
|
||||
players.remove(p);
|
||||
return false;
|
||||
}
|
||||
if(players.size() < MazeSettings.MAXPLAYERS) {
|
||||
players.add(p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean togglePlayer(MazePlayerLocal p, ArrayList<MazePlayer> players) {
|
||||
HashSet<MazePlayer> players2 = new HashSet<>(players);
|
||||
if (alreadyAddedPlayer(p, players2)) {
|
||||
p.dispose();
|
||||
players.remove(p);
|
||||
return false;
|
||||
}
|
||||
if(players.size() < MazeSettings.MAXPLAYERS) {
|
||||
players.add(p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean togglePlayerWithKeys(Set<MazePlayer> players, int... keys) {
|
||||
if (alreadyAddedPlayerWithKeys(players, keys)) {
|
||||
getPlayerWithKeys(players, keys).dispose();
|
||||
players.remove(getPlayerWithKeys(players, keys));
|
||||
return false;
|
||||
}
|
||||
if (players.size() < MazeSettings.MAXPLAYERS) {
|
||||
players.add(new MazePlayerLocal(keys));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean togglePlayerWithKeys(ArrayList<MazePlayer> players, int... keys) {
|
||||
HashSet<MazePlayer> players2 = new HashSet<>(players);
|
||||
if (alreadyAddedPlayerWithKeys(players2, keys)) {
|
||||
getPlayerWithKeys(players2, keys).dispose();
|
||||
players.remove(getPlayerWithKeys(players2, keys));
|
||||
return false;
|
||||
}
|
||||
if (players.size() < MazeSettings.MAXPLAYERS) {
|
||||
players.add(new MazePlayerLocal(keys));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean alreadyAddedPlayerWithKeys(Set<MazePlayer> players, int... keys) {
|
||||
return getPlayerWithKeys(players, keys) != null;
|
||||
}
|
||||
|
||||
public static boolean alreadyAddedPlayer(MazePlayerLocal p, Set<MazePlayer> players) {
|
||||
return players.contains(p);
|
||||
}
|
||||
|
||||
public static MazePlayerLocal getPlayerWithKeys(Set<MazePlayer> players, int... keys) {
|
||||
for (MazePlayer p : players) {
|
||||
if (p instanceof MazePlayerLocal) {
|
||||
for (int k : keys) {
|
||||
if (((MazePlayerLocal) p).kup == k || ((MazePlayerLocal) p).kdown == k
|
||||
|| ((MazePlayerLocal) p).ksx == k || ((MazePlayerLocal) p).kdx == k)
|
||||
return (MazePlayerLocal) p;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean alreadyAddedPlayerWithCtrl(Controller ctrl, Set<MazePlayer> players) {
|
||||
return getPlayerWithCtrl(ctrl, players) != null;
|
||||
}
|
||||
|
||||
public static MazePlayerLocal getPlayerWithCtrl(Controller ctrl, Set<MazePlayer> players) {
|
||||
for (MazePlayer p : players) {
|
||||
if (p instanceof MazePlayerLocal) {
|
||||
if (((MazePlayerLocal) p).ctrl == ctrl)
|
||||
return (MazePlayerLocal) p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//We're not referring as an actual touch ctrl, but just the position (0,1,2,3) it is into
|
||||
public static MazePlayerLocal getPlayerWithTouchCtrl(int pos, Set<MazePlayer> players) {
|
||||
for (MazePlayer p : players) {
|
||||
if (p instanceof MazePlayerLocal) {
|
||||
if (((MazePlayerLocal) p).tctrlPosition == pos)
|
||||
return (MazePlayerLocal) p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.emamaker.amazeing.ui;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.ui.screens.PlayerChooseScreen;
|
||||
import com.emamaker.amazeing.ui.screens.PreGameScreen;
|
||||
import com.emamaker.amazeing.ui.screens.ServerJoinScreen;
|
||||
import com.emamaker.amazeing.ui.screens.ServerLaunchScreen;
|
||||
import com.emamaker.amazeing.ui.screens.SettingsScreen;
|
||||
import com.emamaker.amazeing.ui.screens.TitleScreen;
|
||||
|
||||
public class UIManager {
|
||||
|
||||
public Skin skin;
|
||||
public AMazeIng main;
|
||||
float delta;
|
||||
public TitleScreen titleScreen;
|
||||
public PlayerChooseScreen playersScreen;
|
||||
public SettingsScreen setScreen;
|
||||
public ServerJoinScreen srvJoinScreen;
|
||||
public ServerLaunchScreen srvLaunchScreen;
|
||||
public PreGameScreen preGameScreen;
|
||||
|
||||
public UIManager(Game main_) {
|
||||
main = (AMazeIng)main_;
|
||||
|
||||
//Load the sinks
|
||||
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
|
||||
}
|
||||
|
||||
public void setupScreens() {
|
||||
//Load all the screens after loading the skin
|
||||
titleScreen = new TitleScreen(this);
|
||||
setScreen = new SettingsScreen(this);
|
||||
playersScreen = new PlayerChooseScreen(this);
|
||||
srvJoinScreen = new ServerJoinScreen(this);
|
||||
srvLaunchScreen = new ServerLaunchScreen(this);
|
||||
preGameScreen = new PreGameScreen(this);
|
||||
|
||||
main.setScreen(titleScreen);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
titleScreen.dispose();
|
||||
}
|
||||
|
||||
public BitmapFont generatefont(int size) {
|
||||
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/default.fnt"));
|
||||
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
|
||||
parameter.size = size;
|
||||
parameter.magFilter = Texture.TextureFilter.Linear;
|
||||
parameter.minFilter = Texture.TextureFilter.Linear;
|
||||
BitmapFont font32 = generator.generateFont(parameter); // font size 32 pixels
|
||||
font32.getData().setScale(0.15f);
|
||||
generator.dispose();
|
||||
return font32;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class MyScreen implements Screen {
|
||||
|
||||
// This method makes the UI super easy to scale and resize with just a little
|
||||
// effort in code
|
||||
|
||||
// Main stage. Must only contain tableContainer
|
||||
Stage stage;
|
||||
// Container for main stage table. This must only contain table
|
||||
Container<Table> tableContainer = new Container<Table>();
|
||||
// Table that contains all the stage. Must be cleared any time the window is
|
||||
// resize. Look at buildTable1()
|
||||
Table table = new Table();
|
||||
|
||||
Container<Dialog> dialogContainer = new Container<Dialog>();
|
||||
|
||||
UIManager uiManager;
|
||||
MyScreen prevScreen;
|
||||
|
||||
float width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight();
|
||||
static float sw, sh;
|
||||
float cw, ch;
|
||||
float cwmult = 0.8f, chmult = 1f;
|
||||
|
||||
public MyScreen(UIManager uiManager_) {
|
||||
this.uiManager = uiManager_;
|
||||
stage = new Stage(new ScreenViewport());
|
||||
|
||||
stage = new Stage(new ScreenViewport());
|
||||
tableContainer.setActor(table);
|
||||
stage.addActor(tableContainer);
|
||||
|
||||
// table.setDebug(true);
|
||||
|
||||
sw = width;
|
||||
sh = height;
|
||||
cw = sw * cwmult;
|
||||
ch = sh * chmult;
|
||||
|
||||
createTable();
|
||||
buildTable();
|
||||
}
|
||||
|
||||
// Classes that inherit from this must use createTable to prepare the stage
|
||||
// (create actors and listeners) and buildTable() to layout them
|
||||
// buildTable1 make sure the table is cleared before it's layout, since position
|
||||
// and sizes have to recalculated each time the window is resized
|
||||
public void createTable() {
|
||||
}
|
||||
|
||||
public void buildTable() {
|
||||
table.clear();
|
||||
|
||||
sw = width;
|
||||
sh = height;
|
||||
cw = sw * cwmult;
|
||||
ch = sh * chmult;
|
||||
|
||||
tableContainer.setSize(cw, ch);
|
||||
tableContainer.setPosition((sw - cw) / 2.0f, (sh - ch) / 2.0f);
|
||||
tableContainer.fill();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
uiManager.main.multiplexer.addProcessor(stage);
|
||||
buildTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
uiManager.main.multiplexer.removeProcessor(stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0, 0, 0, 0);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
update();
|
||||
|
||||
stage.act();
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
stage.getViewport().update(width, height, true);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
buildTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
public float containerDiagonal() {
|
||||
return (float) Math.sqrt(cw * cw + ch * ch);
|
||||
}
|
||||
|
||||
public static float screenDiagonal() {
|
||||
return (float) Math.sqrt(sw * sw + sh * sh);
|
||||
}
|
||||
|
||||
public void setPrevScreen(MyScreen s) {
|
||||
this.prevScreen = s;
|
||||
}
|
||||
|
||||
public void showDialog(Dialog d) {
|
||||
dialogContainer.setActor(d);
|
||||
d.setScale(containerDiagonal() * 0.0005f);
|
||||
|
||||
dialogContainer.setSize(cw, ch);
|
||||
dialogContainer.setPosition((sw - dialogContainer.getWidth()) / 2.0f, (sh - dialogContainer.getHeight()) / 2.0f);
|
||||
dialogContainer.fill();
|
||||
|
||||
// d.show(s);
|
||||
stage.addActor(dialogContainer);
|
||||
}
|
||||
|
||||
public void hideDialog() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.AMazeIng.Platform;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSetting;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.player.MazePlayer;
|
||||
import com.emamaker.amazeing.player.MazePlayerLocal;
|
||||
import com.emamaker.amazeing.player.PlayerUtils;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PlayerChooseScreen extends MyScreen {
|
||||
|
||||
Label[] labels;
|
||||
CheckBox[] buttons;
|
||||
int currentLabel = 0;
|
||||
ArrayList<MazePlayer> players = new ArrayList<MazePlayer>();
|
||||
|
||||
MyScreen thisScreen;
|
||||
|
||||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
Label instLab, helpDlgText;
|
||||
TextButton backBtn, setBtn, helpBtn, playBtn, helpDlgOkBtn;
|
||||
Dialog helpDlg;
|
||||
|
||||
int totalPlayers = 0;
|
||||
|
||||
public PlayerChooseScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
|
||||
chmult = 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable() {
|
||||
super.createTable();
|
||||
thisScreen = this;
|
||||
|
||||
firstRowContainer = new Container<Table>();
|
||||
firstRowTable = new Table();
|
||||
|
||||
firstRowContainer.setActor(firstRowTable);
|
||||
|
||||
instLab = new Label(
|
||||
AMazeIng.PLATFORM == Platform.DESKTOP ? "Use WASD, ARROWS, or button on controller to join the match"
|
||||
: "Tap the buttons below to join the match",
|
||||
uiManager.skin);
|
||||
backBtn = new TextButton("<", uiManager.skin);
|
||||
setBtn = new TextButton("Settings", uiManager.skin);
|
||||
helpBtn = new TextButton("?", uiManager.skin);
|
||||
playBtn = new TextButton("Play!", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
// helpDlg.setResizable(true);
|
||||
helpDlgText = new Label("Here you can start a singleplayer or multiplayer game on the local machine:\n"
|
||||
+ "For keyboard players, pressing W,A,S,D or the directional arrows will toggle two different players.\n"
|
||||
+ "Pressing a button on a controller will toggle a player.\n"
|
||||
+ "Mobile players can tap the buttons below to join the game.\n"
|
||||
+ "You can edit game settings from the \"Settings\" menu or use the \"<\" button to go back to the main menu\n"
|
||||
+ "Press the \"Play!\" button to start the game with the players that have currently joined.\n"
|
||||
+ "Once a game is finished you will go back to this menu", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.hide();
|
||||
// hideDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Add actions to the buttons
|
||||
backBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.main.setScreen(uiManager.titleScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
playBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
if (AMazeIng.PLATFORM != Platform.DESKTOP) {
|
||||
for (MazePlayer p : players)
|
||||
p.dispose();
|
||||
players.clear();
|
||||
|
||||
for (int i = 0; i < buttons.length; i++)
|
||||
if (buttons[i].isChecked())
|
||||
players.add(new MazePlayerLocal(new Touchpad(0f, uiManager.skin), i));
|
||||
}
|
||||
if (!players.isEmpty()) {
|
||||
uiManager.main.gameManager.generateMaze(new HashSet<>(players));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
setBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.setScreen.setPrevScreen(thisScreen);
|
||||
uiManager.main.setScreen(uiManager.setScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
helpBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
firstRowTable.clear();
|
||||
|
||||
totalPlayers = 0;
|
||||
|
||||
if (AMazeIng.PLATFORM == Platform.DESKTOP) {
|
||||
|
||||
labels = new Label[MazeSettings.MAXPLAYERS];
|
||||
// Labels to know if players joined
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i] = new Label("-- empty slot --", uiManager.skin);
|
||||
}
|
||||
} else {
|
||||
|
||||
buttons = new CheckBox[MazeSettings.MAXPLAYERS];
|
||||
// Labels to know if players joined
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i] = new CheckBox("-- empty slot --", uiManager.skin);
|
||||
}
|
||||
}
|
||||
|
||||
float d = containerDiagonal();
|
||||
float labScale = d * .00090f;
|
||||
float buttonDim = d * 0.05f;
|
||||
|
||||
firstRowContainer.setSize(cw, ch * 0.2f);
|
||||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw * 0.7f, ch * 0.3f);
|
||||
helpDlg.setPosition((sw - helpDlg.getWidth()) / 2, (sh - helpDlg.getHeight()) / 2);
|
||||
helpDlgText.setFontScale(labScale * 0.8f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale * 0.8f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
setBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
playBtn.getLabel().setFontScale(labScale);
|
||||
|
||||
firstRowTable.add(backBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
firstRowTable.add(instLab).space(cw * 0.25f).width(cw / 2);
|
||||
firstRowTable.add(setBtn).fillX().expandX().space(cw * 0.005f).height(buttonDim);
|
||||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
|
||||
table.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4);
|
||||
|
||||
table.add(firstRowContainer);
|
||||
|
||||
if (AMazeIng.PLATFORM == Platform.DESKTOP) {
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i].setFontScale(labScale);
|
||||
if (i % 4 == 0)
|
||||
table.row().expandY().fillY();
|
||||
table.add(labels[i]).space(1);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i].getLabel().setFontScale(labScale);
|
||||
if (i % 4 == 0)
|
||||
table.row().expandY().fillY();
|
||||
table.add(buttons[i]).space(1);
|
||||
}
|
||||
}
|
||||
|
||||
table.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4);
|
||||
// table.add(playBtn).fillX().width(buttonDim*2f).height(buttonDim);
|
||||
table.add(playBtn).fillX().expandX().height(buttonDim);
|
||||
}
|
||||
|
||||
MazePlayerLocal p;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// Consantly search for new players to be added
|
||||
// First search for keyboard players (WASD and ARROWS)
|
||||
if (Gdx.input.isKeyJustPressed(Keys.W) || Gdx.input.isKeyJustPressed(Keys.A)
|
||||
|| Gdx.input.isKeyJustPressed(Keys.S) || Gdx.input.isKeyJustPressed(Keys.D))
|
||||
PlayerUtils.togglePlayerWithKeys(players, Keys.W, Keys.S, Keys.A, Keys.D);
|
||||
if (Gdx.input.isKeyJustPressed(Keys.UP) || Gdx.input.isKeyJustPressed(Keys.LEFT)
|
||||
|| Gdx.input.isKeyJustPressed(Keys.DOWN) || Gdx.input.isKeyJustPressed(Keys.RIGHT))
|
||||
PlayerUtils.togglePlayerWithKeys(players, Keys.UP, Keys.DOWN, Keys.LEFT, Keys.RIGHT);
|
||||
|
||||
// for (Controller c : Controllers.getControllers()) {
|
||||
// System.out.println(c.getButton(Xbox.A));
|
||||
|
||||
// if (c.getButton(Xbox.Y)) {
|
||||
// p = getPlayerWithCtrl(c);
|
||||
// if (p == null)
|
||||
// p = new MazePlayerLocal(uiManager.main, c);
|
||||
// togglePlayer(p);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Update labels
|
||||
if (AMazeIng.PLATFORM == Platform.DESKTOP) {
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i].setText(i < players.size() ? "-- Player Ready! --" : "-- empty slot --");
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i].setText(buttons[i].isChecked() ? " -- Player Ready -- " : " -- empty slot -- ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.manager.GameType;
|
||||
import com.emamaker.amazeing.manager.network.NetworkCommon;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSetting;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.player.MazePlayerLocal;
|
||||
import com.emamaker.amazeing.player.PlayerUtils;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class PreGameScreen extends MyScreen {
|
||||
|
||||
Label[] labels;
|
||||
// MazePlayer[] players;
|
||||
int nPlayers, nPlayersOld;
|
||||
|
||||
// GameType we are runnig. assuming server for default. If client, the StartGame
|
||||
// button shouldn't appear
|
||||
GameType type = GameType.SERVER;
|
||||
MyScreen thisScreen;
|
||||
|
||||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
Label instLab, helpDlgText, mobileLab1;
|
||||
TextButton backBtn, setBtn, helpBtn, playBtn, helpDlgOkBtn, mobileSetBtn;
|
||||
Dialog helpDlg;
|
||||
|
||||
public PreGameScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
chmult = 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable() {
|
||||
super.createTable();
|
||||
thisScreen = this;
|
||||
|
||||
nPlayers = 0;
|
||||
nPlayersOld = 0;
|
||||
|
||||
firstRowTable = new Table();
|
||||
firstRowContainer = new Container<Table>();
|
||||
|
||||
instLab = new Label("Waiting for players to join...", uiManager.skin);
|
||||
|
||||
|
||||
mobileLab1 = new Label("Remote Players: ", uiManager.skin);
|
||||
|
||||
backBtn = new TextButton("<", uiManager.skin);
|
||||
setBtn = new TextButton("Settings", uiManager.skin);
|
||||
helpBtn = new TextButton("?", uiManager.skin);
|
||||
playBtn = new TextButton("Start the match!", uiManager.skin);
|
||||
mobileSetBtn = new TextButton("Join!", uiManager.skin);
|
||||
|
||||
/* HELP DIALOG */
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
helpDlgText = new Label("An online game is about to start!\n"
|
||||
+ "If you're a client, just wait for the server to start the game.\n"
|
||||
+ "If you're a server, wait for players and start the game pressing the \"Start the match!\" button.\n"
|
||||
+ "How to join (for both client and server):\n"
|
||||
+ "On a computer players can join or leave the game pressing WASD, Arrow buttons or\n"
|
||||
+ "a button on the controller\n" + "On mobile players can be toggled using the buttons below.",
|
||||
uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (type == GameType.CLIENT)
|
||||
instLab.setText("Waiting for server to start the game...");
|
||||
|
||||
// Add actions to the buttons
|
||||
backBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
if (type == GameType.SERVER) {
|
||||
uiManager.main.server.stop();
|
||||
uiManager.main.setScreen(uiManager.srvLaunchScreen);
|
||||
} else if (type == GameType.CLIENT) {
|
||||
uiManager.main.client.stop();
|
||||
uiManager.main.setScreen(uiManager.srvJoinScreen);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
playBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
if (uiManager.main.server.startGame())
|
||||
hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
setBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.setScreen.setPrevScreen(thisScreen);
|
||||
uiManager.main.setScreen(uiManager.setScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
helpBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mobileSetBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
buildTable();
|
||||
AMazeIng.getMain().client.setUpdateMobilePlayers();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
firstRowContainer.setActor(firstRowTable);
|
||||
tableContainer.setActor(table);
|
||||
stage.addActor(tableContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
|
||||
firstRowTable.clear();
|
||||
|
||||
float d = containerDiagonal();
|
||||
float labScale = d * .00090f;
|
||||
float buttonDim = d * 0.05f;
|
||||
|
||||
|
||||
if(AMazeIng.PLATFORM == AMazeIng.Platform.DESKTOP) {
|
||||
labels = new Label[MazeSettings.MAXPLAYERS];
|
||||
|
||||
// Labels to know if players joined
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i] = new Label("-- empty slot --", uiManager.skin);
|
||||
}
|
||||
}else{
|
||||
labels = new Label[MazeSettings.MAXPLAYERS - MazeSettings.MAXPLAYERS_MOBILE];
|
||||
|
||||
// Labels to know if players joined
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i] = new Label("-- empty slot --", uiManager.skin);
|
||||
}
|
||||
}
|
||||
|
||||
firstRowContainer.setSize(cw, ch * 0.2f);
|
||||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw * 0.65f, ch * 0.4f);
|
||||
helpDlg.setPosition((sw - helpDlg.getWidth()) / 2, (sh - helpDlg.getHeight()) / 2);
|
||||
helpDlgText.setFontScale(labScale * 0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale * 0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
mobileLab1.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
setBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
playBtn.getLabel().setFontScale(labScale);
|
||||
mobileSetBtn.getLabel().setFontScale(labScale);
|
||||
|
||||
firstRowTable.add(backBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
firstRowTable.add(instLab).space(cw * 0.25f).width(cw / 2);
|
||||
if (type == GameType.SERVER)
|
||||
firstRowTable.add(setBtn).fillX().expandX().space(cw * 0.005f).height(buttonDim);
|
||||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
|
||||
table.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4);
|
||||
table.row().colspan(4);
|
||||
table.add(firstRowContainer);
|
||||
|
||||
if(AMazeIng.PLATFORM != AMazeIng.Platform.DESKTOP){
|
||||
table.row().expandY().fillY().colspan(6);
|
||||
table.add(MazeSettings.setPlayers_Mobile.getTable());
|
||||
table.add(mobileSetBtn).width(buttonDim).height(buttonDim).expandX();
|
||||
|
||||
table.row().expandY().fillY().colspan(6);
|
||||
table.add(mobileLab1).fillY().expandY();
|
||||
}
|
||||
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i].setFontScale(labScale);
|
||||
if (i % 4 == 0)
|
||||
table.row().expandY().fillY();
|
||||
table.add(labels[i]).space(1);
|
||||
}
|
||||
|
||||
if (type == GameType.SERVER) {
|
||||
table.row().colspan(4);
|
||||
table.add(playBtn).fillX().height(buttonDim);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
instLab.setText(type.toString() + ": Waiting for players to join...");
|
||||
// Constantly update player labels, comparing with the remote players present on
|
||||
// server
|
||||
nPlayers = type == GameType.SERVER ? uiManager.main.server.remotePlayers.values().size()
|
||||
: uiManager.main.client.players.size();
|
||||
|
||||
if(AMazeIng.isMobile()) nPlayers -= MazeSettings.MAXPLAYERS_MOBILE;
|
||||
|
||||
if (labels.length > 0) {
|
||||
// Update Labels
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
labels[i].setText(i < nPlayers ? "-- Player Ready! --" : "-- empty slot --");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setGameType(GameType t) {
|
||||
type = t;
|
||||
show();
|
||||
}
|
||||
|
||||
public GameType getGameType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.emamaker.amazeing.manager.GameType;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class ServerJoinScreen extends MyScreen {
|
||||
|
||||
Label instLab, srvIpL, helpDlgText, failDlgText;
|
||||
TextButton backBtn, connectBtn, helpBtn, helpDlgOkBtn, failDlgOkBtn;
|
||||
TextArea srvIp;
|
||||
|
||||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
Dialog helpDlg, failDlg;
|
||||
|
||||
public ServerJoinScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
chmult=.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable() {
|
||||
super.createTable();
|
||||
|
||||
firstRowTable = new Table();
|
||||
firstRowContainer = new Container<Table>();
|
||||
firstRowContainer.setActor(firstRowTable);
|
||||
|
||||
instLab = new Label("Enter ip address and port and connect to the server!", uiManager.skin);
|
||||
backBtn = new TextButton("<", uiManager.skin);
|
||||
connectBtn = new TextButton("Connect to the server!", uiManager.skin);
|
||||
helpBtn = new TextButton("?", uiManager.skin);
|
||||
srvIpL = new Label("Server IP: ", uiManager.skin);
|
||||
srvIp = new TextArea("", uiManager.skin);
|
||||
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlgText = new Label("Here you can connect to a server to play with your friends over the network.\n"
|
||||
+ "The server host should provide you with address and port info to connect to the server", uiManager.skin);
|
||||
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
failDlg = new Dialog("Server start-up failed", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
failDlgText = new Label("Connection to the server failed. Check your internet connection and address/port combination.\n"
|
||||
+ "Or Pheraps there's no server running there?", uiManager.skin);
|
||||
failDlg.text(failDlgText);
|
||||
failDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
failDlg.button(failDlgOkBtn);
|
||||
failDlg.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
failDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Add actions to the buttons
|
||||
backBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.main.client.stop();
|
||||
uiManager.main.setScreen(uiManager.titleScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
helpBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
connectBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
try {
|
||||
String addr = srvIp.getText().split(":")[0];
|
||||
String port = srvIp.getText().split(":")[1];
|
||||
|
||||
if (uiManager.main.client.start(addr, Integer.valueOf(port))) {
|
||||
hide();
|
||||
|
||||
MazeSettings.setPlayers.setOptions(MazeSettings.maxPlayersDesktop, 3);
|
||||
|
||||
uiManager.preGameScreen.setGameType(uiManager.main.server.isRunning() ? GameType.SERVER : GameType.CLIENT);
|
||||
uiManager.main.setScreen(uiManager.preGameScreen);
|
||||
|
||||
} else {
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
|
||||
firstRowTable.clear();
|
||||
|
||||
|
||||
float d = containerDiagonal();
|
||||
float labScale = d * .00090f;
|
||||
float buttonDim = d * 0.05f;
|
||||
|
||||
firstRowContainer.setSize(cw, ch * 0.2f);
|
||||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.7f, ch*0.2f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
failDlg.setSize(cw*0.7f, ch*0.2f);
|
||||
failDlg.setPosition((sw-failDlg.getWidth())/2, (sh-failDlg.getHeight())/2);
|
||||
failDlgText.setFontScale(labScale*0.9f);
|
||||
failDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
srvIpL.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
connectBtn.getLabel().setFontScale(labScale);
|
||||
|
||||
firstRowTable.add(backBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
firstRowTable.add(instLab).space(cw * 0.25f).width(cw / 2);
|
||||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
|
||||
table.row().colspan(4);
|
||||
table.add(firstRowContainer);
|
||||
|
||||
table.row().colspan(2).fillX().expandX();
|
||||
table.add(srvIpL).space(buttonDim).width(buttonDim*4f).height(buttonDim*0.5f).fillY().expandY();
|
||||
table.add(srvIp).space(buttonDim).width(buttonDim*4f).height(buttonDim*0.5f).fillY().expandY();
|
||||
table.row().colspan(4);
|
||||
// table.add(connectBtn).fillX().width(buttonDim*3f).height(buttonDim);
|
||||
table.add(connectBtn).fillX().expandX().height(buttonDim);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.emamaker.amazeing.manager.GameType;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class ServerLaunchScreen extends MyScreen {
|
||||
|
||||
MyScreen thisScreen;
|
||||
Label instLab, srvPortL, helpDlgText, failDlgText;
|
||||
TextButton backBtn, connectBtn, setBtn, helpBtn, helpDlgOkBtn, failDlgOkBtn;
|
||||
TextArea srvPort;
|
||||
Dialog helpDlg, failDlg;
|
||||
|
||||
|
||||
Table firstRowTable;
|
||||
Container<Table> firstRowContainer;
|
||||
|
||||
public ServerLaunchScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
thisScreen = this;
|
||||
chmult = .8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable() {
|
||||
super.createTable();
|
||||
|
||||
firstRowTable = new Table();
|
||||
firstRowContainer = new Container<Table>();
|
||||
|
||||
instLab = new Label("Enter the port the server must start on", uiManager.skin);
|
||||
backBtn = new TextButton("<", uiManager.skin);
|
||||
connectBtn = new TextButton("Launch the server!", uiManager.skin);
|
||||
setBtn = new TextButton("Settings", uiManager.skin);
|
||||
helpBtn = new TextButton("?", uiManager.skin);
|
||||
srvPortL = new Label("Port: ", uiManager.skin);
|
||||
srvPort = new TextArea("", uiManager.skin);
|
||||
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlgText = new Label("Here you can start a server to play with your friends over the network.\n"
|
||||
+ "Choose a network port to start the server on and start the server.\n"
|
||||
+ "In the next screen you will be given the address and port other players have to connect to play on this server.\n"
|
||||
+ "The port must not being used by another program at the same time, or the server start-up will fail", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
failDlg = new Dialog("Server start-up failed", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
failDlgText = new Label("Server start-up failed. Pheraps the port is already being used?", uiManager.skin);
|
||||
failDlg.text(failDlgText);
|
||||
failDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
failDlg.button(failDlgOkBtn);
|
||||
failDlg.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
failDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Add actions to the buttons
|
||||
backBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.main.server.stop();
|
||||
uiManager.main.setScreen(uiManager.titleScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
helpBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
setBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.setScreen.prevScreen = thisScreen;
|
||||
uiManager.main.setScreen(uiManager.setScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
connectBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
try {
|
||||
if(uiManager.main.server.startServer(Integer.valueOf(srvPort.getText()))) {
|
||||
// If the server and the client have been started successfully, we can show the
|
||||
// joining screen
|
||||
|
||||
MazeSettings.setPlayers.setOptions(MazeSettings.maxPlayersDesktop, 3);
|
||||
|
||||
uiManager.preGameScreen.setGameType(GameType.SERVER);
|
||||
uiManager.main.setScreen(uiManager.preGameScreen);
|
||||
}else {
|
||||
//Show the dialog to say there was something wrong
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
}catch(Exception e) {
|
||||
//Show the dialog to say there was something wrong
|
||||
failDlg.show(stage);
|
||||
buildTable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
firstRowContainer.setActor(firstRowTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
|
||||
firstRowTable.clear();
|
||||
|
||||
float d = containerDiagonal();
|
||||
float labScale = d * .00090f;
|
||||
float buttonDim = d * 0.05f;
|
||||
|
||||
firstRowContainer.setSize(cw, ch * 0.2f);
|
||||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.8f, ch*0.3f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
failDlg.setSize(cw*0.45f, ch*0.2f);
|
||||
failDlg.setPosition((sw-failDlg.getWidth())/2, (sh-failDlg.getHeight())/2);
|
||||
failDlgText.setFontScale(labScale*0.9f);
|
||||
failDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
srvPortL.setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
connectBtn.getLabel().setFontScale(labScale);
|
||||
|
||||
firstRowTable.add(backBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
firstRowTable.add(instLab).space(cw * 0.25f).width(cw / 2);
|
||||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
|
||||
table.row().colspan(4);
|
||||
table.add(firstRowContainer);
|
||||
|
||||
table.row().colspan(2).fillX().expandX();
|
||||
table.add(srvPortL).space(buttonDim).width(buttonDim*4f).height(buttonDim*0.5f).fillY().expandY();
|
||||
table.add(srvPort).space(buttonDim).width(buttonDim*4f).height(buttonDim*0.5f).fillY().expandY();
|
||||
table.row().colspan(4);
|
||||
table.add(connectBtn).fillX().height(buttonDim);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSetting;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class SettingsScreen extends MyScreen {
|
||||
|
||||
Label instLab, helpDlgText, resetDlgText, backDlgText;
|
||||
TextButton backBtn, resetBtn, saveBtn, helpBtn, backDlgOkBtn, backDlgCancelBtn, helpDlgOkBtn, resetDlgOkBtn, resetDlgCancelBtn;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
Dialog helpDlg, resetDlg, backDlg;
|
||||
|
||||
Container<Table> firstRowContainer;
|
||||
Table firstRowTable;
|
||||
|
||||
public SettingsScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
chmult = 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable() {
|
||||
super.createTable();
|
||||
firstRowContainer = new Container<Table>();
|
||||
firstRowTable = new Table();
|
||||
|
||||
firstRowContainer.setActor(firstRowTable);
|
||||
|
||||
instLab = new Label("Here you can customize game settings!", uiManager.skin);
|
||||
backBtn = new TextButton("<", uiManager.skin);
|
||||
resetBtn = new TextButton("Reset All", uiManager.skin);
|
||||
saveBtn = new TextButton("Save", uiManager.skin);
|
||||
helpBtn = new TextButton("?", uiManager.skin);
|
||||
scrollPane = new ScrollPane(setSettings(), uiManager.skin);
|
||||
helpDlg = new Dialog("Help", uiManager.skin);
|
||||
/* HELP DIALOG */
|
||||
helpDlgText = new Label("Here you can customize game settings:\n"
|
||||
+ "Maze Size: changes the size of the maze. Mazes are always squares. This affects both local and online games.\n"
|
||||
+ "Max. Players: changes the max number of players that can join the game. This affects both local and online games.\n"
|
||||
+ "End Point Distance: it's the minimum distance between the end point and every player. This affects both local and online games.\n", uiManager.skin);
|
||||
helpDlg.text(helpDlgText);
|
||||
|
||||
helpDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
helpDlg.button(helpDlgOkBtn);
|
||||
helpDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* BACK DIALOG */
|
||||
backDlg = new Dialog("Go Back", uiManager.skin);
|
||||
backDlgText = new Label("Are you sure you want to go back without saving changes?\nThis cannot be reverted", uiManager.skin);
|
||||
backDlg.text(backDlgText);
|
||||
backDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
backDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
backDlg.button(backDlgCancelBtn);
|
||||
backDlg.button(backDlgOkBtn);
|
||||
backDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
backDlg.hide();
|
||||
MazeSettings.restoreStates();
|
||||
uiManager.main.setScreen(prevScreen == null ? uiManager.titleScreen : prevScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
backDlgCancelBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
backDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* RESET DIALOG */
|
||||
resetDlg = new Dialog("Reset All Settings", uiManager.skin);
|
||||
resetDlgText = new Label("Are you sure you want to reset all settings?\nThis cannot be reverted", uiManager.skin);
|
||||
resetDlg.text(resetDlgText);
|
||||
resetDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
resetDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
resetDlg.button(resetDlgCancelBtn);
|
||||
resetDlg.button(resetDlgOkBtn);
|
||||
resetDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
MazeSettings.resetAll();
|
||||
resetDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
resetDlgCancelBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
resetDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/* ACTIONS TO BUTTONS */
|
||||
backBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
backDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
helpBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
helpDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
resetBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
resetDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
saveBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
//If we are running server, we must send update to clients
|
||||
AMazeIng.getMain().server.updateSettingForAll();
|
||||
|
||||
hide();
|
||||
uiManager.main.setScreen(prevScreen == null ? uiManager.titleScreen : prevScreen);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
|
||||
firstRowTable.clear();
|
||||
|
||||
|
||||
float d = containerDiagonal();
|
||||
float labScale = d * .00090f;
|
||||
float buttonDim = d * 0.05f;
|
||||
|
||||
firstRowContainer.setSize(cw, ch * 0.2f);
|
||||
firstRowContainer.setPosition(tableContainer.getX(), ch * 0.1f);
|
||||
firstRowContainer.fill();
|
||||
|
||||
helpDlg.setSize(cw*0.8f, ch*0.3f);
|
||||
helpDlg.setPosition((sw-helpDlg.getWidth())/2, (sh-helpDlg.getHeight())/2);
|
||||
helpDlgText.setFontScale(labScale*0.9f);
|
||||
helpDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
resetDlg.setSize(cw*0.45f, ch*0.25f);
|
||||
resetDlg.setPosition((sw-resetDlg.getWidth())/2, (sh-resetDlg.getHeight())/2);
|
||||
resetDlgText.setFontScale(labScale*0.9f);
|
||||
resetDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
resetDlgCancelBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
backDlg.setSize(cw*0.45f, ch*0.25f);
|
||||
backDlg.setPosition((sw-backDlg.getWidth())/2, (sh-backDlg.getHeight())/2);
|
||||
backDlgText.setFontScale(labScale*0.9f);
|
||||
backDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
backDlgCancelBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
instLab.setFontScale(labScale);
|
||||
backBtn.getLabel().setFontScale(labScale);
|
||||
helpBtn.getLabel().setFontScale(labScale);
|
||||
resetBtn.getLabel().setFontScale(labScale);
|
||||
saveBtn.getLabel().setFontScale(labScale);
|
||||
|
||||
firstRowTable.add(backBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);
|
||||
firstRowTable.add(instLab).space(cw * 0.25f).width(cw / 2);
|
||||
firstRowTable.add(helpBtn).fillX().expandX().space(cw * 0.005f).width(buttonDim).height(buttonDim);;
|
||||
|
||||
table.row().colspan(4);
|
||||
table.add(firstRowContainer);
|
||||
table.row().colspan(2);
|
||||
table.add(scrollPane).fill().expand();
|
||||
|
||||
table.row();
|
||||
table.add(resetBtn).fillX().expandX().width(buttonDim*2f).height(buttonDim);
|
||||
table.add(saveBtn).fillX().expandX().width(buttonDim*2f).height(buttonDim);
|
||||
|
||||
// table.add(resetBtn).fillX().expandX().pad(buttonDim/2).height(buttonDim);
|
||||
// table.add(saveBtn).fillX().expandX().pad(buttonDim/2).height(buttonDim);
|
||||
}
|
||||
|
||||
public Table setSettings() {
|
||||
Table table = new Table();
|
||||
|
||||
for(MazeSetting s : MazeSettings.settings){
|
||||
table.row().colspan(2);
|
||||
table.add(s.getTable());
|
||||
}
|
||||
/*table.row().colspan(2);
|
||||
table.add(MazeSettings.setDim.getTable());
|
||||
table.row().colspan(2);
|
||||
table.add(MazeSettings.setPlayers.getTable());
|
||||
table.row().colspan(2);
|
||||
table.add(MazeSettings.setEpDist.getTable());*/
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
super.resize(width, height);
|
||||
for(MazeSetting s : MazeSettings.settings) s.buildTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(){
|
||||
super.show();
|
||||
for(MazeSetting s : MazeSettings.settings) s.buildTable();
|
||||
}
|
||||
|
||||
void saveStates() {
|
||||
MazeSettings.setDim.saveState();
|
||||
MazeSettings.setPlayers.saveState();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package com.emamaker.amazeing.ui.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.maze.settings.MazeSettings;
|
||||
import com.emamaker.amazeing.ui.UIManager;
|
||||
|
||||
public class TitleScreen extends MyScreen {
|
||||
|
||||
Label amazeingLab, quitDlgText;
|
||||
TextButton setBut, makeSrvBtn, joinSrvBtn, localBut, quitBut, quitDlgOkBtn, quitDlgCancelBtn;
|
||||
Dialog quitDlg;
|
||||
|
||||
public TitleScreen(UIManager uiManager_) {
|
||||
super(uiManager_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTable() {
|
||||
amazeingLab = new Label("A - MAZE - ING", uiManager.skin);
|
||||
setBut = new TextButton("CUSTOMIZE GAME SETTINGS", uiManager.skin);
|
||||
makeSrvBtn = new TextButton("START SERVER", uiManager.skin);
|
||||
joinSrvBtn = new TextButton("JOIN SERVER", uiManager.skin);
|
||||
localBut = new TextButton("LOCAL GAME", uiManager.skin);
|
||||
quitBut = new TextButton("QUIT GAME", uiManager.skin);
|
||||
|
||||
/* QUIT DIALOG */
|
||||
quitDlg = new Dialog("Quit?", uiManager.skin);
|
||||
quitDlgText = new Label ("Are you sure you want to quit the game?", uiManager.skin);
|
||||
quitDlg.text(quitDlgText);
|
||||
quitDlgCancelBtn = new TextButton("Cancel", uiManager.skin);
|
||||
quitDlgOkBtn = new TextButton("OK", uiManager.skin);
|
||||
quitDlg.button(quitDlgCancelBtn);
|
||||
quitDlg.button(quitDlgOkBtn);
|
||||
quitDlgOkBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
System.out.println("Bye bye");
|
||||
Gdx.app.exit();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
quitDlgCancelBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
quitDlg.hide();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Add actions to the buttons
|
||||
localBut.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
|
||||
if(AMazeIng.PLATFORM == AMazeIng.Platform.DESKTOP) MazeSettings.setPlayers.setOptions(MazeSettings.maxPlayersDesktop, 2);
|
||||
else MazeSettings.setPlayers.setOptions(MazeSettings.maxPlayersMobile);
|
||||
|
||||
uiManager.main.setScreen(uiManager.playersScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
quitBut.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
quitDlg.show(stage);
|
||||
buildTable();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
makeSrvBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
|
||||
MazeSettings.setPlayers.setOptions(MazeSettings.maxPlayersDesktop, 2);
|
||||
|
||||
uiManager.main.setScreen(uiManager.srvLaunchScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
joinSrvBtn.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.main.setScreen(uiManager.srvJoinScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
setBut.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
hide();
|
||||
uiManager.main.setScreen(uiManager.setScreen);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable() {
|
||||
super.buildTable();
|
||||
|
||||
float d = containerDiagonal();
|
||||
|
||||
amazeingLab.setFontScale(d * .005f);
|
||||
|
||||
float spaceBetweenBtns = d * 0.015f;
|
||||
float btnHeight = spaceBetweenBtns * 2.4f;
|
||||
float btnWidth = cw*0.46f;
|
||||
float n = d * 0.0015f;
|
||||
|
||||
float labScale = d * .00090f;
|
||||
|
||||
quitDlg.setSize(cw*0.35f, ch*0.15f);
|
||||
quitDlg.setPosition((sw-quitDlg.getWidth())/2, (sh-quitDlg.getHeight())/2);
|
||||
quitDlgText.setFontScale(labScale*0.9f);
|
||||
quitDlgOkBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
quitDlgCancelBtn.getLabel().setFontScale(labScale*0.9f);
|
||||
|
||||
setBut.getLabel().setFontScale(n);
|
||||
makeSrvBtn.getLabel().setFontScale(n);
|
||||
joinSrvBtn.getLabel().setFontScale(n);
|
||||
localBut.getLabel().setFontScale(n);
|
||||
quitBut.getLabel().setFontScale(n);
|
||||
|
||||
// Add actors to the group
|
||||
table.row().colspan(1);
|
||||
table.add(amazeingLab).spaceBottom(spaceBetweenBtns * 3);
|
||||
table.row();
|
||||
//table.add(setBut).spaceBottom(spaceBetweenBtns).height(btnHeight).width(btnWidth);
|
||||
//table.row();
|
||||
table.add(makeSrvBtn).spaceBottom(spaceBetweenBtns).height(btnHeight).width(btnWidth);
|
||||
table.row();
|
||||
table.add(joinSrvBtn).spaceBottom(spaceBetweenBtns).height(btnHeight).width(btnWidth);
|
||||
table.row();
|
||||
table.add(localBut).spaceBottom(spaceBetweenBtns).height(btnHeight).width(btnWidth);
|
||||
table.row();
|
||||
table.add(quitBut).spaceBottom(ch * 0.05f).height(btnHeight).width(btnWidth);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 4a8f6a52c8cb62361909813042ff99d61bd98611
|
|
@ -0,0 +1,8 @@
|
|||
attribute vec4 a_position;
|
||||
|
||||
uniform mat4 u_projectionViewMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_projectionViewMatrix * a_position;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
apply plugin: "java"
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
sourceSets.main.resources.srcDirs = ["../android/assets"]
|
||||
|
||||
project.ext.mainClassName = "com.emamaker.amazeing.desktop.DesktopLauncher"
|
||||
project.ext.assetsDir = new File("../android/assets")
|
||||
|
||||
task run(dependsOn: classes, type: JavaExec) {
|
||||
main = project.mainClassName
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
workingDir = project.assetsDir
|
||||
ignoreExitValue = true
|
||||
}
|
||||
|
||||
task debug(dependsOn: classes, type: JavaExec) {
|
||||
main = project.mainClassName
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
workingDir = project.assetsDir
|
||||
ignoreExitValue = true
|
||||
debug = true
|
||||
}
|
||||
|
||||
task dist(type: Jar) {
|
||||
manifest {
|
||||
attributes 'Main-Class': project.mainClassName
|
||||
}
|
||||
dependsOn configurations.runtimeClasspath
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
with jar
|
||||
}
|
||||
|
||||
|
||||
dist.dependsOn classes
|
||||
|
||||
eclipse.project.name = appName + "-desktop"
|
|
@ -0,0 +1,13 @@
|
|||
package com.emamaker.amazeing.desktop;
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.emamaker.amazeing.AMazeIng;
|
||||
import com.emamaker.amazeing.AMazeIng.Platform;
|
||||
|
||||
public class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
new LwjglApplication(new AMazeIng(Platform.DESKTOP), config);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms128m -Xmx1500m
|
||||
org.gradle.configureondemand=false
|
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
|
@ -0,0 +1,188 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,100 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${app.name}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${app.executable}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${app.id}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${app.name}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${app.version}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${app.build}</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>opengles-2</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleIconName</key>
|
||||
<string>AppIcon</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,19 @@
|
|||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
|
||||
sourceCompatibility = '1.7'
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
ext {
|
||||
mainClassName = "com.emamaker.amazeing.IOSLauncher"
|
||||
}
|
||||
|
||||
launchIPhoneSimulator.dependsOn build
|
||||
launchIPadSimulator.dependsOn build
|
||||
launchIOSDevice.dependsOn build
|
||||
createIPA.dependsOn build
|
||||
|
||||
robovm {
|
||||
archs = "thumbv7:arm64"
|
||||
}
|
||||
|
||||
eclipse.project.name = appName + "-ios"
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="Logo" translatesAutoresizingMaskIntoConstraints="NO" id="hN2-E0-Tu8">
|
||||
<rect key="frame" x="120" y="402" width="172" height="93"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="52.173913043478265" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="Logo" width="243" height="41"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -0,0 +1,116 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-notification-icon-20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-notification-icon-20@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-spotlight-settings-icon-29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-spotlight-settings-icon-29@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-spotlight-icon-40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-spotlight-icon-40@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-app-icon-60@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "iphone-app-icon-60@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-notifications-icon-20@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-notifications-icon-20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-settings-icon-29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-settings-icon-29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-spotlight-icon-40@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-spotlight-icon-40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-app-icon-76@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-app-icon-76@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "83.5x83.5",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "ipad-pro-app-icon-83.5@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "app-store-icon-1024@1x.png",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 793 B |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 623 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 793 B |
After Width: | Height: | Size: 1.4 KiB |