From aa6a37f80ee5662c5547ed3d211049808f8bda03 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Wed, 10 Jun 2020 15:46:37 +0200 Subject: [PATCH] Pause menu, colored players & bug fixes --- .../data/particles/ball_and_chain.particle | 149 ++++++++ android/assets/data/particles/boom.particle | 142 ++++++++ android/assets/data/particles/boom.png | Bin 0 -> 1996 bytes .../assets/data/particles/explosion.particle | 313 ++++++++++++++++ android/assets/data/particles/explosion.png | Bin 0 -> 1821 bytes .../data/particles/explosion_small.particle | 313 ++++++++++++++++ .../assets/data/particles/feather.particle | 149 ++++++++ android/assets/data/particles/slugs.particle | 149 ++++++++ core/assets/data/pause.png | Bin 0 -> 678 bytes .../amazeing/manager/GameManager.java | 90 ++++- .../manager/managers/GameManagerClient.java | 13 +- .../manager/managers/GameManagerLocal.java | 5 +- .../amazeing/manager/network/GameServer.java | 2 +- .../amazeing/maze/settings/MazeSettings.java | 2 +- .../emamaker/amazeing/player/MazePlayer.java | 34 +- .../amazeing/player/MazePlayerLocal.java | 10 +- .../amazeing/player/powerups/PowerUp.java | 4 +- .../ui/screens/PlayerChooseScreen.java | 342 +++++++++--------- .../emamaker/amazeing/utils/MathUtils.java | 72 +++- 19 files changed, 1591 insertions(+), 198 deletions(-) create mode 100644 android/assets/data/particles/ball_and_chain.particle create mode 100644 android/assets/data/particles/boom.particle create mode 100644 android/assets/data/particles/boom.png create mode 100644 android/assets/data/particles/explosion.particle create mode 100644 android/assets/data/particles/explosion.png create mode 100644 android/assets/data/particles/explosion_small.particle create mode 100644 android/assets/data/particles/feather.particle create mode 100644 android/assets/data/particles/slugs.particle create mode 100644 core/assets/data/pause.png diff --git a/android/assets/data/particles/ball_and_chain.particle b/android/assets/data/particles/ball_and_chain.particle new file mode 100644 index 0000000..bf9d80d --- /dev/null +++ b/android/assets/data/particles/ball_and_chain.particle @@ -0,0 +1,149 @@ +slugs +- Delay - +active: false +- Duration - +lowMin: 10000.0 +lowMax: 10000.0 +- Count - +min: 0 +max: 200 +- Emission - +lowMin: 2.0 +lowMax: 2.0 +highMin: 4.0 +highMax: 4.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Life - +lowMin: 0.0 +lowMax: 0.0 +highMin: 500.0 +highMax: 750.0 +relative: false +scalingCount: 3 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.66 +timeline2: 1.0 +independent: false +- Life Offset - +active: false +independent: false +- X Offset - +active: false +- Y Offset - +active: false +- Spawn Shape - +shape: square +- Spawn Width - +lowMin: 0.0 +lowMax: 0.0 +highMin: 60.0 +highMax: 60.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Spawn Height - +lowMin: 0.0 +lowMax: 0.0 +highMin: 60.0 +highMax: 60.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- X Scale - +lowMin: 0.0 +lowMax: 0.0 +highMin: 20.0 +highMax: 20.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Y Scale - +active: false +- Velocity - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 0.0 +highMax: 0.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Angle - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 359.0 +highMax: 359.0 +relative: false +scalingCount: 3 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.999 +timeline2: 1.0 +- Rotation - +active: false +- Wind - +active: false +- Gravity - +active: false +- Tint - +colorsCount: 9 +colors0: 1.0 +colors1: 1.0 +colors2: 1.0 +colors3: 0.0 +colors4: 0.0 +colors5: 0.0 +colors6: 1.0 +colors7: 1.0 +colors8: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.050933786 +timeline2: 1.0 +- Transparency - +lowMin: 0.0 +lowMax: 0.0 +highMin: 1.0 +highMax: 1.0 +relative: false +scalingCount: 4 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 1.0 +scaling3: 0.0 +timelineCount: 4 +timeline0: 0.0 +timeline1: 0.21232876 +timeline2: 0.65068495 +timeline3: 0.9794521 +- Options - +attached: false +continuous: false +aligned: false +additive: false +behind: false +premultipliedAlpha: false +spriteMode: single +- Image Paths - +/home/emamaker/github/amazeing/gdx/core/assets/data/powerups/ball_and_chain.png + diff --git a/android/assets/data/particles/boom.particle b/android/assets/data/particles/boom.particle new file mode 100644 index 0000000..f057199 --- /dev/null +++ b/android/assets/data/particles/boom.particle @@ -0,0 +1,142 @@ +Untitled +- Delay - +active: false +- Duration - +lowMin: 5000.0 +lowMax: 5000.0 +- Count - +min: 0 +max: 200 +- Emission - +lowMin: 1.0 +lowMax: 1.0 +highMin: 10.0 +highMax: 10.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Life - +lowMin: 0.0 +lowMax: 0.0 +highMin: 150.0 +highMax: 350.0 +relative: false +scalingCount: 3 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 0.9183673 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.66 +timeline2: 1.0 +independent: false +- Life Offset - +active: false +independent: false +- X Offset - +active: false +- Y Offset - +active: false +- Spawn Shape - +shape: square +- Spawn Width - +lowMin: 0.0 +lowMax: 0.0 +highMin: 200.0 +highMax: 200.0 +relative: true +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Spawn Height - +lowMin: 0.0 +lowMax: 0.0 +highMin: 200.0 +highMax: 200.0 +relative: true +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- X Scale - +lowMin: 300.0 +lowMax: 300.0 +highMin: 400.0 +highMax: 400.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Y Scale - +active: false +- Velocity - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 3.0 +highMax: 3.0 +relative: true +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Angle - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 0.0 +highMax: 0.0 +relative: false +scalingCount: 3 +scaling0: 0.0 +scaling1: 0.0 +scaling2: 0.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.5 +timeline2: 1.0 +- Rotation - +active: false +- Wind - +active: false +- Gravity - +active: false +- Tint - +colorsCount: 3 +colors0: 1.0 +colors1: 1.0 +colors2: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Transparency - +lowMin: 0.0 +lowMax: 0.0 +highMin: 1.0 +highMax: 1.0 +relative: false +scalingCount: 4 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 1.0 +scaling3: 1.0 +timelineCount: 4 +timeline0: 0.0 +timeline1: 0.25342464 +timeline2: 0.60761464 +timeline3: 0.98057497 +- Options - +attached: false +continuous: false +aligned: false +additive: false +behind: false +premultipliedAlpha: false +spriteMode: random +- Image Paths - +explosion.png +boom.png + diff --git a/android/assets/data/particles/boom.png b/android/assets/data/particles/boom.png new file mode 100644 index 0000000000000000000000000000000000000000..03a853b53a808090378417a5e35d2b8b3691a735 GIT binary patch literal 1996 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 LNkvXXu0mjfqla6% literal 0 HcmV?d00001 diff --git a/android/assets/data/particles/explosion_small.particle b/android/assets/data/particles/explosion_small.particle new file mode 100644 index 0000000..7d83b8f --- /dev/null +++ b/android/assets/data/particles/explosion_small.particle @@ -0,0 +1,313 @@ +explosion +- Delay - +active: false +- Duration - +lowMin: 1000.0 +lowMax: 1000.0 +- Count - +min: 0 +max: 200 +- Emission - +lowMin: 2.0 +lowMax: 2.0 +highMin: 5.0 +highMax: 5.0 +relative: false +scalingCount: 5 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 1.0 +scaling3: 1.0 +scaling4: 0.59183675 +timelineCount: 5 +timeline0: 0.0 +timeline1: 0.1509288 +timeline2: 0.39041096 +timeline3: 0.72602737 +timeline4: 0.86986303 +- Life - +lowMin: 0.0 +lowMax: 0.0 +highMin: 200.0 +highMax: 1000.0 +relative: false +scalingCount: 6 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 1.0 +scaling3: 1.0 +scaling4: 1.0 +scaling5: 1.0 +timelineCount: 6 +timeline0: 0.0 +timeline1: 0.113777086 +timeline2: 0.47678018 +timeline3: 0.5944272 +timeline4: 0.7972136 +timeline5: 0.89860684 +independent: false +- Life Offset - +active: false +independent: false +- X Offset - +active: false +- Y Offset - +active: false +- Spawn Shape - +shape: square +- Spawn Width - +lowMin: 0.0 +lowMax: 0.0 +highMin: 100.0 +highMax: 100.0 +relative: false +scalingCount: 2 +scaling0: 1.0 +scaling1: 0.0 +timelineCount: 2 +timeline0: 0.0 +timeline1: 0.98630136 +- Spawn Height - +lowMin: 0.0 +lowMax: 0.0 +highMin: 100.0 +highMax: 100.0 +relative: false +scalingCount: 2 +scaling0: 1.0 +scaling1: 0.020408163 +timelineCount: 2 +timeline0: 0.0 +timeline1: 1.0 +- X Scale - +lowMin: 40.0 +lowMax: 40.0 +highMin: 50.0 +highMax: 70.0 +relative: true +scalingCount: 6 +scaling0: 0.039325844 +scaling1: 0.2977528 +scaling2: 0.6011236 +scaling3: 0.71910113 +scaling4: 0.8707865 +scaling5: 1.0 +timelineCount: 6 +timeline0: 0.0 +timeline1: 0.16331269 +timeline2: 0.29256967 +timeline3: 0.46826625 +timeline4: 0.65634674 +timeline5: 0.996904 +- Y Scale - +active: false +- Velocity - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 3.0 +highMax: 3.0 +relative: true +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Angle - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 0.0 +highMax: 0.0 +relative: false +scalingCount: 3 +scaling0: 0.0 +scaling1: 0.0 +scaling2: 0.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.5 +timeline2: 1.0 +- Rotation - +active: false +- Wind - +active: false +- Gravity - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 0.0 +highMax: 0.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Tint - +colorsCount: 3 +colors0: 1.0 +colors1: 1.0 +colors2: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Transparency - +lowMin: 0.0 +lowMax: 0.0 +highMin: 1.0 +highMax: 1.0 +relative: false +scalingCount: 4 +scaling0: 0.0 +scaling1: 0.71929824 +scaling2: 0.8596491 +scaling3: 0.36842105 +timelineCount: 4 +timeline0: 0.0 +timeline1: 0.33561644 +timeline2: 0.65753424 +timeline3: 0.96575344 +- Options - +attached: false +continuous: false +aligned: false +additive: false +behind: false +premultipliedAlpha: false +spriteMode: single +- Image Paths - +explosion.png + + +boom +- Delay - +active: false +- Duration - +lowMin: 1500.0 +lowMax: 1500.0 +- Count - +min: 0 +max: 25 +- Emission - +lowMin: 1.0 +lowMax: 1.0 +highMin: 2.0 +highMax: 2.0 +relative: false +scalingCount: 5 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 0.67346936 +scaling3: 0.0 +scaling4: 0.0 +timelineCount: 5 +timeline0: 0.0 +timeline1: 0.15413533 +timeline2: 0.42465752 +timeline3: 0.5068493 +timeline4: 0.99303406 +- Life - +lowMin: 0.0 +lowMax: 0.0 +highMin: 500.0 +highMax: 500.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +independent: false +- Life Offset - +active: false +independent: false +- X Offset - +active: false +- Y Offset - +active: false +- Spawn Shape - +shape: ellipse +edges: false +side: both +- Spawn Width - +lowMin: 0.0 +lowMax: 0.0 +highMin: 100.0 +highMax: 100.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Spawn Height - +lowMin: 0.0 +lowMax: 0.0 +highMin: 100.0 +highMax: 100.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- X Scale - +lowMin: 10.0 +lowMax: 10.0 +highMin: 30.0 +highMax: 80.0 +relative: false +scalingCount: 3 +scaling0: 0.37078652 +scaling1: 0.75842696 +scaling2: 0.96067417 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.38467494 +timeline2: 0.996904 +- Y Scale - +active: false +- Velocity - +active: false +- Angle - +active: false +- Rotation - +active: true +lowMin: -15.0 +lowMax: -15.0 +highMin: 5.0 +highMax: 5.0 +relative: false +scalingCount: 2 +scaling0: 0.0 +scaling1: 1.0 +timelineCount: 2 +timeline0: 0.0 +timeline1: 1.0 +- Wind - +active: false +- Gravity - +active: false +- Tint - +colorsCount: 3 +colors0: 1.0 +colors1: 1.0 +colors2: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Transparency - +lowMin: 0.0 +lowMax: 0.0 +highMin: 1.0 +highMax: 1.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Options - +attached: false +continuous: false +aligned: false +additive: true +behind: false +premultipliedAlpha: false +spriteMode: single +- Image Paths - +boom.png + diff --git a/android/assets/data/particles/feather.particle b/android/assets/data/particles/feather.particle new file mode 100644 index 0000000..3312ed9 --- /dev/null +++ b/android/assets/data/particles/feather.particle @@ -0,0 +1,149 @@ +slugs +- Delay - +active: false +- Duration - +lowMin: 10000.0 +lowMax: 10000.0 +- Count - +min: 0 +max: 200 +- Emission - +lowMin: 2.0 +lowMax: 2.0 +highMin: 4.0 +highMax: 4.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Life - +lowMin: 0.0 +lowMax: 0.0 +highMin: 500.0 +highMax: 750.0 +relative: false +scalingCount: 3 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.66 +timeline2: 1.0 +independent: false +- Life Offset - +active: false +independent: false +- X Offset - +active: false +- Y Offset - +active: false +- Spawn Shape - +shape: square +- Spawn Width - +lowMin: 0.0 +lowMax: 0.0 +highMin: 60.0 +highMax: 60.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Spawn Height - +lowMin: 0.0 +lowMax: 0.0 +highMin: 60.0 +highMax: 60.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- X Scale - +lowMin: 0.0 +lowMax: 0.0 +highMin: 20.0 +highMax: 20.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Y Scale - +active: false +- Velocity - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 0.0 +highMax: 0.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Angle - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 359.0 +highMax: 359.0 +relative: false +scalingCount: 3 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.999 +timeline2: 1.0 +- Rotation - +active: false +- Wind - +active: false +- Gravity - +active: false +- Tint - +colorsCount: 9 +colors0: 1.0 +colors1: 1.0 +colors2: 1.0 +colors3: 1.0 +colors4: 1.0 +colors5: 1.0 +colors6: 1.0 +colors7: 1.0 +colors8: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.01 +timeline2: 1.0 +- Transparency - +lowMin: 0.0 +lowMax: 0.0 +highMin: 1.0 +highMax: 1.0 +relative: false +scalingCount: 4 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 1.0 +scaling3: 0.0 +timelineCount: 4 +timeline0: 0.0 +timeline1: 0.21232876 +timeline2: 0.65068495 +timeline3: 0.9794521 +- Options - +attached: false +continuous: false +aligned: false +additive: false +behind: false +premultipliedAlpha: false +spriteMode: single +- Image Paths - +/home/emamaker/github/amazeing/gdx/core/assets/data/powerups/feather.png + diff --git a/android/assets/data/particles/slugs.particle b/android/assets/data/particles/slugs.particle new file mode 100644 index 0000000..bf3e43b --- /dev/null +++ b/android/assets/data/particles/slugs.particle @@ -0,0 +1,149 @@ +slugs +- Delay - +active: false +- Duration - +lowMin: 15000.0 +lowMax: 15000.0 +- Count - +min: 0 +max: 200 +- Emission - +lowMin: 2.0 +lowMax: 2.0 +highMin: 4.0 +highMax: 4.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Life - +lowMin: 0.0 +lowMax: 0.0 +highMin: 500.0 +highMax: 750.0 +relative: false +scalingCount: 3 +scaling0: 1.0 +scaling1: 1.0 +scaling2: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.66 +timeline2: 1.0 +independent: false +- Life Offset - +active: false +independent: false +- X Offset - +active: false +- Y Offset - +active: false +- Spawn Shape - +shape: square +- Spawn Width - +lowMin: 0.0 +lowMax: 0.0 +highMin: 60.0 +highMax: 60.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Spawn Height - +lowMin: 0.0 +lowMax: 0.0 +highMin: 60.0 +highMax: 60.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- X Scale - +lowMin: 0.0 +lowMax: 0.0 +highMin: 20.0 +highMax: 20.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Y Scale - +active: false +- Velocity - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 0.0 +highMax: 0.0 +relative: false +scalingCount: 1 +scaling0: 1.0 +timelineCount: 1 +timeline0: 0.0 +- Angle - +active: true +lowMin: 0.0 +lowMax: 0.0 +highMin: 359.0 +highMax: 359.0 +relative: false +scalingCount: 3 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.999 +timeline2: 1.0 +- Rotation - +active: false +- Wind - +active: false +- Gravity - +active: false +- Tint - +colorsCount: 9 +colors0: 0.58431375 +colors1: 0.8784314 +colors2: 0.43529412 +colors3: 0.0 +colors4: 0.0 +colors5: 0.0 +colors6: 1.0 +colors7: 1.0 +colors8: 1.0 +timelineCount: 3 +timeline0: 0.0 +timeline1: 0.050933786 +timeline2: 1.0 +- Transparency - +lowMin: 0.0 +lowMax: 0.0 +highMin: 1.0 +highMax: 1.0 +relative: false +scalingCount: 4 +scaling0: 0.0 +scaling1: 1.0 +scaling2: 1.0 +scaling3: 0.0 +timelineCount: 4 +timeline0: 0.0 +timeline1: 0.21232876 +timeline2: 0.65068495 +timeline3: 0.9794521 +- Options - +attached: false +continuous: false +aligned: false +additive: false +behind: false +premultipliedAlpha: false +spriteMode: single +- Image Paths - +/home/emamaker/github/amazeing/gdx/core/assets/data/powerups/slug.png + diff --git a/core/assets/data/pause.png b/core/assets/data/pause.png new file mode 100644 index 0000000000000000000000000000000000000000..e8a6a52395636b0c0494c27c45d1f3fd0c9ab477 GIT binary patch literal 678 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU~J8Fb`J1#c2+1T%1_J8No8Qr zm{>c}*5j~)%+dJhtwGv+VuFPyE?7khh!$Sa5?Sc9LNuz>VCNU-j7t-i?6BZk$I5Om zwwh1x+%BsfTul$yJ0>rlyr_H1kNrz7C>?8lT(@WU_Z`*jKVGLUnWb(I_=|i2{{VB}9@*6L#x*c6C zzntHpZI{)^mS!_!p6m|p>pQCa~4oYvcxr_#5q4VH#M(> z!MP|ku_QG`p**uBL&4qCHz2%`PaLSI*3-o?q~g}wTY+2*0s;<>+TZtovSOaJ>GQr$ zwNvdU&V=o}*ToK02LdZ@M@UqEO6fUUdHs3`D@2S~vgX#Q_=go6_7^b0b?BKg_D8Wc TpZ~Dl3nb?0>gTe~DWM4fh0zG; literal 0 HcmV?d00001 diff --git a/core/src/com/emamaker/amazeing/manager/GameManager.java b/core/src/com/emamaker/amazeing/manager/GameManager.java index 50497f9..f53e59e 100755 --- a/core/src/com/emamaker/amazeing/manager/GameManager.java +++ b/core/src/com/emamaker/amazeing/manager/GameManager.java @@ -5,8 +5,14 @@ import java.util.Random; import java.util.Set; import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector3; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.Stage; +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.badlogic.gdx.utils.viewport.ScreenViewport; import com.emamaker.amazeing.AMazeIng; import com.emamaker.amazeing.AMazeIng.Platform; @@ -16,6 +22,7 @@ import com.emamaker.amazeing.player.MazePlayer; import com.emamaker.amazeing.player.MazePlayerLocal; import com.emamaker.amazeing.player.powerups.PowerUp; import com.emamaker.amazeing.player.powerups.PowerUps; +import com.emamaker.amazeing.utils.MathUtils; import com.emamaker.voxelengine.block.CellId; import com.emamaker.voxelengine.player.Player; @@ -40,6 +47,12 @@ public class GameManager { PowerUp pup; + TextButton pauseBtn; + Dialog pauseDlg; + Label pauseDlgText; + TextButton pauseDlgResumeBtn, pauseDlgQuitBtn; + boolean showingDialog = false; + public GameManager(Game main_, GameType t) { main = (AMazeIng) main_; gameStarted = false; @@ -54,7 +67,6 @@ public class GameManager { public void generateMaze(Set pl, int todraw[][]) { main.setScreen(null); - AMazeIng.getMain().multiplexer.removeProcessor(stage); AMazeIng.getMain().multiplexer.addProcessor(stage); anyoneWon = false; @@ -96,6 +108,8 @@ public class GameManager { resetCamera(); gameStarted = true; + showingDialog = false; + } public void addTouchScreenInput() { @@ -109,11 +123,70 @@ public class GameManager { } } + public void setupHud() { + pauseBtn = new TextButton("Pause", main.uiManager.skin); +// pauseBtn.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("data/pause.png")))); +// pauseBtn.getStyle().imageDown = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("data/pause.png")))); + + pauseDlg = new Dialog("Pause", main.uiManager.skin); + + pauseDlgText = new Label("What do you want to do?", main.uiManager.skin); + + pauseDlgResumeBtn = new TextButton("Resume", main.uiManager.skin); + pauseDlgQuitBtn = new TextButton("Quit", main.uiManager.skin); + + pauseDlg.text(pauseDlgText); + pauseDlg.button(pauseDlgQuitBtn); + pauseDlg.button(pauseDlgResumeBtn); + + pauseBtn.addListener(new InputListener() { + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + pauseDlg.show(stage); + return true; + } + }); + + pauseDlgResumeBtn.addListener(new InputListener() { + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + pauseDlg.hide(); + return true; + } + }); + pauseDlgQuitBtn.addListener(new InputListener() { + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + quitGameByBtn(); + return true; + } + }); + + stage.addActor(pauseBtn); + } + + + float cw, ch, d, labScale, buttonDim; public void hudUpdate() { resetCamera(); - setCamera(new Vector3((MazeSettings.MAZEX + 1) / 2, (MazeSettings.MAZEX + MazeSettings.MAZEZ) * 0.45f, + setCamera(new Vector3((MazeSettings.MAZEX + 1) / 2, (MazeSettings.MAZEX + MazeSettings.MAZEZ) * 0.48f, MazeSettings.MAZEZ / 2 - 1), new Vector3(0, -90, 0)); + cw = Gdx.graphics.getWidth(); + ch = Gdx.graphics.getHeight(); + d = MathUtils.pythagoreanTheorem(cw, ch); + labScale = d * .00090f; + buttonDim = d * 0.04f; + pauseBtn.setSize(buttonDim, buttonDim); + pauseBtn.setPosition((cw - pauseBtn.getWidth()) / 2, ch - pauseBtn.getHeight()); + pauseBtn.getLabel().setFontScale(labScale*0.9f); + + pauseDlg.setSize(cw*0.2f, ch*0.15f); + pauseDlg.setPosition((cw-pauseDlg.getWidth())/2, (ch-pauseDlg.getHeight())/2); + pauseDlgResumeBtn.getLabel().setFontScale(labScale*0.9f); + pauseDlgQuitBtn.getLabel().setFontScale(labScale*0.9f); + pauseDlgText.setFontScale(labScale*0.9f); + stage.act(); stage.draw(); } @@ -182,11 +255,19 @@ public class GameManager { public void setFinished() { anyoneWon = true; gameStarted = false; - + + AMazeIng.getMain().multiplexer.removeProcessor(stage); for (MazePlayer p : players) p.disablePowerUp(); main.clearEffects(); } + + public void quitGameByBtn() { + setFinished(); + if (pauseDlg != null) { + pauseDlg.hide(); + } + } public boolean getFinished() { return anyoneWon; @@ -230,7 +311,7 @@ public class GameManager { 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) || thereIsPowerUpInPos(x, z)); + } while (thereIsPlayerInPos(x, z) || mazeGen.occupiedSpot(x, z)); System.out.println("Spawning power-up in " + x + ", " + z); spawnPowerUp(x + .5f, z + .5f); } @@ -370,4 +451,5 @@ public class GameManager { p.dispose(); players.clear(); } + } diff --git a/core/src/com/emamaker/amazeing/manager/managers/GameManagerClient.java b/core/src/com/emamaker/amazeing/manager/managers/GameManagerClient.java index c7a31c0..45cdfb2 100644 --- a/core/src/com/emamaker/amazeing/manager/managers/GameManagerClient.java +++ b/core/src/com/emamaker/amazeing/manager/managers/GameManagerClient.java @@ -12,6 +12,7 @@ public class GameManagerClient extends GameManager { public GameManagerClient() { super(AMazeIng.getMain(), GameType.CLIENT); + setupHud(); } @Override @@ -26,7 +27,6 @@ public class GameManagerClient extends GameManager { super.inGameUpdate(); renderWorld(); - hudUpdate(); main.world.modelBatch.begin(main.world.cam); @@ -34,6 +34,8 @@ public class GameManagerClient extends GameManager { renderPowerUps(); main.world.modelBatch.end(); + + hudUpdate(); } boolean showed = false; @@ -62,4 +64,13 @@ public class GameManagerClient extends GameManager { public void checkWin() { } + @Override + public void quitGameByBtn() { + super.quitGameByBtn(); + main.server.stop(); + main.client.stop(); + main.setScreen(main.uiManager.titleScreen); + } + } + diff --git a/core/src/com/emamaker/amazeing/manager/managers/GameManagerLocal.java b/core/src/com/emamaker/amazeing/manager/managers/GameManagerLocal.java index 407f095..9efe5cc 100644 --- a/core/src/com/emamaker/amazeing/manager/managers/GameManagerLocal.java +++ b/core/src/com/emamaker/amazeing/manager/managers/GameManagerLocal.java @@ -11,6 +11,7 @@ public class GameManagerLocal extends GameManager { public GameManagerLocal() { super(AMazeIng.getMain(), GameType.LOCAL); + setupHud(); } @Override @@ -35,7 +36,6 @@ public class GameManagerLocal extends GameManager { assignPowerUps(); renderWorld(); - hudUpdate(); main.world.modelBatch.begin(main.world.cam); @@ -44,6 +44,8 @@ public class GameManagerLocal extends GameManager { main.world.modelBatch.end(); + hudUpdate(); + } boolean showed = false; @@ -55,4 +57,5 @@ public class GameManagerLocal extends GameManager { showed = true; } } + } diff --git a/core/src/com/emamaker/amazeing/manager/network/GameServer.java b/core/src/com/emamaker/amazeing/manager/network/GameServer.java index 78e944e..efac57c 100755 --- a/core/src/com/emamaker/amazeing/manager/network/GameServer.java +++ b/core/src/com/emamaker/amazeing/manager/network/GameServer.java @@ -79,7 +79,7 @@ public class GameServer extends NetworkHandler { players.get(s).dispose(); players.remove(s); } - System.out.println(Arrays.toString(players.values().toArray())); +// System.out.println(Arrays.toString(players.values().toArray())); } } } diff --git a/core/src/com/emamaker/amazeing/maze/settings/MazeSettings.java b/core/src/com/emamaker/amazeing/maze/settings/MazeSettings.java index 22ceb56..bae4cbb 100755 --- a/core/src/com/emamaker/amazeing/maze/settings/MazeSettings.java +++ b/core/src/com/emamaker/amazeing/maze/settings/MazeSettings.java @@ -36,7 +36,7 @@ public class MazeSettings { AMazeIng.getMain().uiManager); setStartPowerups = new MazeSettingStartPowerUps("POWERUPS AT START : ", - new String[] { "1", "2", "3", "4", "5", "8", "10", "15" }, 6, AMazeIng.getMain().uiManager); + new String[] { "1", "2", "3", "4", "5", "8", "10", "15" }, 3, AMazeIng.getMain().uiManager); setEpDist = new MazeSettingEPDIST("END POINT DISTANCE:", new String[] { "1", "2", "5", "10", "20" }, 2, AMazeIng.getMain().uiManager); diff --git a/core/src/com/emamaker/amazeing/player/MazePlayer.java b/core/src/com/emamaker/amazeing/player/MazePlayer.java index 154a11b..f586f6c 100755 --- a/core/src/com/emamaker/amazeing/player/MazePlayer.java +++ b/core/src/com/emamaker/amazeing/player/MazePlayer.java @@ -1,5 +1,9 @@ package com.emamaker.amazeing.player; +import java.util.Random; +import java.util.UUID; + +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.VertexAttributes; import com.badlogic.gdx.graphics.g3d.Environment; @@ -7,6 +11,7 @@ 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.attributes.ColorAttribute; import com.badlogic.gdx.graphics.g3d.model.Node; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; @@ -15,10 +20,9 @@ import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Disposable; import com.emamaker.amazeing.AMazeIng; import com.emamaker.amazeing.player.powerups.PowerUp; +import com.emamaker.amazeing.utils.MathUtils; import com.emamaker.voxelengine.physics.GameObject; -import java.util.Random; - public abstract class MazePlayer implements Disposable { AMazeIng main; @@ -39,7 +43,7 @@ public abstract class MazePlayer implements Disposable { boolean initedPhysics = false; boolean toUpdatePos = false; - public String uuid; + public String uuid = UUID.randomUUID().toString();; public PowerUp currentPowerUp; public float baseSpeed = 3f; @@ -49,9 +53,11 @@ public abstract class MazePlayer implements Disposable { public float turnSpeed; public long LAST_NETWORK_TIME = 0; - + Vector3 pos = new Vector3(); Quaternion rot = new Quaternion(); + + protected Color color = new Color(1f, 1f, 1f, 1f); MazePlayer(boolean s) { this(String.valueOf((char) (65 + rand.nextInt(26))), s); @@ -113,7 +119,11 @@ public abstract class MazePlayer implements Disposable { 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); + color = setColorByUUID(); + modelBuilder + .part("MazePlayer", GL20.GL_TRIANGLES, meshAttr, + new Material(ColorAttribute.createDiffuse(color))) + .box(0.6f, 0.6f, 0.6f); mazePlayerModel = modelBuilder.end(); instance = new ModelInstance(mazePlayerModel); } @@ -169,4 +179,18 @@ public abstract class MazePlayer implements Disposable { public boolean isDisposed() { return disposed; } + + public Color setColorByUUID() { + return setColor(MathUtils.getRandomColor(uuid)); + } + + public Color setColor(Color c) { + color.set(c); + return color; + } + + public Color getColor() { + return color; + } + } diff --git a/core/src/com/emamaker/amazeing/player/MazePlayerLocal.java b/core/src/com/emamaker/amazeing/player/MazePlayerLocal.java index 049b884..22e8604 100755 --- a/core/src/com/emamaker/amazeing/player/MazePlayerLocal.java +++ b/core/src/com/emamaker/amazeing/player/MazePlayerLocal.java @@ -71,7 +71,6 @@ public class MazePlayerLocal extends MazePlayer { this.startx = startx; this.starty = starty; this.startz = startz; - } public MazePlayerLocal(Controller ctrl_) { @@ -93,7 +92,6 @@ public class MazePlayerLocal extends MazePlayer { this.startx = startx; this.starty = starty; this.startz = startz; - } public MazePlayerLocal(Touchpad ctrl_, int p) { @@ -279,13 +277,15 @@ public class MazePlayerLocal extends MazePlayer { @Override public void update() { super.update(); - if(initedPhysics && !isDisposed()) inputs(); + if (initedPhysics && !isDisposed()) + inputs(); } @Override protected void updateFromTmpPos() { super.updateFromTmpPos(); - if(initedPhysics && !isDisposed()) pos.set(ghostObject.getWorldTransform().getTranslation(new Vector3())); + if (initedPhysics && !isDisposed()) + pos.set(ghostObject.getWorldTransform().getTranslation(new Vector3())); } // @Override @@ -319,7 +319,7 @@ public class MazePlayerLocal extends MazePlayer { disposed = true; } } - + public boolean getPressed() { return pressed; } diff --git a/core/src/com/emamaker/amazeing/player/powerups/PowerUp.java b/core/src/com/emamaker/amazeing/player/powerups/PowerUp.java index 7e98ab5..92095cd 100755 --- a/core/src/com/emamaker/amazeing/player/powerups/PowerUp.java +++ b/core/src/com/emamaker/amazeing/player/powerups/PowerUp.java @@ -171,11 +171,11 @@ class PowerUpTemporized extends PowerUp { if (System.currentTimeMillis() - startTime <= time) { temporizedEffect(player); - System.out.println("starting " + name); +// System.out.println("starting " + name); return false; } else { used = false; - System.out.println("finishing " + name); +// System.out.println("finishing " + name); e = null; temporizedEffectExpired(player); return true; diff --git a/core/src/com/emamaker/amazeing/ui/screens/PlayerChooseScreen.java b/core/src/com/emamaker/amazeing/ui/screens/PlayerChooseScreen.java index 4215923..fcd757c 100755 --- a/core/src/com/emamaker/amazeing/ui/screens/PlayerChooseScreen.java +++ b/core/src/com/emamaker/amazeing/ui/screens/PlayerChooseScreen.java @@ -22,201 +22,201 @@ import java.util.HashSet; public class PlayerChooseScreen extends MyScreen { - Label[] labels; - CheckBox[] buttons; - int currentLabel = 0; - ArrayList players = new ArrayList(); + Label[] labels; + CheckBox[] buttons; + int currentLabel = 0; + ArrayList players = new ArrayList(); - MyScreen thisScreen; + MyScreen thisScreen; - Container firstRowContainer; - Table firstRowTable; + Container
firstRowContainer; + Table firstRowTable; - Label instLab, helpDlgText; - TextButton backBtn, setBtn, helpBtn, playBtn, helpDlgOkBtn; - Dialog helpDlg; + Label instLab, helpDlgText; + TextButton backBtn, setBtn, helpBtn, playBtn, helpDlgOkBtn; + Dialog helpDlg; - int totalPlayers = 0; + int totalPlayers = 0; - public PlayerChooseScreen(UIManager uiManager_) { - super(uiManager_); + public PlayerChooseScreen(UIManager uiManager_) { + super(uiManager_); - chmult = 0.8f; - } + chmult = 0.8f; + } - @Override - public void createTable() { - super.createTable(); - thisScreen = this; + @Override + public void createTable() { + super.createTable(); + thisScreen = this; - firstRowContainer = new Container
(); - firstRowTable = new Table(); + firstRowContainer = new Container
(); + firstRowTable = new Table(); - firstRowContainer.setActor(firstRowTable); + 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); + 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(); + 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; - } - }); + 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(); + // 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)); - } + 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; - } - }); + 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(); + @Override + public void buildTable() { + super.buildTable(); + firstRowTable.clear(); - totalPlayers = 0; + 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); - } - } + 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; + 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(); + 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); + 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); + 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); + 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.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4); - table.add(firstRowContainer); + 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); - } - } + 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.row().colspan(MazeSettings.MAXPLAYERS == 2 ? 2 : 4); // table.add(playBtn).fillX().width(buttonDim*2f).height(buttonDim); - table.add(playBtn).fillX().expandX().height(buttonDim); - } + table.add(playBtn).fillX().expandX().height(buttonDim); + } - MazePlayerLocal p; + MazePlayerLocal p; - @Override - public void update() { - // Consantly search for new players to be added - // First search for keyboard players (WASD and ARROWS) - if (PlayerUtils.wasdJustPressed()) - PlayerUtils.togglePlayerWithKeys(players, PlayerUtils.WASDKEYS); - if (PlayerUtils.arrowsJustPressed()) - PlayerUtils.togglePlayerWithKeys(players, PlayerUtils.ARROWKEYS); + @Override + public void update() { + // Consantly search for new players to be added + // First search for keyboard players (WASD and ARROWS) + if (PlayerUtils.wasdJustPressed()) + PlayerUtils.togglePlayerWithKeys(players, PlayerUtils.WASDKEYS); + if (PlayerUtils.arrowsJustPressed()) + PlayerUtils.togglePlayerWithKeys(players, PlayerUtils.ARROWKEYS); // for (Controller c : Controllers.getControllers()) { // System.out.println(c.getButton(Xbox.A)); - // if (c.getButton(Xbox.Y)) { + // if (c.getButton(Xbox.Y)) { // p = getPlayerWithCtrl(c); // if (p == null) // p = new MazePlayerLocal(uiManager.main, c); @@ -224,16 +224,16 @@ public class PlayerChooseScreen extends MyScreen { // } // } - // 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 -- "); - } - } - } + // 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 -- "); + } + } + } } diff --git a/core/src/com/emamaker/amazeing/utils/MathUtils.java b/core/src/com/emamaker/amazeing/utils/MathUtils.java index aebd40b..5a81f2a 100644 --- a/core/src/com/emamaker/amazeing/utils/MathUtils.java +++ b/core/src/com/emamaker/amazeing/utils/MathUtils.java @@ -1,5 +1,9 @@ package com.emamaker.amazeing.utils; +import java.nio.ByteBuffer; +import java.util.UUID; + +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector3; import com.emamaker.amazeing.AMazeIng; @@ -9,22 +13,76 @@ public class MathUtils extends net.dermetfan.gdx.math.MathUtils { return (float) Math .sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z)); } - - + public static Vector3 toScreenCoords(Vector3 vec) { - //This exta variable is needed otherwise the cam.project will convert the vector in argument from world coordinates to screen coordinates + // This exta variable is needed otherwise the cam.project will convert the + // vector in argument from world coordinates to screen coordinates Vector3 v1 = new Vector3(vec); return AMazeIng.getMain().world.cam.project(v1); } - + public static long map(long x, long in_min, long in_max, long out_min, long out_max) { - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } - + public static int map(int x, int in_min, int in_max, int out_min, int out_max) { - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + } + + public static float pythagoreanTheorem(float a, float b) { + return (float) Math.sqrt(a * a + b * b); + } + + public static Color getRandomColor(String s) { + return getRandomColor(UUID.fromString(s)); + } + + /** + * Method return a random color. + * https://stackoverflow.com/questions/38394240/how-to-generate-color-code-with-uuid-in-java + */ + public static Color getRandomColor(UUID u) { + + byte[] bytes = UUID2Bytes(u); + + float r = Math.abs(bytes[0]) / 255f; + float g = Math.abs(bytes[1]) / 255f; + float b = Math.abs(bytes[2]) / 255f; + + float value = (r+g+b) / 3; //this is your value between 0 and 1 + float minHue = min(r, g, b); + float maxHue = max(r, g, b); + float hue = value*maxHue + (1-value)*minHue; + Color c = new Color(java.awt.Color.HSBtoRGB(hue, 1, 1f)); + + System.out.println(r + ", " + g + ", " + b); + + return new Color(c); + } + + public static float min(float... fs) { + float r = Float.MAX_VALUE; + for(float f : fs) { + if(f < r) r = f; + } + return r; } + public static float max(float... fs) { + float r = Float.MIN_VALUE; + for(float f : fs) { + if(f > r) r = f; + } + return r; + } + + public static byte[] UUID2Bytes(UUID uuid) { + + long hi = uuid.getMostSignificantBits(); + long lo = uuid.getLeastSignificantBits(); + return ByteBuffer.allocate(16).putLong(hi).putLong(lo).array(); + } + public static class Constants { public static int NETWORK_ACTION_TIMEOUT_MILLIS = 7000;