Compare commits
326 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27120bbed5 | |||
| 03d6e1f822 | |||
| 648d15fc88 | |||
| d6af58875d | |||
| 16a5adefad | |||
| 682eaa677c | |||
| 4319d66c61 | |||
| f6f729e8d4 | |||
| a39b02bfe7 | |||
| 1cfc98dd57 | |||
| ee846f6219 | |||
| e353d97415 | |||
| 2b49fafa0b | |||
| b33b853747 | |||
| 8e3e6bdb6c | |||
| d9d385b0ef | |||
| 8c16b5ba90 | |||
| 1aaa69f2d7 | |||
| 6240846f0c | |||
| 70e6565e1f | |||
| fffb6a3214 | |||
| 04bea46b3b | |||
| 4da06e52e5 | |||
| 8878a825b8 | |||
| 7de1897b32 | |||
| d670722674 | |||
| e7d031db58 | |||
| 71087286b2 | |||
| 757bc87426 | |||
| 1b5eef810c | |||
| cfa1475cf6 | |||
| 1e79fcfacb | |||
| b34cb41bff | |||
| d2aff5f2ee | |||
| beda5e6c5f | |||
| 50c4aebc0f | |||
| 30325f6d16 | |||
| bddb590d30 | |||
| de831fcb26 | |||
| 5645fb6d0f | |||
| bab588e6fb | |||
| 2565b6017a | |||
| 112cd7ba2f | |||
| 77ddd78d84 | |||
| 4fa5cf84fa | |||
| 40bdf6a5cc | |||
| 47039bbaa5 | |||
| 4d7fcb4b4b | |||
| 5f24e85deb | |||
| 42fd008a54 | |||
| c2b0618c93 | |||
| 94f72f71e3 | |||
| bb4b928c89 | |||
| d67d4e5709 | |||
| a4bbeb2573 | |||
| e032c25e1a | |||
| d9cce32bb8 | |||
| 10d5e0df40 | |||
| 0f3392aa0c | |||
| 9d4558ca47 | |||
| 6609756065 | |||
| 605935528b | |||
| f072d8dc6e | |||
| 00cd404a98 | |||
| d47be9ea8a | |||
| 2d70a5652b | |||
| bbf1438728 | |||
| c0496f2e7c | |||
| 636be8611f | |||
| 48f9c433e2 | |||
| 314f5a480c | |||
| 46f2abab05 | |||
| 883f14fb76 | |||
| cc151322d8 | |||
| de64e2813e | |||
| db80c151bb | |||
| ef971e03b9 | |||
| f10da93a12 | |||
| e63b41ae8a | |||
| 43a34cce39 | |||
| b9b5453f89 | |||
| f5af6716d5 | |||
| 7125cc1e9f | |||
| 8a3ceec1ee | |||
| 523f334c1b | |||
| a547b68dc0 | |||
| 45cabc1926 | |||
| 42138cd4ad | |||
| e8e3a6f1b3 | |||
| 6d5148e0a5 | |||
| 262221d969 | |||
| 9eccb263c0 | |||
| ba90b90cd3 | |||
| 94340bddb1 | |||
| 3361d252ee | |||
| 637772f2dd | |||
| f703c76c21 | |||
| 5fe307a218 | |||
| 670a11d6ba | |||
| 1ec1c3baae | |||
| 24f5b0c218 | |||
| b7bc1d244f | |||
| fbc9238d2f | |||
| eb7c311bb6 | |||
| 9640414ba4 | |||
| bc95ca03e2 | |||
| d0ebf05f1c | |||
| 91dd84a437 | |||
| 1b36016a1a | |||
| db0adbac30 | |||
| 948648b313 | |||
| 73822dc95a | |||
| 282bc68734 | |||
| 2ff374abb6 | |||
| f999c66fea | |||
| 2b3f368e0f | |||
| c0ab953115 | |||
| e39de4467d | |||
| 4c3f1ca0fc | |||
| 7fa5a4e048 | |||
| dc1279f636 | |||
| 5798fa9db7 | |||
| c534cf20fd | |||
| 38e14c9269 | |||
| a66b72ba22 | |||
| 2c42d993ca | |||
| a49d673f25 | |||
| ee5de9f3db | |||
| 94b3a94cbb | |||
| caab6ba3a3 | |||
| 7f70c49b87 | |||
| 8f50da64c2 | |||
| 982ca09a23 | |||
| dbf30decae | |||
| abd1b834d7 | |||
| 6ad9076987 | |||
| 78bbf5264e | |||
| 4c8ae66624 | |||
| 5a3d5b974e | |||
| fb9a28c126 | |||
| 7115ea8ac2 | |||
| 01417f5bbd | |||
| abf944418e | |||
| c7946ef1da | |||
| 241499bc2d | |||
| 74297dd9c7 | |||
| 31cb20bf85 | |||
| 1d95de02e1 | |||
| ba13111a8e | |||
| 94b19a1c26 | |||
| 50a0cee044 | |||
| 26ad5f47cd | |||
| 864d5f3335 | |||
| 4b426183e8 | |||
| a5722dfa9d | |||
| 7984d8282c | |||
| 17823ede11 | |||
| 5db3ae1af0 | |||
| bbe2aeb7fb | |||
| 09b188cf24 | |||
| 11f8fc6190 | |||
| 96e608c36f | |||
| 3c116db135 | |||
| efe826110c | |||
| c1ff14111d | |||
| cd7dd1984b | |||
| 686c659c84 | |||
| 797dfca2be | |||
| aa10825b12 | |||
| 608ed3acc4 | |||
| 03b461f082 | |||
| cbb28f4158 | |||
| 13240677b0 | |||
| b0ae85334b | |||
| 183c6c16f1 | |||
| a7f286dc42 | |||
| 20b60009e3 | |||
| d6b572aead | |||
| d11d0ac53f | |||
| ab02460b11 | |||
| fc18e2e0b7 | |||
| 363a48bb1b | |||
| e9de677ceb | |||
| 5ff7b19475 | |||
| 7ddba8f69b | |||
| b86e0ddd20 | |||
| a3f3de3af5 | |||
| 4a4ca463c3 | |||
| 13d01293f6 | |||
| d0104e4361 | |||
| c3db9f2414 | |||
| f34d35e03a | |||
| 9868d27bc3 | |||
| c0b4b2a4c1 | |||
| 9dc0a4ce06 | |||
| c58735ea43 | |||
| 4e2b65c225 | |||
| 663935bd75 | |||
| d1ed17d1d7 | |||
| 135ad0d992 | |||
| 8fb1d6132d | |||
| f60feea6e8 | |||
| d7b7744eb8 | |||
| 2eb606aa21 | |||
| a86c4fc447 | |||
| 1ea216fd20 | |||
| 121c470b00 | |||
| 404dd77806 | |||
| d2f23e7777 | |||
| fd0e2382d0 | |||
| e609dafedc | |||
| a948dfbaad | |||
| 5b804c6902 | |||
| 556cd2f1a9 | |||
| 7d570336a5 | |||
| a9b591a7ca | |||
| 216e1aa476 | |||
| 4d8de90419 | |||
| 0b17fbf804 | |||
| c6639e11b1 | |||
| e6f9aa8ba1 | |||
| 2c191d932c | |||
| d52b94d095 | |||
| c67385576e | |||
| f09e70c5f8 | |||
| 0f5cf7fdc5 | |||
| 426b2718bb | |||
| 8ea862a118 | |||
| 1f87a71833 | |||
| 56c2cd9437 | |||
| 85e5f9a553 | |||
| d9915120d4 | |||
| 4863f37eef | |||
| c9ec4395ee | |||
| b62956cc95 | |||
| b2ba4362fe | |||
| 7cca35195d | |||
| d4a9c720d6 | |||
| d2383fc4f0 | |||
| 74322ca6a4 | |||
| a6323edb36 | |||
| 2d4c56d04c | |||
| e3d3359019 | |||
| 2aa1c82aea | |||
| 45af6c2a50 | |||
| d6cf708035 | |||
| 085431fe73 | |||
| 95148a9b0b | |||
| a24d610b05 | |||
| f8bba85eb4 | |||
| 80f2ac25ad | |||
| 17e4f1f172 | |||
| af5aa6b8e6 | |||
| 1fd1c669a0 | |||
| 122c54a0de | |||
| ac1df9a9a4 | |||
| d0c796aab2 | |||
| 17289fde92 | |||
| 7d27f0cd35 | |||
| a64463ddc6 | |||
| 007621c48c | |||
| 33b0693a4e | |||
| 13c1299bf0 | |||
| fbdf018422 | |||
| 8800fe48ee | |||
| 2be44de710 | |||
| 9269bde518 | |||
| 4c8181b3ea | |||
| 61852ab47e | |||
| 914a4dcf3b | |||
| 8f3fb4474c | |||
| 08ef40b736 | |||
| 0048d6fc92 | |||
| caae1216d0 | |||
| 2255a806b9 | |||
| 0eb150eb8b | |||
| 01f811ebd2 | |||
| c70eed8a06 | |||
| b12b26b87e | |||
| 836eebaf11 | |||
| 92a2628e90 | |||
| d2360fde25 | |||
| c603753226 | |||
| c8448b7848 | |||
| 6d2a1a002b | |||
| f6ebec32ca | |||
| 7a57f22967 | |||
| dd2c1eb9d2 | |||
| e657fb16bd | |||
| f7bf5e2b0e | |||
| 51f07bd330 | |||
| 2183c0710c | |||
| e9212a889d | |||
| 0d4ac4e3e5 | |||
| df99ff817a | |||
| 2705afc327 | |||
| 5330be142c | |||
| 73c46d821e | |||
| 0565eec871 | |||
| d895fb70f7 | |||
| 45fab2c0b5 | |||
| 634f5ad2d0 | |||
| 34e5ac2b9e | |||
| 336896b37e | |||
| c9698f1f5c | |||
| dd447656f8 | |||
| db2339ab3a | |||
| 8d3308d74a | |||
| 22e7965442 | |||
| 2e856c1256 | |||
| 5b04242aab | |||
| a127777e49 | |||
| 11aea59cf8 | |||
| 5456a01551 | |||
| a93a67161d | |||
| 52a4e44e47 | |||
| 79039ae79e | |||
| 1ae84cf5a8 | |||
| 032fa0c0ad | |||
| 1f8b43ba5d | |||
| 4fc0ae103e | |||
| bd86412d83 | |||
| 592e59e01f | |||
| 05b6fe4a56 | |||
| f68e5d160f | |||
| d279d52b09 |
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Editor configuration, see http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.yaml]
|
||||||
|
indent_size = 2
|
||||||
10
.env.default
Normal file
10
.env.default
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
PROJECT=tankz
|
||||||
|
SDK_PATH=$HOME/sdk
|
||||||
|
PUBLISH_PATH=$HOME/public/$PROJECT
|
||||||
|
BUILD_PATH=./build
|
||||||
|
TARGET_PATH=./target
|
||||||
|
KEY_STORE=<keystore.jks>
|
||||||
|
KEY_PASS=<passphrase>
|
||||||
|
REPO=https://git.shmyga.ru/api/packages/InfernalGames
|
||||||
|
PUBLISH_USER=<username>
|
||||||
|
PUBLISH_PASSWORD=<passphrase>
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
build/
|
||||||
target/
|
target/
|
||||||
src-gen/
|
src-gen/
|
||||||
out/
|
out/
|
||||||
@@ -9,6 +10,8 @@ out/
|
|||||||
.idea/
|
.idea/
|
||||||
.ideaDataSources/
|
.ideaDataSources/
|
||||||
config.json
|
config.json
|
||||||
package-lock.json
|
|
||||||
/node_modules
|
/node_modules
|
||||||
/log
|
/log
|
||||||
|
/ansible/*.retry
|
||||||
|
.npmrc
|
||||||
|
.env
|
||||||
44
CHANGELOG.md
Normal file
44
CHANGELOG.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
0.17.0
|
||||||
|
------
|
||||||
|
* Improved `ResultFrame`
|
||||||
|
* Improved bonuses
|
||||||
|
* Set `DeviceType.SCREEN` as default on mobile devices
|
||||||
|
|
||||||
|
0.16.0
|
||||||
|
------
|
||||||
|
* Added `GamepadView` for sensor control
|
||||||
|
* Added `AppTheme`
|
||||||
|
* Replace `LevelPopup` with `StartFrame`
|
||||||
|
* Added `LevelPack`
|
||||||
|
* Added scrolls to lists
|
||||||
|
* Fixed `GameView` size for small screens
|
||||||
|
|
||||||
|
0.15.0
|
||||||
|
------
|
||||||
|
* Added display tank player name in `Render`
|
||||||
|
* Fixed join game after relogin
|
||||||
|
* Updated `CreateGamePopup` for any screen sizes
|
||||||
|
* Fixed tank destroy zero score label
|
||||||
|
* Added custom size map support
|
||||||
|
* Fixed clock bonus for spawned tanks
|
||||||
|
|
||||||
|
0.14.0
|
||||||
|
------
|
||||||
|
* Added `CreateGamePopup`
|
||||||
|
* Fixed null tank color
|
||||||
|
* Updated `Ticker`
|
||||||
|
|
||||||
|
0.13.0
|
||||||
|
------
|
||||||
|
* Added `Ticker`
|
||||||
|
* Fixed `PacketQueue` stream reading
|
||||||
|
* Added `PlayerControl` and `ControlPreset`
|
||||||
|
* Added `BaseControlFactory`
|
||||||
|
|
||||||
|
0.12.0
|
||||||
|
------
|
||||||
|
* Added `GameRoomFrame`
|
||||||
|
* Improved websocket connection with using binary protocol instead of text
|
||||||
|
* Added `GameListFrame`
|
||||||
|
* Added `DesktopConnection` for linux client build
|
||||||
|
* Updated `SoundManager`
|
||||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
FROM ubuntu:noble AS base
|
||||||
|
RUN apt update && apt install -y \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
openjdk-11-jre \
|
||||||
|
protobuf-compiler \
|
||||||
|
jq
|
||||||
|
RUN node -v
|
||||||
|
RUN npm -v
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
ENV GRADLE_USER_HOME=/sdk/gradle
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY gulpfile.js protohx.json ./
|
||||||
|
COPY tasks ./tasks
|
||||||
|
COPY config.example.json ./config.example.json
|
||||||
|
RUN --mount=type=secret,id=KEY_STORE \
|
||||||
|
cat /run/secrets/KEY_STORE > ./key.jks
|
||||||
|
RUN --mount=type=secret,id=KEY_PASS,env=KEY_PASS \
|
||||||
|
jq --arg key_pass "$KEY_PASS" \
|
||||||
|
'.SdkDir = "/sdk" | .PublishDir = "/app/publish" | .Key.store = "key.jks" | .Key.pass = $key_pass' \
|
||||||
|
config.example.json > config.json
|
||||||
|
COPY src ./src
|
||||||
|
#COPY dependencies ./dependencies
|
||||||
|
VOLUME ["/sdk", "/app/build", "/app/target", "/app/publish", "/app/src-gen"]
|
||||||
|
CMD ["npx", "gulp", "default"]
|
||||||
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Tankz
|
||||||
|
|
||||||
|
## Play
|
||||||
|
|
||||||
|
https://shmyga.ru/tankz/html5/index.html
|
||||||
|
|
||||||
|
## Packages
|
||||||
|
|
||||||
|
https://git.shmyga.ru/InfernalGames/-/packages/generic/tankz
|
||||||
82
WORK.md
82
WORK.md
@@ -1,62 +1,20 @@
|
|||||||
* build
|
* death game bonus
|
||||||
* gulp 100%
|
* tanks and bullets speed balancing
|
||||||
* linux 100%
|
* clean player state on lose in classic type
|
||||||
* deb-package 100%
|
* network series
|
||||||
* windows 0%
|
* bot upgrade
|
||||||
* exe-package 0% (inno setup)
|
* game config validate
|
||||||
|
* mine z-order
|
||||||
* deploy
|
* mine spawn position
|
||||||
* capistrano 100%
|
* mine spawn on other mine
|
||||||
|
* double rocket
|
||||||
* ui
|
* display ammo count (panel)
|
||||||
* auth frame 0%
|
* display ammo count (screen gamepad)
|
||||||
* select game frame 30% (classic 1/2 player, dota singe/coop/vs)
|
* bonus ammo
|
||||||
* select level frame 10%
|
* game panel rework
|
||||||
* game frame 50%
|
* game state: config, map, entities, players
|
||||||
|
* game menu pack progress
|
||||||
* engine
|
* game save
|
||||||
* config 100%
|
* balloons: change mute, network, pause
|
||||||
* map 100%
|
* settings: mute, pause, reset device actions
|
||||||
* tanks 100%
|
* game view: toggle panel on mobile
|
||||||
* bullets 100%
|
|
||||||
* boxes 100%
|
|
||||||
* map changes 100%
|
|
||||||
* bonuses 0%
|
|
||||||
* eagle 100%
|
|
||||||
|
|
||||||
* game
|
|
||||||
* classic
|
|
||||||
* state 50%
|
|
||||||
* bot 50%
|
|
||||||
* player: 50%
|
|
||||||
* dota
|
|
||||||
* state 50%
|
|
||||||
* bot 10%
|
|
||||||
* player 0%
|
|
||||||
|
|
||||||
* state
|
|
||||||
* score 0%
|
|
||||||
* save/load 0%
|
|
||||||
* export/import 0%
|
|
||||||
|
|
||||||
* render
|
|
||||||
* map 100%
|
|
||||||
* tanks 100%
|
|
||||||
* bullet 100%
|
|
||||||
* calc redraw 50%
|
|
||||||
* animations
|
|
||||||
* tank spawn 0%
|
|
||||||
* tank move 100%
|
|
||||||
* map water 0%
|
|
||||||
* bullet boom 90%
|
|
||||||
* tank boom 90%
|
|
||||||
* bonuses 0%
|
|
||||||
* html5 50%
|
|
||||||
|
|
||||||
* proto
|
|
||||||
...
|
|
||||||
|
|
||||||
* editor
|
|
||||||
* open 0%
|
|
||||||
* edit 0%
|
|
||||||
* save 0%
|
|
||||||
|
|||||||
11
ansible/ansible.cfg
Normal file
11
ansible/ansible.cfg
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[defaults]
|
||||||
|
hash_behaviour = merge
|
||||||
|
host_key_checking = False
|
||||||
|
#callback_whitelist = profile_tasks
|
||||||
|
display_skipped_hosts = False
|
||||||
|
stdout_callback = yaml
|
||||||
|
bin_ansible_callbacks = True
|
||||||
|
|
||||||
|
[ssh_connection]
|
||||||
|
pipelining = True
|
||||||
|
ssh_args = -o ForwardAgent=yes
|
||||||
14
ansible/deploy.yml
Normal file
14
ansible/deploy.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
ansible_user: "{{ deploy_user }}"
|
||||||
|
roles:
|
||||||
|
- ansible-deploy
|
||||||
|
- build
|
||||||
|
post_tasks:
|
||||||
|
- include_role:
|
||||||
|
name: ansible-deploy
|
||||||
|
tasks_from: complete.yml
|
||||||
|
- include_role:
|
||||||
|
name: service
|
||||||
|
tasks_from: restart.yml
|
||||||
2
ansible/dev/inventory.yml
Normal file
2
ansible/dev/inventory.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
all:
|
||||||
|
hosts: localhost
|
||||||
15
ansible/group_vars/all.yml
Normal file
15
ansible/group_vars/all.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
project_name: tankz
|
||||||
|
project_user: holop
|
||||||
|
|
||||||
|
deploy_user: "{{ project_user }}"
|
||||||
|
deploy_project: "{{ project_name }}"
|
||||||
|
deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git"
|
||||||
|
deploy_repo_version: develop
|
||||||
|
deploy_npm: yes
|
||||||
|
|
||||||
|
service_name: "{{ project_name }}"
|
||||||
|
service_work_dir: "{{ deploy_current_dir }}/target/server/cpp"
|
||||||
|
service_command: "{{ service_work_dir }}/{{ project_name }} {{ service_host }}"
|
||||||
|
service_user: www-data
|
||||||
|
service_control_user: "{{ project_user }}"
|
||||||
5
ansible/prod/inventory.yml
Normal file
5
ansible/prod/inventory.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
all:
|
||||||
|
hosts: shmyga.ru
|
||||||
|
vars:
|
||||||
|
service_host: 213.139.208.180
|
||||||
|
config_src: "/home/holop/tankz/config.json"
|
||||||
7
ansible/requirements.yml
Normal file
7
ansible/requirements.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: ansible-deploy
|
||||||
|
src: git@bitbucket.org:shmyga/ansible-deploy.git
|
||||||
|
version: master
|
||||||
|
scm: git
|
||||||
|
|
||||||
|
- name: geerlingguy.nodejs
|
||||||
2
ansible/roles/build/defaults/main.yml
Normal file
2
ansible/roles/build/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
config_src: "{{ deploy_release_dir }}/config.{{ inventory_hostname }}.json"
|
||||||
|
config_dest: "{{ deploy_release_dir }}/config.json"
|
||||||
11
ansible/roles/build/tasks/main.yml
Normal file
11
ansible/roles/build/tasks/main.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
- name: "Copy config"
|
||||||
|
copy:
|
||||||
|
src: "{{ config_src }}"
|
||||||
|
dest: "{{ config_dest }}"
|
||||||
|
remote_src: true
|
||||||
|
|
||||||
|
- name: "Gulp build"
|
||||||
|
command: "{{ deploy_release_dir }}/node_modules/.bin/gulp default --host shmyga.ru"
|
||||||
|
args:
|
||||||
|
chdir: "{{ deploy_release_dir }}"
|
||||||
6
ansible/roles/service/defaults/main.yml
Normal file
6
ansible/roles/service/defaults/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
service_name: null
|
||||||
|
service_description: "{{ service_name }} service"
|
||||||
|
service_work_dir: null
|
||||||
|
service_command: null
|
||||||
|
service_user: null
|
||||||
|
service_control_user: null
|
||||||
21
ansible/roles/service/tasks/main.yml
Normal file
21
ansible/roles/service/tasks/main.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: "Install {{ service_name }} systemd unit file"
|
||||||
|
template:
|
||||||
|
src: "template/service.j2"
|
||||||
|
dest: "/etc/systemd/system/{{ service_name }}.service"
|
||||||
|
|
||||||
|
- name: "Start {{ service_name }} service"
|
||||||
|
systemd:
|
||||||
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
name: "{{ service_name }}"
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
|
- name: "Add sudoers record for {{ service_name }} service"
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/sudoers.d/{{ service_name }}
|
||||||
|
state: present
|
||||||
|
create: yes
|
||||||
|
regexp: "^{{ service_control_user }} ALL="
|
||||||
|
line: "{{ service_control_user }} ALL= NOPASSWD: /bin/systemctl * {{ service_name }}"
|
||||||
|
validate: "/usr/sbin/visudo -cf %s"
|
||||||
11
ansible/roles/service/tasks/restart.yml
Normal file
11
ansible/roles/service/tasks/restart.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
# - name: "Restart {{ service_name }} service"
|
||||||
|
# systemd:
|
||||||
|
# enabled: yes
|
||||||
|
# state: restarted
|
||||||
|
# name: "{{ service_name }}"
|
||||||
|
|
||||||
|
- name: "Restart {{ service_name }} service"
|
||||||
|
command: "sudo /bin/systemctl restart {{ service_name }}"
|
||||||
|
args:
|
||||||
|
warn: no
|
||||||
15
ansible/roles/service/template/service.j2
Normal file
15
ansible/roles/service/template/service.j2
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description={{ service_description }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
PIDFile=/var/run/{{ service_name }}.pid
|
||||||
|
WorkingDirectory={{ service_work_dir }}
|
||||||
|
User={{ service_user }}
|
||||||
|
Group={{ service_user }}
|
||||||
|
ExecStart={{ service_command }}
|
||||||
|
TimeoutSec=300
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
3
ansible/roles/setup/tasks/apt.yml
Normal file
3
ansible/roles/setup/tasks/apt.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
- name: "Install neko package"
|
||||||
|
apt:
|
||||||
|
name: neko
|
||||||
2
ansible/roles/setup/tasks/main.yml
Normal file
2
ansible/roles/setup/tasks/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- import_tasks: apt.yml
|
||||||
|
when: ansible_distribution|lower == 'ubuntu'
|
||||||
1
ansible/roles/user/keys/shmyga.pub
Normal file
1
ansible/roles/user/keys/shmyga.pub
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCot1zSeqj7Tj5/7aNMzXAuXQPPxudYFV9z6M03dPijh2bXyHDcXk53xUO8XY5R4GyLhvAn98axbPM++urKY8BXuQqAG36soI7iZJ/KcPY1EKDwVBeZneFC/wMc8HMT0hj9+uHcGAMtmklIgPPkawzLxbEh6oAY4H8Vvz08qyco6suYB5NjkpFwVMf9Xa2Fj8rTodKpPRDBh/Xk+5bh11RKL6b9WcwuwpKU8zl2qZiqNfjr0H+sKEk7ohcYvzSCltLdKJcoKbiCcnrnBJT5/JpGWeAbA2MMmvmt/dJrHykd1CbmXW2DuG4tIlwMb5xU739PoKCePctK1retb8TrWOLT shmyga@shmyga-desktop
|
||||||
40
ansible/roles/user/tasks/main.yml
Normal file
40
ansible/roles/user/tasks/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# barin
|
||||||
|
- name: Make barin group
|
||||||
|
group:
|
||||||
|
name: barin
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Make barin user
|
||||||
|
user:
|
||||||
|
name: barin
|
||||||
|
group: barin
|
||||||
|
password: '$6$mbw5KZWwtrRUy$eFcMNTW.QzG1Em45r5hZf/qri4hKAHImozWuW4/pYnDK.tOrVKrXTKYfRDtYEFRgCgVVg0zuPvyq/xn0KiKlz0'
|
||||||
|
groups: www-data,sudo,adm
|
||||||
|
|
||||||
|
- name: Set up authorized_keys for the barin user
|
||||||
|
authorized_key:
|
||||||
|
user: barin
|
||||||
|
key: '{{ item }}'
|
||||||
|
with_file:
|
||||||
|
- keys/shmyga.pub
|
||||||
|
|
||||||
|
|
||||||
|
# holop
|
||||||
|
- name: Make holop group
|
||||||
|
group:
|
||||||
|
name: holop
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Make holop user
|
||||||
|
user:
|
||||||
|
name: holop
|
||||||
|
group: holop
|
||||||
|
password: '$6$B/7g0xlcXFCIHk$hzSjb8KLll7YrTsp3z640sxNixNAkLpm6UUdZgWPh0Ffy7Ue18AiXTzkDdGTaTH6Woz4kvgVDSggnKGTU6u03.'
|
||||||
|
groups: www-data
|
||||||
|
|
||||||
|
- name: Set up authorized_keys for the holop user
|
||||||
|
authorized_key:
|
||||||
|
user: holop
|
||||||
|
key: '{{ item }}'
|
||||||
|
with_file:
|
||||||
|
- keys/shmyga.pub
|
||||||
1
ansible/roles/user/vars/main.yml
Normal file
1
ansible/roles/user/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ansible_become: yes
|
||||||
8
ansible/service.yml
Normal file
8
ansible/service.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
ansible_user: "{{ deploy_user }}"
|
||||||
|
tasks:
|
||||||
|
- include_role:
|
||||||
|
name: service
|
||||||
|
tasks_from: restart.yml
|
||||||
16
ansible/setup.yml
Normal file
16
ansible/setup.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- hosts:
|
||||||
|
- all
|
||||||
|
pre_tasks:
|
||||||
|
- include_role:
|
||||||
|
name: ansible-deploy
|
||||||
|
tasks_from: facts.yml
|
||||||
|
roles:
|
||||||
|
- geerlingguy.nodejs
|
||||||
|
- setup
|
||||||
|
- service
|
||||||
|
vars:
|
||||||
|
nodejs_version: 9.x
|
||||||
|
nodejs_npm_global_packages: [gulp-cli]
|
||||||
|
vars_files:
|
||||||
|
- vars/barin.yml
|
||||||
4
ansible/user.yml
Normal file
4
ansible/user.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
roles:
|
||||||
|
- user
|
||||||
4
ansible/vars/barin.yml
Normal file
4
ansible/vars/barin.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
ansible_user: barin
|
||||||
|
ansible_become_pass: 1234!QAZ
|
||||||
|
ansible_become: yes
|
||||||
137
build/client.js
137
build/client.js
@@ -1,137 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const concat = require('gulp-concat');
|
|
||||||
const uglify = require('gulp-uglify');
|
|
||||||
const babel = require('gulp-babel');
|
|
||||||
const template = require('gulp-template');
|
|
||||||
const yargs = require('yargs');
|
|
||||||
const Haxe = require('../tasks/haxe');
|
|
||||||
const FlashPlayer = require('../tasks/flashplayer');
|
|
||||||
const version = require('./version');
|
|
||||||
const prepare = require('./prepare');
|
|
||||||
const debug = require('../tasks/debug');
|
|
||||||
const webserver = require('gulp-webserver');
|
|
||||||
const run = require('gulp-run');
|
|
||||||
const tail = require('../tasks/tail');
|
|
||||||
const deb = require('gulp-debian');
|
|
||||||
|
|
||||||
|
|
||||||
const generate = () => function generate() {
|
|
||||||
return new Haxe().haxelib([
|
|
||||||
'run', 'protohx', 'generate', 'protohx.json'
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const build = (platform) => function build() {
|
|
||||||
const argv = yargs.argv;
|
|
||||||
return gulp.src('.')
|
|
||||||
.pipe(new Haxe().openfl({
|
|
||||||
command: 'build',
|
|
||||||
platform: platform,
|
|
||||||
version: version,
|
|
||||||
debug: argv.dev,
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(`target/${platform}`));
|
|
||||||
};
|
|
||||||
|
|
||||||
const flashIndex = function() {
|
|
||||||
return gulp.src('src/client/html/index.html')
|
|
||||||
.pipe(template({
|
|
||||||
scripts: ['app.min.js'],
|
|
||||||
swf: 'tankz.swf'
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest('target/flash'))
|
|
||||||
};
|
|
||||||
|
|
||||||
const flashJs = function() {
|
|
||||||
const src = [
|
|
||||||
'src/client/html/js/*.js'
|
|
||||||
];
|
|
||||||
return gulp.src(src)
|
|
||||||
.pipe(babel({presets: ['es2015']}))
|
|
||||||
.pipe(uglify())
|
|
||||||
.pipe(concat('app.min.js'))
|
|
||||||
.pipe(gulp.dest('target/flash'))
|
|
||||||
};
|
|
||||||
|
|
||||||
const webapp = function () {
|
|
||||||
return gulp.src('src/webapp/*').pipe(gulp.dest('target'));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const buildDeb = gulp.series(
|
|
||||||
() => gulp.src('src/client/debian/**/*').pipe(gulp.dest('target/debian')),
|
|
||||||
() => gulp.src('target/linux/**/*').pipe(gulp.dest('target/debian/usr/share/tankz')),
|
|
||||||
() => gulp.src('target/debian/*')
|
|
||||||
.pipe(deb({
|
|
||||||
package: 'tankz',
|
|
||||||
version: version,
|
|
||||||
section: 'base',
|
|
||||||
priority: 'optional',
|
|
||||||
architecture: 'all',
|
|
||||||
maintainer: 'shmyga <shmyga.z@gmail.com>',
|
|
||||||
description: 'Tank\'z',
|
|
||||||
changelog: [],
|
|
||||||
postinst: [
|
|
||||||
'if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ] ; then\n' +
|
|
||||||
' update-menus\n' +
|
|
||||||
'fi'
|
|
||||||
],
|
|
||||||
_target: '/',
|
|
||||||
_out: 'target',
|
|
||||||
_clean: false,
|
|
||||||
_verbose: true
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
exports['client:flash:html'] = gulp.parallel(flashIndex, flashJs);
|
|
||||||
exports['client:flash'] = gulp.series(prepare(Haxe.ID), generate(), build('flash'), exports['client:flash:html']);
|
|
||||||
exports['client:html5'] = gulp.series(prepare(Haxe.ID), generate(), build('html5'));
|
|
||||||
exports['client:linux'] = gulp.series(prepare(Haxe.ID), generate(), build('linux'));
|
|
||||||
exports['client:webapp'] = webapp;
|
|
||||||
exports['client:deb'] = buildDeb;
|
|
||||||
exports['client'] = gulp.series(
|
|
||||||
prepare(Haxe.ID),
|
|
||||||
generate(),
|
|
||||||
gulp.parallel(build('flash'), build('html5'), build('linux')),
|
|
||||||
exports['client:flash:html'],
|
|
||||||
webapp,
|
|
||||||
buildDeb,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const testFlash = function() {
|
|
||||||
const argv = yargs.argv;
|
|
||||||
return build('flash')()
|
|
||||||
.pipe(new FlashPlayer().run(argv.dev))
|
|
||||||
.pipe(debug());
|
|
||||||
};
|
|
||||||
|
|
||||||
const testHtml5 = function() {
|
|
||||||
return gulp.series(
|
|
||||||
build('html5'),
|
|
||||||
() => gulp.src('target/html5').pipe(webserver({
|
|
||||||
host: 'localhost', port: 3000,
|
|
||||||
open: true,
|
|
||||||
fallback: 'index.html'
|
|
||||||
}))
|
|
||||||
)();
|
|
||||||
};
|
|
||||||
|
|
||||||
const testLinux = gulp.series(
|
|
||||||
build('linux'),
|
|
||||||
() => gulp.src('target/linux/tankz')
|
|
||||||
.pipe(run('./tankz', {cwd: 'target/linux', verbosity: 1}))
|
|
||||||
.pipe(tail(debug.log))
|
|
||||||
.pipe(gulp.dest('target/log'))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports['client:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), testFlash);
|
|
||||||
exports['client:html5:test'] = gulp.series(prepare(Haxe.ID), testHtml5);
|
|
||||||
exports['client:linux:test'] = gulp.series(prepare(Haxe.ID), testLinux);
|
|
||||||
exports['client:test'] = exports['client:flash:test'];
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const yargs = require('yargs');
|
|
||||||
const Haxe = require('../tasks/haxe');
|
|
||||||
const FlashPlayer = require('../tasks/flashplayer');
|
|
||||||
const version = require('./version');
|
|
||||||
const prepare = require('./prepare');
|
|
||||||
const debug = require('../tasks/debug');
|
|
||||||
|
|
||||||
|
|
||||||
const build = (platform) => function build() {
|
|
||||||
const argv = yargs.argv;
|
|
||||||
return gulp.src('.')
|
|
||||||
.pipe(new Haxe().openfl({
|
|
||||||
command: 'build',
|
|
||||||
platform: platform,
|
|
||||||
version: version,
|
|
||||||
values: {
|
|
||||||
build_editor: true
|
|
||||||
},
|
|
||||||
debug: argv.dev,
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(`target/${platform}`));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const testFlash = function() {
|
|
||||||
const argv = yargs.argv;
|
|
||||||
return build('flash')()
|
|
||||||
.pipe(new FlashPlayer().run(argv.dev))
|
|
||||||
.pipe(debug());
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
exports['editor:flash'] = gulp.series(prepare(Haxe.ID), build('flash'));
|
|
||||||
exports['editor:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), testFlash);
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
const AdobeAir = require('../tasks/adobeAir');
|
|
||||||
const Haxe = require('../tasks/haxe');
|
|
||||||
const FlashPlayer = require('../tasks/flashplayer');
|
|
||||||
const packageInfo = require('../package.json');
|
|
||||||
|
|
||||||
|
|
||||||
const prepareOne = (value) => {
|
|
||||||
switch (value) {
|
|
||||||
case Haxe.ID:
|
|
||||||
const haxe = new Haxe();
|
|
||||||
return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies));
|
|
||||||
case AdobeAir.ID:
|
|
||||||
return new AdobeAir().prepare();
|
|
||||||
case FlashPlayer.ID:
|
|
||||||
return new FlashPlayer().prepare();
|
|
||||||
default:
|
|
||||||
throw Error(`Unknown target: ${value}`)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const prepare = (...targets) => function prepare() {
|
|
||||||
const tasks = targets.map((target) => prepareOne(target));
|
|
||||||
return Promise.all(tasks);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const update = () => {
|
|
||||||
return new Haxe().upgrade();
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = prepare;
|
|
||||||
module.exports.update = update;
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
const gulp = require('gulp');
|
|
||||||
const yargs = require('yargs');
|
|
||||||
const Haxe = require('../tasks/haxe');
|
|
||||||
const FlashPlayer = require('../tasks/flashplayer');
|
|
||||||
const Neko = require('../tasks/neko');
|
|
||||||
const version = require('./version');
|
|
||||||
const prepare = require('./prepare');
|
|
||||||
const debug = require('../tasks/debug');
|
|
||||||
|
|
||||||
|
|
||||||
const build = () => function build() {
|
|
||||||
const argv = yargs.argv;
|
|
||||||
return gulp.src('.')
|
|
||||||
.pipe(new Haxe().build({
|
|
||||||
platform: 'neko',
|
|
||||||
version: version,
|
|
||||||
lib: [
|
|
||||||
'protohx',
|
|
||||||
'orm',
|
|
||||||
'haxework:git',
|
|
||||||
],
|
|
||||||
cp: [
|
|
||||||
'src/common/haxe',
|
|
||||||
'src/server/haxe',
|
|
||||||
'src-gen/haxe',
|
|
||||||
],
|
|
||||||
main: 'ru.m.tankz.server.Server',
|
|
||||||
outputFile: 'tankz.n',
|
|
||||||
debug: argv.dev,
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest('target'));
|
|
||||||
};
|
|
||||||
|
|
||||||
const test = (build) => function test() {
|
|
||||||
const argv = yargs.argv;
|
|
||||||
return build()
|
|
||||||
.pipe(new Neko().run(argv.dev))
|
|
||||||
.pipe(debug());
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
exports['server'] = gulp.series(prepare(Haxe.ID), build());
|
|
||||||
exports['server:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), test(build()));
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
const packageInfo = require('../package.json');
|
|
||||||
module.exports = packageInfo.version;
|
|
||||||
11
capfile
11
capfile
@@ -1,11 +0,0 @@
|
|||||||
require 'capistrano/setup'
|
|
||||||
require 'capistrano/deploy'
|
|
||||||
require 'capistrano/scm/git'
|
|
||||||
install_plugin Capistrano::SCM::Git
|
|
||||||
require 'capistrano/scm/git-with-submodules'
|
|
||||||
install_plugin Capistrano::SCM::Git::WithSubmodules
|
|
||||||
require 'capistrano/npm'
|
|
||||||
require 'capistrano/gulp'
|
|
||||||
require 'airbrussh/capistrano'
|
|
||||||
|
|
||||||
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
|
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"SdkDir": "C:\\sdk",
|
"SdkDir": "C:\\sdk",
|
||||||
"SSH": {
|
"BuildDir": null,
|
||||||
"PrivateKey": null,
|
"PublishDir": "",
|
||||||
"Passphrase": null
|
"PublishUrl": "https://shmyga.ru/repo/tankz",
|
||||||
}
|
"Develop": false,
|
||||||
|
"Key": {
|
||||||
|
"store": "keystore.jks",
|
||||||
|
"pass": null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"SdkDir": "/home/holop/sdk",
|
|
||||||
"SSH": {
|
|
||||||
"PrivateKey": null,
|
|
||||||
"Passphrase": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
set :config_role, :app
|
|
||||||
set :config_path, -> { release_path }
|
|
||||||
set :config_type, 'json'
|
|
||||||
|
|
||||||
|
|
||||||
namespace :config do
|
|
||||||
task :setup do
|
|
||||||
config_role = fetch(:config_role)
|
|
||||||
config_path = fetch(:config_path)
|
|
||||||
config_type = fetch(:config_type)
|
|
||||||
on roles(config_role) do |server|
|
|
||||||
# stage = fetch(:stage)
|
|
||||||
execute "cd #{config_path} && cp config.#{server.hostname}.#{config_type} config.#{config_type}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
require_relative 'npm'
|
|
||||||
require_relative 'config'
|
|
||||||
|
|
||||||
app = 'tankz'
|
|
||||||
user = 'holop'
|
|
||||||
|
|
||||||
# git
|
|
||||||
set :application, app
|
|
||||||
set :repo_url, "git@bitbucket.org:infernalgames/#{app}.git"
|
|
||||||
set :user, user
|
|
||||||
set :deploy_to, "/home/#{user}/repo/#{app}"
|
|
||||||
|
|
||||||
# airbrussh
|
|
||||||
set :format, :airbrussh
|
|
||||||
set :format_options, command_output: false
|
|
||||||
|
|
||||||
# config
|
|
||||||
before 'deploy:updated', 'config:setup'
|
|
||||||
|
|
||||||
# npm
|
|
||||||
set :npm_target_path, -> { "/home/#{fetch(:user)}/npm" }
|
|
||||||
set :npm_flags, '--silent --no-spin'
|
|
||||||
set :npm_roles, :web
|
|
||||||
set :npm_env_variables, {}
|
|
||||||
|
|
||||||
# gulp
|
|
||||||
set :gulp_target_path, -> { release_path }
|
|
||||||
set :gulp_tasks, 'default'
|
|
||||||
set :gulp_flags, '--no-color'
|
|
||||||
set :gulp_roles, :web
|
|
||||||
before 'deploy:updated', 'gulp'
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
role :app, %w{localhost}
|
|
||||||
role :web, %w{localhost}
|
|
||||||
role :db, %w{localhost}
|
|
||||||
|
|
||||||
set :user, ENV['USER']
|
|
||||||
user = fetch(:user)
|
|
||||||
|
|
||||||
server 'localhost', ssh_options: { port: 22, user: user, forward_agent: true }
|
|
||||||
|
|
||||||
set :tmp_dir, "/home/#{user}/tmp"
|
|
||||||
set :branch, 'master'
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# host = '94.130.110.9'
|
|
||||||
host = 'shmyga.ru'
|
|
||||||
|
|
||||||
role :app, host
|
|
||||||
role :web, host
|
|
||||||
role :db, host
|
|
||||||
|
|
||||||
user = fetch(:user)
|
|
||||||
|
|
||||||
server host, ssh_options: { port: 22, user: user, forward_agent: true }
|
|
||||||
|
|
||||||
set :tmp_dir, "/home/#{user}/tmp"
|
|
||||||
set :branch, 'master'
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
set :npm_path, -> { release_path }
|
|
||||||
|
|
||||||
namespace :npm do
|
|
||||||
task :prepare do
|
|
||||||
npm_roles = fetch(:npm_roles)
|
|
||||||
on roles(npm_roles) do
|
|
||||||
npm_target_path = fetch(:npm_target_path)
|
|
||||||
npm_path = fetch(:npm_path)
|
|
||||||
execute "mkdir -p #{npm_target_path}"
|
|
||||||
execute "cp #{npm_path}/package.json #{npm_target_path}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
task :link do
|
|
||||||
npm_roles = fetch(:npm_roles)
|
|
||||||
on roles(npm_roles) do
|
|
||||||
npm_target_path = fetch(:npm_target_path)
|
|
||||||
npm_path = fetch(:npm_path)
|
|
||||||
execute "ln -s #{npm_target_path}/node_modules #{npm_path}/"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
before 'npm:install', 'npm:prepare'
|
|
||||||
after 'npm:install', 'npm:link'
|
|
||||||
22
docker-compose.yaml
Normal file
22
docker-compose.yaml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: $PROJECT
|
||||||
|
services:
|
||||||
|
builder:
|
||||||
|
container_name: $PROJECT-builder
|
||||||
|
image: infernal-games/$PROJECT-builder
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
secrets:
|
||||||
|
- KEY_STORE
|
||||||
|
- KEY_PASS
|
||||||
|
volumes:
|
||||||
|
- ${SDK_PATH}:/sdk
|
||||||
|
- ${BUILD_PATH}:/app/build
|
||||||
|
- ${TARGET_PATH}:/app/target
|
||||||
|
- ${PUBLISH_PATH}:/app/publish
|
||||||
|
- ./src-gen:/app/src-gen
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
KEY_STORE:
|
||||||
|
file: $KEY_STORE
|
||||||
|
KEY_PASS:
|
||||||
|
environment: KEY_PASS
|
||||||
6
gemfile
6
gemfile
@@ -1,6 +0,0 @@
|
|||||||
source 'https://rubygems.org'
|
|
||||||
gem 'capistrano', '~> 3.7.0'
|
|
||||||
gem 'capistrano-git-with-submodules', '~> 2.0'
|
|
||||||
gem 'capistrano-npm'
|
|
||||||
gem 'capistrano-gulp'
|
|
||||||
gem 'airbrussh', :require => false
|
|
||||||
4
gen.sh
4
gen.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
haxelib run protohx generate protohx.json
|
haxelib run protohx generate protohx.json
|
||||||
haxelib run orm mysql://shmyga:xkbp8jh9z2@localhost:3306/armageddon \
|
haxelib run orm mysql://shmyga:password@localhost:3306/armageddon \
|
||||||
-s src-gen/haxe \
|
-s src-gen/haxe \
|
||||||
-c ru.m.tankz.db \
|
-c ru.m.tankz.db \
|
||||||
-a ru.m.tankz.db
|
-a ru.m.tankz.db
|
||||||
|
|||||||
222
gulpfile.js
222
gulpfile.js
@@ -1,36 +1,214 @@
|
|||||||
"use strict";
|
|
||||||
const os = require('os');
|
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const clean = require('gulp-clean');
|
const gulpClean = require('gulp-clean');
|
||||||
const Sdk = require('./tasks/sdk');
|
|
||||||
const FlashPlayer = require('./tasks/flashplayer');
|
|
||||||
const Config = require('./config.json');
|
const Config = require('./config.json');
|
||||||
const prepare = require('./build/prepare');
|
const packageInfo = require('./package.json');
|
||||||
|
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||||
|
const dateformat = require('dateformat');
|
||||||
|
const argv = require('yargs').argv;
|
||||||
|
const publish = require('./tasks/gulp-publish');
|
||||||
|
|
||||||
//FlashPlayer.VERSION = '25.0.0.171';
|
if (packageInfo.haxe) {
|
||||||
|
Haxe.VERSION = packageInfo.haxe;
|
||||||
|
}
|
||||||
|
|
||||||
if (Config.SdkDir) {
|
if (Config.SdkDir) {
|
||||||
Sdk.dir = Config.SdkDir;
|
Sdk.dir = Config.SdkDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.clean = () => {
|
if (Config.BuildDir) {
|
||||||
return gulp.src('target/*', {read: false}).pipe(clean());
|
Haxe.buildDir = Config.BuildDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.clean = function clean() {
|
||||||
|
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
||||||
};
|
};
|
||||||
|
|
||||||
const merge = (value) => {
|
exports.setup = function setup() {
|
||||||
if (typeof value === 'string') {
|
const builder = Project.Builder.new(
|
||||||
value = require(value);
|
client.config,
|
||||||
}
|
Project.Platform.ANDROID,
|
||||||
for (let key in value) if (value.hasOwnProperty(key)) {
|
client.buildSystem,
|
||||||
exports[key] = value[key];
|
);
|
||||||
}
|
return builder.prepare();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.update = prepare.update;
|
exports.generate = function generate() {
|
||||||
merge('./build/prepare');
|
return exports.setup().then(() =>
|
||||||
merge('./build/client');
|
new Haxe()
|
||||||
merge('./build/editor');
|
.haxelib(["run", "protohx", "generate", "protohx.json"])
|
||||||
merge('./build/server');
|
.then(({ stdout }) => {
|
||||||
|
if (stdout.indexOf("FAIL") > -1) {
|
||||||
|
throw stdout;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* base config
|
||||||
|
*/
|
||||||
|
const config = new Project.Config({
|
||||||
|
meta: {
|
||||||
|
title: 'Tank\'z',
|
||||||
|
filename: 'tankz',
|
||||||
|
icon: 'src/client/resources/icon.png',
|
||||||
|
pack: 'ru.m.tankz',
|
||||||
|
author: 'shmyga <shmyga.z@gmail.com>',
|
||||||
|
company: 'MegaLoMania',
|
||||||
|
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
|
||||||
|
},
|
||||||
|
key: Config.Key,
|
||||||
|
libs: packageInfo.haxeDependencies,
|
||||||
|
sources: [
|
||||||
|
'src/common/haxe',
|
||||||
|
'src-gen/haxe',
|
||||||
|
],
|
||||||
|
assets: [
|
||||||
|
'src/common/resources/config',
|
||||||
|
],
|
||||||
|
flags: [
|
||||||
|
'proto_debug',
|
||||||
|
],
|
||||||
|
macros: [
|
||||||
|
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`,
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
exports.default = gulp.series(exports.clean, exports.client);
|
const host = argv.host || 'localhost';
|
||||||
|
const port = argv.port || 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* client
|
||||||
|
*/
|
||||||
|
const client = new Project(
|
||||||
|
Project.BuildSystem.OPENFL,
|
||||||
|
[
|
||||||
|
Project.Platform.FLASH,
|
||||||
|
Project.Platform.HTML5,
|
||||||
|
Project.Platform.LINUX,
|
||||||
|
Project.Platform.WINDOWS,
|
||||||
|
Project.Platform.ANDROID,
|
||||||
|
],
|
||||||
|
config.branch({
|
||||||
|
name: 'client',
|
||||||
|
sources: [
|
||||||
|
'src/client/haxe',
|
||||||
|
],
|
||||||
|
main: 'ru.m.tankz.Client',
|
||||||
|
preloader: 'ru.m.tankz.Preloader',
|
||||||
|
assets: [
|
||||||
|
'src/common/resources/level',
|
||||||
|
'src/client/resources',
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
width: 1024,
|
||||||
|
height: 576,
|
||||||
|
},
|
||||||
|
flags: [
|
||||||
|
//'proto_debug',
|
||||||
|
//'dom',
|
||||||
|
//'dev_layout',
|
||||||
|
//'bitmap_text',
|
||||||
|
],
|
||||||
|
macros: [
|
||||||
|
`CompilationOption.set('host','${host}')`,
|
||||||
|
`CompilationOption.set('port',${port})`,
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
).bind(module, gulp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* editor
|
||||||
|
*/
|
||||||
|
const editor = new Project(
|
||||||
|
Project.BuildSystem.OPENFL,
|
||||||
|
[
|
||||||
|
Project.Platform.FLASH,
|
||||||
|
Project.Platform.HTML5,
|
||||||
|
Project.Platform.LINUX,
|
||||||
|
],
|
||||||
|
config.branch({
|
||||||
|
name: 'editor',
|
||||||
|
sources: [
|
||||||
|
'src/client/haxe',
|
||||||
|
'src/editor/haxe',
|
||||||
|
],
|
||||||
|
main: 'ru.m.tankz.editor.Editor',
|
||||||
|
preloader: 'ru.m.tankz.Preloader',
|
||||||
|
assets: [
|
||||||
|
'src/client/resources',
|
||||||
|
'src/editor/resources',
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
filename: 'editor',
|
||||||
|
pack: 'ru.m.tankz.editor',
|
||||||
|
width: 1024,
|
||||||
|
height: 768,
|
||||||
|
},
|
||||||
|
flags: [
|
||||||
|
//'dev_layout',
|
||||||
|
]
|
||||||
|
})
|
||||||
|
).bind(module, gulp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* server
|
||||||
|
*/
|
||||||
|
const server = new Project(
|
||||||
|
Project.BuildSystem.HAXE,
|
||||||
|
Project.Platform.CPP,
|
||||||
|
config.branch({
|
||||||
|
name: 'server',
|
||||||
|
sources: ['src/server/haxe'],
|
||||||
|
main: 'ru.m.tankz.server.Server',
|
||||||
|
assets: [
|
||||||
|
'src/common/resources/level',
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
).bind(module, gulp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* publish
|
||||||
|
*/
|
||||||
|
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default
|
||||||
|
*/
|
||||||
|
const defaultSeries = [
|
||||||
|
exports.clean,
|
||||||
|
exports.generate,
|
||||||
|
module.exports['client:flash:build'],
|
||||||
|
module.exports['client:flash:html'],
|
||||||
|
module.exports['client:html5:build'],
|
||||||
|
|
||||||
|
module.exports['editor:flash:build'],
|
||||||
|
module.exports['editor:flash:html'],
|
||||||
|
module.exports['editor:html5:build'],
|
||||||
|
|
||||||
|
module.exports['server:cpp:build'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (System.isLinux) {
|
||||||
|
defaultSeries.push(
|
||||||
|
module.exports['client:linux:build'],
|
||||||
|
module.exports['client:linux:archive'],
|
||||||
|
module.exports['client:linux:deb'],
|
||||||
|
|
||||||
|
module.exports['client:android:build'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.isWindows) {
|
||||||
|
defaultSeries.push(
|
||||||
|
module.exports['client:windows:build'],
|
||||||
|
module.exports['client:windows:archive'],
|
||||||
|
module.exports['client:windows:installer'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultSeries.push(
|
||||||
|
exports.publish,
|
||||||
|
);
|
||||||
|
|
||||||
|
module.exports.default = gulp.series(defaultSeries);
|
||||||
|
|||||||
5
hxformat.json
Normal file
5
hxformat.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"indentation": {
|
||||||
|
"character": " "
|
||||||
|
}
|
||||||
|
}
|
||||||
7374
package-lock.json
generated
Normal file
7374
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@@ -1,42 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.6.0",
|
"version": "0.18.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ansi-colors": "^1.0.1",
|
"dateformat": "^3.0.3",
|
||||||
"async": "^2.6.0",
|
"gulp": "^4.0.0",
|
||||||
"babel-core": "^6.26.0",
|
"gulp-add": "0.0.2",
|
||||||
"babel-preset-es2015": "^6.24.1",
|
"gulp-clean": "^0.4.0",
|
||||||
"download": "^6.2.5",
|
"gulp-haxetool": "^0.1.9",
|
||||||
"fancy-log": "^1.3.2",
|
"yargs": "^13.2.4"
|
||||||
"fs-extra": "^5.0.0",
|
|
||||||
"got": "^8.0.1",
|
|
||||||
"gulp": "github:gulpjs/gulp#4.0",
|
|
||||||
"gulp-babel": "^7.0.0",
|
|
||||||
"gulp-clean": "^0.3.2",
|
|
||||||
"gulp-concat": "^2.6.1",
|
|
||||||
"gulp-debian": "^0.1.9",
|
|
||||||
"gulp-run": "^1.7.1",
|
|
||||||
"gulp-template": "^5.0.0",
|
|
||||||
"gulp-uglify": "^3.0.0",
|
|
||||||
"gulp-webserver": "^0.9.1",
|
|
||||||
"plugin-error": "^0.1.2",
|
|
||||||
"progress": "^2.0.0",
|
|
||||||
"promise-streams": "^2.1.1",
|
|
||||||
"rmdir": "^1.2.0",
|
|
||||||
"tar": "^4.2.0",
|
|
||||||
"tmp-file": "^2.0.1",
|
|
||||||
"unzip-stream": "^0.2.1",
|
|
||||||
"vinyl-fs": "^3.0.1",
|
|
||||||
"yargs": "^10.0.3"
|
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"haxeDependencies": {
|
||||||
"lime": "6.0.1",
|
"haxework": "2.1.0",
|
||||||
"openfl": "7.0.0",
|
"lime": "8.0.0",
|
||||||
"promhx": "1.1.0",
|
"openfl": "9.2.0",
|
||||||
|
"hxcpp": "4.2.1",
|
||||||
"protohx": "0.4.6",
|
"protohx": "0.4.6",
|
||||||
"yaml": "1.3.0",
|
"orm": "2.1.0",
|
||||||
"haxework": "git@bitbucket.org:shmyga/haxework.git",
|
"haxe-crypto": "0.0.8",
|
||||||
"orm": "2.1.0"
|
"svg": "1.1.3",
|
||||||
}
|
"formatter": "1.16.0"
|
||||||
|
},
|
||||||
|
"haxe": "4.2.5"
|
||||||
}
|
}
|
||||||
|
|||||||
28
project.xml
28
project.xml
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<project>
|
|
||||||
<meta title="Tank'z" package="ru.m.tankz" version="0.0.0" company="MegaLoMania"/>
|
|
||||||
<app main="ru.m.tankz.Client" path="target" file="tankz"/>
|
|
||||||
<source path="src/common/haxe"/>
|
|
||||||
<source path="src/client/haxe"/>
|
|
||||||
<source path="src-gen/haxe"/>
|
|
||||||
<assets path="src/client/resources" rename="resources" include="*"/>
|
|
||||||
<haxelib name="lime" version="6.0.1"/>
|
|
||||||
<haxelib name="openfl" version="7.0.0"/>
|
|
||||||
<haxelib name="promhx" version="1.1.0"/>
|
|
||||||
<haxelib name="protohx" version="0.4.6"/>
|
|
||||||
<haxelib name="haxework" version="git"/>
|
|
||||||
<haxelib name="yaml" version="1.3.0"/>
|
|
||||||
<window fps="30"/>
|
|
||||||
<window width="1024" height="768" unless="html5"/>
|
|
||||||
<haxeflag name="-D" value="swf-gpu"/>
|
|
||||||
<haxeflag name="-D" value="native-trace"/>
|
|
||||||
<!--<haxeflag name="-D" value="proto_debug"/>-->
|
|
||||||
<haxeflag name="-dce" value="no"/>
|
|
||||||
<haxeflag name="-D" value="dom"/>
|
|
||||||
<!--<template path="src/client/webapp/index_template.html" rename="index.html"/>-->
|
|
||||||
|
|
||||||
<section if="build_editor">
|
|
||||||
<app main="ru.m.tankz.editor.Editor" path="target" file="editor"/>
|
|
||||||
<source path="src/editor/haxe"/>
|
|
||||||
</section>
|
|
||||||
</project>
|
|
||||||
@@ -3,9 +3,10 @@
|
|||||||
"protoFiles": [
|
"protoFiles": [
|
||||||
"src/common/proto/core.proto",
|
"src/common/proto/core.proto",
|
||||||
"src/common/proto/game.proto",
|
"src/common/proto/game.proto",
|
||||||
|
"src/common/proto/room.proto",
|
||||||
"src/common/proto/pack.proto"
|
"src/common/proto/pack.proto"
|
||||||
],
|
],
|
||||||
"cleanOut": true,
|
"cleanOut": true,
|
||||||
"haxeOut": "src-gen/haxe",
|
"haxeOut": "src-gen/haxe",
|
||||||
"javaOut": null
|
"javaOut": null
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
resources/11756.png
Normal file
BIN
resources/11756.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
resources/60016.png
Normal file
BIN
resources/60016.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
7
scripts/build
Executable file
7
scripts/build
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname $(dirname "$0"))" || exit
|
||||||
|
|
||||||
|
source .env
|
||||||
|
mkdir -p "$SDK_PATH" "$PUBLISH_PATH" "$BUILD_PATH" "$TARGET_PATH" "src-gen"
|
||||||
|
docker compose run --rm --user $(id -u):$(id -g) --build --remove-orphans builder
|
||||||
12
scripts/format
Executable file
12
scripts/format
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname $(dirname "$0"))" || exit
|
||||||
|
|
||||||
|
source $NEKO_SDK/activate
|
||||||
|
source $HAXE_SDK/activate
|
||||||
|
haxelib install formatter
|
||||||
|
haxelib run formatter \
|
||||||
|
-s ./src/common/haxe \
|
||||||
|
-s ./src/client/haxe \
|
||||||
|
-s ./src/server/haxe \
|
||||||
|
-s ./src/editor/haxe
|
||||||
13
scripts/lint
Executable file
13
scripts/lint
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname $(dirname "$0"))" || exit
|
||||||
|
|
||||||
|
source $NEKO_SDK/activate
|
||||||
|
source $HAXE_SDK/activate
|
||||||
|
haxelib install formatter
|
||||||
|
haxelib run formatter \
|
||||||
|
--check \
|
||||||
|
-s ./src/common/haxe \
|
||||||
|
-s ./src/client/haxe \
|
||||||
|
-s ./src/server/haxe \
|
||||||
|
-s ./src/editor/haxe
|
||||||
32
scripts/publish
Executable file
32
scripts/publish
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname $(dirname "$0"))" || exit
|
||||||
|
source .env
|
||||||
|
|
||||||
|
VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+\.\d+')
|
||||||
|
|
||||||
|
curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" -X DELETE \
|
||||||
|
"${REPO}/generic/${PROJECT}/${VERSION}"
|
||||||
|
|
||||||
|
PACKAGES=(
|
||||||
|
"android/${PROJECT}_${VERSION}.apk"
|
||||||
|
"debian/${PROJECT}_${VERSION}_all.deb"
|
||||||
|
"archive/${PROJECT}_${VERSION}_linux.tar.gz"
|
||||||
|
)
|
||||||
|
|
||||||
|
for PACKAGE in "${PACKAGES[@]}"
|
||||||
|
do
|
||||||
|
PACKAGE_NAME=$(basename "$PACKAGE")
|
||||||
|
echo "publish: $PACKAGE"
|
||||||
|
curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" \
|
||||||
|
--upload-file "${PUBLISH_PATH}/${PACKAGE}" \
|
||||||
|
"${REPO}/generic/${PROJECT}/${VERSION}/${PACKAGE_NAME}"
|
||||||
|
|
||||||
|
if [[ "$PACKAGE" == *.deb ]]; then
|
||||||
|
curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" -X DELETE \
|
||||||
|
"${REPO}/debian/pool/noble/main/${PROJECT}/${VERSION}/all"
|
||||||
|
curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" \
|
||||||
|
--upload-file "${PUBLISH_PATH}/${PACKAGE}" \
|
||||||
|
"${REPO}/debian/pool/noble/main/upload"
|
||||||
|
fi
|
||||||
|
done
|
||||||
5
scripts/setup
Executable file
5
scripts/setup
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname $(dirname "$0"))" || exit
|
||||||
|
|
||||||
|
npm ci
|
||||||
31
sql/init.sql
31
sql/init.sql
@@ -1,31 +0,0 @@
|
|||||||
-- mysql -u shmyga -pxkbp8jh9z2 armageddon --protocol TCP
|
|
||||||
CREATE USER 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';
|
|
||||||
|
|
||||||
DROP DATABASE IF EXISTS armageddon;
|
|
||||||
CREATE DATABASE IF NOT EXISTS armageddon;
|
|
||||||
GRANT ALL ON armageddon.* TO 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';
|
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS armageddon.account;
|
|
||||||
CREATE TABLE IF NOT EXISTS armageddon.account (
|
|
||||||
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
|
||||||
login VARCHAR(255) UNIQUE,
|
|
||||||
password VARCHAR(32)
|
|
||||||
);
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS armageddon.person;
|
|
||||||
CREATE TABLE IF NOT EXISTS armageddon.person (
|
|
||||||
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
|
||||||
account_id INT UNSIGNED NOT NULL,
|
|
||||||
name VARCHAR(255),
|
|
||||||
|
|
||||||
CONSTRAINT person_2_account FOREIGN KEY (account_id) REFERENCES armageddon.account(id)
|
|
||||||
MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO armageddon.account (id,login,password) VALUES(1,'shmyga', 'd48cc4eb42c058869ae90daef9606e43');
|
|
||||||
INSERT INTO armageddon.person (id,account_id,name) VALUES(1,1,'-=Shmyga=-');
|
|
||||||
|
|
||||||
INSERT INTO armageddon.account (id,login,password) VALUES(2,'a', md5('a'));
|
|
||||||
INSERT INTO armageddon.person (id,account_id,name) VALUES(2,2,'a');
|
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Encoding=UTF-8
|
|
||||||
Type=Application
|
|
||||||
Comment=Tank'z game
|
|
||||||
Exec=bash -c 'cd "/usr/share/tankz" && ./tankz'
|
|
||||||
Icon=/usr/share/tankz/resources/images/tank/player/tank_p3_0-0.png
|
|
||||||
Name=Tank'z
|
|
||||||
Categories=Game
|
|
||||||
Terminal=false
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "state", "@type": "haxework.gui.LabelView", "@style": "label",
|
|
||||||
"pWidth": 100, "height": 20
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "render", "@type": "ru.m.tankz.render.Render",
|
|
||||||
"contentSize": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id":"levels", "@type":"haxework.gui.list.VListView<Int>",
|
|
||||||
"factory": "@class:ru.m.tankz.view.frames.list.LevelView",
|
|
||||||
"pWidth":100,
|
|
||||||
"pHeight":100,
|
|
||||||
"paddings":10,
|
|
||||||
"scroll":{
|
|
||||||
"@type":"haxework.gui.list.VScrollView",
|
|
||||||
"width":10, "pHeight":100,
|
|
||||||
"skin":{"@type":"haxework.gui.list.VScrollSkin"}
|
|
||||||
},
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ColorSkin",
|
|
||||||
"color": "0x000000", "alpha": 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.ImageView",
|
|
||||||
"image": "@asset:image:resources/images/logo/logo.png",
|
|
||||||
"contentSize": true, "bottomMargin": 15
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView", "@style": "label",
|
|
||||||
"fontSize": 20, "topMargin": 15,
|
|
||||||
"contentSize": true,
|
|
||||||
"text": "Classic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "classic_1p",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "1 Player",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "classic_2p",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "2 Player",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView", "@style": "label",
|
|
||||||
"fontSize": 20, "topMargin": 15,
|
|
||||||
"contentSize": true,
|
|
||||||
"text": "DotA"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dota_1p",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "1 Player",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dota_2p_coop",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "2 COOP",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dota_2p_vs",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "2 VS",
|
|
||||||
"@style": "button"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"@type": "haxework.gui.VGroupView",
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher",
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.BitmapSkin",
|
|
||||||
"image": "@asset:image:resources/images/background.png",
|
|
||||||
"fillType": "REPEAT"
|
|
||||||
},
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "start",
|
|
||||||
"@type": "ru.m.tankz.view.frames.StartFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "level",
|
|
||||||
"@type": "ru.m.tankz.view.frames.LevelFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "game",
|
|
||||||
"@type": "ru.m.tankz.view.frames.GameFrame"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"inLayout": false,
|
|
||||||
"contentSize": true,
|
|
||||||
"vAlign": "BOTTOM",
|
|
||||||
"hAlign": "RIGHT",
|
|
||||||
"text": "@res:text:version",
|
|
||||||
"@style": "label"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"level": {
|
|
||||||
"width": 440, "height": 44,
|
|
||||||
"margins": 5,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "label",
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"pWidth": 100, "pHeight": 100, "text": "",
|
|
||||||
"@style": "label"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ColorSkin",
|
|
||||||
"color": "0x000000", "alpha": 0.2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
"button": {
|
|
||||||
"width":250, "height":60,
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ButtonBitmapSkin",
|
|
||||||
"upImage": "@asset:image:resources/images/control/button_normal.png",
|
|
||||||
"downImage": "@asset:image:resources/images/control/button_down.png",
|
|
||||||
"overImage": "@asset:image:resources/images/control/button_over.png",
|
|
||||||
"fillType": "NINEPATH"
|
|
||||||
},
|
|
||||||
"fontFamily":"@res:text:font", "fontEmbed":true, "fontColor":"0xE7E0BB", "fontSize":20
|
|
||||||
},
|
|
||||||
|
|
||||||
"label": {
|
|
||||||
"fontColor": "0xffffff",
|
|
||||||
"fontEmbed": false,
|
|
||||||
"fontFamily": "@res:text:fontName",
|
|
||||||
"fontSize": 16,
|
|
||||||
"shadowColor": "0x000000"
|
|
||||||
},
|
|
||||||
|
|
||||||
"input": {
|
|
||||||
"fontColor": "0xffffff",
|
|
||||||
"fontEmbed": false,
|
|
||||||
"fontFamily": "@res:text:fontName",
|
|
||||||
"fontSize": 16,
|
|
||||||
"shadowColor": "0x000000",
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ColorSkin",
|
|
||||||
"color": "0x000000"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
44
src/client/haxe/ru/m/Device.hx
Normal file
44
src/client/haxe/ru/m/Device.hx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package ru.m;
|
||||||
|
|
||||||
|
@:enum abstract Platform(String) from String to String {
|
||||||
|
var ANDROID = "android";
|
||||||
|
var LINUX = "linux";
|
||||||
|
var WINDOWS = "windows";
|
||||||
|
}
|
||||||
|
|
||||||
|
class Device {
|
||||||
|
|
||||||
|
public static var platform(get, null):Platform;
|
||||||
|
|
||||||
|
private static function get_platform():Platform {
|
||||||
|
#if android
|
||||||
|
return ANDROID;
|
||||||
|
#elseif linux
|
||||||
|
return LINUX;
|
||||||
|
#elseif windows
|
||||||
|
return WINDOWS;
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
private static var MOBILES(default, never):Array<String> = [
|
||||||
|
"Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function isMobile():Bool {
|
||||||
|
#if android
|
||||||
|
return true;
|
||||||
|
#elseif js
|
||||||
|
var userAgent = js.Browser.navigator.userAgent;
|
||||||
|
for (mobile in MOBILES) {
|
||||||
|
if (userAgent.indexOf(mobile) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,73 +1,56 @@
|
|||||||
package ru.m.animate;
|
package ru.m.animate;
|
||||||
|
|
||||||
import flash.display.PixelSnapping;
|
|
||||||
import haxe.Timer;
|
|
||||||
import flash.display.Bitmap;
|
import flash.display.Bitmap;
|
||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
|
import flash.display.PixelSnapping;
|
||||||
|
|
||||||
|
typedef Frame = {
|
||||||
|
var image:BitmapData;
|
||||||
|
var length:Int;
|
||||||
|
}
|
||||||
|
|
||||||
class Animate extends Bitmap {
|
class Animate extends Bitmap {
|
||||||
|
|
||||||
private static var timer:Timer;
|
public var playing(default, default):Bool;
|
||||||
private static var instances:Array<Animate> = [];
|
public var frames(default, set):Array<Frame>;
|
||||||
|
|
||||||
private static function init():Void {
|
private var sequence:Array<BitmapData>;
|
||||||
if (timer == null) {
|
|
||||||
timer = new Timer(30);
|
|
||||||
timer.run = updateAll;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function updateAll():Void {
|
|
||||||
for (instance in instances) {
|
|
||||||
if (instance.playing) {
|
|
||||||
instance.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static var a = new BitmapData(1, 1);
|
|
||||||
|
|
||||||
public var playing(default, set):Bool;
|
|
||||||
public var frames(default, set):Array<BitmapData>;
|
|
||||||
private var index:Int;
|
private var index:Int;
|
||||||
|
|
||||||
public function new(?frames:Array<BitmapData>) {
|
@:provide private static var manager:AnimateManager;
|
||||||
|
|
||||||
|
public function new(?frames:Array<Frame>) {
|
||||||
super(null, PixelSnapping.AUTO, true);
|
super(null, PixelSnapping.AUTO, true);
|
||||||
this.frames = frames == null ? [] : frames;
|
this.frames = frames == null ? [] : frames;
|
||||||
init();
|
manager.add(this);
|
||||||
instances.push(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_frames(value:Array<BitmapData>):Array<BitmapData> {
|
public function set_frames(value:Array<Frame>):Array<Frame> {
|
||||||
|
sequence = [];
|
||||||
|
index = 0;
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
frames = value;
|
frames = value;
|
||||||
bitmapData = frames[0];
|
for (frame in frames) {
|
||||||
index = 0;
|
sequence = sequence.concat([for (i in 0...frame.length) frame.image]);
|
||||||
|
}
|
||||||
|
bitmapData = sequence[0];
|
||||||
|
} else {
|
||||||
|
bitmapData = null;
|
||||||
}
|
}
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_playing(value:Bool):Bool {
|
public function update():Void {
|
||||||
if (playing != value) {
|
if (++index >= sequence.length) {
|
||||||
playing = value;
|
|
||||||
}
|
|
||||||
return playing;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update():Void {
|
|
||||||
if (++index >= frames.length) {
|
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
var nextBitmapData = frames[index];
|
var nextBitmapData = sequence[index];
|
||||||
x -= (nextBitmapData.width - bitmapData.width) / 2;
|
x -= (nextBitmapData.width - bitmapData.width) / 2;
|
||||||
y -= (nextBitmapData.height - bitmapData.height) / 2;
|
y -= (nextBitmapData.height - bitmapData.height) / 2;
|
||||||
bitmapData = nextBitmapData;
|
bitmapData = nextBitmapData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dispose():Void {
|
public function dispose():Void {
|
||||||
if (instances.indexOf(this) > -1) {
|
manager.remove(this);
|
||||||
instances.remove(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/client/haxe/ru/m/animate/AnimateManager.hx
Normal file
34
src/client/haxe/ru/m/animate/AnimateManager.hx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package ru.m.animate;
|
||||||
|
|
||||||
|
@:provide class AnimateManager {
|
||||||
|
public var playing(default, default):Bool;
|
||||||
|
|
||||||
|
private var timer:Timer;
|
||||||
|
private var animations:Array<Animate>;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
animations = [];
|
||||||
|
timer = new Timer(30);
|
||||||
|
timer.run = update;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update():Void {
|
||||||
|
if (playing) {
|
||||||
|
for (animation in animations) {
|
||||||
|
if (animation.playing) {
|
||||||
|
animation.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(animate:Animate):Void {
|
||||||
|
animations.push(animate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove(animate:Animate):Void {
|
||||||
|
if (animations.indexOf(animate) > -1) {
|
||||||
|
animations.remove(animate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,26 @@
|
|||||||
package ru.m.animate;
|
package ru.m.animate;
|
||||||
|
|
||||||
import promhx.Deferred;
|
import promhx.Deferred;
|
||||||
import flash.display.BitmapData;
|
|
||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
|
|
||||||
|
|
||||||
class OnceAnimate extends Animate {
|
class OnceAnimate extends Animate {
|
||||||
|
|
||||||
private var deferred:Deferred<Animate>;
|
private var deferred:Deferred<Animate>;
|
||||||
|
|
||||||
public function new(frames:Array<BitmapData>) {
|
|
||||||
super(frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function play():Promise<Animate> {
|
public function play():Promise<Animate> {
|
||||||
deferred = new Deferred();
|
deferred = new Deferred();
|
||||||
playing = true;
|
playing = true;
|
||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
override private function update():Void {
|
override public function update():Void {
|
||||||
super.update();
|
super.update();
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
playing = false;
|
playing = false;
|
||||||
if (deferred != null) {
|
if (deferred != null) {
|
||||||
deferred.resolve(this);
|
deferred.resolve(this);
|
||||||
}
|
}
|
||||||
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/client/haxe/ru/m/control/ControlBus.hx
Normal file
43
src/client/haxe/ru/m/control/ControlBus.hx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
import hw.signal.Signal;
|
||||||
|
import ru.m.control.IControlBus;
|
||||||
|
|
||||||
|
class ControlBus implements IControlBus {
|
||||||
|
|
||||||
|
private static inline var TAG = "control";
|
||||||
|
|
||||||
|
public var devices(default, null):Array<IControlDevice>;
|
||||||
|
|
||||||
|
public var signal(default, null):Signal3<DeviceType, DeviceAction, Bool>;
|
||||||
|
public var devicesSignal(default, null):Signal<Array<IControlDevice>>;
|
||||||
|
|
||||||
|
private var connections:Map<DeviceType, DeviceAction->Bool->Void>;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
devices = [];
|
||||||
|
signal = new Signal3();
|
||||||
|
devicesSignal = new Signal();
|
||||||
|
connections = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function connect(device:IControlDevice):Void {
|
||||||
|
var connector = function(action:DeviceAction, on:Bool):Void {
|
||||||
|
//L.d("TAG", '${device.type}, ${action}, ${on}');
|
||||||
|
signal.emit(device.type, action, on);
|
||||||
|
}
|
||||||
|
connections.set(device.type, connector);
|
||||||
|
device.signal.connect(connector);
|
||||||
|
devices.push(device);
|
||||||
|
devicesSignal.emit(devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disconnect(device:IControlDevice):Void {
|
||||||
|
if (connections.exists(device.type)) {
|
||||||
|
device.signal.disconnect(connections.get(device.type));
|
||||||
|
connections.remove(device.type);
|
||||||
|
devices.remove(device);
|
||||||
|
devicesSignal.emit(devices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/client/haxe/ru/m/control/DeviceAction.hx
Normal file
8
src/client/haxe/ru/m/control/DeviceAction.hx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
import ru.m.geom.Direction;
|
||||||
|
|
||||||
|
enum DeviceAction {
|
||||||
|
DIRECTION(direction:Direction);
|
||||||
|
KEY(code:Int);
|
||||||
|
}
|
||||||
8
src/client/haxe/ru/m/control/DeviceType.hx
Normal file
8
src/client/haxe/ru/m/control/DeviceType.hx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
enum DeviceType {
|
||||||
|
NONE;
|
||||||
|
KEYBOARD;
|
||||||
|
SCREEN;
|
||||||
|
GAMEPAD(id:Int);
|
||||||
|
}
|
||||||
13
src/client/haxe/ru/m/control/IControlBus.hx
Normal file
13
src/client/haxe/ru/m/control/IControlBus.hx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
import hw.signal.Signal;
|
||||||
|
|
||||||
|
interface IControlBus {
|
||||||
|
public var devices(default, null):Array<IControlDevice>;
|
||||||
|
|
||||||
|
public var signal(default, null):Signal3<DeviceType, DeviceAction, Bool>;
|
||||||
|
public var devicesSignal(default, null):Signal<Array<IControlDevice>>;
|
||||||
|
|
||||||
|
public function connect(device:IControlDevice):Void;
|
||||||
|
public function disconnect(device:IControlDevice):Void;
|
||||||
|
}
|
||||||
10
src/client/haxe/ru/m/control/IControlDevice.hx
Normal file
10
src/client/haxe/ru/m/control/IControlDevice.hx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
import hw.signal.Signal;
|
||||||
|
|
||||||
|
interface IControlDevice {
|
||||||
|
public var type(default, null):DeviceType;
|
||||||
|
public var signal(default, null):Signal2<DeviceAction, Bool>;
|
||||||
|
|
||||||
|
public function dispose():Void;
|
||||||
|
}
|
||||||
62
src/client/haxe/ru/m/control/JoystickDevice.hx
Normal file
62
src/client/haxe/ru/m/control/JoystickDevice.hx
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
import hw.signal.Signal;
|
||||||
|
import lime.ui.Joystick;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.control.DeviceType;
|
||||||
|
import ru.m.geom.Direction;
|
||||||
|
|
||||||
|
class JoystickDevice implements IControlDevice {
|
||||||
|
|
||||||
|
public var type(default, null):DeviceType;
|
||||||
|
public var signal(default, null):Signal2<DeviceAction, Bool>;
|
||||||
|
|
||||||
|
private var joystick:Joystick;
|
||||||
|
private var axisState:Map<Int, Direction>;
|
||||||
|
|
||||||
|
public function new(joystick:Joystick) {
|
||||||
|
this.joystick = joystick;
|
||||||
|
type = GAMEPAD(joystick.id);
|
||||||
|
signal = new Signal2();
|
||||||
|
axisState = new Map();
|
||||||
|
joystick.onButtonDown.add(onButtonDown);
|
||||||
|
joystick.onButtonUp.add(onButtonUp);
|
||||||
|
joystick.onAxisMove.add(onAxisMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onButtonDown(code:Int):Void {
|
||||||
|
signal.emit(KEY(code), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onButtonUp(code:Int):Void {
|
||||||
|
signal.emit(KEY(code), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onAxisMove(axis:Int, position:Float):Void {
|
||||||
|
var direction:Direction = switch [axis, position] {
|
||||||
|
case [0, 1]: Direction.RIGHT;
|
||||||
|
case [0, -1]: Direction.LEFT;
|
||||||
|
case [1, 1]: Direction.BOTTOM;
|
||||||
|
case [1, -1]: Direction.TOP;
|
||||||
|
case _: null;
|
||||||
|
}
|
||||||
|
if (direction != null) {
|
||||||
|
axisState.set(axis, direction);
|
||||||
|
signal.emit(DIRECTION(direction), true);
|
||||||
|
} else if (position == 0) {
|
||||||
|
if (axisState.exists(axis)) {
|
||||||
|
signal.emit(DIRECTION(axisState.get(axis)), false);
|
||||||
|
axisState.remove(axis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispose():Void {
|
||||||
|
if (joystick != null) {
|
||||||
|
joystick.onButtonDown.remove(onButtonDown);
|
||||||
|
joystick.onButtonUp.remove(onButtonUp);
|
||||||
|
joystick.onAxisMove.remove(onAxisMove);
|
||||||
|
joystick = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/client/haxe/ru/m/control/KeyboardDevice.hx
Normal file
38
src/client/haxe/ru/m/control/KeyboardDevice.hx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package ru.m.control;
|
||||||
|
|
||||||
|
import flash.display.Stage;
|
||||||
|
import flash.events.KeyboardEvent;
|
||||||
|
import hw.signal.Signal;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
|
||||||
|
class KeyboardDevice implements IControlDevice {
|
||||||
|
|
||||||
|
public var type(default, null):DeviceType;
|
||||||
|
public var signal(default, null):Signal2<DeviceAction, Bool>;
|
||||||
|
|
||||||
|
private var stage:Stage;
|
||||||
|
|
||||||
|
public function new(stage:Stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
type = DeviceType.KEYBOARD;
|
||||||
|
signal = new Signal2();
|
||||||
|
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
|
||||||
|
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onKeyDown(event:KeyboardEvent):Void {
|
||||||
|
signal.emit(KEY(event.keyCode), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onKeyUp(event:KeyboardEvent):Void {
|
||||||
|
signal.emit(KEY(event.keyCode), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispose():Void {
|
||||||
|
if (stage != null) {
|
||||||
|
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
|
||||||
|
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
|
||||||
|
stage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package ru.m.display;
|
||||||
|
|
||||||
|
import flash.display.DisplayObject;
|
||||||
|
import flash.display.DisplayObjectContainer;
|
||||||
|
|
||||||
|
class DisplayObjectContainerExtender {
|
||||||
|
|
||||||
|
public static function childrenIterator():Iterator<DisplayObject> {
|
||||||
|
throw "Not implemented";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function removeChildSafety(self:DisplayObjectContainer, child:DisplayObject):DisplayObject {
|
||||||
|
if (self.contains(child)) {
|
||||||
|
return self.removeChild(child);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function containsRecursivle(child:DisplayObject):Bool {
|
||||||
|
throw "Not implemented";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package ru.m.draw;
|
|
||||||
|
|
||||||
import flash.geom.ColorTransform;
|
|
||||||
import flash.geom.Rectangle;
|
|
||||||
import flash.display.BitmapData;
|
|
||||||
|
|
||||||
|
|
||||||
class BitmapUtil {
|
|
||||||
|
|
||||||
public static function colorize(data: BitmapData, color: Color):BitmapData {
|
|
||||||
if (color.zero) return data;
|
|
||||||
var result = data.clone();
|
|
||||||
var transform = new ColorTransform(color.red / 255, color.green / 255, color.blue / 255, 1, 0, 0, 0, 0);
|
|
||||||
result.colorTransform(new Rectangle(0, 0, result.width, result.height), transform);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package ru.m.draw;
|
|
||||||
|
|
||||||
abstract Color(Int) {
|
|
||||||
public var alpha(get, never):Int;
|
|
||||||
public var red(get, never):Int;
|
|
||||||
public var green(get, never):Int;
|
|
||||||
public var blue(get, never):Int;
|
|
||||||
public var zero(get, never):Bool;
|
|
||||||
|
|
||||||
public inline function new(value:Int) {
|
|
||||||
this = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function get_alpha():Int {
|
|
||||||
return (this >> 24) & 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function get_red():Int {
|
|
||||||
return (this >> 16) & 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function get_green():Int {
|
|
||||||
return (this >> 8) & 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function get_blue():Int {
|
|
||||||
return this & 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function get_zero():Bool {
|
|
||||||
return this == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@:from
|
|
||||||
static public inline function fromInt(value:Int):Color {
|
|
||||||
return new Color(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@:from
|
|
||||||
static public inline function fromString(value:String):Color {
|
|
||||||
return new Color(Std.parseInt('0x${value.split('#').pop()}'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toString():String {
|
|
||||||
return 'Color(${red},${green},${blue})';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
56
src/client/haxe/ru/m/skin/ButtonSVGSkin.hx
Normal file
56
src/client/haxe/ru/m/skin/ButtonSVGSkin.hx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package ru.m.skin;
|
||||||
|
|
||||||
|
import format.SVG;
|
||||||
|
import hw.color.Color;
|
||||||
|
import hw.view.form.ButtonView;
|
||||||
|
import hw.view.skin.ISkin;
|
||||||
|
|
||||||
|
using StringTools;
|
||||||
|
using hw.color.ColorUtil;
|
||||||
|
|
||||||
|
@:style class ButtonSVGSkin implements ISkin<ButtonView> {
|
||||||
|
|
||||||
|
@:style(null) private var svg:String;
|
||||||
|
@:style(0) private var color:Null<Color>;
|
||||||
|
@:style(false) private var solid:Null<Bool>;
|
||||||
|
|
||||||
|
private var svgs:Map<ButtonState, SVG>;
|
||||||
|
|
||||||
|
public function new(?svg:String, ?color:Color, ?solid:Bool) {
|
||||||
|
this.svg = svg;
|
||||||
|
this.color = color;
|
||||||
|
this.solid = solid;
|
||||||
|
init(solid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function buildSVG(color:Color):SVG {
|
||||||
|
return new SVG(svg.replace("currentColor", '#${color}'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function init(solid:Bool):Void {
|
||||||
|
var color = color;
|
||||||
|
if (solid) {
|
||||||
|
color = color.multiply(1.5);
|
||||||
|
}
|
||||||
|
svgs = new Map();
|
||||||
|
svgs.set(UP, buildSVG(color));
|
||||||
|
svgs.set(DOWN, buildSVG(color.diff(-24)));
|
||||||
|
svgs.set(OVER, buildSVG(color.diff(24)));
|
||||||
|
svgs.set(DISABLED, buildSVG(color.grey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function draw(view:ButtonView):Void {
|
||||||
|
var svg = svgs.get(view.state);
|
||||||
|
var graphics = view.content.graphics;
|
||||||
|
graphics.beginFill(0, 0);
|
||||||
|
graphics.drawRect(0, 0, view.width, view.height);
|
||||||
|
graphics.beginFill(color);
|
||||||
|
if (!solid) {
|
||||||
|
graphics.lineStyle(2, color.multiply(1.5));
|
||||||
|
}
|
||||||
|
// ToDo: padding
|
||||||
|
svg.render(graphics, 0, 0, Std.int(view.width * 0.8), Std.int(view.height * 0.8));
|
||||||
|
graphics.lineStyle();
|
||||||
|
graphics.endFill();
|
||||||
|
}
|
||||||
|
}
|
||||||
200
src/client/haxe/ru/m/tankz/AppTheme.hx
Normal file
200
src/client/haxe/ru/m/tankz/AppTheme.hx
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.text.TextFormatAlign;
|
||||||
|
import hw.color.Color;
|
||||||
|
import hw.view.geometry.Box;
|
||||||
|
import hw.view.geometry.HAlign;
|
||||||
|
import hw.view.geometry.SizeValue;
|
||||||
|
import hw.view.geometry.VAlign;
|
||||||
|
import hw.view.theme.ITheme;
|
||||||
|
import hw.view.theme.Theme;
|
||||||
|
import hw.view.utils.DrawUtil;
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.skin.ButtonSVGSkin;
|
||||||
|
|
||||||
|
using hw.color.ColorUtil;
|
||||||
|
|
||||||
|
class AppTheme extends Theme {
|
||||||
|
|
||||||
|
public static var COLORS(default, never):ThemeColors = {
|
||||||
|
light: 0x95937D,
|
||||||
|
dark: 0x777564,
|
||||||
|
text: 0xE7E0BB,
|
||||||
|
active: 0xFFFF00,
|
||||||
|
}
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super({embed: true}, COLORS, {base: "3h", big: "4h", veryBig: "4.5h"});
|
||||||
|
}
|
||||||
|
|
||||||
|
override private function reload():Void {
|
||||||
|
super.reload();
|
||||||
|
register(new Style("light", [
|
||||||
|
"skin.background.color" => colors.light,
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("dark", [
|
||||||
|
"skin.background.color" => colors.dark,
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("font", [
|
||||||
|
"_" => null,
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
|
register(new Style("text.header", [
|
||||||
|
"font.size" => fontSize.big,
|
||||||
|
"font.align" => TextFormatAlign.CENTER,
|
||||||
|
"skin.background.color" => Color.fromInt(0x000000),
|
||||||
|
"skin.background.alpha" => 0.1,
|
||||||
|
"skin.border.color" => colors.light,
|
||||||
|
"geometry.padding" => Box.fromArray([50, 8]),
|
||||||
|
"geometry.margin" => Box.fromArray([0, 0, 30, 30]),
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
|
register(new Style("button.menu", [
|
||||||
|
"font.size" => fontSize.big,
|
||||||
|
"geometry.padding" => Box.fromFloat(0),
|
||||||
|
"geometry.width" => SizeValue.fromInt(250),
|
||||||
|
"geometry.height" => SizeValue.fromInt(50),
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
|
register(new Style("button.small", [
|
||||||
|
"font.size" => SizeValue.fromString("3h"),
|
||||||
|
"geometry.padding" => Box.fromArray([8, 2]),
|
||||||
|
"skin.round" => 5,
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
|
register(new Style("text.box", [
|
||||||
|
"skin.background.color" => Color.fromInt(0x000000),
|
||||||
|
"skin.background.alpha" => 0.1,
|
||||||
|
"skin.border.color" => colors.light,
|
||||||
|
"geometry.padding" => Box.fromArray([15, 8]),
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
|
register(new Style("text.box.active", [
|
||||||
|
"skin.background.color" => Color.fromInt(0x55aa55),
|
||||||
|
"skin.background.alpha" => 1,
|
||||||
|
"skin.border.color" => Color.fromInt(0x88dd88),
|
||||||
|
], ["text.box"]));
|
||||||
|
|
||||||
|
register(new Style("button.level", [
|
||||||
|
"font.size" => fontSize.big,
|
||||||
|
"geometry.width" => SizeValue.fromString("12h"),
|
||||||
|
"geometry.height" => SizeValue.fromString("12h"),
|
||||||
|
"geometry.padding" => Box.fromFloat(0),
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
|
register(new Style("container", [
|
||||||
|
"geometry.width" => SizeValue.fromString("100%"),
|
||||||
|
"geometry.height" => SizeValue.fromString("100%"),
|
||||||
|
"layout.hAlign" => HAlign.CENTER,
|
||||||
|
"layout.vAlign" => VAlign.MIDDLE,
|
||||||
|
], ["dark"]));
|
||||||
|
|
||||||
|
register(new Style("panel", [
|
||||||
|
"geometry.width" => SizeValue.fromString("100%"),
|
||||||
|
"geometry.padding" => Box.fromArray([20, 10]),
|
||||||
|
"layout.vAlign" => VAlign.MIDDLE,
|
||||||
|
], ["light"]));
|
||||||
|
|
||||||
|
register(new Style("panel_button", [
|
||||||
|
"font.size" => fontSize.big,
|
||||||
|
"geometry.height" => SizeValue.fromString("100%"),
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
|
register(new Style("window", [
|
||||||
|
"geometry.padding" => Box.fromFloat(2),
|
||||||
|
], ["dark", "border"]));
|
||||||
|
|
||||||
|
register(new Style("line", [
|
||||||
|
"geometry.width" => SizeValue.fromString("100%"),
|
||||||
|
"geometry.height" => SizeValue.fromInt(2),
|
||||||
|
], ["border"]));
|
||||||
|
|
||||||
|
register(new Style("window.close", [
|
||||||
|
"skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"), colors.light),
|
||||||
|
"geometry.width" => SizeValue.fromString("8h"),
|
||||||
|
"geometry.height" => SizeValue.fromString("8h"),
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("icon.tank", [
|
||||||
|
"geometry.width" => SizeValue.fromString("6h"),
|
||||||
|
"geometry.height" => SizeValue.fromString("6h"),
|
||||||
|
"skin.fillType" => FillType.CONTAIN,
|
||||||
|
]));
|
||||||
|
|
||||||
|
var green:Color = 0x00ff00;
|
||||||
|
var red:Color = 0xff0000;
|
||||||
|
register(new Style("result.winner", [
|
||||||
|
"skin.border.color" => green,
|
||||||
|
"skin.border.alpha" => 0.5,
|
||||||
|
"skin.border.thickness" => 5,
|
||||||
|
"skin.round" => 10,
|
||||||
|
], ["light"]));
|
||||||
|
register(new Style("result.loser", [
|
||||||
|
"skin.border.color" => red,
|
||||||
|
"skin.border.alpha" => 0.5,
|
||||||
|
"skin.border.thickness" => 5,
|
||||||
|
"skin.round" => 10,
|
||||||
|
], ["light"]));
|
||||||
|
register(new Style("player.winner", [
|
||||||
|
"skin.background.alpha" => 0.2,
|
||||||
|
"skin.background.color" => green,
|
||||||
|
]));
|
||||||
|
register(new Style("player.loser", [
|
||||||
|
"skin.background.alpha" => 0.2,
|
||||||
|
"skin.background.color" => red,
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("button.pack", [
|
||||||
|
"geometry.width" => SizeValue.fromString("35h"),
|
||||||
|
"geometry.height" => SizeValue.fromString("20h"),
|
||||||
|
"geometry.padding" => Box.fromFloat(5),
|
||||||
|
"layout.hAlign" => HAlign.CENTER,
|
||||||
|
"layout.vAlign" => VAlign.MIDDLE,
|
||||||
|
"content.buttonMode" => true,
|
||||||
|
"content.mouseChildren" => false,
|
||||||
|
"skin.round" => 15,
|
||||||
|
], ["border", "light"]));
|
||||||
|
|
||||||
|
register(new Style("button.menu", [
|
||||||
|
"geometry.padding" => Box.fromArray([20, 10]),
|
||||||
|
]));
|
||||||
|
|
||||||
|
registerButton("settings", "cog-solid.svg");
|
||||||
|
registerButton("close", "times-circle-solid.svg");
|
||||||
|
registerButton("next", "arrow-alt-circle-right-solid.svg");
|
||||||
|
registerButton("prev", "arrow-alt-circle-left-solid.svg");
|
||||||
|
registerButton("start", "play-circle-solid.svg");
|
||||||
|
registerButton("login", "sign-in-solid.svg");
|
||||||
|
registerButton("logout", "sign-out-solid.svg");
|
||||||
|
registerButton("bars", "bars-solid.svg");
|
||||||
|
|
||||||
|
registerButton("keyboard", "keyboard-light.svg", true);
|
||||||
|
registerButton("backspace", "backspace-light.svg", true);
|
||||||
|
registerButton("tablet-android-alt", "tablet-android-alt-light.svg", true);
|
||||||
|
|
||||||
|
register(new Style("gamepad", [
|
||||||
|
"skin.color" => colors.text,
|
||||||
|
"skin.activeColor" => colors.active,
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("render", [
|
||||||
|
"skin.background.color" => colors.dark,
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function registerButton(name:String, resource:String, solid:Bool = false):Void {
|
||||||
|
register(new Style('button.$name', [
|
||||||
|
"geometry.width" => SizeValue.fromString("10h"),
|
||||||
|
"geometry.height" => SizeValue.fromString("10h"),
|
||||||
|
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
|
||||||
|
]));
|
||||||
|
register(new Style('button.$name.small', [
|
||||||
|
"geometry.width" => SizeValue.fromString("7h"),
|
||||||
|
"geometry.height" => SizeValue.fromString("7h"),
|
||||||
|
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,100 +1,60 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
import ru.m.tankz.game.ClassicGame;
|
import ru.m.animate.AnimateManager;
|
||||||
import ru.m.tankz.game.DotaGame;
|
import flash.Lib;
|
||||||
import ru.m.tankz.game.Game;
|
import hw.animate.Animate;
|
||||||
import flash.ui.Keyboard;
|
import hw.log.TraceLogger;
|
||||||
import flash.events.KeyboardEvent;
|
import hw.net.manage.LoaderManager;
|
||||||
import flash.text.Font;
|
import hw.view.Root;
|
||||||
import ru.m.tankz.view.frames.StartFrame;
|
import hw.view.popup.PopupManager;
|
||||||
import haxework.log.SocketLogger;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
import haxework.resources.Resources;
|
import ru.m.tankz.storage.SettingsStorage;
|
||||||
import haxework.resources.IResources;
|
import ru.m.tankz.view.ClientView;
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import ru.m.tankz.PacketBuilder;
|
|
||||||
import haxework.log.JSLogger;
|
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
|
||||||
import haxework.provider.Provider;
|
|
||||||
import haxework.gui.frame.FrameSwitcher;
|
|
||||||
import haxework.gui.Root;
|
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.connect.IConnection;
|
|
||||||
import haxework.log.TraceLogger;
|
|
||||||
|
|
||||||
@:template("layout/main.json", "layout/styles.json")
|
|
||||||
class MainView extends VGroupView implements ViewBuilder {}
|
|
||||||
|
|
||||||
class Client implements IConnectionHandler {
|
|
||||||
|
|
||||||
|
class Client {
|
||||||
private static inline var TAG = "Tankz";
|
private static inline var TAG = "Tankz";
|
||||||
|
|
||||||
|
@:provide private static var settings:SettingsStorage;
|
||||||
|
|
||||||
public static function main() {
|
public static function main() {
|
||||||
L.push(new TraceLogger());
|
L.push(new TraceLogger());
|
||||||
#if flash
|
#if flash
|
||||||
L.push(new JSLogger());
|
L.push(new hw.log.JSLogger());
|
||||||
#end
|
#end
|
||||||
#if debug
|
#if debug
|
||||||
L.push(new SocketLogger());
|
//L.push(new hw.log.SocketLogger());
|
||||||
#end
|
#end
|
||||||
|
// ToDo: fix @:provide macro
|
||||||
|
PopupManager;
|
||||||
|
LoaderManager;
|
||||||
|
GameStorage;
|
||||||
|
AnimateManager;
|
||||||
|
//
|
||||||
Const.init();
|
Const.init();
|
||||||
L.d(TAG, "Debug: " + Const.DEBUG);
|
Init.init();
|
||||||
L.i(TAG, "Version: " + Const.VERSION);
|
// TODO:
|
||||||
L.i(TAG, "Build: " + Const.BUILD);
|
// Animate.bind(Lib.current.stage);
|
||||||
new Client();
|
L.d(TAG, 'Debug: ${Const.DEBUG}');
|
||||||
}
|
L.i(TAG, 'Version: ${Const.VERSION}');
|
||||||
|
L.i(TAG, 'Build: ${Const.BUILD}');
|
||||||
|
L.i(TAG, 'Mobile: ${Device.isMobile()}');
|
||||||
private var view:MainView;
|
#if linux
|
||||||
|
LinuxIcon.apply();
|
||||||
public function new() {
|
|
||||||
Provider.setFactory(IResources, Resources);
|
|
||||||
|
|
||||||
var font:Font = Font.enumerateFonts()[0];
|
|
||||||
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
|
||||||
Provider.get(IResources).text.put("version", 'v${Const.VERSION} b${Const.BUILD}');
|
|
||||||
|
|
||||||
Provider.set(IPacketBuilder, new PacketBuilder());
|
|
||||||
#if flash
|
|
||||||
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection("localhost", 5001));
|
|
||||||
#elseif html5
|
|
||||||
Provider.set(IConnection, new ru.m.connect.js.JsConnection("localhost", 5001));
|
|
||||||
#end
|
#end
|
||||||
|
var view:ClientView = new ClientView();
|
||||||
//Provider.get(IConnection).handler.addListener(this);
|
|
||||||
view = new MainView();
|
|
||||||
Provider.set(IFrameSwitcher, view.switcher);
|
|
||||||
Root.bind(view);
|
Root.bind(view);
|
||||||
view.content.stage.stageFocusRect = false;
|
view.launch();
|
||||||
//view.logout.onPress = this;
|
|
||||||
view.switcher.change(StartFrame.ID);
|
|
||||||
|
|
||||||
view.content.stage.addEventListener(KeyboardEvent.KEY_UP, function(event:KeyboardEvent):Void {
|
var fps = new openfl.display.FPS(0, 0, 0x00ff00);
|
||||||
if (event.keyCode == Keyboard.ESCAPE) {
|
fps.visible = settings.displayFPS;
|
||||||
view.switcher.change(StartFrame.ID);
|
Lib.current.addChild(fps);
|
||||||
}
|
|
||||||
|
settings.signal.connect(function(setting) {
|
||||||
|
switch setting {
|
||||||
|
case DISPLAY_FPS(value):
|
||||||
|
fps.visible = value;
|
||||||
|
case _:
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
|
||||||
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
|
||||||
switch (view.id) {
|
|
||||||
case "logout":
|
|
||||||
Provider.get(IConnection).disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onConnected():Void {}
|
|
||||||
|
|
||||||
public function onDisconnected():Void {
|
|
||||||
//view.switcher.change(AuthFrame.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onError(error:Dynamic):Void {
|
|
||||||
L.e(TAG, "", error);
|
|
||||||
//view.switcher.change(AuthFrame.ID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,18 @@ package ru.m.tankz;
|
|||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
import flash.system.Capabilities;
|
import flash.system.Capabilities;
|
||||||
|
|
||||||
|
|
||||||
class Const {
|
class Const {
|
||||||
public static var FPS:Int;
|
public static var FPS:Int;
|
||||||
public static var BUILD:String;
|
public static var BUILD:String;
|
||||||
public static var VERSION:String;
|
public static var VERSION:String;
|
||||||
public static var DEBUG:Bool;
|
public static var NAME:String;
|
||||||
|
public static var DEBUG:Bool;
|
||||||
|
|
||||||
public static function init():Void {
|
public static function init():Void {
|
||||||
FPS = Lib.current.stage.application.config.fps;
|
FPS = Std.parseInt(Lib.current.stage.application.meta.get("fps"));
|
||||||
BUILD = CompilationOption.get("build");
|
BUILD = CompilationOption.get("build");
|
||||||
VERSION = Lib.current.stage.application.config.version;
|
VERSION = Lib.current.stage.application.meta.get("version");
|
||||||
DEBUG = Capabilities.isDebugger;
|
NAME = Lib.current.stage.application.meta.get("name");
|
||||||
}
|
DEBUG = Capabilities.isDebugger;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
78
src/client/haxe/ru/m/tankz/Init.hx
Normal file
78
src/client/haxe/ru/m/tankz/Init.hx
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.Lib;
|
||||||
|
import hw.animate.FadeAnimate;
|
||||||
|
import hw.animate.UnFadeAnimate;
|
||||||
|
import hw.storage.SharedObjectStorage;
|
||||||
|
import hw.view.popup.PopupManager;
|
||||||
|
import hw.view.theme.ITheme;
|
||||||
|
import lime.ui.Gamepad;
|
||||||
|
import lime.ui.Joystick;
|
||||||
|
import ru.m.connect.IConnection;
|
||||||
|
import ru.m.control.ControlBus;
|
||||||
|
import ru.m.control.IControlBus;
|
||||||
|
import ru.m.control.JoystickDevice;
|
||||||
|
import ru.m.control.KeyboardDevice;
|
||||||
|
import ru.m.tankz.bundle.CachedLevelBundle;
|
||||||
|
import ru.m.tankz.bundle.ClientLevelSource;
|
||||||
|
import ru.m.tankz.bundle.ConfigBundle;
|
||||||
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
|
import ru.m.tankz.proto.pack.Request;
|
||||||
|
import ru.m.tankz.proto.pack.Response;
|
||||||
|
import ru.m.update.Updater;
|
||||||
|
|
||||||
|
class Init {
|
||||||
|
|
||||||
|
@:provide static var theme:ITheme;
|
||||||
|
@:provide static var levelBundle:ILevelBundle;
|
||||||
|
@:provide static var configBundle:IConfigBundle;
|
||||||
|
@:provide static var popupManager:PopupManager;
|
||||||
|
@:provide static var connection:IConnection<Request, Response>;
|
||||||
|
@:provide static var bus:IControlBus;
|
||||||
|
@:provide static var updater:Updater;
|
||||||
|
|
||||||
|
private static function buildConnection():IConnection<Request, Response> {
|
||||||
|
var host:String = CompilationOption.get("host");
|
||||||
|
var port:Int = CompilationOption.get("port");
|
||||||
|
L.d("Init", 'connect to $host:$port');
|
||||||
|
#if flash
|
||||||
|
return new ru.m.connect.flash.FlashConnection<Request, Response>(host, port, Response);
|
||||||
|
#elseif html5
|
||||||
|
return new ru.m.connect.js.JsConnection<Request, Response>(host, port + (ru.m.connect.js.JsConnection.isSecured() ? 1 : 0), Response);
|
||||||
|
#else
|
||||||
|
return new ru.m.connect.desktop.DesktopConnection<Request, Response>(host, port, Response);
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function init():Void {
|
||||||
|
theme = new AppTheme();
|
||||||
|
levelBundle = new CachedLevelBundle(new ClientLevelSource(), new SharedObjectStorage());
|
||||||
|
levelBundle.load();
|
||||||
|
configBundle = new ConfigBundle();
|
||||||
|
|
||||||
|
popupManager.showAnimateFactory = function(v) return new UnFadeAnimate(v, 100);
|
||||||
|
popupManager.closeAnimateFactory = function(v) return new FadeAnimate(v, 100);
|
||||||
|
|
||||||
|
connection = buildConnection();
|
||||||
|
|
||||||
|
bus = new ControlBus();
|
||||||
|
bus.connect(new KeyboardDevice(Lib.current.stage));
|
||||||
|
|
||||||
|
updater = new Updater(Const.VERSION, "https://shmyga.ru/repo/tankz/packages.json");
|
||||||
|
|
||||||
|
for (device in Gamepad.devices) {
|
||||||
|
trace('gamepad', device);
|
||||||
|
}
|
||||||
|
Gamepad.onConnect.add(function(device) {
|
||||||
|
trace('connect gamepad', device);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (device in Joystick.devices) {
|
||||||
|
bus.connect(new JoystickDevice(device));
|
||||||
|
}
|
||||||
|
Joystick.onConnect.add(function(device) {
|
||||||
|
bus.connect(new JoystickDevice(device));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/client/haxe/ru/m/tankz/LinuxIcon.hx
Normal file
27
src/client/haxe/ru/m/tankz/LinuxIcon.hx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.display.BitmapData;
|
||||||
|
import flash.filters.ColorMatrixFilter;
|
||||||
|
import flash.geom.Point;
|
||||||
|
import flash.Lib;
|
||||||
|
import openfl.Assets;
|
||||||
|
|
||||||
|
class LinuxIcon {
|
||||||
|
|
||||||
|
private static function prepareIcon(bitmap:BitmapData):BitmapData {
|
||||||
|
var matrix:Array<Float> = [];
|
||||||
|
matrix = matrix.concat([0, 0, 1, 0, 0]);
|
||||||
|
matrix = matrix.concat([0, 1, 0, 0, 0]);
|
||||||
|
matrix = matrix.concat([1, 0, 0, 0, 0]);
|
||||||
|
matrix = matrix.concat([0, 0, 0, 1, 0]);
|
||||||
|
var cmf:ColorMatrixFilter = new ColorMatrixFilter(matrix);
|
||||||
|
var bitmap:BitmapData = bitmap.clone();
|
||||||
|
bitmap.applyFilter(bitmap, bitmap.rect, new Point(0, 0), cmf);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function apply() {
|
||||||
|
var icon = Assets.getBitmapData("resources/icon.png");
|
||||||
|
Lib.current.stage.window.setIcon(prepareIcon(icon).image);
|
||||||
|
}
|
||||||
|
}
|
||||||
142
src/client/haxe/ru/m/tankz/Preloader.hx
Normal file
142
src/client/haxe/ru/m/tankz/Preloader.hx
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.display.Shape;
|
||||||
|
import flash.display.Sprite;
|
||||||
|
import flash.events.Event;
|
||||||
|
import flash.events.ProgressEvent;
|
||||||
|
import flash.Lib;
|
||||||
|
import hw.view.geometry.Size;
|
||||||
|
import ru.m.tankz.AppTheme;
|
||||||
|
|
||||||
|
class Progress extends Sprite {
|
||||||
|
|
||||||
|
public var color(default, set):Int = 0;
|
||||||
|
public var backColor(default, set):Int = 0;
|
||||||
|
public var progress(default, set):Float = 0;
|
||||||
|
public var size(default, set):Size = [0, 0];
|
||||||
|
public var radius(get, null):Float;
|
||||||
|
|
||||||
|
private var maskShape:Shape;
|
||||||
|
private var toRedraw:Bool;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super();
|
||||||
|
maskShape = new Shape();
|
||||||
|
addChild(maskShape);
|
||||||
|
mask = maskShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_radius():Float {
|
||||||
|
return Math.min(size.width, size.height) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_color(value:Int):Int {
|
||||||
|
if (color != value) {
|
||||||
|
color = value;
|
||||||
|
toRedraw = true;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_backColor(value:Int):Int {
|
||||||
|
if (backColor != value) {
|
||||||
|
backColor = value;
|
||||||
|
toRedraw = true;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_progress(value:Float):Float {
|
||||||
|
if (progress != value) {
|
||||||
|
progress = value;
|
||||||
|
toRedraw = true;
|
||||||
|
}
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_size(value:Size):Size {
|
||||||
|
if (size != value) {
|
||||||
|
size = value;
|
||||||
|
toRedraw = true;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update():Void {
|
||||||
|
if (toRedraw) {
|
||||||
|
redraw();
|
||||||
|
redrawMask();
|
||||||
|
toRedraw = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redraw():Void {
|
||||||
|
graphics.clear();
|
||||||
|
graphics.beginFill(color);
|
||||||
|
graphics.drawCircle(radius, radius, radius);
|
||||||
|
graphics.beginFill(backColor);
|
||||||
|
graphics.drawCircle(radius, radius, radius / 2);
|
||||||
|
graphics.endFill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redrawMask():Void {
|
||||||
|
maskShape.graphics.clear();
|
||||||
|
maskShape.graphics.beginFill(0x00ff00);
|
||||||
|
maskShape.graphics.moveTo(radius, radius);
|
||||||
|
var sides = 6;
|
||||||
|
var rotation = (-(Math.PI) / 2);
|
||||||
|
var r = radius / Math.cos(1/sides * Math.PI);
|
||||||
|
var lineToRadians = function(rads:Float):Void {
|
||||||
|
maskShape.graphics.lineTo(Math.cos(rads) * r + radius, Math.sin(rads) * r + radius);
|
||||||
|
};
|
||||||
|
var sidesToDraw:Int = Math.floor(progress * sides);
|
||||||
|
for (i in 0...sidesToDraw + 1) {
|
||||||
|
lineToRadians((i / sides) * (Math.PI * 2) + rotation);
|
||||||
|
}
|
||||||
|
if (progress * sides != sidesToDraw) {
|
||||||
|
lineToRadians(progress * (Math.PI * 2) + rotation);
|
||||||
|
}
|
||||||
|
maskShape.graphics.endFill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Preloader extends Sprite {
|
||||||
|
|
||||||
|
private var progress:Progress;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super();
|
||||||
|
Lib.current.stage.color = AppTheme.COLORS.light;
|
||||||
|
progress = new Progress();
|
||||||
|
progress.color = AppTheme.COLORS.dark;
|
||||||
|
progress.backColor = AppTheme.COLORS.light;
|
||||||
|
progress.size = [200, 200];
|
||||||
|
addChild(progress);
|
||||||
|
onResize(null);
|
||||||
|
Lib.current.stage.addEventListener(Event.RESIZE, onResize);
|
||||||
|
Lib.current.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
|
||||||
|
Lib.current.stage.addEventListener(ProgressEvent.PROGRESS, onProgress);
|
||||||
|
addEventListener(Event.COMPLETE, onComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onResize(event:Event):Void {
|
||||||
|
progress.x = (Lib.current.stage.stageWidth - progress.size.width) / 2;
|
||||||
|
progress.y = (Lib.current.stage.stageHeight - progress.size.height) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onEnterFrame(event:Event):Void {
|
||||||
|
progress.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onProgress(event:ProgressEvent):Void {
|
||||||
|
progress.progress = event.bytesLoaded / event.bytesTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onComplete(event:Event):Void {
|
||||||
|
progress.update();
|
||||||
|
Lib.current.stage.removeEventListener(Event.RESIZE, onResize);
|
||||||
|
Lib.current.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
|
||||||
|
Lib.current.stage.removeEventListener(ProgressEvent.PROGRESS, onProgress);
|
||||||
|
removeEventListener(Event.COMPLETE, onComplete);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/client/haxe/ru/m/tankz/bundle/ClientLevelSource.hx
Normal file
33
src/client/haxe/ru/m/tankz/bundle/ClientLevelSource.hx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package ru.m.tankz.bundle;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import openfl.utils.AssetType;
|
||||||
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import ru.m.tankz.util.LevelUtil;
|
||||||
|
|
||||||
|
class ClientLevelSource implements ILevelSource {
|
||||||
|
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function resolveMeta(id:PackId):LevelPackMeta {
|
||||||
|
var bytes = Assets.getBytes('level/${id}.zip');
|
||||||
|
return LevelUtil.getMeta(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(id:PackId):LevelPack {
|
||||||
|
var bytes = Assets.getBytes('level/${id}.zip');
|
||||||
|
return LevelUtil.unpack(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list():Array<PackId> {
|
||||||
|
var result = [];
|
||||||
|
for (path in Assets.list(AssetType.BINARY)) {
|
||||||
|
if (StringTools.startsWith(path, "level")) {
|
||||||
|
result.push(PackId.fromString(path.split("/").pop().split(".").shift()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/client/haxe/ru/m/tankz/bundle/ConfigBundle.hx
Normal file
23
src/client/haxe/ru/m/tankz/bundle/ConfigBundle.hx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.m.tankz.bundle;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import yaml.Parser;
|
||||||
|
import yaml.Yaml;
|
||||||
|
|
||||||
|
class ConfigBundle implements IConfigBundle {
|
||||||
|
|
||||||
|
private var _cache:Map<GameType, Config> = new Map();
|
||||||
|
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function get(type:GameType):Config {
|
||||||
|
if (!_cache.exists(type)) {
|
||||||
|
var source:ConfigSource = Yaml.parse(Assets.getText('config/${type}.yaml'), Parser.options().useObjects());
|
||||||
|
_cache.set(type, Config.fromSource(type, source));
|
||||||
|
}
|
||||||
|
return _cache.get(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/client/haxe/ru/m/tankz/control/Binding.hx
Normal file
12
src/client/haxe/ru/m/tankz/control/Binding.hx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package ru.m.tankz.control;
|
||||||
|
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.control.DeviceType;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
|
||||||
|
typedef BindAction = {
|
||||||
|
var device:DeviceType;
|
||||||
|
var action:DeviceAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef Binding = Map<TankAction, BindAction>;
|
||||||
@@ -1,63 +1,99 @@
|
|||||||
package ru.m.tankz.control;
|
package ru.m.tankz.control;
|
||||||
|
|
||||||
import flash.events.FocusEvent;
|
import flash.events.FocusEvent;
|
||||||
import flash.events.KeyboardEvent;
|
|
||||||
import flash.Lib;
|
|
||||||
import flash.ui.Keyboard;
|
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.control.DeviceType;
|
||||||
|
import ru.m.control.IControlBus;
|
||||||
import ru.m.geom.Direction;
|
import ru.m.geom.Direction;
|
||||||
import ru.m.tankz.control.Control;
|
import ru.m.tankz.control.Control;
|
||||||
|
import ru.m.tankz.storage.SettingsStorage;
|
||||||
import ru.m.tankz.Type;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
using haxe.EnumTools.EnumValueTools;
|
||||||
typedef KeyBinding = Map<Int, TankAction>;
|
|
||||||
|
|
||||||
class HumanControl extends Control {
|
class HumanControl extends Control {
|
||||||
|
|
||||||
private var keyBinding:KeyBinding;
|
@:provide static var storage:SettingsStorage;
|
||||||
private var moveQueue:Array<Int>;
|
@:provide static var bus:IControlBus;
|
||||||
private var shotTimer:Timer;
|
|
||||||
|
private var binding:Map<DeviceType, Map<DeviceAction, TankAction>>;
|
||||||
|
|
||||||
|
private var moveQueue:Array<Direction>;
|
||||||
|
private var shotTimers:Map<Int, Timer>;
|
||||||
|
|
||||||
public function new(playerId:PlayerId, controlIndex:Int) {
|
public function new(playerId:PlayerId, controlIndex:Int) {
|
||||||
super(playerId);
|
super(playerId);
|
||||||
this.keyBinding = resolve(controlIndex);
|
var config = storage.getBinding(controlIndex);
|
||||||
moveQueue = new Array<Int>();
|
binding = new Map();
|
||||||
Lib.current.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
|
for (action in config.keys()) {
|
||||||
Lib.current.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
|
var bind = config.get(action);
|
||||||
//Lib.current.stage.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
|
if (!binding.exists(bind.device)) {
|
||||||
|
binding.set(bind.device, new Map());
|
||||||
|
}
|
||||||
|
binding.get(bind.device).set(bind.action, action);
|
||||||
|
}
|
||||||
|
moveQueue = [];
|
||||||
|
shotTimers = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onKeyDown(event:KeyboardEvent):Void {
|
public function hasDevice(device:DeviceType):Bool {
|
||||||
if (keyBinding.exists(event.keyCode)) switch (keyBinding.get(event.keyCode)) {
|
for (d in binding.keys()) {
|
||||||
case TankAction.MOVE(direction):
|
if (d.equals(device)) {
|
||||||
if (moveQueue.indexOf(event.keyCode) == -1) {
|
return true;
|
||||||
moveQueue.unshift(event.keyCode);
|
}
|
||||||
updateMove();
|
|
||||||
}
|
|
||||||
case TankAction.SHOT:
|
|
||||||
if (shotTimer == null) {
|
|
||||||
shotTimer = new Timer(300);
|
|
||||||
shotTimer.run = shot;
|
|
||||||
shot();
|
|
||||||
}
|
|
||||||
case _:
|
|
||||||
}
|
}
|
||||||
if (event.keyCode == Keyboard.U) {
|
return false;
|
||||||
action(TankAction.UPGRADE);
|
}
|
||||||
|
|
||||||
|
private function onDeviceAction(device:DeviceType, action:DeviceAction, on:Bool):Void {
|
||||||
|
if (binding.exists(device) && binding[device].exists(action)) {
|
||||||
|
toggleAction(binding[device][action], on);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onKeyUp(event:KeyboardEvent):Void {
|
override public function start():Void {
|
||||||
if (keyBinding.exists(event.keyCode)) switch (keyBinding.get(event.keyCode)) {
|
super.start();
|
||||||
|
bus.signal.connect(onDeviceAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function stop():Void {
|
||||||
|
super.stop();
|
||||||
|
bus.signal.disconnect(onDeviceAction);
|
||||||
|
moveQueue = [];
|
||||||
|
for (timer in shotTimers) {
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
shotTimers = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleAction(action:TankAction, on:Bool):Void {
|
||||||
|
switch action {
|
||||||
case TankAction.MOVE(direction):
|
case TankAction.MOVE(direction):
|
||||||
moveQueue.remove(event.keyCode);
|
if (on) {
|
||||||
|
if (moveQueue.indexOf(direction) == -1) {
|
||||||
|
moveQueue.unshift(direction);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
moveQueue.remove(direction);
|
||||||
|
}
|
||||||
updateMove();
|
updateMove();
|
||||||
case TankAction.SHOT:
|
case TankAction.SHOT(weapon):
|
||||||
if (shotTimer != null) {
|
if (on) {
|
||||||
shotTimer.stop();
|
if (!shotTimers.exists(weapon)) {
|
||||||
shotTimer = null;
|
// ToDo: weapon.config.delay
|
||||||
|
var timer = new Timer(350);
|
||||||
|
timer.run = shooter(weapon);
|
||||||
|
timer.run();
|
||||||
|
shotTimers.set(weapon, timer);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (shotTimers.exists(weapon)) {
|
||||||
|
shotTimers.get(weapon).stop();
|
||||||
|
shotTimers.remove(weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case _:
|
case TankAction.STOP:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,40 +104,15 @@ class HumanControl extends Control {
|
|||||||
|
|
||||||
private function updateMove():Void {
|
private function updateMove():Void {
|
||||||
if (moveQueue.length == 0) {
|
if (moveQueue.length == 0) {
|
||||||
action(TankAction.STOP);
|
action(STOP);
|
||||||
} else {
|
} else {
|
||||||
switch (keyBinding.get(moveQueue[0])) {
|
action(MOVE(moveQueue[0]));
|
||||||
case TankAction.MOVE(direction):
|
|
||||||
action(TankAction.MOVE(direction));
|
|
||||||
case _:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shot():Void {
|
private function shooter(weapon:Int):Void -> Void {
|
||||||
action(TankAction.SHOT);
|
return function():Void {
|
||||||
}
|
action(SHOT(weapon));
|
||||||
|
|
||||||
private static function resolve(controlIndex:Int):KeyBinding {
|
|
||||||
switch (controlIndex) {
|
|
||||||
case 0:
|
|
||||||
return [
|
|
||||||
Keyboard.A => TankAction.MOVE(Direction.LEFT),
|
|
||||||
Keyboard.S => TankAction.MOVE(Direction.BOTTOM),
|
|
||||||
Keyboard.W => TankAction.MOVE(Direction.TOP),
|
|
||||||
Keyboard.D => TankAction.MOVE(Direction.RIGHT),
|
|
||||||
Keyboard.SPACE => TankAction.SHOT
|
|
||||||
];
|
|
||||||
case 1:
|
|
||||||
return [
|
|
||||||
Keyboard.LEFT => TankAction.MOVE(Direction.LEFT),
|
|
||||||
Keyboard.DOWN => TankAction.MOVE(Direction.BOTTOM),
|
|
||||||
Keyboard.UP => TankAction.MOVE(Direction.TOP),
|
|
||||||
Keyboard.RIGHT => TankAction.MOVE(Direction.RIGHT),
|
|
||||||
Keyboard.NUMPAD_0 => TankAction.SHOT
|
|
||||||
];
|
|
||||||
case x:
|
|
||||||
throw 'Invalid control index ${x}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/client/haxe/ru/m/tankz/game/GameInit.hx
Normal file
11
src/client/haxe/ru/m/tankz/game/GameInit.hx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.game.record.GameRecord;
|
||||||
|
import ru.m.tankz.network.NetworkManager;
|
||||||
|
|
||||||
|
enum GameInit {
|
||||||
|
LOCAL(start:Start);
|
||||||
|
NETWORK(network:NetworkManager);
|
||||||
|
RECORD(record:GameRecord);
|
||||||
|
}
|
||||||
13
src/client/haxe/ru/m/tankz/local/LocalControlFactory.hx
Normal file
13
src/client/haxe/ru/m/tankz/local/LocalControlFactory.hx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package ru.m.tankz.local;
|
||||||
|
|
||||||
|
import ru.m.tankz.control.BaseControlFactory;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
import ru.m.tankz.control.HumanControl;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
class LocalControlFactory extends BaseControlFactory {
|
||||||
|
|
||||||
|
override private function buildHuman(id:PlayerId, index:Int):Control {
|
||||||
|
return new HumanControl(id, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/client/haxe/ru/m/tankz/local/LocalGame.hx
Normal file
42
src/client/haxe/ru/m/tankz/local/LocalGame.hx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package ru.m.tankz.local;
|
||||||
|
|
||||||
|
import ru.m.tankz.control.HumanControl;
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.game.GameRunner;
|
||||||
|
import ru.m.tankz.local.LocalControlFactory;
|
||||||
|
import ru.m.tankz.storage.GameStorage;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
class LocalGame extends GameRunner {
|
||||||
|
|
||||||
|
@:provide static var gameStorage:GameStorage;
|
||||||
|
|
||||||
|
public function new(start:Start) {
|
||||||
|
super(start);
|
||||||
|
controlFactory = new LocalControlFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function onGameEvent(event:GameEvent):Void {
|
||||||
|
super.onGameEvent(event);
|
||||||
|
switch event {
|
||||||
|
case COMPLETE(result):
|
||||||
|
updateProgress(result);
|
||||||
|
case _:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updateProgress(result:Result):Void {
|
||||||
|
var complete = false;
|
||||||
|
var humansTeams:Array<TeamId> = [];
|
||||||
|
for (control in controls) {
|
||||||
|
if (Std.is(control, HumanControl) && humansTeams.indexOf(control.playerId.team) == -1) {
|
||||||
|
humansTeams.push(control.playerId.team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (humansTeams.length == 1 && result.winner == humansTeams[0]) {
|
||||||
|
var progress = gameStorage.get(result.level.packId);
|
||||||
|
progress.completeLevel(result.level.id, result.state.presetId, {});
|
||||||
|
gameStorage.set(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/client/haxe/ru/m/tankz/local/StageCaller.hx
Normal file
31
src/client/haxe/ru/m/tankz/local/StageCaller.hx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package ru.m.tankz.local;
|
||||||
|
|
||||||
|
import flash.display.Stage;
|
||||||
|
import flash.events.Event;
|
||||||
|
import ru.m.tankz.engine.ICaller;
|
||||||
|
|
||||||
|
class StageCaller implements ICaller {
|
||||||
|
|
||||||
|
private var stage:Stage;
|
||||||
|
private var event:String;
|
||||||
|
private var calback:Void -> Void;
|
||||||
|
|
||||||
|
public function new(stage:Stage, ?event:String) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.event = event != null ? event : Event.ENTER_FRAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onEvent(_):Void {
|
||||||
|
calback();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function start(calback:Void -> Void):Void {
|
||||||
|
this.calback = calback;
|
||||||
|
stage.addEventListener(event, onEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stop():Void {
|
||||||
|
stage.removeEventListener(event, onEvent);
|
||||||
|
calback = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/client/haxe/ru/m/tankz/network/NetworkControl.hx
Normal file
16
src/client/haxe/ru/m/tankz/network/NetworkControl.hx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package ru.m.tankz.network;
|
||||||
|
|
||||||
|
import ru.m.tankz.control.HumanControl;
|
||||||
|
import ru.m.tankz.network.NetworkManager;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
|
||||||
|
class NetworkControl extends HumanControl {
|
||||||
|
|
||||||
|
@:provide private var network:NetworkManager;
|
||||||
|
|
||||||
|
override public function action(action:TankAction):Void {
|
||||||
|
if (tankId > -1) {
|
||||||
|
network.action(tankId, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/client/haxe/ru/m/tankz/network/NetworkControlFactory.hx
Normal file
16
src/client/haxe/ru/m/tankz/network/NetworkControlFactory.hx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package ru.m.tankz.network;
|
||||||
|
|
||||||
|
import ru.m.tankz.control.BaseControlFactory;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
class NetworkControlFactory extends BaseControlFactory {
|
||||||
|
|
||||||
|
override private function buildHuman(id:PlayerId, index:Int):Control {
|
||||||
|
return new NetworkControl(id, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
override private function buildBot(id:PlayerId, type:String):Control {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/client/haxe/ru/m/tankz/network/NetworkGame.hx
Normal file
54
src/client/haxe/ru/m/tankz/network/NetworkGame.hx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package ru.m.tankz.network;
|
||||||
|
|
||||||
|
import haxe.Unserializer;
|
||||||
|
import ru.m.tankz.control.Controller;
|
||||||
|
import ru.m.tankz.game.Game;
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.network.NetworkControlFactory;
|
||||||
|
import ru.m.tankz.network.NetworkManager;
|
||||||
|
import ru.m.tankz.proto.pack.GameEventResponse;
|
||||||
|
import ru.m.tankz.proto.room.RoomSlotProto;
|
||||||
|
|
||||||
|
class NetworkGame extends Game {
|
||||||
|
|
||||||
|
private var network:NetworkManager;
|
||||||
|
|
||||||
|
public function new(network:NetworkManager) {
|
||||||
|
super(network.room.game.type);
|
||||||
|
this.network = network;
|
||||||
|
this.controlFactory = new NetworkControlFactory();
|
||||||
|
network.gameEventSignal.connect(onGameEventProto);
|
||||||
|
network.stateSignal.connect(onConnectionState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onGameEventProto(game:GameEventResponse):Void {
|
||||||
|
var time = game.event.time;
|
||||||
|
var eventStr = game.event.event;
|
||||||
|
var event:GameEvent = Unserializer.run(eventStr);
|
||||||
|
gameEventSignal.emit(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onConnectionState(state:ConnectionState):Void {
|
||||||
|
switch state {
|
||||||
|
case ONLINE(user):
|
||||||
|
if (network.room != null) {
|
||||||
|
network.joinGame(network.room.game.id);
|
||||||
|
}
|
||||||
|
case _:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override private function onStart(start:Start):Void {
|
||||||
|
var slot:RoomSlotProto = Lambda.find(network.room.slots, function(slot:RoomSlotProto) return slot.hasUser() && slot.user.uuid == network.user.uuid);
|
||||||
|
if (slot != null) {
|
||||||
|
start.state.controls.push({playerId: [slot.slot.team, slot.slot.index], controller: HUMAN(0)});
|
||||||
|
}
|
||||||
|
super.onStart(start);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function dispose():Void {
|
||||||
|
super.dispose();
|
||||||
|
network.gameEventSignal.disconnect(onGameEventProto);
|
||||||
|
network.stateSignal.disconnect(onConnectionState);
|
||||||
|
}
|
||||||
|
}
|
||||||
199
src/client/haxe/ru/m/tankz/network/NetworkManager.hx
Normal file
199
src/client/haxe/ru/m/tankz/network/NetworkManager.hx
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
package ru.m.tankz.network;
|
||||||
|
|
||||||
|
import haxe.Serializer;
|
||||||
|
import hw.signal.Signal;
|
||||||
|
import ru.m.connect.IConnection;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.proto.core.UserProto;
|
||||||
|
import ru.m.tankz.proto.game.GameEventProto;
|
||||||
|
import ru.m.tankz.proto.pack.GameEventRequest;
|
||||||
|
import ru.m.tankz.proto.pack.GameEventResponse;
|
||||||
|
import ru.m.tankz.proto.pack.LoginRequest;
|
||||||
|
import ru.m.tankz.proto.pack.LogoutRequest;
|
||||||
|
import ru.m.tankz.proto.pack.Request;
|
||||||
|
import ru.m.tankz.proto.pack.Response;
|
||||||
|
import ru.m.tankz.proto.room.CreateRequest;
|
||||||
|
import ru.m.tankz.proto.room.JoinRequest;
|
||||||
|
import ru.m.tankz.proto.room.LeaveRequest;
|
||||||
|
import ru.m.tankz.proto.room.RoomListRequest;
|
||||||
|
import ru.m.tankz.proto.room.RoomProto;
|
||||||
|
import ru.m.tankz.proto.room.RoomRequest;
|
||||||
|
import ru.m.tankz.proto.room.SlotProto;
|
||||||
|
import ru.m.tankz.proto.room.SlotRequest;
|
||||||
|
import ru.m.tankz.proto.room.StartRequest;
|
||||||
|
import ru.m.tankz.storage.NetworkStorage;
|
||||||
|
import ru.m.tankz.storage.SettingsStorage;
|
||||||
|
|
||||||
|
typedef ClientConnection = IConnection<Request, Response>;
|
||||||
|
|
||||||
|
enum ConnectionState {
|
||||||
|
OFFLINE;
|
||||||
|
CONNECT;
|
||||||
|
CONNECTED;
|
||||||
|
LOGIN;
|
||||||
|
ONLINE(user:User);
|
||||||
|
ERROR(error:Dynamic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@:provide class NetworkManager {
|
||||||
|
|
||||||
|
private static inline var TAG = "NetworkManager";
|
||||||
|
|
||||||
|
public var state(default, null):ConnectionState;
|
||||||
|
public var room(default, null):RoomProto;
|
||||||
|
public var user(default, null):UserProto;
|
||||||
|
|
||||||
|
public var stateSignal:Signal<ConnectionState>;
|
||||||
|
public var listRoomSignal:Signal<Array<RoomProto>>;
|
||||||
|
public var roomSignal:Signal<RoomProto>;
|
||||||
|
public var gameEventSignal:Signal<GameEventResponse>;
|
||||||
|
|
||||||
|
@:provide private var connection:ClientConnection;
|
||||||
|
@:provide private var storage:NetworkStorage;
|
||||||
|
@:provide private var settings:SettingsStorage;
|
||||||
|
|
||||||
|
private var reconnectTimer:Timer;
|
||||||
|
private var reconnectDelay:Int;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
reconnectDelay = 500;
|
||||||
|
stateSignal = new Signal();
|
||||||
|
listRoomSignal = new Signal();
|
||||||
|
roomSignal = new Signal();
|
||||||
|
gameEventSignal = new Signal();
|
||||||
|
updateState(OFFLINE);
|
||||||
|
connection.handler.connect(onConnectionEvent);
|
||||||
|
connection.receiveHandler.connect(onResponse);
|
||||||
|
if (settings.enableNetwork) {
|
||||||
|
connect();
|
||||||
|
}
|
||||||
|
settings.signal.connect(onSettingChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onSettingChange(setting:Setting):Void {
|
||||||
|
switch setting {
|
||||||
|
case ENABLE_NETWORK(value):
|
||||||
|
if (value) {
|
||||||
|
connect();
|
||||||
|
} else {
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
case _:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updateState(value:ConnectionState):Void {
|
||||||
|
L.d(TAG, 'State: ${value}');
|
||||||
|
state = value;
|
||||||
|
stateSignal.emit(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(name:String, uuid:String = null):Void {
|
||||||
|
updateState(LOGIN);
|
||||||
|
connection.send(new Request().setLogin(
|
||||||
|
new LoginRequest()
|
||||||
|
.setUuid(uuid)
|
||||||
|
.setName(name)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout():Void {
|
||||||
|
connection.send(new Request().setLogout(new LogoutRequest()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function listGame(subscribe:Bool):Void {
|
||||||
|
connection.send(new Request().setRoomList(new RoomListRequest().setSubscribe(subscribe)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createGame(type:String, level:Int):Void {
|
||||||
|
connection.send(new Request().setRoom(new RoomRequest().setCreate(new CreateRequest().setType(type).setLevel(level))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function joinGame(gameId:Int, restore:Bool = false):Void {
|
||||||
|
connection.send(new Request().setRoom(new RoomRequest().setJoin(new JoinRequest().setGameId(gameId).setRestore(restore))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectSlot(slot:SlotProto):Void {
|
||||||
|
connection.send(new Request().setRoom(new RoomRequest().setSlot(new SlotRequest().setSlot(slot))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function leaveGame():Void {
|
||||||
|
connection.send(new Request().setRoom(new RoomRequest().setLeave(new LeaveRequest())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function startGame():Void {
|
||||||
|
connection.send(new Request().setRoom(new RoomRequest().setStart(new StartRequest())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function action(tankId:Int, action:TankAction):Void {
|
||||||
|
connection.send(new Request().setGameEvent(new GameEventRequest().setEvent(
|
||||||
|
new GameEventProto().setTime(0).setEvent(
|
||||||
|
Serializer.run(GameEvent.ACTION(tankId, action))
|
||||||
|
)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function connect():Void {
|
||||||
|
if (reconnectTimer != null) {
|
||||||
|
reconnectTimer.stop();
|
||||||
|
reconnectTimer = null;
|
||||||
|
}
|
||||||
|
reconnectTimer = null;
|
||||||
|
updateState(CONNECT);
|
||||||
|
connection.connect().catchError(function(error) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function reconnect():Void {
|
||||||
|
reconnectDelay = Std.int(Math.min(reconnectDelay * 2, 10000));
|
||||||
|
if (reconnectTimer == null) {
|
||||||
|
reconnectTimer = Timer.delay(connect, reconnectDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function disconnect():Void {
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onConnectionEvent(event:ConnectionEvent):Void {
|
||||||
|
updateState(switch event {
|
||||||
|
case CONNECTED: CONNECTED;
|
||||||
|
case DISCONNECTED: OFFLINE;
|
||||||
|
case ERROR(error): ERROR(error);
|
||||||
|
});
|
||||||
|
switch event {
|
||||||
|
case CONNECTED:
|
||||||
|
reconnectDelay = 500;
|
||||||
|
var user = storage.user;
|
||||||
|
if (user != null) {
|
||||||
|
login(user.name, user.uuid);
|
||||||
|
}
|
||||||
|
case DISCONNECTED | ERROR(_):
|
||||||
|
if (settings.enableNetwork) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onResponse(packet:Response):Void {
|
||||||
|
if (packet.hasLogin()) {
|
||||||
|
this.user = packet.login.user;
|
||||||
|
var user = {
|
||||||
|
uuid: this.user.uuid,
|
||||||
|
name: this.user.name,
|
||||||
|
};
|
||||||
|
storage.user = user;
|
||||||
|
updateState(ONLINE(user));
|
||||||
|
} else if (packet.hasLogout()) {
|
||||||
|
storage.user = null;
|
||||||
|
updateState(CONNECTED);
|
||||||
|
} else if (packet.hasRoomList()) {
|
||||||
|
listRoomSignal.emit(packet.roomList.rooms);
|
||||||
|
} else if (packet.hasRoom()) {
|
||||||
|
room = packet.room.room;
|
||||||
|
roomSignal.emit(room);
|
||||||
|
} else if (packet.hasGameEvent()) {
|
||||||
|
gameEventSignal.emit(packet.gameEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/client/haxe/ru/m/tankz/render/AnimateBundle.hx
Normal file
42
src/client/haxe/ru/m/tankz/render/AnimateBundle.hx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package ru.m.tankz.render;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.animate.Animate;
|
||||||
|
import ru.m.animate.OnceAnimate;
|
||||||
|
|
||||||
|
class AnimateBundle {
|
||||||
|
|
||||||
|
private static function buildAnimate(name:String, sequence:Array<Int>):OnceAnimate {
|
||||||
|
var template:String = 'resources/image/animate/${name}/%index%.png';
|
||||||
|
var frames = [for (i in sequence) ({
|
||||||
|
image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))),
|
||||||
|
length: 1
|
||||||
|
})];
|
||||||
|
return new OnceAnimate(frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tankSpawn():OnceAnimate {
|
||||||
|
return buildAnimate('appear', [
|
||||||
|
0, 1, 2, 3, 3, 4, 5, 5, 6
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tankBoom():OnceAnimate {
|
||||||
|
return buildAnimate('boom', [
|
||||||
|
0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function bulletBoom():OnceAnimate {
|
||||||
|
return buildAnimate('boom-sm', [
|
||||||
|
0, 1, 1, 0, 0, 1
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tankProtect():Animate {
|
||||||
|
return new Animate([for (i in 0...2) ({
|
||||||
|
image: Assets.getBitmapData('resources/image/animate/protect/${i}.png'),
|
||||||
|
length: 5
|
||||||
|
})]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user