├── .gitIgnore ├── README.md ├── actionscript-match3 ├── README.md ├── assets │ ├── atlas │ │ ├── buttons │ │ │ ├── button_medium_down.png │ │ │ ├── button_medium_up.png │ │ │ ├── button_small_danger_down.png │ │ │ ├── button_small_danger_up.png │ │ │ ├── button_small_down.png │ │ │ ├── button_small_up.png │ │ │ ├── icon_close.png │ │ │ ├── icon_config.png │ │ │ ├── icon_confirm.png │ │ │ ├── icon_delete.png │ │ │ ├── icon_home.png │ │ │ ├── icon_level_select.png │ │ │ ├── icon_pause.png │ │ │ ├── icon_resume.png │ │ │ ├── icon_retry.png │ │ │ └── level_select_small_star.png │ │ ├── displays │ │ │ ├── logo_matchthree.png │ │ │ ├── logo_setzer.png │ │ │ ├── popup_star.png │ │ │ ├── star_hud_display_00.png │ │ │ ├── star_hud_display_01.png │ │ │ ├── star_hud_display_02.png │ │ │ ├── star_hud_display_03.png │ │ │ ├── star_hud_display_04.png │ │ │ ├── star_hud_display_05.png │ │ │ ├── star_hud_display_06.png │ │ │ ├── star_hud_display_07.png │ │ │ ├── star_hud_display_08.png │ │ │ ├── star_hud_display_09.png │ │ │ └── star_hud_display_10.png │ │ ├── extras │ │ │ └── logo_actionscript.png │ │ ├── game │ │ │ ├── piece_col_1.png │ │ │ ├── piece_col_2.png │ │ │ ├── piece_col_3.png │ │ │ ├── piece_col_4.png │ │ │ ├── piece_col_5.png │ │ │ ├── piece_col_6.png │ │ │ ├── piece_normal_1.png │ │ │ ├── piece_normal_2.png │ │ │ ├── piece_normal_3.png │ │ │ ├── piece_normal_4.png │ │ │ ├── piece_normal_5.png │ │ │ ├── piece_normal_6.png │ │ │ ├── piece_rainbow.png │ │ │ ├── piece_row_1.png │ │ │ ├── piece_row_2.png │ │ │ ├── piece_row_3.png │ │ │ ├── piece_row_4.png │ │ │ ├── piece_row_5.png │ │ │ └── piece_row_6.png │ │ ├── matchthree-starling-atlas.png │ │ ├── matchthree-starling-atlas.xml │ │ └── matchthree-startling-atlas.tps │ ├── backgrounds │ │ ├── background.png │ │ ├── background_hud.png │ │ └── background_popup.png │ ├── fonts │ │ ├── BerlinSansDemi.fnt │ │ └── BerlinSansDemi_1.png │ └── gimp │ │ ├── assets.xcf │ │ └── stars.xcf ├── bin │ └── actionscript-match3.swf ├── gif_match3_as_demo.gif ├── img_cover_match3_as.png ├── img_game_match3_as.png ├── img_ss_match3_as_01.png ├── img_ss_match3_as_02.png ├── img_ss_match3_as_03.png ├── img_ss_match3_as_04.png ├── img_ss_match3_as_05.png ├── libs │ ├── flexunit-4.2.0-20140410-as3_4.12.0.swc │ ├── greensock.swc │ ├── robotlegs-extensions-palidor-v1.0.swc │ ├── robotlegs-framework-v2.2.1.swc │ └── starling-2.1.swc ├── src │ └── setzer │ │ └── matchthree │ │ ├── Main.as │ │ ├── assets │ │ ├── Assets.as │ │ ├── AtlasKeys.as │ │ └── Embeds.as │ │ ├── config │ │ ├── GameConfig.as │ │ └── ViewsConfig.as │ │ ├── events │ │ ├── FlowEvent.as │ │ └── GameEvent.as │ │ ├── game │ │ ├── commands │ │ │ ├── CreateLevelCommand.as │ │ │ ├── GameOverCommand.as │ │ │ ├── RetryGameCommand.as │ │ │ ├── SwapPiecesCommand.as │ │ │ └── SwapPiecesConfirmCommand.as │ │ ├── displays │ │ │ ├── BlankedCell.as │ │ │ └── PieceDisplay.as │ │ ├── managers │ │ │ └── GameManager.as │ │ ├── models │ │ │ ├── GameStatus.as │ │ │ ├── GridData.as │ │ │ ├── LevelInfo.as │ │ │ ├── LevelModel.as │ │ │ ├── PieceData.as │ │ │ ├── SwapModel.as │ │ │ └── Tile.as │ │ └── utils │ │ │ ├── AnimationUtils.as │ │ │ ├── GridUtils.as │ │ │ ├── LevelsRepository.as │ │ │ ├── PieceDisplayPool.as │ │ │ ├── PieceIds.as │ │ │ ├── PieceType.as │ │ │ ├── PieceUtils.as │ │ │ └── PowerUpUtils.as │ │ ├── mediators │ │ ├── AlertPopupMediator.as │ │ ├── GameOverPopupMediator.as │ │ ├── GameViewMediator.as │ │ ├── GridFieldComponentMediator.as │ │ ├── HUDGameComponentMediator.as │ │ ├── HomeViewMediator.as │ │ ├── IntroViewMediator.as │ │ ├── LevelSelectViewMediator.as │ │ ├── OptionsViewMediator.as │ │ ├── PausePopupMediator.as │ │ ├── StartingPopupMediator.as │ │ └── YouWinPopupMediator.as │ │ ├── services │ │ ├── FlowService.as │ │ └── GameService.as │ │ ├── utils │ │ ├── MagicValues.as │ │ ├── SharedObjectManager.as │ │ ├── StarlingFactory.as │ │ ├── Texts.as │ │ └── ViewPortSize.as │ │ └── views │ │ ├── AlertPopup.as │ │ ├── GameOverPopup.as │ │ ├── GameView.as │ │ ├── HomeView.as │ │ ├── IntroView.as │ │ ├── LevelSelectView.as │ │ ├── MainStarlingView.as │ │ ├── OptionsView.as │ │ ├── PausePopup.as │ │ ├── StartingPopup.as │ │ ├── YouWinPopup.as │ │ └── components │ │ ├── GridFieldComponent.as │ │ ├── HUDGameComponent.as │ │ ├── IconButton.as │ │ ├── LevelSelectButton.as │ │ └── StarDisplayComponent.as └── test │ └── setzer │ └── matchthree │ └── game │ ├── managers │ └── GameManagerTest.as │ ├── models │ ├── GridDataTest.as │ ├── LevelModelTest.as │ └── PieceTest.as │ └── utils │ ├── GridUtilsTest.as │ ├── PieceUtilsTest.as │ └── PowerUpUtilsTest.as ├── gif_match3_as_demo.gif ├── gif_match3_ts_demo.gif ├── img_cover_match3.png ├── img_game_match3.png └── typescript-match3 ├── .editorconfig ├── .prettierrc ├── README.md ├── assets ├── BerlinSansDemi.fnt ├── BerlinSansDemi_1.png ├── atlas │ ├── buttons │ │ ├── button_medium_down.png │ │ ├── button_medium_up.png │ │ ├── button_small_danger_down.png │ │ ├── button_small_danger_up.png │ │ ├── button_small_down.png │ │ ├── button_small_up.png │ │ ├── icon_close.png │ │ ├── icon_config.png │ │ ├── icon_confirm.png │ │ ├── icon_delete.png │ │ ├── icon_home.png │ │ ├── icon_level_select.png │ │ ├── icon_pause.png │ │ ├── icon_resume.png │ │ ├── icon_retry.png │ │ └── level_select_small_star.png │ ├── displays │ │ ├── logo_matchthree.png │ │ ├── logo_setzer.png │ │ ├── popup_star.png │ │ ├── star_hud_display_00.png │ │ ├── star_hud_display_01.png │ │ ├── star_hud_display_02.png │ │ ├── star_hud_display_03.png │ │ ├── star_hud_display_04.png │ │ ├── star_hud_display_05.png │ │ ├── star_hud_display_06.png │ │ ├── star_hud_display_07.png │ │ ├── star_hud_display_08.png │ │ ├── star_hud_display_09.png │ │ └── star_hud_display_10.png │ ├── game │ │ ├── piece_col_1.png │ │ ├── piece_col_2.png │ │ ├── piece_col_3.png │ │ ├── piece_col_4.png │ │ ├── piece_col_5.png │ │ ├── piece_col_6.png │ │ ├── piece_normal_1.png │ │ ├── piece_normal_2.png │ │ ├── piece_normal_3.png │ │ ├── piece_normal_4.png │ │ ├── piece_normal_5.png │ │ ├── piece_normal_6.png │ │ ├── piece_rainbow.png │ │ ├── piece_row_1.png │ │ ├── piece_row_2.png │ │ ├── piece_row_3.png │ │ ├── piece_row_4.png │ │ ├── piece_row_5.png │ │ └── piece_row_6.png │ ├── matchthree-pixijs-atlas.json │ ├── matchthree-pixijs-atlas.png │ ├── matchthree-starling-atlas.png │ ├── matchthree-starling-atlas.xml │ └── matchthree-startling-atlas.tps ├── backgrounds │ ├── background.png │ ├── background_hud.png │ └── background_popup.png ├── fonts │ ├── BerlinSansDemi.fnt │ └── BerlinSansDemi.png ├── gimp │ ├── assets.xcf │ └── stars.xcf ├── logo_typescript.png ├── matchthree-pixijs-atlas.json └── matchthree-pixijs-atlas.png ├── karma.conf.js ├── media ├── gif_match3_ts_demo.gif ├── img_cover_match3_ts.png ├── img_game_match3_ts.png ├── img_ss_match3_ts_01.png ├── img_ss_match3_ts_02.png ├── img_ss_match3_ts_03.png └── img_ss_match3_ts_04.png ├── package.json ├── src ├── index.ts └── matchthree │ ├── configs │ ├── GameConfig.ts │ ├── PalidorConfig.ts │ └── ViewsConfig.ts │ ├── events │ ├── FlowEvent.ts │ └── GameEvent.ts │ ├── game │ ├── commands │ │ ├── CreateLevelCommand.ts │ │ ├── GameOverCommand.ts │ │ ├── RetryGameCommand.ts │ │ ├── SwapPiecesCommand.ts │ │ └── SwapPiecesConfirmCommand.ts │ ├── displays │ │ └── BlankedCell.ts │ ├── managers │ │ └── GameManager.ts │ ├── models │ │ ├── GameStatus.ts │ │ ├── GridData.ts │ │ ├── LevelInfo.ts │ │ ├── LevelModel.ts │ │ ├── PieceData.ts │ │ ├── SwapModel.ts │ │ ├── Tile.ts │ │ └── TouchPhase.ts │ └── utils │ │ ├── AnimationUtils.ts │ │ ├── GridUtils.ts │ │ ├── LevelRepository.ts │ │ ├── PieceDisplayPool.ts │ │ ├── PieceIds.ts │ │ ├── PieceType.ts │ │ ├── PieceUtils.ts │ │ ├── PowerUpUtils.ts │ │ └── ScoreUtils.ts │ ├── mediators │ ├── AlertPopupMediator.ts │ ├── GameOverPopupMediator.ts │ ├── GameViewMediator.ts │ ├── GridFieldComponentMediator.ts │ ├── HUDGameComponentMediator.ts │ ├── HomeViewMediator.ts │ ├── IntroViewMediator.ts │ ├── LevelSelectViewMediator.ts │ ├── OptionsViewMediator.ts │ ├── PausePopupMediator.ts │ ├── StartingPopupMediator.ts │ └── YouWinPopupMediator.ts │ ├── services │ ├── FlowService.ts │ └── GameService.ts │ ├── utils │ ├── AtlasKeys.ts │ ├── MagicValues.ts │ ├── PixiFactory.ts │ ├── Texts.ts │ └── ViewPortSize.ts │ └── views │ ├── AlertPopup.ts │ ├── GameOverPopup.ts │ ├── GameView.ts │ ├── HomeView.ts │ ├── IntroView.ts │ ├── LevelSelectView.ts │ ├── OptionsView.ts │ ├── PausePopup.ts │ ├── StartingPopup.ts │ ├── YouWinPopup.ts │ └── components │ ├── GridFieldComponent.ts │ ├── HUDGameComponent.ts │ ├── IconButton.ts │ ├── LevelSelectButton.ts │ ├── SingleStart.ts │ └── StarDisplayComponent.ts ├── test ├── entry.test.ts └── matchthree │ ├── game │ ├── managers │ │ └── GameManager.test.ts │ ├── models │ │ ├── GridData.test.ts │ │ ├── LevelInfo.test.ts │ │ ├── LevelModel.test.ts │ │ ├── PieceData.test.ts │ │ ├── SwapModel.test.ts │ │ └── Tile.test.ts │ └── utils │ │ ├── GridUtils.test.ts │ │ ├── PieceUtils.test.ts │ │ └── PowerUpUtils.test.ts │ ├── services │ └── GameService.test.ts │ └── utils │ └── AtlasKeys.test.ts ├── tsconfig.json ├── tslint.json ├── webpack.config.js ├── webpack.setzer.config.js └── yarn.lock /.gitIgnore: -------------------------------------------------------------------------------- 1 | # Game-SpaceInvaders 2 | 3 | # Build and Release Folders 4 | bin-debug/ 5 | bin-release/ 6 | temp/ 7 | dist/ 8 | node_modules/ 9 | coverage/ 10 | 11 | # Project property files 12 | .actionScriptProperties 13 | .flexLibProperties 14 | .settings/ 15 | .project 16 | 17 | *.iml 18 | *.ipr 19 | *.iws 20 | *.DS_STORE 21 | .idea/ 22 | .vscode/ 23 | out/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![cover](img_cover_match3.png) 2 | 3 | In this repository, you will find the source of a Match3 game, developed in some different programming languages such as Actionscript and TypeScript, following the micro architecture Robotlegs. 4 | 5 | ### Status 6 | 7 | + **[ActionScript/Starling](https://ronaldosetzer.github.io/portfolio/open_source/match3_as/) :** Done 8 | + **Haxe/OpenFl:** in Progress. 9 | + **[TypeScript/PixiJs](https://ronaldosetzer.github.io/portfolio/open_source/match_ts/) :** Done 10 | + **C#/Unity:** to do. 11 | 12 | 13 | * * * 14 | 15 | ### Gameplay ActionScript 16 | 17 | ![gif_as](gif_match3_as_demo.gif) 18 | 19 | * * * 20 | 21 | ### Gameplay TypeScript 22 | 23 | ![gif_ts](gif_match3_ts_demo.gif) 24 | 25 | * * * 26 | 27 | ### Demos 28 | + **[ActionScript](https://ronaldosetzer.github.io/portfolio/open_source/match3_as/)** 29 | + **[TypeScript](https://ronaldosetzer.github.io/portfolio/open_source/match3_ts/)** 30 | 31 | * * * 32 | 33 | ### Screenshots 34 | ![screenshot01](img_game_match3.png) 35 | 36 | * * * 37 | 38 | **Ronaldo Santiago** - Game Developer [ [portfolio](https://ronaldosetzer.github.io/portfolio/) ] -------------------------------------------------------------------------------- /actionscript-match3/README.md: -------------------------------------------------------------------------------- 1 | ![cover](img_cover_match3_as.png) 2 | 3 | This is a TypeScript open-source game which is a port of the ActionScript version, following the same concepts, graphics, and architecture. 4 | 5 | + **Category:** Arcade. 6 | + **Platform:** Web. 7 | + **Language:** TypeScript. 8 | + **Technologies:** PixiJs, RobotlegsJs, RobotlegsJs-Pixi, Palidor. 9 | 10 | * * * 11 | 12 | ### Gameplay 13 | 14 | ![gif_ts](gif_match3_as_demo.gif) 15 | 16 | * * * 17 | 18 | ### Dependencies 19 | 20 | + [PixiJs](http://www.pixijs.com/) 21 | + [RobotlegsJs](https://github.com/GoodgameStudios/RobotlegsJS) 22 | + [Robotlegs-Pixi](https://github.com/GoodgameStudios/RobotlegsJS-Pixi) 23 | 24 | * * * 25 | 26 | ### Demos 27 | + **[ActionScript](https://ronaldosetzer.github.io/portfolio/open_source/match3_as/)** 28 | + **[TypeScript](https://ronaldosetzer.github.io/portfolio/open_source/match3_as/)** 29 | 30 | * * * 31 | 32 | ### Game 33 | 34 | ![screenshot01](img_ss_match3_as_01.png) 35 | 36 | ![screenshot02](img_ss_match3_as_02.png) 37 | 38 | ![screenshot03](img_ss_match3_as_03.png) 39 | 40 | #### Views - Mediators - Managers - Models - Utils - Commands - Tests 41 | 42 | ![screenshot05](img_ss_match3_as_05.png) 43 | 44 | ![screenshot04](img_ss_match3_as_04.png) 45 | 46 | * * * 47 | 48 | ### Screenshots 49 | ![screenshot01](img_game_match3_as.png) 50 | * * * 51 | 52 | **Ronaldo Santiago** - Game Developer [ [portfolio](https://ronaldosetzer.github.io/portfolio/) ] 53 | -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/button_medium_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/button_medium_down.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/button_medium_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/button_medium_up.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/button_small_danger_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/button_small_danger_down.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/button_small_danger_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/button_small_danger_up.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/button_small_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/button_small_down.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/button_small_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/button_small_up.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_close.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_config.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_confirm.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_delete.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_home.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_level_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_level_select.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_pause.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_resume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_resume.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/icon_retry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/icon_retry.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/buttons/level_select_small_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/buttons/level_select_small_star.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/logo_matchthree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/logo_matchthree.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/logo_setzer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/logo_setzer.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/popup_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/popup_star.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_00.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_01.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_02.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_03.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_04.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_05.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_06.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_07.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_08.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_09.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/displays/star_hud_display_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/displays/star_hud_display_10.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/extras/logo_actionscript.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/extras/logo_actionscript.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_col_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_col_1.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_col_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_col_2.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_col_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_col_3.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_col_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_col_4.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_col_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_col_5.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_col_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_col_6.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_normal_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_normal_1.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_normal_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_normal_2.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_normal_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_normal_3.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_normal_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_normal_4.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_normal_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_normal_5.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_normal_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_normal_6.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_rainbow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_rainbow.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_row_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_row_1.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_row_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_row_2.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_row_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_row_3.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_row_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_row_4.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_row_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_row_5.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/game/piece_row_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/game/piece_row_6.png -------------------------------------------------------------------------------- /actionscript-match3/assets/atlas/matchthree-starling-atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/atlas/matchthree-starling-atlas.png -------------------------------------------------------------------------------- /actionscript-match3/assets/backgrounds/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/backgrounds/background.png -------------------------------------------------------------------------------- /actionscript-match3/assets/backgrounds/background_hud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/backgrounds/background_hud.png -------------------------------------------------------------------------------- /actionscript-match3/assets/backgrounds/background_popup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/backgrounds/background_popup.png -------------------------------------------------------------------------------- /actionscript-match3/assets/fonts/BerlinSansDemi_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/fonts/BerlinSansDemi_1.png -------------------------------------------------------------------------------- /actionscript-match3/assets/gimp/assets.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/gimp/assets.xcf -------------------------------------------------------------------------------- /actionscript-match3/assets/gimp/stars.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/assets/gimp/stars.xcf -------------------------------------------------------------------------------- /actionscript-match3/bin/actionscript-match3.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/bin/actionscript-match3.swf -------------------------------------------------------------------------------- /actionscript-match3/gif_match3_as_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/gif_match3_as_demo.gif -------------------------------------------------------------------------------- /actionscript-match3/img_cover_match3_as.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_cover_match3_as.png -------------------------------------------------------------------------------- /actionscript-match3/img_game_match3_as.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_game_match3_as.png -------------------------------------------------------------------------------- /actionscript-match3/img_ss_match3_as_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_ss_match3_as_01.png -------------------------------------------------------------------------------- /actionscript-match3/img_ss_match3_as_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_ss_match3_as_02.png -------------------------------------------------------------------------------- /actionscript-match3/img_ss_match3_as_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_ss_match3_as_03.png -------------------------------------------------------------------------------- /actionscript-match3/img_ss_match3_as_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_ss_match3_as_04.png -------------------------------------------------------------------------------- /actionscript-match3/img_ss_match3_as_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/img_ss_match3_as_05.png -------------------------------------------------------------------------------- /actionscript-match3/libs/flexunit-4.2.0-20140410-as3_4.12.0.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/libs/flexunit-4.2.0-20140410-as3_4.12.0.swc -------------------------------------------------------------------------------- /actionscript-match3/libs/greensock.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/libs/greensock.swc -------------------------------------------------------------------------------- /actionscript-match3/libs/robotlegs-extensions-palidor-v1.0.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/libs/robotlegs-extensions-palidor-v1.0.swc -------------------------------------------------------------------------------- /actionscript-match3/libs/robotlegs-framework-v2.2.1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/libs/robotlegs-framework-v2.2.1.swc -------------------------------------------------------------------------------- /actionscript-match3/libs/starling-2.1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/actionscript-match3/libs/starling-2.1.swc -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/Main.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree 2 | { 3 | 4 | import flash.display.Sprite; 5 | import flash.display.StageAlign; 6 | import flash.display.StageScaleMode; 7 | import flash.events.Event; 8 | import flash.geom.Rectangle; 9 | 10 | import robotlegs.bender.bundles.palidor.PalidorBundle; 11 | import robotlegs.bender.extensions.contextView.ContextView; 12 | import robotlegs.bender.framework.api.IContext; 13 | import robotlegs.bender.framework.impl.Context; 14 | 15 | import setzer.matchthree.config.GameConfig; 16 | import setzer.matchthree.config.ViewsConfig; 17 | import setzer.matchthree.views.MainStarlingView; 18 | 19 | import starling.core.Starling; 20 | import starling.utils.Color; 21 | 22 | [SWF(width="340", height="480", frameRate="60", backgroundColor="#000000")] 23 | public class Main extends Sprite 24 | { 25 | public function Main() 26 | { 27 | stage.align = StageAlign.TOP_LEFT; 28 | stage.scaleMode = StageScaleMode.NO_SCALE; 29 | stage.frameRate = 60; 30 | stage.color = Color.BLACK; 31 | 32 | addEventListener( Event.ADDED_TO_STAGE, tetris_onAddedToStageHandler ); 33 | } 34 | 35 | private function tetris_onAddedToStageHandler( e:Event ):void 36 | { 37 | var starling:Starling = new Starling( MainStarlingView, stage, new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ) ); 38 | starling.nativeStage.frameRate = 60; 39 | starling.start(); 40 | 41 | const robotlegsContext:IContext = new Context(); 42 | robotlegsContext.install( PalidorBundle ); 43 | robotlegsContext.configure( ViewsConfig, GameConfig, starling, new ContextView( this ) ); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/assets/Assets.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.assets 2 | { 3 | import starling.text.BitmapFont; 4 | import starling.text.TextField; 5 | import starling.textures.Texture; 6 | import starling.textures.TextureAtlas; 7 | 8 | public class Assets 9 | { 10 | private static var _atlas:TextureAtlas; 11 | 12 | public static function init():void 13 | { 14 | var atlasTexture:Texture = Texture.fromEmbeddedAsset( Embeds.ATLAS_IMAGE ); 15 | var atlasXML:XML = XML( new Embeds.ATLAS_XML() ); 16 | _atlas = new TextureAtlas( atlasTexture, atlasXML ); 17 | 18 | var fontTexture:Texture = Texture.fromEmbeddedAsset( Embeds.FONT_IMAGE ); 19 | var font:BitmapFont = new BitmapFont( fontTexture, XML( new Embeds.FONT_XML() ) ); 20 | 21 | TextField.registerBitmapFont( font ); 22 | } 23 | 24 | public static function getTexture( preFix:String ):Texture 25 | { 26 | return _atlas.getTexture( preFix ); 27 | } 28 | 29 | public static function getTextures( preFix:String ):Vector. 30 | { 31 | return _atlas.getTextures( preFix ); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/assets/AtlasKeys.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.assets 2 | { 3 | public class AtlasKeys 4 | { 5 | /* ATLAS PREFIX */ 6 | public static const LOGO_SETZER:String = "logo_setzer"; 7 | public static const LOGO_MATCH_THREE:String = "logo_matchthree"; 8 | 9 | public static const PIECE_NORMAL:String = "piece_normal"; 10 | public static const PIECE_ROW:String = "piece_row"; 11 | public static const PIECE_COL:String = "piece_col"; 12 | public static const PIECE_RAINBOW:String = "piece_rainbow"; 13 | 14 | /* BUTTONS */ 15 | public static const BUTTON_SMALL_UP:String = "button_small_up"; 16 | public static const BUTTON_SMALL_DOWN:String = "button_small_down"; 17 | public static const BUTTON_SMALL_DANGER_UP:String = "button_small_danger_up"; 18 | public static const BUTTON_SMALL_DANGER_DOWN:String = "button_small_danger_down"; 19 | public static const BUTTON_MEDIUM_UP:String = "button_medium_up"; 20 | public static const BUTTON_MEDIUM_DOWN:String = "button_medium_down"; 21 | 22 | /* ICONS */ 23 | public static const ICON_LEVEL_SELECT:String = "icon_level_select"; 24 | public static const ICON_PAUSE:String = "icon_pause"; 25 | public static const ICON_RESUME:String = "icon_resume"; 26 | public static const ICON_DELETE:String = "icon_delete"; 27 | public static const ICON_RETRY:String = "icon_retry"; 28 | public static const ICON_CONFIG:String = "icon_config"; 29 | public static const ICON_HOME:String = "icon_home"; 30 | 31 | public static const ICON_CONFIRM:String = "icon_confirm"; 32 | public static const ICON_CLOSE:String = "icon_close"; 33 | 34 | /* Others */ 35 | public static const POPUP_STAR:String = "popup_star"; 36 | public static const STAR_HUD_DISPLAY:String = "star_hud_display_"; 37 | public static const LEVEL_SELECT_SMALL_STAR:String = "level_select_small_star"; 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/assets/Embeds.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.assets 2 | { 3 | public class Embeds 4 | { 5 | [Embed(source="/../assets/atlas/extras/logo_actionscript.png")] 6 | public static const LANGUAGE_IMAGE:Class; 7 | 8 | /* BACKGROUND */ 9 | [Embed(source="/../assets/backgrounds/background.png")] 10 | public static const BG_IMAGE:Class; 11 | 12 | [Embed(source="/../assets/backgrounds/background_popup.png")] 13 | public static const BG_POPUP_IMAGE:Class; 14 | 15 | [Embed(source="/../assets/backgrounds/background_hud.png")] 16 | public static const BG_HUD_IMAGE:Class; 17 | 18 | /* ATLAS */ 19 | [Embed(source="/../assets/atlas/matchthree-starling-atlas.png")] 20 | public static const ATLAS_IMAGE:Class; 21 | 22 | [Embed(source="/../assets/atlas/matchthree-starling-atlas.xml", mimeType="application/octet-stream")] 23 | public static const ATLAS_XML:Class; 24 | 25 | /* FONT */ 26 | [Embed(source="/../assets/fonts/BerlinSansDemi.fnt", mimeType="application/octet-stream")] 27 | public static const FONT_XML:Class; 28 | 29 | [Embed(source="/../assets/fonts/BerlinSansDemi_1.png")] 30 | public static const FONT_IMAGE:Class; 31 | } 32 | } -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/events/FlowEvent.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.events 2 | { 3 | import starling.events.Event; 4 | 5 | public class FlowEvent extends Event 6 | { 7 | public static const SHOW_INTRO_VIEW:String = "showIntroView"; 8 | public static const SHOW_HOME_VIEW:String = "showHomeView"; 9 | public static const SHOW_GAME_VIEW:String = "showGameView"; 10 | public static const SHOW_LEVEL_SELECT_VIEW:String = "showLevelSelectView"; 11 | public static const SHOW_OPTIONS_VIEW:String = "showOptionsView"; 12 | 13 | public static const SHOW_PAUSE_POPUP:String = "showPausePopup"; 14 | public static const SHOW_ALERT_POPUP:String = "showAlertPopup"; 15 | public static const SHOW_GAME_OVER_POPUP:String = "showGameOverPopup"; 16 | public static const SHOW_STARTING_POPUP:String = "showStartingPopup"; 17 | public static const SHOW_YOU_WIN_POPUP:String = "showYouWinPopup"; 18 | 19 | public function FlowEvent( type:String, bubbles:Boolean = false, data:Object = null ) 20 | { 21 | super( type, bubbles, data ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/events/GameEvent.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.events 2 | { 3 | import starling.events.Event; 4 | 5 | public class GameEvent extends Event 6 | { 7 | public static const RETRY_GAME_COMMAND:String = "retryGameCommand"; 8 | public static const CREATE_LEVEL_COMMAND:String = "createLevelCommand"; 9 | 10 | public static const SWAP_PIECES_COMMAND:String = "swapPiecesCommand"; 11 | public static const SWAP_PIECES_CONFIRM_COMMAND:String = "piecesSwappedCommand"; 12 | 13 | public static const GAME_OVER_COMMAND:String = "gameOver"; 14 | 15 | public static const RESUME:String = "resume"; 16 | public static const PAUSE:String = "pause"; 17 | 18 | public static const UPDATE_HUD_DATA:String = "updateData"; 19 | 20 | public static const CLEAR_GRID:String = "clearGridField"; 21 | 22 | public static const UPDATE_GRID:String = "update"; 23 | 24 | public var extra:Object; 25 | 26 | public function GameEvent( type:String, bubbles:Boolean = false, data:Object = null ) 27 | { 28 | super( type, bubbles, data ); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/commands/CreateLevelCommand.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.commands 2 | { 3 | import robotlegs.bender.extensions.commandCenter.api.ICommand; 4 | 5 | import setzer.matchthree.events.GameEvent; 6 | import setzer.matchthree.game.managers.GameManager; 7 | import setzer.matchthree.game.models.LevelModel; 8 | import setzer.matchthree.game.utils.LevelsRepository; 9 | import setzer.matchthree.services.FlowService; 10 | import setzer.matchthree.services.GameService; 11 | 12 | public class CreateLevelCommand implements ICommand 13 | { 14 | [Inject] 15 | public var levelModel:LevelModel; 16 | 17 | [Inject] 18 | public var gameManager:GameManager; 19 | 20 | [Inject] 21 | public var gameService:GameService; 22 | 23 | [Inject] 24 | public var flowService:FlowService; 25 | 26 | [Inject] 27 | public var gameEvent:GameEvent; 28 | 29 | public function execute():void 30 | { 31 | levelModel.levelId = gameEvent.extra.levelId; 32 | levelModel.levelInfo = LevelsRepository.getLevelInfoById( levelModel.levelId ); 33 | levelModel.reset(); 34 | levelModel.numMoves = levelModel.levelInfo.numMoves; 35 | 36 | gameManager.generateGrid( levelModel.maxCols, levelModel.maxRows ); 37 | 38 | gameService.updateHUDData(); 39 | gameService.start(); 40 | 41 | flowService.setGameView(); 42 | flowService.showStartingPopup(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/commands/GameOverCommand.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.commands 2 | { 3 | import robotlegs.bender.extensions.commandCenter.api.ICommand; 4 | 5 | import setzer.matchthree.game.models.LevelModel; 6 | import setzer.matchthree.game.utils.LevelsRepository; 7 | import setzer.matchthree.services.FlowService; 8 | import setzer.matchthree.services.GameService; 9 | import setzer.matchthree.utils.SharedObjectManager; 10 | 11 | public class GameOverCommand implements ICommand 12 | { 13 | [Inject] 14 | public var levelModel:LevelModel; 15 | 16 | [Inject] 17 | public var gameService:GameService; 18 | 19 | [Inject] 20 | public var flowService:FlowService; 21 | 22 | 23 | public function execute():void 24 | { 25 | gameService.pause(); 26 | var hiScore:int = levelModel.levelInfo.hiScore; 27 | hiScore = Math.max( hiScore, levelModel.score ); 28 | 29 | LevelsRepository.updateHiScore( levelModel.levelId, hiScore ); 30 | SharedObjectManager.updateHighScore(); 31 | 32 | var stars:int = 0; 33 | for ( var i:int = 0; i < levelModel.levelInfo.scoreStarts.length; i++ ) 34 | { 35 | if ( levelModel.score >= levelModel.levelInfo.scoreStarts[i] ) 36 | stars++; 37 | } 38 | 39 | levelModel.numStars = stars; 40 | 41 | if ( stars > 0 ) 42 | flowService.showYouWinPopup(); // 43 | else 44 | flowService.showGameOverPopup(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/commands/RetryGameCommand.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.commands 2 | { 3 | import robotlegs.bender.extensions.commandCenter.api.ICommand; 4 | 5 | import setzer.matchthree.game.managers.GameManager; 6 | import setzer.matchthree.game.models.LevelModel; 7 | import setzer.matchthree.services.FlowService; 8 | import setzer.matchthree.services.GameService; 9 | 10 | public class RetryGameCommand implements ICommand 11 | { 12 | [Inject] 13 | public var levelModel:LevelModel; 14 | 15 | [Inject] 16 | public var gameManager:GameManager; 17 | 18 | [Inject] 19 | public var gameService:GameService; 20 | 21 | [Inject] 22 | public var flowService:FlowService; 23 | 24 | public function execute():void 25 | { 26 | gameService.clearGridField(); 27 | 28 | levelModel.reset(); 29 | 30 | gameService.updateHUDData(); 31 | gameService.start(); 32 | flowService.showStartingPopup(); 33 | 34 | gameManager.generateGrid( levelModel.maxCols, levelModel.maxRows ); 35 | gameManager.nextStep(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/commands/SwapPiecesCommand.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.commands 2 | { 3 | import robotlegs.bender.extensions.commandCenter.api.ICommand; 4 | 5 | import setzer.matchthree.events.GameEvent; 6 | import setzer.matchthree.game.managers.GameManager; 7 | import setzer.matchthree.game.models.SwapModel; 8 | 9 | import starling.events.TouchPhase; 10 | 11 | public class SwapPiecesCommand implements ICommand 12 | { 13 | [Inject] 14 | public var swapModel:SwapModel; 15 | 16 | [Inject] 17 | public var gameManager:GameManager; 18 | 19 | [Inject] 20 | public var gameEvent:GameEvent; 21 | 22 | public function execute():void 23 | { 24 | swapModel.status = SwapModel.WAIT; 25 | swapModel.setPosition( gameEvent.extra.phase, gameEvent.extra.col, gameEvent.extra.row ); 26 | 27 | if ( gameEvent.extra.phase == TouchPhase.ENDED ) 28 | { 29 | swapModel.status = SwapModel.SWAP; 30 | gameManager.nextStep(); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/commands/SwapPiecesConfirmCommand.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.commands 2 | { 3 | import robotlegs.bender.extensions.commandCenter.api.ICommand; 4 | 5 | import setzer.matchthree.game.models.GameStatus; 6 | import setzer.matchthree.game.models.LevelInfo; 7 | import setzer.matchthree.game.models.LevelModel; 8 | import setzer.matchthree.services.GameService; 9 | 10 | public class SwapPiecesConfirmCommand implements ICommand 11 | { 12 | [Inject] 13 | public var levelModel:LevelModel; 14 | 15 | [Inject] 16 | public var gameStatus:GameStatus; 17 | 18 | [Inject] 19 | public var gameService:GameService; 20 | 21 | public function execute():void 22 | { 23 | if ( levelModel.levelInfo.levelType == LevelInfo.TIMER_TYPE ) return; 24 | 25 | levelModel.numMoves -= 1; 26 | 27 | gameService.updateHUDData(); 28 | 29 | if ( levelModel.numMoves == 0 ) 30 | gameStatus.gameOver(); 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/displays/BlankedCell.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.displays 2 | { 3 | import setzer.matchthree.game.models.Tile; 4 | 5 | import starling.display.Quad; 6 | 7 | public class BlankedCell extends Quad 8 | { 9 | public function BlankedCell() 10 | { 11 | super( Tile.TILE_WIDTH, Tile.TILE_HEIGHT, 0xFFFFFF ); 12 | alpha = .3; 13 | alignPivot(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/displays/PieceDisplay.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.displays 2 | { 3 | import setzer.matchthree.assets.Assets; 4 | import setzer.matchthree.game.utils.PieceDisplayPool; 5 | import setzer.matchthree.game.utils.PieceUtils; 6 | 7 | import starling.display.Image; 8 | 9 | public class PieceDisplay extends Image 10 | { 11 | private var _assetId:String; 12 | 13 | public function PieceDisplay( pieceId:int, pieceType:String ) 14 | { 15 | _assetId = PieceUtils.getAssetId( pieceId, pieceType ); 16 | super( Assets.getTexture( _assetId ) ); 17 | 18 | alignPivot(); 19 | } 20 | 21 | public function destroy():void 22 | { 23 | PieceDisplayPool.back( this ); 24 | removeFromParent(); 25 | } 26 | 27 | public function get assetId():String 28 | { 29 | return _assetId; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/models/GameStatus.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | public class GameStatus 4 | { 5 | private var _isPaused:Boolean; 6 | private var _isGameOver:Boolean; 7 | public var hasToWait:Boolean; 8 | 9 | public function start():void 10 | { 11 | _isGameOver = false; 12 | } 13 | 14 | public function gameOver():void 15 | { 16 | _isGameOver = true; 17 | } 18 | 19 | public function pause():void 20 | { 21 | _isPaused = true; 22 | } 23 | 24 | public function resume():void 25 | { 26 | _isPaused = false; 27 | } 28 | 29 | public function get isPaused():Boolean 30 | { 31 | return _isPaused; 32 | } 33 | 34 | public function get isGameOver():Boolean 35 | { 36 | return _isGameOver; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/models/GridData.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | import setzer.matchthree.game.utils.PieceUtils; 4 | 5 | public class GridData 6 | { 7 | private var _maxCols:uint; 8 | private var _maxRows:uint; 9 | private var _grid:Vector.>; 10 | 11 | public function GridData( cols:uint = 8, rows:uint = 8 ) 12 | { 13 | _grid = new Vector.>(); 14 | _maxCols = cols; 15 | _maxRows = rows; 16 | generateEmptyGrid(); 17 | } 18 | 19 | private function generateEmptyGrid():void 20 | { 21 | var line:Vector.; 22 | for ( var row:int = 0; row < _maxRows; row++ ) 23 | { 24 | line = new Vector.(); 25 | for ( var col:int = 0; col < _maxCols; col++ ) 26 | { 27 | line.push( PieceUtils.getEmptyPiece( col, row ) ); 28 | } 29 | _grid.push( line ); 30 | } 31 | } 32 | 33 | public function get maxRows():uint 34 | { 35 | return _maxRows; 36 | } 37 | 38 | public function get maxCols():uint 39 | { 40 | return _maxCols; 41 | } 42 | 43 | public function getPiece( col:int, row:int ):PieceData 44 | { 45 | return _grid[row][col] || null; 46 | } 47 | 48 | public function setPiece( piece:PieceData ):void 49 | { 50 | _grid[piece.row][piece.col] = piece; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/models/LevelInfo.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | public class LevelInfo 4 | { 5 | public static const MOVE_TYPE:String = "moveType"; 6 | public static const TIMER_TYPE:String = "timerType"; 7 | 8 | public var hiScore:int; 9 | 10 | private var _maxCols:int; 11 | private var _maxRows:int; 12 | private var _levelType:String; 13 | 14 | private var _scoreStarts:Vector.; 15 | private var _numMoves:int; 16 | private var _time:int; 17 | private var _levelId:int; 18 | 19 | public function LevelInfo( levelId:int, maxCols:int, maxRows:int, levelType:String, scoreStart1:int, scoreStart2:int, scoreStart3:int, moves:int = 16, time:int = 0 ) 20 | { 21 | _levelId = levelId; 22 | _numMoves = moves; 23 | _time = time; 24 | this._maxCols = maxCols; 25 | this._maxRows = maxRows; 26 | this._levelType = levelType; 27 | this._scoreStarts = new [scoreStart1, scoreStart2, scoreStart3]; 28 | } 29 | 30 | public function getNumStars():int 31 | { 32 | var numStars:int = 0; 33 | for ( var i:int = 0; i < scoreStarts.length; i++ ) 34 | { 35 | if ( hiScore >= scoreStarts[i] ) 36 | numStars++; 37 | } 38 | 39 | return numStars; 40 | } 41 | 42 | public function get scoreStarts():Vector. 43 | { 44 | return _scoreStarts; 45 | } 46 | 47 | public function get levelType():String 48 | { 49 | return _levelType; 50 | } 51 | 52 | public function get maxRows():int 53 | { 54 | return _maxRows; 55 | } 56 | 57 | public function get maxCols():int 58 | { 59 | return _maxCols; 60 | } 61 | 62 | public function get numMoves():int 63 | { 64 | return _numMoves; 65 | } 66 | 67 | public function get time():int 68 | { 69 | return _time; 70 | } 71 | 72 | public function get levelId():int 73 | { 74 | return _levelId; 75 | } 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/models/PieceData.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | import setzer.matchthree.game.displays.PieceDisplay; 4 | import setzer.matchthree.game.utils.PieceDisplayPool; 5 | import setzer.matchthree.game.utils.PieceType; 6 | 7 | public class PieceData 8 | { 9 | private var _pieceType:String; 10 | public var pieceId:int; 11 | public var row:int; 12 | public var col:int; 13 | 14 | public var display:PieceDisplay; 15 | 16 | public function PieceData( col:int = 0, row:int = 0, pieceType:String = PieceType.EMPTY, pieceId:int = 0 ) 17 | { 18 | this._pieceType = pieceType; 19 | this.pieceId = pieceId; 20 | this.col = col; 21 | this.row = row; 22 | } 23 | 24 | public function createDisplay():void 25 | { 26 | display = PieceDisplayPool.getPieceDisplay( pieceId, _pieceType ); 27 | display.x = Tile.TILE_WIDTH * col; 28 | display.y = row ? Tile.TILE_WIDTH * row : -Tile.TILE_HEIGHT; 29 | } 30 | 31 | public function setPosition( col:int, row:int ):void 32 | { 33 | this.col = col; 34 | this.row = row; 35 | } 36 | 37 | public function toString():String 38 | { 39 | return "piece_id_" + pieceId + "_type_" + _pieceType + "_col_" + col + "_row_" + row; 40 | } 41 | 42 | public function get pieceType():String 43 | { 44 | return _pieceType; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/models/SwapModel.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | import starling.events.TouchPhase; 4 | 5 | public class SwapModel 6 | { 7 | 8 | public static const SWAP:String = "swap"; 9 | public static const WAIT:String = "wait"; 10 | public static const ROLLBACK:String = "rollback"; 11 | public static const VALIDATE:String = "validate"; 12 | public static const HORIZONTAL:String = "horizontal"; 13 | public static const VERTICAL:String = "vertical"; 14 | 15 | public var status:String; 16 | 17 | private var _first:Tile; 18 | private var _second:Tile; 19 | private var _maxCols:int; 20 | private var _maxRows:int; 21 | 22 | public function SwapModel() 23 | { 24 | _first = new Tile(); 25 | _second = new Tile(); 26 | } 27 | 28 | public function setMaxValues( maxCols:int, maxRows:int ):void 29 | { 30 | _maxCols = maxCols; 31 | _maxRows = maxRows; 32 | } 33 | 34 | public function setPosition( phase:String, col:int, row:int ):void 35 | { 36 | var position:Tile = (TouchPhase.BEGAN == phase) ? _first : _second; 37 | 38 | position.col = solveRanger( col, _maxCols ); 39 | position.row = solveRanger( row, _maxRows ); 40 | } 41 | 42 | private static function solveRanger( value:int, max:int ):int 43 | { 44 | return Math.max( Math.min( value, max - 1 ), 0 ); 45 | } 46 | 47 | public function get swapDirection():String 48 | { 49 | return (first.col == second.col) ? VERTICAL : HORIZONTAL; 50 | } 51 | 52 | public function get first():Tile 53 | { 54 | return _first; 55 | } 56 | 57 | public function get second():Tile 58 | { 59 | return _second; 60 | } 61 | 62 | public function updateStatus():void 63 | { 64 | if ( status == SwapModel.SWAP ) 65 | status = SwapModel.VALIDATE; // 66 | else 67 | status = ""; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/models/Tile.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | public class Tile 4 | { 5 | public static const TILE_WIDTH:int = 36; 6 | public static const TILE_HEIGHT:int = 36; 7 | 8 | public var col:int; 9 | public var row:int; 10 | 11 | public function Tile( col:int = 0, row:int = 0 ) 12 | { 13 | this.col = col; 14 | this.row = row; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/utils/AnimationUtils.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.utils 2 | { 3 | import com.greensock.TimelineLite; 4 | import com.greensock.TweenLite; 5 | 6 | import setzer.matchthree.game.models.PieceData; 7 | import setzer.matchthree.game.models.Tile; 8 | 9 | public class AnimationUtils 10 | { 11 | public static function createMoveTween( piece:PieceData ):TweenLite 12 | { 13 | return new TweenLite( piece.display, .1, {x:piece.col * Tile.TILE_WIDTH, y:piece.row * Tile.TILE_HEIGHT} ); 14 | } 15 | 16 | public static function createRemoveTween( piece:PieceData ):TweenLite 17 | { 18 | return new TweenLite( piece.display, .25, { 19 | alpha:0, scaleX:1.3, scaleY:1.3, onComplete:piece.display.destroy 20 | } ); 21 | } 22 | 23 | public static function applyAnimation( animationList:Array, complete:Function ):void 24 | { 25 | var timeline:TimelineLite = new TimelineLite(); 26 | timeline.insertMultiple( animationList ); 27 | timeline.insert( new TweenLite( {}, animationList[0].duration + 0.01, {onComplete:complete} ) ) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/utils/LevelsRepository.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.utils 2 | { 3 | import setzer.matchthree.game.models.LevelInfo; 4 | 5 | public class LevelsRepository 6 | { 7 | private static var levels:Vector.; 8 | 9 | public static function init():void 10 | { 11 | levels = new Vector.(); 12 | levels.push( new LevelInfo( 0, 5, 7, LevelInfo.MOVE_TYPE, 4200, 5000, 6000, 10 ) );//35 13 | levels.push( new LevelInfo( 1, 6, 8, LevelInfo.TIMER_TYPE, 8000, 9000, 10000, 0, 80 ) );//48 14 | levels.push( new LevelInfo( 2, 6, 9, LevelInfo.MOVE_TYPE, 8000, 10000, 12000, 20 ) );//54 15 | levels.push( new LevelInfo( 3, 8, 6, LevelInfo.MOVE_TYPE, 8000, 9000, 10000, 15 ) );//48 16 | levels.push( new LevelInfo( 4, 7, 7, LevelInfo.TIMER_TYPE, 16000, 18000, 20000, 0, 120 ) );//49 17 | levels.push( new LevelInfo( 5, 9, 5, LevelInfo.TIMER_TYPE, 42000, 48000, 55000, 0, 300 ) );//45 18 | levels.push( new LevelInfo( 6, 5, 5, LevelInfo.MOVE_TYPE, 1800, 2600, 3200, 5 ) );//25 19 | levels.push( new LevelInfo( 7, 6, 8, LevelInfo.MOVE_TYPE, 16000, 21000, 26000, 30 ) );//48 20 | levels.push( new LevelInfo( 8, 6, 7, LevelInfo.TIMER_TYPE, 24500, 28200, 32000, 0, 180 ) );//45 21 | } 22 | 23 | public static function getLevelInfoById( levelId:int ):LevelInfo 24 | { 25 | return levels[levelId] || levels[0]; 26 | } 27 | 28 | public static function updateHiScore( levelId:int, hiScore:int ):void 29 | { 30 | getLevelInfoById( levelId ).hiScore = hiScore; 31 | } 32 | 33 | public static function getLevels():Vector. 34 | { 35 | return levels; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/utils/PieceDisplayPool.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.utils 2 | { 3 | import flash.utils.Dictionary; 4 | 5 | import setzer.matchthree.game.displays.PieceDisplay; 6 | 7 | public class PieceDisplayPool 8 | { 9 | public static var pieceLists:Dictionary; 10 | 11 | public static function init():void 12 | { 13 | pieceLists = new Dictionary(); 14 | } 15 | 16 | public static function getPieceDisplay( pieceId:int, pieceType:String ):PieceDisplay 17 | { 18 | var assetId:String = PieceUtils.getAssetId( pieceId, pieceType ); 19 | 20 | if ( pieceLists[assetId] == null ) pieceLists[assetId] = new Vector.(); 21 | 22 | var list:Vector. = pieceLists[assetId]; 23 | var piece:PieceDisplay = list.shift() || new PieceDisplay( pieceId, pieceType ); 24 | piece.visible = true; 25 | piece.alpha = 1; 26 | piece.scaleX = 1; 27 | piece.scaleY = 1; 28 | 29 | return piece; 30 | } 31 | 32 | public static function back( piece:PieceDisplay ):void 33 | { 34 | var list:Vector. = pieceLists[piece.assetId]; 35 | piece.visible = false; 36 | 37 | if ( list.indexOf( piece ) == -1 ) 38 | list.push( piece ); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/utils/PieceIds.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.utils 2 | { 3 | public class PieceIds 4 | { 5 | public static const EMPTY:int = 0; 6 | 7 | public static const BLUE:int = 1; 8 | public static const GREEN:int = 2; 9 | public static const ORANGE:int = 3; 10 | public static const YELLOW:int = 4; 11 | public static const PINK:int = 5; 12 | public static const LIGHT_BLUE:int = 6; 13 | 14 | public static const RAINBOW:int = 7; 15 | 16 | public static const ALL_NORMAL_IDS:Array = [BLUE, ORANGE, GREEN, YELLOW, PINK, LIGHT_BLUE]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/utils/PieceType.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.utils 2 | { 3 | public class PieceType 4 | { 5 | public static const EMPTY:String = "empty"; 6 | 7 | public static const NORMAL:String = "normal"; 8 | public static const ROW:String = "row"; 9 | public static const COL:String = "col"; 10 | public static const RAINBOW:String = "rainbow"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/game/utils/PowerUpUtils.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.utils 2 | { 3 | import setzer.matchthree.game.models.GridData; 4 | import setzer.matchthree.game.models.PieceData; 5 | 6 | public class PowerUpUtils 7 | { 8 | public static function getPiecesAffectedByPowerUp( piece:PieceData, grid:GridData ):Vector. 9 | { 10 | var piecesToRemove:Vector. = new Vector.(); 11 | if ( piece.pieceType == PieceType.ROW ) 12 | { 13 | piecesToRemove = piecesToRemove.concat( GridUtils.getRow( grid, piece.row ) ); 14 | 15 | } else if ( piece.pieceType == PieceType.COL ) 16 | { 17 | piecesToRemove = piecesToRemove.concat( GridUtils.getCol( grid, piece.col ) ); 18 | 19 | } else if ( piece.pieceType == PieceType.RAINBOW && piece.pieceId == PieceIds.RAINBOW ) 20 | { 21 | piecesToRemove = piecesToRemove.concat( GridUtils.getRow( grid, piece.row ) ); 22 | piecesToRemove = piecesToRemove.concat( GridUtils.getCol( grid, piece.col ) ); 23 | 24 | } else if ( piece.pieceType == PieceType.RAINBOW && (PieceIds.ALL_NORMAL_IDS.indexOf( piece.pieceId ) != -1) ) 25 | { 26 | piecesToRemove = piecesToRemove.concat( GridUtils.getAllPiecesById( grid, piece.pieceId ) ); 27 | } 28 | 29 | return piecesToRemove; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/AlertPopupMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.utils.SharedObjectManager; 6 | import setzer.matchthree.views.AlertPopup; 7 | 8 | import starling.events.Event; 9 | 10 | public class AlertPopupMediator extends StarlingMediator 11 | { 12 | [Inject] 13 | public var view:AlertPopup; 14 | 15 | override public function initialize():void 16 | { 17 | eventMap.mapListener( view.confirmButton, Event.TRIGGERED, confirmButton_onTriggeredHandler ); 18 | eventMap.mapListener( view.cancelButton, Event.TRIGGERED, cancelButton_onTriggeredHandler ); 19 | } 20 | 21 | private function confirmButton_onTriggeredHandler( e:Event ):void 22 | { 23 | SharedObjectManager.clear(); 24 | view.removeFromParent(); 25 | } 26 | 27 | private function cancelButton_onTriggeredHandler( e:Event ):void 28 | { 29 | view.removeFromParent(); 30 | } 31 | 32 | override public function destroy():void 33 | { 34 | eventMap.unmapListeners(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/GameOverPopupMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.services.FlowService; 6 | import setzer.matchthree.services.GameService; 7 | import setzer.matchthree.views.GameOverPopup; 8 | 9 | import starling.events.Event; 10 | 11 | public class GameOverPopupMediator extends StarlingMediator 12 | { 13 | [Inject] 14 | public var view:GameOverPopup; 15 | 16 | [Inject] 17 | public var flowService:FlowService; 18 | 19 | [Inject] 20 | public var gameService:GameService; 21 | 22 | override public function initialize():void 23 | { 24 | eventMap.mapListener( view.retryButton, Event.TRIGGERED, retryButton_onTriggeredHandler ); 25 | eventMap.mapListener( view.levelSelectButton, Event.TRIGGERED, levelSelectButton_onTriggeredHandler ); 26 | } 27 | 28 | private function retryButton_onTriggeredHandler( e:Event ):void 29 | { 30 | gameService.retryCommand(); 31 | view.removeFromParent(); 32 | } 33 | 34 | private function levelSelectButton_onTriggeredHandler( e:Event ):void 35 | { 36 | flowService.setLevelSelectView(); 37 | view.removeFromParent(); 38 | } 39 | 40 | override public function destroy():void 41 | { 42 | eventMap.unmapListeners(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/GameViewMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.views.GameView; 6 | 7 | public class GameViewMediator extends StarlingMediator 8 | { 9 | [Inject] 10 | public var view:GameView; 11 | 12 | override public function initialize():void 13 | { 14 | view.createComponents(); 15 | } 16 | 17 | override public function destroy():void 18 | { 19 | view.destroy(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/HomeViewMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.services.FlowService; 6 | import setzer.matchthree.views.HomeView; 7 | 8 | import starling.events.Event; 9 | 10 | public class HomeViewMediator extends StarlingMediator 11 | { 12 | [Inject] 13 | public var view:HomeView; 14 | 15 | [Inject] 16 | public var flowService:FlowService; 17 | 18 | override public function initialize():void 19 | { 20 | eventMap.mapListener( view.optionsButton, Event.TRIGGERED, optionsButton_onTriggeredHandler ); 21 | eventMap.mapListener( view.playButton, Event.TRIGGERED, playButton_onTriggeredHandler ); 22 | } 23 | 24 | private function optionsButton_onTriggeredHandler( e:Event ):void 25 | { 26 | flowService.setOptionsView(); 27 | } 28 | 29 | private function playButton_onTriggeredHandler( e:Event ):void 30 | { 31 | flowService.setLevelSelectView(); 32 | } 33 | 34 | override public function destroy():void 35 | { 36 | eventMap.unmapListeners(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/IntroViewMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import flash.utils.setTimeout; 4 | 5 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 6 | 7 | import setzer.matchthree.services.FlowService; 8 | import setzer.matchthree.views.IntroView; 9 | 10 | public class IntroViewMediator extends StarlingMediator 11 | { 12 | [Inject] 13 | public var flowService:FlowService; 14 | 15 | [Inject] 16 | public var view:IntroView; 17 | 18 | override public function initialize():void 19 | { 20 | view.playAnimation(); 21 | setTimeout( onTimerOutHandler, 3000 ); 22 | } 23 | 24 | private function onTimerOutHandler():void 25 | { 26 | flowService.setHomeView(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/LevelSelectViewMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import flash.utils.Dictionary; 4 | 5 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 6 | 7 | import setzer.matchthree.game.models.LevelInfo; 8 | import setzer.matchthree.game.utils.LevelsRepository; 9 | import setzer.matchthree.services.FlowService; 10 | import setzer.matchthree.services.GameService; 11 | import setzer.matchthree.utils.SharedObjectManager; 12 | import setzer.matchthree.utils.ViewPortSize; 13 | import setzer.matchthree.views.LevelSelectView; 14 | import setzer.matchthree.views.components.LevelSelectButton; 15 | 16 | import starling.events.Event; 17 | 18 | public class LevelSelectViewMediator extends StarlingMediator 19 | { 20 | [Inject] 21 | public var view:LevelSelectView; 22 | 23 | [Inject] 24 | public var flowService:FlowService; 25 | 26 | [Inject] 27 | public var gameService:GameService; 28 | 29 | private var levelsIds:Dictionary; 30 | 31 | override public function initialize():void 32 | { 33 | SharedObjectManager.getExternalData(); 34 | 35 | createMapButtons(); 36 | eventMap.mapListener( view.backButton, Event.TRIGGERED, backButton_onTriggeredHandler ); 37 | } 38 | 39 | private function createMapButtons():void 40 | { 41 | levelsIds = new Dictionary(); 42 | var levels:Vector. = LevelsRepository.getLevels(); 43 | var levelInfo:LevelInfo; 44 | var levelButton:LevelSelectButton; 45 | for ( var i:int = 0; i < levels.length; i++ ) 46 | { 47 | levelInfo = levels[i]; 48 | levelButton = view.createLevelButton( String( levelInfo.levelId + 1 ) ); 49 | levelButton.x = ViewPortSize.HALF_WIDTH - (levelButton.width + 4) + (Math.floor( i % 3 ) * (levelButton.width + 4)); 50 | levelButton.y = 180 + (Math.floor( i / 3 ) * (levelButton.height + 8)); 51 | levelButton.setStars( levelInfo.getNumStars() ); 52 | levelButton.alignPivot(); 53 | levelsIds[levelButton] = levels[i].levelId; 54 | eventMap.mapListener( levelButton, Event.TRIGGERED, levelButton_onTriggeredHandler ) 55 | } 56 | } 57 | 58 | private function backButton_onTriggeredHandler( e:Event ):void 59 | { 60 | flowService.setHomeView(); 61 | } 62 | 63 | private function levelButton_onTriggeredHandler( e:Event ):void 64 | { 65 | gameService.createLevel( levelsIds[e.currentTarget] ); 66 | } 67 | 68 | override public function destroy():void 69 | { 70 | eventMap.unmapListeners(); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/OptionsViewMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.services.FlowService; 6 | import setzer.matchthree.views.OptionsView; 7 | 8 | import starling.events.Event; 9 | 10 | public class OptionsViewMediator extends StarlingMediator 11 | { 12 | [Inject] 13 | public var view:OptionsView; 14 | 15 | [Inject] 16 | public var flowService:FlowService; 17 | 18 | override public function initialize():void 19 | { 20 | eventMap.mapListener( view.backButton, Event.TRIGGERED, closeButton_onTriggeredHandler ) 21 | eventMap.mapListener( view.deleteButton, Event.TRIGGERED, deleteButton_onTriggeredHandler ) 22 | } 23 | 24 | private function deleteButton_onTriggeredHandler( e:Event ):void 25 | { 26 | flowService.showAlertPopup(); 27 | } 28 | 29 | private function closeButton_onTriggeredHandler( e:Event ):void 30 | { 31 | flowService.setHomeView(); 32 | } 33 | 34 | override public function destroy():void 35 | { 36 | eventMap.unmapListeners(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/PausePopupMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.services.FlowService; 6 | import setzer.matchthree.services.GameService; 7 | import setzer.matchthree.views.PausePopup; 8 | 9 | import starling.events.Event; 10 | 11 | public class PausePopupMediator extends StarlingMediator 12 | { 13 | [Inject] 14 | public var view:PausePopup; 15 | 16 | [Inject] 17 | public var gameService:GameService; 18 | 19 | [Inject] 20 | public var flowService:FlowService; 21 | 22 | override public function initialize():void 23 | { 24 | eventMap.mapListener( view.resumeButton, Event.TRIGGERED, resumeButton_onTriggeredHandler ); 25 | eventMap.mapListener( view.levelSelectButton, Event.TRIGGERED, levelSelectButton_onTriggeredHandler ); 26 | eventMap.mapListener( view.retryButton, Event.TRIGGERED, replayButton_onTriggeredHandler ); 27 | } 28 | 29 | private function resumeButton_onTriggeredHandler( e:Event ):void 30 | { 31 | flowService.showStartingPopup(); 32 | view.removeFromParent(); 33 | } 34 | 35 | private function levelSelectButton_onTriggeredHandler( e:Event ):void 36 | { 37 | flowService.setLevelSelectView(); 38 | view.removeFromParent(); 39 | } 40 | 41 | private function replayButton_onTriggeredHandler( e:Event ):void 42 | { 43 | gameService.retryCommand(); 44 | view.removeFromParent(); 45 | } 46 | 47 | override public function destroy():void 48 | { 49 | eventMap.unmapListeners(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/StartingPopupMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.services.GameService; 6 | import setzer.matchthree.views.StartingPopup; 7 | 8 | import starling.events.Event; 9 | 10 | public class StartingPopupMediator extends StarlingMediator 11 | { 12 | [Inject] 13 | public var view:StartingPopup; 14 | 15 | [Inject] 16 | public var gameService:GameService; 17 | 18 | override public function initialize():void 19 | { 20 | eventMap.mapListener( view, Event.COMPLETE, view_completeHandler ); 21 | view.start(); 22 | } 23 | 24 | private function view_completeHandler( e:Event ):void 25 | { 26 | view.destroy(); 27 | gameService.resume(); 28 | } 29 | 30 | override public function destroy():void 31 | { 32 | eventMap.unmapListeners(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/mediators/YouWinPopupMediator.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.mediators 2 | { 3 | import robotlegs.bender.extensions.palidor.starlingIntegration.starlingViewMap.impl.StarlingMediator; 4 | 5 | import setzer.matchthree.game.models.LevelModel; 6 | import setzer.matchthree.services.FlowService; 7 | import setzer.matchthree.services.GameService; 8 | import setzer.matchthree.views.YouWinPopup; 9 | 10 | import starling.events.Event; 11 | 12 | public class YouWinPopupMediator extends StarlingMediator 13 | { 14 | [Inject] 15 | public var view:YouWinPopup; 16 | 17 | [Inject] 18 | public var levelModel:LevelModel; 19 | 20 | [Inject] 21 | public var flowService:FlowService; 22 | 23 | [Inject] 24 | public var gameService:GameService; 25 | 26 | override public function initialize():void 27 | { 28 | view.createStars( levelModel.numStars ); 29 | view.updateValues( String( levelModel.score ), String( levelModel.levelInfo.hiScore ) ); 30 | 31 | eventMap.mapListener( view.retryButton, Event.TRIGGERED, retryButton_onTriggeredHandler ); 32 | eventMap.mapListener( view.levelSelectButton, Event.TRIGGERED, levelSelectButton_onTriggeredHandler ); 33 | } 34 | 35 | private function retryButton_onTriggeredHandler( e:Event ):void 36 | { 37 | gameService.retryCommand(); 38 | view.removeFromParent(); 39 | } 40 | 41 | private function levelSelectButton_onTriggeredHandler( e:Event ):void 42 | { 43 | flowService.setLevelSelectView(); 44 | view.removeFromParent(); 45 | } 46 | 47 | override public function destroy():void 48 | { 49 | eventMap.unmapListeners(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/services/FlowService.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.services 2 | { 3 | import setzer.matchthree.events.FlowEvent; 4 | 5 | import starling.events.EventDispatcher; 6 | 7 | public class FlowService 8 | { 9 | [Inject] 10 | public var eventDispatcher:EventDispatcher; 11 | 12 | //Views 13 | public function setHomeView():void 14 | { 15 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_HOME_VIEW ); 16 | } 17 | 18 | public function setGameView():void 19 | { 20 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_GAME_VIEW ); 21 | } 22 | 23 | public function setLevelSelectView():void 24 | { 25 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_LEVEL_SELECT_VIEW ); 26 | } 27 | 28 | public function setOptionsView():void 29 | { 30 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_OPTIONS_VIEW ); 31 | } 32 | 33 | //Floating Views 34 | public function showAlertPopup():void 35 | { 36 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_ALERT_POPUP ); 37 | } 38 | 39 | public function showPausePopup():void 40 | { 41 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_PAUSE_POPUP ); 42 | } 43 | 44 | public function showStartingPopup():void 45 | { 46 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_STARTING_POPUP ); 47 | } 48 | 49 | public function showGameOverPopup():void 50 | { 51 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_GAME_OVER_POPUP ); 52 | } 53 | 54 | public function showYouWinPopup():void 55 | { 56 | eventDispatcher.dispatchEventWith( FlowEvent.SHOW_YOU_WIN_POPUP ); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/services/GameService.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.services 2 | { 3 | import setzer.matchthree.events.GameEvent; 4 | import setzer.matchthree.game.models.GameStatus; 5 | 6 | import starling.events.EventDispatcher; 7 | 8 | public class GameService 9 | { 10 | [Inject] 11 | public var dispatcher:EventDispatcher; 12 | 13 | [Inject] 14 | public var gameStatus:GameStatus; 15 | 16 | //Commands 17 | public function createLevel( levelId:int = 1 ):void 18 | { 19 | var event:GameEvent = new GameEvent( GameEvent.CREATE_LEVEL_COMMAND ); 20 | event.extra = {levelId:levelId}; 21 | dispatcher.dispatchEvent( event ); 22 | } 23 | 24 | public function retryCommand():void 25 | { 26 | dispatcher.dispatchEventWith( GameEvent.RETRY_GAME_COMMAND ); 27 | } 28 | 29 | public function swapPiecesCommand( phase:String, col:int, row:int ):void 30 | { 31 | var event:GameEvent = new GameEvent( GameEvent.SWAP_PIECES_COMMAND ); 32 | event.extra = { 33 | phase:phase, // 34 | col:col, // 35 | row:row // 36 | }; 37 | dispatcher.dispatchEvent( event ); 38 | } 39 | 40 | public function swapPiecesConfirmCommand():void 41 | { 42 | dispatcher.dispatchEvent( new GameEvent( GameEvent.SWAP_PIECES_CONFIRM_COMMAND ) ); 43 | } 44 | 45 | public function gameOverCommand():void 46 | { 47 | dispatcher.dispatchEventWith( GameEvent.GAME_OVER_COMMAND ); 48 | } 49 | 50 | //Game 51 | public function start():void 52 | { 53 | gameStatus.start(); 54 | } 55 | 56 | public function pause():void 57 | { 58 | gameStatus.pause(); 59 | dispatcher.dispatchEventWith( GameEvent.PAUSE ); 60 | } 61 | 62 | public function resume():void 63 | { 64 | gameStatus.resume(); 65 | dispatcher.dispatchEventWith( GameEvent.RESUME ); 66 | } 67 | 68 | public function gameOver():void 69 | { 70 | gameStatus.gameOver(); 71 | } 72 | 73 | //UPDATE_GRID 74 | public function updateHUDData():void 75 | { 76 | dispatcher.dispatchEvent( new GameEvent( GameEvent.UPDATE_HUD_DATA ) ); 77 | } 78 | 79 | public function clearGridField():void 80 | { 81 | dispatcher.dispatchEvent( new GameEvent( GameEvent.CLEAR_GRID ) ); 82 | } 83 | 84 | public function updateGridField():void 85 | { 86 | dispatcher.dispatchEvent( new GameEvent( GameEvent.UPDATE_GRID ) ); 87 | } 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/utils/MagicValues.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.utils 2 | { 3 | public class MagicValues 4 | { 5 | /* FONT */ 6 | public static const FONT_FAMILY:String = "BerlinSansFBDemi"; 7 | 8 | public static const SHARED_OBJECT_NAME:String = "Match3Palidor"; 9 | 10 | public static const SIZE_TITLE:int = 42; 11 | public static const SIZE_DEFAULT:int = 32; 12 | public static const SIZE_HUD:int = 22; 13 | 14 | public static const TEXT_SMALL_WIDTH:int = 60; 15 | public static const TEXT_MEDIUM_WIDTH:int = 120; 16 | public static const TEXT_TITLE_WIDTH:int = 200; 17 | public static const TEXT_LARGE_WIDTH:int = 320; 18 | 19 | public static const BORDER_OFFSET:int = 18; 20 | public static const BORDER_OFFSET_BOTTOM:int = 120; 21 | public static const BORDER_OFFSET_POPUP:Number = 60; 22 | public static const BORDER_OFFSET_HUD:Number = 10; 23 | 24 | public static function convertTime( secs:Number ):String 25 | { 26 | var m:Number = Math.floor( (secs % 3600) / 60 ); 27 | var s:Number = Math.max( Math.floor( (secs % 3600) % 60 ), 0 ); 28 | return ( m.toString() + ":" + (s < 10 ? "0" + s.toString() : s.toString())); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/utils/SharedObjectManager.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.utils 2 | { 3 | import flash.net.SharedObject; 4 | 5 | import setzer.matchthree.game.models.LevelInfo; 6 | import setzer.matchthree.game.utils.LevelsRepository; 7 | 8 | public class SharedObjectManager 9 | { 10 | public static function getExternalData():void 11 | { 12 | var so:SharedObject = SharedObject.getLocal( MagicValues.SHARED_OBJECT_NAME ); 13 | var levelsInfo:Vector. = LevelsRepository.getLevels(); 14 | 15 | if ( so.data.levels ) 16 | { 17 | for ( var levelId:int = 0; levelId < so.data.levels.length; levelId++ ) 18 | { 19 | levelsInfo[levelId].hiScore = int( so.data.levels[levelId] ); 20 | 21 | trace( "LevelId:", levelId, ":: hiScore: " + so.data.levels[levelId].toString() ); 22 | } 23 | 24 | } 25 | so.close(); 26 | } 27 | 28 | public static function updateHighScore():void 29 | { 30 | var so:SharedObject = SharedObject.getLocal( MagicValues.SHARED_OBJECT_NAME ); 31 | var levelsInfo:Vector. = LevelsRepository.getLevels(); 32 | var levels:Array = []; 33 | 34 | for ( var levelId:int = 0; levelId < levelsInfo.length; levelId++ ) 35 | { 36 | levels.push( levelsInfo[levelId].hiScore ); 37 | 38 | trace( "LevelId:", levelId, ":: hiScore: " + levels[levelId].toString() ); 39 | } 40 | so.data.levels = levels; 41 | 42 | so.flush(); 43 | so.close(); 44 | } 45 | 46 | public static function clear():void 47 | { 48 | var so:SharedObject = SharedObject.getLocal( MagicValues.SHARED_OBJECT_NAME ); 49 | if ( so.data.levels ) 50 | { 51 | for ( var levelId:int = 0; levelId < so.data.levels.length; levelId++ ) 52 | { 53 | so.data.levels[levelId] = 0; 54 | 55 | trace( "LevelId:", levelId, ":: hiScore: " + so.data.levels[levelId].toString() ); 56 | } 57 | 58 | } 59 | 60 | so.flush(); 61 | so.close(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/utils/Texts.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.utils 2 | { 3 | public class Texts 4 | { 5 | public static const DEVELOPER:String = "RONALDO\nSANTIAGO"; 6 | 7 | /* HUD */ 8 | public static const SCORE:String = "Score:"; 9 | public static const HI_SCORE:String = "Hi-Score:"; 10 | public static const MOVES:String = "Moves"; 11 | public static const TIME:String = "Time"; 12 | 13 | /* Alerts */ 14 | public static const CONFIRM_DELETE:String = "Would like to reset\nAll Hi-Scores?"; 15 | 16 | /* Buttons */ 17 | public static const BUTTON_PLAY:String = "Play"; 18 | public static const BUTTON_CONFIG:String = "Options"; 19 | public static const BUTTON_BACK:String = "Back"; 20 | 21 | /* Titles */ 22 | public static const LEVEL_SELECT:String = "Level Select"; 23 | public static const OPTIONS:String = "Options"; 24 | public static const ALERT:String = "Alert ! !"; 25 | public static const GAME_OVER:String = "Game Over"; 26 | public static const PAUSED:String = "Paused"; 27 | public static const YOU_WIN:String = "You Win ! !"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/utils/ViewPortSize.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.utils 2 | { 3 | public class ViewPortSize 4 | { 5 | public static const MAX_WIDTH:int = 340; 6 | public static const MAX_HEIGHT:int = 480; 7 | public static const HALF_WIDTH:int = 170; 8 | public static const HALF_HEIGHT:int = 240; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/AlertPopup.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.MagicValues; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | import setzer.matchthree.utils.Texts; 7 | import setzer.matchthree.utils.ViewPortSize; 8 | 9 | import starling.display.Button; 10 | import starling.display.Sprite; 11 | import starling.text.TextField; 12 | 13 | public class AlertPopup extends Sprite 14 | { 15 | private var _cancelButton:Button; 16 | private var _confirmButton:Button; 17 | 18 | public function AlertPopup() 19 | { 20 | createBackground(); 21 | createText(); 22 | createButtons(); 23 | } 24 | 25 | private function createBackground():void 26 | { 27 | addChild( StarlingFactory.getShadowBackground( .9 ) ); 28 | } 29 | 30 | private function createText():void 31 | { 32 | addChild( StarlingFactory.getTitle( Texts.ALERT ) ); 33 | 34 | var alert:TextField = StarlingFactory.getTextField( MagicValues.TEXT_LARGE_WIDTH, Texts.CONFIRM_DELETE ); 35 | alert.x = ViewPortSize.HALF_WIDTH; 36 | alert.y = ViewPortSize.HALF_HEIGHT; 37 | alert.height = 350; 38 | alert.alignPivot(); 39 | addChild( alert ); 40 | } 41 | 42 | private function createButtons():void 43 | { 44 | _confirmButton = StarlingFactory.getIconButton( AtlasKeys.ICON_CONFIRM ); 45 | _confirmButton.alignPivot(); 46 | _confirmButton.x = ViewPortSize.HALF_WIDTH - _confirmButton.width * .5 - 4; 47 | _confirmButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 48 | addChild( _confirmButton ); 49 | 50 | _cancelButton = StarlingFactory.getIconButton( AtlasKeys.ICON_CLOSE ); 51 | _cancelButton.alignPivot(); 52 | _cancelButton.x = ViewPortSize.HALF_WIDTH + _cancelButton.width * .5 + 4; 53 | _cancelButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 54 | addChild( _cancelButton ); 55 | } 56 | 57 | public function get confirmButton():Button 58 | { 59 | return _confirmButton; 60 | } 61 | 62 | public function get cancelButton():Button 63 | { 64 | return _cancelButton; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/GameOverPopup.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.MagicValues; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | import setzer.matchthree.utils.Texts; 7 | import setzer.matchthree.utils.ViewPortSize; 8 | 9 | import starling.display.Button; 10 | import starling.display.Sprite; 11 | 12 | public class GameOverPopup extends Sprite 13 | { 14 | private var _levelSelectButton:Button; 15 | private var _retryButton:Button; 16 | 17 | public function GameOverPopup() 18 | { 19 | createBackground(); 20 | createText(); 21 | createButtons(); 22 | } 23 | 24 | private function createBackground():void 25 | { 26 | addChild( StarlingFactory.getShadowBackground( .9 ) ); 27 | } 28 | 29 | private function createText():void 30 | { 31 | addChild( StarlingFactory.getTitle( Texts.GAME_OVER ) ); 32 | } 33 | 34 | private function createButtons():void 35 | { 36 | _retryButton = StarlingFactory.getIconButton( AtlasKeys.ICON_RETRY ); 37 | _retryButton.alignPivot(); 38 | _retryButton.x = ViewPortSize.HALF_WIDTH - _retryButton.width * .5 - 4; 39 | _retryButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 40 | addChild( _retryButton ); 41 | 42 | _levelSelectButton = StarlingFactory.getIconButton( AtlasKeys.ICON_LEVEL_SELECT ); 43 | _levelSelectButton.alignPivot(); 44 | _levelSelectButton.x = ViewPortSize.HALF_WIDTH + _levelSelectButton.width * .5 + 4; 45 | _levelSelectButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 46 | addChild( _levelSelectButton ); 47 | } 48 | 49 | public function get retryButton():Button 50 | { 51 | return _retryButton; 52 | } 53 | 54 | public function get levelSelectButton():Button 55 | { 56 | return _levelSelectButton; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/GameView.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.utils.StarlingFactory; 4 | import setzer.matchthree.views.components.GridFieldComponent; 5 | import setzer.matchthree.views.components.HUDGameComponent; 6 | 7 | import starling.display.Sprite; 8 | 9 | public class GameView extends Sprite 10 | { 11 | private var _gridField:GridFieldComponent; 12 | private var _hudComponent:HUDGameComponent; 13 | 14 | public function GameView() 15 | { 16 | createBackground(); 17 | } 18 | 19 | private function createBackground():void 20 | { 21 | addChild( StarlingFactory.getBackground() ); 22 | } 23 | 24 | public function destroy():void 25 | { 26 | removeChild( _gridField ); 27 | removeChild( _hudComponent ); 28 | 29 | _gridField = null; 30 | _hudComponent = null; 31 | } 32 | 33 | public function createComponents():void 34 | { 35 | _hudComponent = new HUDGameComponent(); 36 | addChild( _hudComponent ); 37 | 38 | _gridField = new GridFieldComponent(); 39 | addChild( _gridField ); 40 | } 41 | 42 | public function get gridField():GridFieldComponent 43 | { 44 | return _gridField; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/HomeView.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.MagicValues; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | import setzer.matchthree.utils.ViewPortSize; 7 | import setzer.matchthree.views.components.IconButton; 8 | 9 | import starling.display.Button; 10 | import starling.display.Image; 11 | import starling.display.Sprite; 12 | 13 | public class HomeView extends Sprite 14 | { 15 | private var _playButton:Button; 16 | private var _optionsButton:Button; 17 | 18 | public function HomeView() 19 | { 20 | createBackground(); 21 | createImages(); 22 | createButtons(); 23 | } 24 | 25 | private function createBackground():void 26 | { 27 | addChild( StarlingFactory.getBackground() ); 28 | } 29 | 30 | private function createImages():void 31 | { 32 | var logo:Image = StarlingFactory.getImage( AtlasKeys.LOGO_MATCH_THREE ); 33 | logo.x = ViewPortSize.HALF_WIDTH; 34 | logo.y = ViewPortSize.MAX_HEIGHT * .3; 35 | logo.alignPivot(); 36 | addChild( logo ); 37 | 38 | var logoSetzer:Image = StarlingFactory.getImage( AtlasKeys.LOGO_SETZER ); 39 | logoSetzer.x = MagicValues.BORDER_OFFSET; 40 | logoSetzer.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET - logoSetzer.height; 41 | addChild( logoSetzer ); 42 | } 43 | 44 | private function createButtons():void 45 | { 46 | _playButton = StarlingFactory.getIconButton( AtlasKeys.ICON_RESUME, IconButton.TYPE_MEDIUM ); 47 | _playButton.x = ViewPortSize.HALF_WIDTH; 48 | _playButton.y = ViewPortSize.MAX_HEIGHT - 50 - MagicValues.BORDER_OFFSET_BOTTOM; 49 | _playButton.alignPivot(); 50 | 51 | addChild( _playButton ); 52 | 53 | _optionsButton = StarlingFactory.getIconButton( AtlasKeys.ICON_CONFIG, IconButton.TYPE_MEDIUM ); 54 | _optionsButton.x = ViewPortSize.HALF_WIDTH; 55 | _optionsButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 56 | _optionsButton.alignPivot(); 57 | addChild( _optionsButton ); 58 | } 59 | 60 | public function get playButton():Button 61 | { 62 | return _playButton; 63 | } 64 | 65 | public function get optionsButton():Button 66 | { 67 | return _optionsButton; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/IntroView.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import com.greensock.TimelineLite; 4 | import com.greensock.TweenLite; 5 | 6 | import setzer.matchthree.assets.Embeds; 7 | 8 | import setzer.matchthree.utils.MagicValues; 9 | 10 | import setzer.matchthree.utils.StarlingFactory; 11 | import setzer.matchthree.utils.Texts; 12 | import setzer.matchthree.utils.ViewPortSize; 13 | 14 | import starling.display.Image; 15 | 16 | import starling.display.Sprite; 17 | import starling.text.TextField; 18 | import starling.textures.Texture; 19 | 20 | public class IntroView extends Sprite 21 | { 22 | private var _developer:TextField; 23 | private var _logo:Image; 24 | 25 | public function IntroView() 26 | { 27 | createBackground(); 28 | createText(); 29 | createImages(); 30 | } 31 | 32 | private function createImages():void 33 | { 34 | _logo = new Image( Texture.fromEmbeddedAsset( Embeds.LANGUAGE_IMAGE ) ); 35 | _logo.pivotX = _logo.width * .5; 36 | _logo.x = ViewPortSize.HALF_WIDTH; 37 | _logo.y = ViewPortSize.MAX_HEIGHT - _logo.height; 38 | _logo.alpha = 0; 39 | addChild( _logo ); 40 | } 41 | 42 | private function createText():void 43 | { 44 | _developer = StarlingFactory.getTextField( MagicValues.TEXT_TITLE_WIDTH, Texts.DEVELOPER ); 45 | _developer.height = 100; 46 | _developer.alignPivot(); 47 | _developer.x = ViewPortSize.HALF_WIDTH; 48 | _developer.y = ViewPortSize.HALF_HEIGHT; 49 | _developer.alpha = 0; 50 | addChild( _developer ); 51 | } 52 | 53 | private function createBackground():void 54 | { 55 | addChild( StarlingFactory.getColorBackground(0x773f16) ); 56 | } 57 | 58 | public function playAnimation():void 59 | { 60 | var timeline:TimelineLite = new TimelineLite(); 61 | timeline.append( new TweenLite( _developer, .8, {scaleX:1.2, scaleY:1.2, alpha:1} ) ); 62 | timeline.append( new TweenLite( _developer, 2, {scaleX:1.2, scaleY:1.2, alpha:1} ) ); 63 | timeline.append( new TweenLite( _developer, .3, {scaleX:1, scaleY:1, alpha:0} ) ); 64 | 65 | var timelineLogo:TimelineLite = new TimelineLite(); 66 | timelineLogo.append( new TweenLite( _logo, .8, {alpha:1} ) ); 67 | timelineLogo.append( new TweenLite( _logo, 2, {alpha:1} ) ); 68 | timelineLogo.append( new TweenLite( _logo, .3, {alpha:0} ) ); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/LevelSelectView.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.MagicValues; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | import setzer.matchthree.utils.Texts; 7 | import setzer.matchthree.utils.ViewPortSize; 8 | import setzer.matchthree.views.components.IconButton; 9 | import setzer.matchthree.views.components.LevelSelectButton; 10 | 11 | import starling.display.Button; 12 | import starling.display.Sprite; 13 | 14 | public class LevelSelectView extends Sprite 15 | { 16 | private var _backButton:Button; 17 | 18 | public function LevelSelectView() 19 | { 20 | createBackground(); 21 | createText(); 22 | createButton(); 23 | } 24 | 25 | private function createBackground():void 26 | { 27 | addChild( StarlingFactory.getBackground() ); 28 | addChild( StarlingFactory.getBackgroundPopup() ); 29 | } 30 | 31 | private function createText():void 32 | { 33 | addChild( StarlingFactory.getTitle( Texts.LEVEL_SELECT ) ); 34 | } 35 | 36 | private function createButton():void 37 | { 38 | _backButton = StarlingFactory.getIconButton( AtlasKeys.ICON_HOME, IconButton.TYPE_MEDIUM ); 39 | _backButton.x = ViewPortSize.HALF_WIDTH; 40 | _backButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 41 | _backButton.alignPivot(); 42 | addChild( _backButton ); 43 | } 44 | 45 | public function createLevelButton( text:String ):LevelSelectButton 46 | { 47 | var level:LevelSelectButton = StarlingFactory.getLevelSelectButton(); 48 | level.text = text; 49 | addChild( level ); 50 | 51 | return level; 52 | } 53 | 54 | public function get backButton():Button 55 | { 56 | return _backButton; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/MainStarlingView.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import starling.display.Sprite; 4 | 5 | public class MainStarlingView extends Sprite 6 | { 7 | public function MainStarlingView() 8 | { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/OptionsView.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.MagicValues; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | import setzer.matchthree.utils.Texts; 7 | import setzer.matchthree.utils.ViewPortSize; 8 | import setzer.matchthree.views.components.IconButton; 9 | 10 | import starling.display.Button; 11 | import starling.display.Sprite; 12 | import starling.text.TextField; 13 | 14 | public class OptionsView extends Sprite 15 | { 16 | private var _deleteButton:Button; 17 | private var _backButton:Button; 18 | 19 | public function OptionsView() 20 | { 21 | createBackgrounds(); 22 | createTexts(); 23 | createButtons(); 24 | } 25 | 26 | private function createBackgrounds():void 27 | { 28 | addChild( StarlingFactory.getBackground() ); 29 | addChild( StarlingFactory.getBackgroundPopup() ); 30 | } 31 | 32 | private function createTexts():void 33 | { 34 | addChild( StarlingFactory.getTitle( Texts.OPTIONS ) ); 35 | 36 | var hiScore:TextField = StarlingFactory.getTextField( MagicValues.TEXT_MEDIUM_WIDTH, Texts.HI_SCORE, "left" ); 37 | hiScore.x = MagicValues.BORDER_OFFSET_POPUP; 38 | hiScore.y = 180; 39 | addChild( hiScore ); 40 | } 41 | 42 | private function createButtons():void 43 | { 44 | _deleteButton = StarlingFactory.getIconButton( AtlasKeys.ICON_DELETE, IconButton.TYPE_SMALL_DANGER ); 45 | _deleteButton.pivotX = _deleteButton.width; 46 | _deleteButton.x = ViewPortSize.MAX_WIDTH - MagicValues.BORDER_OFFSET_POPUP; 47 | _deleteButton.y = 175; 48 | addChild( _deleteButton ); 49 | 50 | _backButton = StarlingFactory.getIconButton( AtlasKeys.ICON_HOME, IconButton.TYPE_MEDIUM ); 51 | _backButton.x = ViewPortSize.HALF_WIDTH; 52 | _backButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 53 | _backButton.alignPivot(); 54 | addChild( _backButton ); 55 | } 56 | 57 | public function get deleteButton():Button 58 | { 59 | return _deleteButton; 60 | } 61 | 62 | public function get backButton():Button 63 | { 64 | return _backButton; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/PausePopup.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.MagicValues; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | import setzer.matchthree.utils.Texts; 7 | import setzer.matchthree.utils.ViewPortSize; 8 | 9 | import starling.display.Button; 10 | import starling.display.Sprite; 11 | 12 | public class PausePopup extends Sprite 13 | { 14 | private var _resumeButton:Button; 15 | private var _levelSelectButton:Button; 16 | private var _retryButton:Button; 17 | 18 | public function PausePopup() 19 | { 20 | createBackground(); 21 | createText(); 22 | createButtons(); 23 | } 24 | 25 | private function createBackground():void 26 | { 27 | addChild( StarlingFactory.getShadowBackground( .9 ) ); 28 | } 29 | 30 | private function createText():void 31 | { 32 | addChild( StarlingFactory.getTitle( Texts.PAUSED ) ); 33 | } 34 | 35 | private function createButtons():void 36 | { 37 | _resumeButton = StarlingFactory.getIconButton( AtlasKeys.ICON_RESUME ); 38 | _resumeButton.x = ViewPortSize.MAX_WIDTH - MagicValues.BORDER_OFFSET_HUD; 39 | _resumeButton.y = MagicValues.BORDER_OFFSET_HUD; 40 | _resumeButton.pivotX = _resumeButton.width; 41 | addChild( _resumeButton ); 42 | 43 | _retryButton = StarlingFactory.getIconButton( AtlasKeys.ICON_RETRY ); 44 | _retryButton.x = ViewPortSize.HALF_WIDTH - _retryButton.width * .5 - 4; 45 | _retryButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 46 | _retryButton.alignPivot(); 47 | addChild( _retryButton ); 48 | 49 | _levelSelectButton = StarlingFactory.getIconButton( AtlasKeys.ICON_LEVEL_SELECT ); 50 | _levelSelectButton.x = ViewPortSize.HALF_WIDTH + _levelSelectButton.width * .5 + 4; 51 | _levelSelectButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 52 | _levelSelectButton.alignPivot(); 53 | addChild( _levelSelectButton ); 54 | } 55 | 56 | public function get resumeButton():Button 57 | { 58 | return _resumeButton; 59 | } 60 | 61 | public function get levelSelectButton():Button 62 | { 63 | return _levelSelectButton; 64 | } 65 | 66 | public function get retryButton():Button 67 | { 68 | return _retryButton; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/StartingPopup.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views 2 | { 3 | import com.greensock.TimelineLite; 4 | import com.greensock.TweenLite; 5 | import com.greensock.easing.Bounce; 6 | 7 | import setzer.matchthree.utils.MagicValues; 8 | 9 | import setzer.matchthree.utils.StarlingFactory; 10 | import setzer.matchthree.utils.ViewPortSize; 11 | 12 | import starling.display.DisplayObject; 13 | import starling.display.Sprite; 14 | import starling.events.Event; 15 | import starling.text.TextField; 16 | 17 | public class StartingPopup extends Sprite 18 | { 19 | private var _clockText:TextField; 20 | private var timeline:TimelineLite; 21 | private var count:int; 22 | private var background:DisplayObject; 23 | 24 | public function StartingPopup() 25 | { 26 | createBackground(); 27 | 28 | createText(); 29 | 30 | createStopwatch(); 31 | } 32 | 33 | private function createStopwatch():void 34 | { 35 | timeline = new TimelineLite( {onComplete:timeLineComplete} ); 36 | timeline.append( new TweenLite( _clockText, .4, { 37 | scaleX:1.5, scaleY:1.5, ease:Bounce.easeOut, onComplete:changeNumber 38 | } ) ); 39 | timeline.append( new TweenLite( _clockText, .4, { 40 | scaleX:1.5, scaleY:1.5, ease:Bounce.easeOut, onComplete:changeNumber 41 | } ) ); 42 | timeline.append( new TweenLite( _clockText, .4, { 43 | scaleX:1.5, scaleY:1.5, ease:Bounce.easeOut 44 | } ) ); 45 | timeline.stop(); 46 | } 47 | 48 | private function createText():void 49 | { 50 | count = 3; 51 | 52 | _clockText = StarlingFactory.getTextField( MagicValues.TEXT_SMALL_WIDTH, "3" ); 53 | _clockText.alignPivot(); 54 | _clockText.x = ViewPortSize.HALF_WIDTH; 55 | _clockText.y = ViewPortSize.HALF_HEIGHT; 56 | addChild( _clockText ); 57 | } 58 | 59 | private function createBackground():void 60 | { 61 | background = StarlingFactory.getShadowBackground(); 62 | addChild( background ); 63 | } 64 | 65 | private function changeNumber():void 66 | { 67 | count -= 1; 68 | background.alpha -= .1; 69 | _clockText.scaleX = .1; 70 | _clockText.scaleY = .1; 71 | _clockText.text = String( count ); 72 | } 73 | 74 | private function timeLineComplete():void 75 | { 76 | timeline.stop(); 77 | timeline = null; 78 | dispatchEvent( new Event( Event.COMPLETE ) ); 79 | } 80 | 81 | public function destroy():void 82 | { 83 | removeFromParent(); 84 | } 85 | 86 | public function start():void 87 | { 88 | timeline.restart(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/components/GridFieldComponent.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views.components 2 | { 3 | import setzer.matchthree.game.displays.BlankedCell; 4 | import setzer.matchthree.game.models.Tile; 5 | import setzer.matchthree.utils.ViewPortSize; 6 | 7 | import starling.display.Quad; 8 | import starling.display.Sprite; 9 | 10 | public class GridFieldComponent extends Sprite 11 | { 12 | public function GridFieldComponent() 13 | { 14 | x = 10 + (Tile.TILE_WIDTH * .5); 15 | y = 130 + (Tile.TILE_HEIGHT * .5); 16 | } 17 | 18 | public function generateGrid( maxCols:int, maxRows:int ):void 19 | { 20 | var gridSize:int = maxCols * Tile.TILE_WIDTH; 21 | var newX:int = (ViewPortSize.MAX_WIDTH - gridSize) * .5; 22 | x = newX + (Tile.TILE_WIDTH * .5); 23 | 24 | for ( var row:int = 0; row < maxRows; row++ ) 25 | { 26 | for ( var col:int = 0; col < maxCols; col++ ) 27 | { 28 | var cell:Quad = new BlankedCell(); 29 | cell.x = Tile.TILE_WIDTH * col; 30 | cell.y = Tile.TILE_HEIGHT * row; 31 | addChild( cell ); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/components/IconButton.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views.components 2 | { 3 | import flash.utils.Dictionary; 4 | 5 | import setzer.matchthree.assets.Assets; 6 | import setzer.matchthree.assets.AtlasKeys; 7 | import setzer.matchthree.utils.MagicValues; 8 | 9 | import starling.display.Button; 10 | import starling.display.Image; 11 | import starling.text.TextFormat; 12 | 13 | public class IconButton extends Button 14 | { 15 | public static const TYPE_SMALL:String = "small"; 16 | public static const TYPE_MEDIUM:String = "medium"; 17 | public static const TYPE_SMALL_DANGER:String = "small_danger"; 18 | 19 | private var size:String; 20 | 21 | private var _ico:Image; 22 | 23 | public function IconButton( shapeType:String = TYPE_SMALL ) 24 | { 25 | this.size = shapeType; 26 | 27 | var prefix:Dictionary = new Dictionary(); 28 | prefix[TYPE_SMALL + "up"] = AtlasKeys.BUTTON_SMALL_UP; 29 | prefix[TYPE_SMALL + "down"] = AtlasKeys.BUTTON_SMALL_DOWN; 30 | 31 | prefix[TYPE_MEDIUM + "up"] = AtlasKeys.BUTTON_MEDIUM_UP; 32 | prefix[TYPE_MEDIUM + "down"] = AtlasKeys.BUTTON_MEDIUM_DOWN; 33 | 34 | prefix[TYPE_SMALL_DANGER + "up"] = AtlasKeys.BUTTON_SMALL_DANGER_UP; 35 | prefix[TYPE_SMALL_DANGER + "down"] = AtlasKeys.BUTTON_SMALL_DANGER_DOWN; 36 | 37 | super( Assets.getTexture( prefix[shapeType + "up"] ), "", Assets.getTexture( prefix[shapeType + "down"] ) ); 38 | 39 | textFormat = new TextFormat( MagicValues.FONT_FAMILY, MagicValues.SIZE_DEFAULT, 0xFFFFFF, "center", "top" ); 40 | } 41 | 42 | public function setIco( name:String ):void 43 | { 44 | if ( _ico ) _ico.removeFromParent(); 45 | 46 | _ico = new Image( Assets.getTexture( name ) ); 47 | _ico.pivotX = _ico.width * .5; 48 | _ico.pivotY = _ico.height * .5; 49 | _ico.x = width * .5; 50 | _ico.y = height * .5; 51 | addChild( _ico ); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/components/LevelSelectButton.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views.components 2 | { 3 | import setzer.matchthree.assets.AtlasKeys; 4 | import setzer.matchthree.utils.StarlingFactory; 5 | 6 | import starling.display.Quad; 7 | 8 | public class LevelSelectButton extends IconButton 9 | { 10 | public function LevelSelectButton() 11 | { 12 | super(); 13 | } 14 | 15 | public function setStars( numStars:int ):void 16 | { 17 | var star:Quad; 18 | for ( var i:int = 0; i < numStars; i++ ) 19 | { 20 | star = StarlingFactory.getImage( AtlasKeys.LEVEL_SELECT_SMALL_STAR ); 21 | star.x = i * 15 + 7; 22 | star.y = height - 14; 23 | addChild( star ); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /actionscript-match3/src/setzer/matchthree/views/components/StarDisplayComponent.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.views.components 2 | { 3 | 4 | import setzer.matchthree.assets.AtlasKeys; 5 | import setzer.matchthree.utils.StarlingFactory; 6 | 7 | import starling.display.MovieClip; 8 | import starling.display.Sprite; 9 | 10 | public class StarDisplayComponent extends Sprite 11 | { 12 | private var _stars:Vector.; 13 | 14 | public function StarDisplayComponent() 15 | { 16 | createMovieClips(); 17 | } 18 | 19 | private function createMovieClips():void 20 | { 21 | _stars = new Vector.(); 22 | _stars.push( createSingleStar( -36, -6 ) ); 23 | _stars.push( createSingleStar( 0, 0 ) ); 24 | _stars.push( createSingleStar( 36, -6 ) ); 25 | } 26 | 27 | private function createSingleStar( x:int, y:int ):MovieClip 28 | { 29 | var star:MovieClip = StarlingFactory.getMovieClip( AtlasKeys.STAR_HUD_DISPLAY ); 30 | star.alignPivot(); 31 | star.x = x; 32 | star.y = y; 33 | addChild( star ); 34 | 35 | return star; 36 | } 37 | 38 | public function update( score:int, scoreStarts:Vector. ):void 39 | { 40 | var nextFrame:Number; 41 | var scoreStarsPrevious:int = 0; 42 | var scoreIni:int; 43 | var scoreEnd:int; 44 | var star:MovieClip; 45 | 46 | for ( var i:int = 0; i < scoreStarts.length; i++ ) 47 | { 48 | scoreIni = score - scoreStarsPrevious; 49 | scoreEnd = scoreStarts[i] - scoreStarsPrevious; 50 | star = _stars[i]; 51 | 52 | nextFrame = Math.min( Math.floor( (scoreIni / scoreEnd) * 10 ), star.numFrames - 1 ); 53 | nextFrame = Math.max( nextFrame, 0 ); 54 | 55 | star.currentFrame = nextFrame; 56 | star.readjustSize(); 57 | scoreStarsPrevious = scoreStarts[i] 58 | } 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /actionscript-match3/test/setzer/matchthree/game/models/GridDataTest.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | import org.flexunit.Assert; 4 | 5 | import setzer.matchthree.game.utils.PieceType; 6 | 7 | public class GridDataTest 8 | { 9 | private var grid:GridData; 10 | 11 | [Before] 12 | public function setUp():void 13 | { 14 | grid = new GridData(); 15 | } 16 | 17 | [After] 18 | public function tearDown():void 19 | { 20 | grid = null; 21 | } 22 | 23 | [Test] 24 | public function testConstructorDefaultValues():void 25 | { 26 | grid = new GridData(); 27 | Assert.assertEquals( 8, grid.maxCols ); 28 | Assert.assertEquals( 8, grid.maxRows ); 29 | } 30 | 31 | [Test] 32 | public function testGenerateGrid():void 33 | { 34 | grid = new GridData(); 35 | Assert.assertEquals( PieceType.EMPTY, grid.getPiece( 0, 0 ).pieceType ); 36 | Assert.assertNotNull( grid.getPiece( grid.maxCols - 1, grid.maxRows - 1 ) ); 37 | } 38 | 39 | [Test] 40 | public function testGetTile():void 41 | { 42 | var piece:PieceData = new PieceData( 1, 1 ); 43 | 44 | grid.setPiece( piece ); 45 | 46 | var pieceGet:PieceData = grid.getPiece( 1, 1 ); 47 | 48 | Assert.assertEquals( 1, pieceGet.col ); 49 | Assert.assertEquals( 1, pieceGet.row ); 50 | Assert.assertNotNull( pieceGet ); 51 | } 52 | 53 | [Test] 54 | public function testSetPiece():void 55 | { 56 | var piece1:PieceData = new PieceData( 0, 0 ); 57 | var piece2:PieceData = new PieceData( 1, 1 ); 58 | 59 | grid.setPiece( piece1 ); 60 | grid.setPiece( piece2 ); 61 | 62 | Assert.assertEquals( piece1, grid.getPiece( 0, 0 ) ); 63 | Assert.assertEquals( piece2, grid.getPiece( 1, 1 ) ); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /actionscript-match3/test/setzer/matchthree/game/models/PieceTest.as: -------------------------------------------------------------------------------- 1 | package setzer.matchthree.game.models 2 | { 3 | import org.flexunit.Assert; 4 | 5 | import setzer.matchthree.game.utils.PieceType; 6 | 7 | public class PieceTest 8 | { 9 | private var piece:PieceData; 10 | 11 | [Before] 12 | public function setUp():void 13 | { 14 | piece = new PieceData(); 15 | } 16 | 17 | [After] 18 | public function tearDown():void 19 | { 20 | piece = null; 21 | } 22 | 23 | [Test] 24 | public function testConstructor():void 25 | { 26 | piece = new PieceData( 1, 2, PieceType.NORMAL ); 27 | Assert.assertEquals( PieceType.NORMAL, piece.pieceType ); 28 | Assert.assertEquals( 1, piece.col ); 29 | Assert.assertEquals( 2, piece.row ); 30 | } 31 | 32 | [Test] 33 | public function testSetPosition():void 34 | { 35 | piece.setPosition( 1, 2 ); 36 | Assert.assertEquals( 1, piece.col ); 37 | Assert.assertEquals( 2, piece.row ); 38 | } 39 | 40 | [Test] 41 | public function testToString():void 42 | { 43 | piece.row = 5; 44 | piece.col = 5; 45 | 46 | var str:String = piece.toString(); 47 | Assert.assertEquals( "piece_id_0_type_empty_col_5_row_5", str ); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /gif_match3_as_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/gif_match3_as_demo.gif -------------------------------------------------------------------------------- /gif_match3_ts_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/gif_match3_ts_demo.gif -------------------------------------------------------------------------------- /img_cover_match3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/img_cover_match3.png -------------------------------------------------------------------------------- /img_game_match3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/img_game_match3.png -------------------------------------------------------------------------------- /typescript-match3/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | indent_style = space 8 | indent_size = 4 9 | 10 | [*.{ts}] 11 | indent_style = space 12 | indent_size = 4 13 | 14 | [*.{js,json}] 15 | indent_style = space 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /typescript-match3/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "tabWidth": 2, 4 | "overrides": [ 5 | { 6 | "files": "*.ts", 7 | "options": { 8 | "tabWidth": 4 9 | } 10 | } 11 | ], 12 | "useTabs": false, 13 | "semi": true, 14 | "singleQuote": false, 15 | "trailingComma": "none", 16 | "bracketSpacing": true 17 | } 18 | -------------------------------------------------------------------------------- /typescript-match3/README.md: -------------------------------------------------------------------------------- 1 | ![cover](media/img_cover_match3_ts.png) 2 | 3 | This is a TypeScript open-source game which is a port of the ActionScript version, following the same concepts, graphics, and architecture. 4 | 5 | + **Category:** Arcade. 6 | + **Platform:** Web. 7 | + **Language:** TypeScript. 8 | + **Technologies:** PixiJS, RobotlegsJS, RobotlegsJS-Pixi, RobotlegsJS-Pixi-Palidor. 9 | 10 | * * * 11 | 12 | ### Gameplay 13 | 14 | ![gif_ts](media/gif_match3_ts_demo.gif) 15 | 16 | * * * 17 | 18 | ### Dependencies 19 | 20 | + [PixiJs](http://www.pixijs.com/) 21 | + [RobotlegsJs](https://github.com/RobotlegsJS/RobotlegsJS) 22 | + [Robotlegs-Pixi](https://github.com/RobotlegsJS/RobotlegsJS-Pixi) 23 | + [Robotlegs-Pixi-Palidor](https://github.com/RobotlegsJS/RobotlegsJS-Pixi-Palidor) 24 | 25 | * * * 26 | 27 | ### Demos 28 | + **[ActionScript](https://ronaldosetzer.github.io/portfolio/open_source/match3_as/)** 29 | + **[TypeScript](https://ronaldosetzer.github.io/portfolio/open_source/match3_ts/)** 30 | 31 | * * * 32 | 33 | ### Game 34 | 35 | ![screenshot01](media/img_ss_match3_ts_01.png) 36 | 37 | ![screenshot02](media/img_ss_match3_ts_02.png) 38 | 39 | ![screenshot03](media/img_ss_match3_ts_03.png) 40 | 41 | ![screenshot04](media/img_ss_match3_ts_04.png) 42 | 43 | * * * 44 | 45 | ### Screenshots 46 | ![screenshot01](media/img_game_match3_ts.png) 47 | * * * 48 | 49 | **Ronaldo Santiago** - Game Developer [ [portfolio](https://ronaldosetzer.github.io/portfolio/) ] 50 | -------------------------------------------------------------------------------- /typescript-match3/assets/BerlinSansDemi_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/BerlinSansDemi_1.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/button_medium_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/button_medium_down.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/button_medium_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/button_medium_up.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/button_small_danger_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/button_small_danger_down.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/button_small_danger_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/button_small_danger_up.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/button_small_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/button_small_down.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/button_small_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/button_small_up.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_close.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_config.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_confirm.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_delete.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_home.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_level_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_level_select.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_pause.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_resume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_resume.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/icon_retry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/icon_retry.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/buttons/level_select_small_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/buttons/level_select_small_star.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/logo_matchthree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/logo_matchthree.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/logo_setzer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/logo_setzer.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/popup_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/popup_star.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_00.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_01.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_02.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_03.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_04.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_05.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_06.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_07.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_08.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_09.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/displays/star_hud_display_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/displays/star_hud_display_10.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_col_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_col_1.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_col_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_col_2.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_col_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_col_3.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_col_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_col_4.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_col_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_col_5.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_col_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_col_6.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_normal_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_normal_1.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_normal_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_normal_2.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_normal_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_normal_3.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_normal_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_normal_4.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_normal_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_normal_5.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_normal_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_normal_6.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_rainbow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_rainbow.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_row_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_row_1.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_row_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_row_2.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_row_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_row_3.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_row_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_row_4.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_row_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_row_5.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/game/piece_row_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/game/piece_row_6.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/matchthree-pixijs-atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/matchthree-pixijs-atlas.png -------------------------------------------------------------------------------- /typescript-match3/assets/atlas/matchthree-starling-atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/atlas/matchthree-starling-atlas.png -------------------------------------------------------------------------------- /typescript-match3/assets/backgrounds/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/backgrounds/background.png -------------------------------------------------------------------------------- /typescript-match3/assets/backgrounds/background_hud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/backgrounds/background_hud.png -------------------------------------------------------------------------------- /typescript-match3/assets/backgrounds/background_popup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/backgrounds/background_popup.png -------------------------------------------------------------------------------- /typescript-match3/assets/fonts/BerlinSansDemi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/fonts/BerlinSansDemi.png -------------------------------------------------------------------------------- /typescript-match3/assets/gimp/assets.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/gimp/assets.xcf -------------------------------------------------------------------------------- /typescript-match3/assets/gimp/stars.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/gimp/stars.xcf -------------------------------------------------------------------------------- /typescript-match3/assets/logo_typescript.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/logo_typescript.png -------------------------------------------------------------------------------- /typescript-match3/assets/matchthree-pixijs-atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/assets/matchthree-pixijs-atlas.png -------------------------------------------------------------------------------- /typescript-match3/karma.conf.js: -------------------------------------------------------------------------------- 1 | process.env.TEST = true; 2 | process.env.NODE_ENV = "test"; 3 | 4 | const webpack = require("webpack"); 5 | const path = require("path"); 6 | const webpackConfig = require("./webpack.config.js"); 7 | 8 | delete webpackConfig.entry; 9 | 10 | module.exports = function(config) { 11 | var configuration = { 12 | basePath: "", 13 | frameworks: ["mocha", "chai", "sinon", "es6-shim"], 14 | files: [ 15 | "./test/entry.test.ts", 16 | "./test/**/**/**.test.ts", 17 | { 18 | pattern: "**/*.map", 19 | served: true, 20 | included: false, 21 | watched: true 22 | } 23 | ], 24 | preprocessors: { 25 | "./**/**/**/**.ts": ["sourcemap"], 26 | "./test/**/**/**.test.ts": ["webpack"] 27 | }, 28 | webpack: webpackConfig, 29 | webpackMiddleware: { 30 | noInfo: true 31 | }, 32 | plugins: [ 33 | "karma-webpack", 34 | "karma-sourcemap-writer", 35 | "karma-sourcemap-loader", 36 | "karma-remap-istanbul", 37 | "karma-mocha-reporter", 38 | "karma-mocha", 39 | "karma-chai", 40 | "karma-sinon", 41 | "karma-es6-shim", 42 | "karma-coverage-istanbul-reporter" 43 | ], 44 | reporters: config.singleRun ? ["mocha", "coverage-istanbul"] : ["mocha"], 45 | coverageIstanbulReporter: { 46 | reports: ["html", "lcov", "lcovonly", "text-summary"], 47 | dir: "coverage", 48 | fixWebpackSourcePaths: true, 49 | "report-config": { 50 | html: { 51 | subdir: "html-report" 52 | } 53 | } 54 | }, 55 | port: 9876, 56 | colors: true, 57 | logLevel: config.LOG_INFO, 58 | autoWatch: true, 59 | browsers: ["Chrome"] 60 | }; 61 | 62 | configuration.browsers = ["PhantomJS"]; 63 | configuration.plugins.push("karma-phantomjs-launcher"); 64 | 65 | config.set(configuration); 66 | }; 67 | -------------------------------------------------------------------------------- /typescript-match3/media/gif_match3_ts_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/gif_match3_ts_demo.gif -------------------------------------------------------------------------------- /typescript-match3/media/img_cover_match3_ts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/img_cover_match3_ts.png -------------------------------------------------------------------------------- /typescript-match3/media/img_game_match3_ts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/img_game_match3_ts.png -------------------------------------------------------------------------------- /typescript-match3/media/img_ss_match3_ts_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/img_ss_match3_ts_01.png -------------------------------------------------------------------------------- /typescript-match3/media/img_ss_match3_ts_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/img_ss_match3_ts_02.png -------------------------------------------------------------------------------- /typescript-match3/media/img_ss_match3_ts_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/img_ss_match3_ts_03.png -------------------------------------------------------------------------------- /typescript-match3/media/img_ss_match3_ts_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RonaldoSetzer/GAME-Match3/f39776a015e759eff3e9728bdce49c29885b6346/typescript-match3/media/img_ss_match3_ts_04.png -------------------------------------------------------------------------------- /typescript-match3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-match3", 3 | "version": "1.0.0", 4 | "description": "OpenSource Game", 5 | "main": "src/index.ts", 6 | "scripts": { 7 | "autoformat": "prettier --config .prettierrc --write {src,test}/**/*.ts", 8 | "start": "webpack-dev-server --config ./webpack.setzer.config.js", 9 | "clean": "rimraf coverage", 10 | "lint": "tslint-config-prettier-check ./tslint.json", 11 | "prepush": "npm run clean && npm run autoformat && npm run lint", 12 | "test": "./node_modules/.bin/karma start --single-run --browsers PhantomJS", 13 | "karma": "karma start" 14 | }, 15 | "keywords": [ 16 | "Game" 17 | ], 18 | "author": "Ronaldo Santiago", 19 | "license": "MIT", 20 | "dependencies": { 21 | "@robotlegsjs/core": "^0.1.1", 22 | "@robotlegsjs/pixi": "^0.1.2", 23 | "@robotlegsjs/pixi-palidor": "^0.1.1", 24 | "gsap": "^1.20.3", 25 | "pixi.js": "^4.6.1", 26 | "prettier": "^1.8.2", 27 | "reflect-metadata": "^0.1.10" 28 | }, 29 | "devDependencies": { 30 | "@types/chai": "^4.0.5", 31 | "@types/mocha": "^2.2.44", 32 | "@types/pixi.js": "^4.6.0", 33 | "@types/sinon": "^4.0.0", 34 | "chai": "^4.1.2", 35 | "es6-map": "^0.1.5", 36 | "es6-symbol": "^3.1.1", 37 | "html-webpack-plugin": "^2.30.1", 38 | "istanbul": "^0.4.5", 39 | "istanbul-instrumenter-loader": "^3.0.0", 40 | "jasmine-core": "^2.8.0", 41 | "karma": "^1.7.1", 42 | "karma-chai": "^0.1.0", 43 | "karma-coverage-istanbul-reporter": "^1.3.0", 44 | "karma-es6-shim": "^1.0.0", 45 | "karma-mocha": "^1.3.0", 46 | "karma-mocha-reporter": "^2.2.5", 47 | "karma-phantomjs-launcher": "^1.0.4", 48 | "karma-remap-istanbul": "^0.6.0", 49 | "karma-sinon": "^1.0.5", 50 | "karma-sourcemap-loader": "^0.3.7", 51 | "karma-sourcemap-writer": "^0.1.2", 52 | "karma-webpack": "^2.0.6", 53 | "mocha": "^4.0.1", 54 | "rimraf": "^2.6.2", 55 | "sinon": "^4.1.2", 56 | "ts-loader": "^3.1.1", 57 | "ts-node": "^3.3.0", 58 | "tslint": "^5.8.0", 59 | "tslint-config-prettier": "^1.6.0", 60 | "typescript": "^2.6.1", 61 | "webpack": "^3.8.1", 62 | "webpack-dev-server": "^2.9.4" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /typescript-match3/src/index.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:no-reference 2 | /// 3 | import "reflect-metadata"; 4 | 5 | import { Context, MVCSBundle } from "@robotlegsjs/core"; 6 | import { ContextView, PixiBundle } from "@robotlegsjs/pixi"; 7 | import { PalidorPixiExtension } from "@robotlegsjs/pixi-palidor"; 8 | import PIXI = require("pixi.js"); 9 | import { Container } from "pixi.js"; 10 | 11 | import { GameConfig } from "./matchthree/configs/GameConfig"; 12 | import { PalidorConfig } from "./matchthree/configs/PalidorConfig"; 13 | import { ViewsConfig } from "./matchthree/configs/ViewsConfig"; 14 | import { AtlasKeys } from "./matchthree/utils/AtlasKeys"; 15 | 16 | class Main { 17 | private stage: PIXI.Container; 18 | private renderer: PIXI.CanvasRenderer | PIXI.WebGLRenderer; 19 | private context: Context; 20 | 21 | constructor() { 22 | this.renderer = PIXI.autoDetectRenderer(340, 480, {}); 23 | this.stage = new PIXI.Container(); 24 | this.context = new Context(); 25 | // this.context.logLevel = LogLevel.DEBUG; 26 | this.context 27 | .install(MVCSBundle, PixiBundle) 28 | .install(PalidorPixiExtension) 29 | .configure(new ContextView(this.stage)) 30 | .configure(GameConfig, ViewsConfig, PalidorConfig) 31 | .initialize(); 32 | 33 | const loader = PIXI.loader 34 | .add(AtlasKeys.ATLAS_PNG) 35 | .add(AtlasKeys.ATLAS_XML) 36 | .add(AtlasKeys.FONT_FNT) 37 | .add(AtlasKeys.BG_HUD_IMAGE) 38 | .add(AtlasKeys.BG_IMAGE) 39 | .add(AtlasKeys.BG_POPUP_IMAGE) 40 | .load(this.onLoad); 41 | 42 | document.body.appendChild(this.renderer.view); 43 | } 44 | public onLoad(): void { 45 | AtlasKeys.update(PIXI.utils.TextureCache); 46 | } 47 | public render = () => { 48 | this.renderer.render(this.stage); 49 | window.requestAnimationFrame(this.render); 50 | }; 51 | } 52 | const main = new Main(); 53 | main.render(); 54 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/configs/PalidorConfig.ts: -------------------------------------------------------------------------------- 1 | import { IConfig, IContext, IEventDispatcher, inject, injectable } from "@robotlegsjs/core"; 2 | import { IFlowManager } from "@robotlegsjs/pixi-palidor"; 3 | 4 | import { YouWinPopup } from "../views/YouWinPopup"; 5 | import { FlowEvent } from "./../events/FlowEvent"; 6 | import { FlowService } from "./../services/FlowService"; 7 | import { AlertPopup } from "./../views/AlertPopup"; 8 | import { GameOverPopup } from "./../views/GameOverPopup"; 9 | import { GameView } from "./../views/GameView"; 10 | import { HomeView } from "./../views/HomeView"; 11 | import { IntroView } from "./../views/IntroView"; 12 | import { LevelSelectView } from "./../views/LevelSelectView"; 13 | import { OptionsView } from "./../views/OptionsView"; 14 | import { PausePopup } from "./../views/PausePopup"; 15 | import { StartingPopup } from "./../views/StartingPopup"; 16 | 17 | @injectable() 18 | export class PalidorConfig implements IConfig { 19 | @inject(IContext) private context: IContext; 20 | @inject(IFlowManager) private flowManager: IFlowManager; 21 | @inject(IEventDispatcher) private eventDispatcher: IEventDispatcher; 22 | 23 | public configure(): void { 24 | this.mapPalidor(); 25 | this.eventDispatcher.dispatchEvent(new FlowEvent(FlowEvent.SHOW_INTRO_VIEW)); 26 | } 27 | private mapPalidor(): void { 28 | this.context.injector 29 | .bind(FlowService) 30 | .to(FlowService) 31 | .inSingletonScope(); 32 | 33 | this.flowManager.map(FlowEvent.SHOW_GAME_VIEW).toView(GameView); 34 | this.flowManager.map(FlowEvent.SHOW_HOME_VIEW).toView(HomeView); 35 | this.flowManager.map(FlowEvent.SHOW_INTRO_VIEW).toView(IntroView); 36 | this.flowManager.map(FlowEvent.SHOW_LEVEL_SELECT_VIEW).toView(LevelSelectView); 37 | this.flowManager.map(FlowEvent.SHOW_OPTIONS_VIEW).toView(OptionsView); 38 | 39 | this.flowManager.map(FlowEvent.SHOW_ALERT_POPUP).toFloatingView(AlertPopup); 40 | this.flowManager.map(FlowEvent.SHOW_GAME_OVER_POPUP).toFloatingView(GameOverPopup); 41 | this.flowManager.map(FlowEvent.SHOW_PAUSE_POPUP).toFloatingView(PausePopup); 42 | this.flowManager.map(FlowEvent.SHOW_STARTING_POPUP).toFloatingView(StartingPopup); 43 | this.flowManager.map(FlowEvent.SHOW_YOU_WIN_POPUP).toFloatingView(YouWinPopup); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/events/FlowEvent.ts: -------------------------------------------------------------------------------- 1 | import { Event } from "@robotlegsjs/core"; 2 | 3 | export class FlowEvent extends Event { 4 | public static SHOW_INTRO_VIEW = "showIntroView"; 5 | public static SHOW_GAME_VIEW = "showGameView"; 6 | public static SHOW_HOME_VIEW = "showHomeView"; 7 | public static SHOW_LEVEL_SELECT_VIEW = "showLevelSelectView"; 8 | public static SHOW_OPTIONS_VIEW = "showOptionsView"; 9 | 10 | public static SHOW_ALERT_POPUP = "showAlertPopup"; 11 | public static SHOW_GAME_OVER_POPUP = "showGameOverPopup"; 12 | public static SHOW_PAUSE_POPUP = "showPausePopup"; 13 | public static SHOW_STARTING_POPUP = "showStartingPopup"; 14 | public static SHOW_YOU_WIN_POPUP = "showYouWinPopup"; 15 | 16 | constructor(type: string) { 17 | super(type); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/events/GameEvent.ts: -------------------------------------------------------------------------------- 1 | import { Event } from "@robotlegsjs/core"; 2 | 3 | export class GameEvent extends Event { 4 | public static CREATE_LEVEL_COMMAND = "createLevelCommand"; 5 | public static GAME_OVER_COMMAND = "gameOverCommand"; 6 | public static RETRY_GAME_COMMAND = "retryGameCommand"; 7 | public static SWAP_PIECES_COMMAND = "swapPiecesCommand"; 8 | public static SWAP_PIECES_CONFIRM_COMMAND = "piecesSwappedCommand"; 9 | 10 | public static RESUME = "resume"; 11 | public static PAUSE = "pause"; 12 | 13 | public static UPDATE_HUD_DATA = "updateData"; 14 | 15 | public static CLEAR_GRID = "clearGridField"; 16 | public static UPDATE_GRID = "update"; 17 | 18 | public extra: any; 19 | 20 | constructor(type: string) { 21 | super(type); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/commands/CreateLevelCommand.ts: -------------------------------------------------------------------------------- 1 | import { ICommand, inject, injectable } from "@robotlegsjs/core"; 2 | 3 | import { GameEvent } from "./../../events/GameEvent"; 4 | import { FlowService } from "./../../services/FlowService"; 5 | import { GameService } from "./../../services/GameService"; 6 | import { GameManager } from "./../managers/GameManager"; 7 | import { LevelModel } from "./../models/LevelModel"; 8 | import { LevelsRepository } from "./../utils/LevelRepository"; 9 | 10 | @injectable() 11 | export class CreateLevelCommand implements ICommand { 12 | @inject(LevelModel) private levelModel: LevelModel; 13 | @inject(GameManager) private gameManager: GameManager; 14 | @inject(GameService) private gameService: GameService; 15 | @inject(FlowService) private flowService: FlowService; 16 | @inject(GameEvent) private gameEvent: GameEvent; 17 | @inject(LevelsRepository) private levelsRepository: LevelsRepository; 18 | 19 | public execute(): void { 20 | this.levelModel.levelId = this.gameEvent.extra.levelId; 21 | this.levelModel.levelInfo = this.levelsRepository.getLevelInfoById(this.levelModel.levelId); 22 | this.levelModel.reset(); 23 | this.levelModel.numMoves = this.levelModel.levelInfo.numMoves; 24 | 25 | this.gameManager.generateGrid(this.levelModel.maxCols, this.levelModel.maxRows); 26 | 27 | this.gameService.updateHUDData(); 28 | this.gameService.start(); 29 | 30 | this.flowService.setGameView(); 31 | this.flowService.showStartingPopup(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/commands/GameOverCommand.ts: -------------------------------------------------------------------------------- 1 | import { ICommand, inject, injectable } from "@robotlegsjs/core"; 2 | 3 | import { FlowService } from "./../../services/FlowService"; 4 | import { GameService } from "./../../services/GameService"; 5 | import { LevelModel } from "./../models/LevelModel"; 6 | import { LevelsRepository } from "./../utils/LevelRepository"; 7 | import { ScoreUtils } from "./../utils/ScoreUtils"; 8 | 9 | @injectable() 10 | export class GameOverCommand implements ICommand { 11 | @inject(LevelModel) private levelModel: LevelModel; 12 | @inject(GameService) private gameService: GameService; 13 | @inject(FlowService) private flowService: FlowService; 14 | @inject(LevelsRepository) private levelsRepository: LevelsRepository; 15 | 16 | public execute(): void { 17 | this.gameService.pause(); 18 | let hiScore = this.levelModel.levelInfo.hiScore; 19 | hiScore = Math.max(hiScore, this.levelModel.score); 20 | 21 | this.levelsRepository.updateHiScore(this.levelModel.levelId, hiScore); 22 | // SharedObjectManager.updateHighScore(); 23 | 24 | const stars = ScoreUtils.getNumStars(this.levelModel.score, this.levelModel.levelInfo.scoreStarts); 25 | 26 | this.levelModel.numStars = stars; 27 | 28 | if (stars > 0) { 29 | this.flowService.showYouWinPopup(); 30 | } else { 31 | this.flowService.showGameOverPopup(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/commands/RetryGameCommand.ts: -------------------------------------------------------------------------------- 1 | import { ICommand, inject, injectable } from "@robotlegsjs/core"; 2 | 3 | import { FlowService } from "./../../services/FlowService"; 4 | import { GameService } from "./../../services/GameService"; 5 | import { GameManager } from "./../managers/GameManager"; 6 | import { LevelModel } from "./../models/LevelModel"; 7 | 8 | @injectable() 9 | export class RetryGameCommand implements ICommand { 10 | @inject(LevelModel) private levelModel: LevelModel; 11 | @inject(GameManager) private gameManager: GameManager; 12 | @inject(GameService) private gameService: GameService; 13 | @inject(FlowService) private flowService: FlowService; 14 | 15 | public execute(): void { 16 | this.gameService.clearGridField(); 17 | 18 | this.levelModel.reset(); 19 | 20 | this.gameService.updateHUDData(); 21 | this.gameService.start(); 22 | this.flowService.showStartingPopup(); 23 | 24 | this.gameManager.generateGrid(this.levelModel.maxCols, this.levelModel.maxRows); 25 | this.gameManager.nextStep(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/commands/SwapPiecesCommand.ts: -------------------------------------------------------------------------------- 1 | import { ICommand, inject, injectable } from "@robotlegsjs/core"; 2 | 3 | import { GameEvent } from "./../../events/GameEvent"; 4 | import { GameManager } from "./../managers/GameManager"; 5 | import { SwapModel } from "./../models/SwapModel"; 6 | import { TouchPhase } from "./../models/TouchPhase"; 7 | 8 | @injectable() 9 | export class SwapPiecesCommand implements ICommand { 10 | @inject(SwapModel) private swapModel: SwapModel; 11 | @inject(GameManager) private gameManager: GameManager; 12 | @inject(GameEvent) private gameEvent: GameEvent; 13 | 14 | public execute(): void { 15 | this.swapModel.status = SwapModel.WAIT; 16 | this.swapModel.setPosition(this.gameEvent.extra.phase, this.gameEvent.extra.col, this.gameEvent.extra.row); 17 | 18 | if (this.gameEvent.extra.phase === TouchPhase.ENDED) { 19 | this.swapModel.status = SwapModel.SWAP; 20 | this.gameManager.nextStep.bind(this)(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/commands/SwapPiecesConfirmCommand.ts: -------------------------------------------------------------------------------- 1 | import { ICommand, inject, injectable } from "@robotlegsjs/core"; 2 | 3 | import { GameService } from "./../../services/GameService"; 4 | import { GameStatus } from "./../models/GameStatus"; 5 | import { LevelInfo } from "./../models/LevelInfo"; 6 | import { LevelModel } from "./../models/LevelModel"; 7 | 8 | @injectable() 9 | export class SwapPiecesConfirmCommand implements ICommand { 10 | @inject(LevelModel) private levelModel: LevelModel; 11 | @inject(GameStatus) private gameStatus: GameStatus; 12 | @inject(GameService) private gameService: GameService; 13 | 14 | public execute(): void { 15 | if (this.levelModel.levelInfo.levelType === LevelInfo.TIMER_TYPE) { 16 | return; 17 | } 18 | 19 | this.levelModel.numMoves -= 1; 20 | 21 | this.gameService.updateHUDData(); 22 | 23 | if (this.levelModel.numMoves === 0) { 24 | this.gameStatus.gameOver(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/displays/BlankedCell.ts: -------------------------------------------------------------------------------- 1 | import { Graphics } from "pixi.js"; 2 | 3 | import { Tile } from "./../models/Tile"; 4 | 5 | export class BlankedCell extends Graphics { 6 | constructor() { 7 | super(); 8 | this.beginFill(0xffffff); 9 | this.drawRect(0, 0, Tile.TILE_WIDTH, Tile.TILE_HEIGHT); 10 | this.alpha = 0.3; 11 | this.pivot.x = this.width * 0.5; 12 | this.pivot.y = this.height * 0.5; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/GameStatus.ts: -------------------------------------------------------------------------------- 1 | import { injectable } from "@robotlegsjs/core"; 2 | 3 | @injectable() 4 | export class GameStatus { 5 | public hasToWait: boolean; 6 | private _isPaused: boolean; 7 | private _isGameOver: boolean; 8 | 9 | public start(): void { 10 | this._isGameOver = false; 11 | } 12 | public gameOver(): void { 13 | this._isGameOver = true; 14 | } 15 | public pause(): void { 16 | this._isPaused = true; 17 | } 18 | public resume(): void { 19 | this._isPaused = false; 20 | } 21 | public get isPaused(): boolean { 22 | return this._isPaused; 23 | } 24 | public get isGameOver(): boolean { 25 | return this._isGameOver; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/GridData.ts: -------------------------------------------------------------------------------- 1 | import { PieceUtils } from "../utils/PieceUtils"; 2 | import { PieceData } from "./PieceData"; 3 | 4 | export class GridData { 5 | private _grid: PieceData[][]; 6 | private _maxCols: number; 7 | private _maxRows: number; 8 | public get maxRows(): number { 9 | return this._maxRows; 10 | } 11 | public get maxCols(): number { 12 | return this._maxCols; 13 | } 14 | 15 | constructor(cols = 8, rows = 8) { 16 | this._grid = new Array(); 17 | this._maxCols = cols; 18 | this._maxRows = rows; 19 | this.generateEmptyGrid(); 20 | } 21 | public getPiece(col: number, row: number): PieceData { 22 | if (col < this._maxCols && row < this._maxRows) { 23 | return this._grid[row][col]; 24 | } 25 | return undefined; 26 | } 27 | public setPiece(piece: PieceData): void { 28 | this._grid[piece.row][piece.col] = piece; 29 | } 30 | private generateEmptyGrid(): void { 31 | let line: PieceData[]; 32 | for (let row = 0; row < this._maxRows; row++) { 33 | line = new Array(); 34 | for (let col = 0; col < this._maxCols; col++) { 35 | line.push(PieceUtils.getEmptyPiece(col, row)); 36 | } 37 | this._grid.push(line); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/LevelInfo.ts: -------------------------------------------------------------------------------- 1 | export class LevelInfo { 2 | public static MOVE_TYPE = "moveType"; 3 | public static TIMER_TYPE = "timerType"; 4 | 5 | public hiScore: number; 6 | 7 | private _maxCols: number; 8 | private _maxRows: number; 9 | private _levelType: string; 10 | 11 | private _scoreStarts: number[]; 12 | private _numMoves: number; 13 | private _time: number; 14 | private _levelId: number; 15 | 16 | constructor( 17 | levelId: number, 18 | maxCols: number, 19 | maxRows: number, 20 | levelType: string, 21 | scoreStarts: number[], 22 | moves: number, 23 | time = 0 24 | ) { 25 | this._levelId = levelId; 26 | this._numMoves = moves; 27 | this._time = time; 28 | this._maxCols = maxCols; 29 | this._maxRows = maxRows; 30 | this._levelType = levelType; 31 | this._scoreStarts = scoreStarts; 32 | } 33 | 34 | public get scoreStarts(): number[] { 35 | return this._scoreStarts; 36 | } 37 | public get levelType(): String { 38 | return this._levelType; 39 | } 40 | public get maxRows(): number { 41 | return this._maxRows; 42 | } 43 | public get maxCols(): number { 44 | return this._maxCols; 45 | } 46 | public get numMoves(): number { 47 | return this._numMoves; 48 | } 49 | public get time(): number { 50 | return this._time; 51 | } 52 | public get levelId(): number { 53 | return this._levelId; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/PieceData.ts: -------------------------------------------------------------------------------- 1 | import { Sprite } from "pixi.js"; 2 | 3 | import { PieceType } from "./../utils/PieceType"; 4 | import { Tile } from "./Tile"; 5 | 6 | export class PieceData { 7 | public pieceId: number; 8 | public row: number; 9 | public col: number; 10 | public display: Sprite; 11 | 12 | private _pieceType: string; 13 | public get pieceType(): string { 14 | return this._pieceType; 15 | } 16 | 17 | constructor(col = 0, row = 0, pieceType: string = PieceType.EMPTY, pieceId = 0) { 18 | this._pieceType = pieceType; 19 | this.pieceId = pieceId; 20 | this.col = col; 21 | this.row = row; 22 | } 23 | public updateDisplayPosition(): void { 24 | if (this._pieceType === PieceType.EMPTY) { 25 | return; 26 | } 27 | this.display.x = Tile.TILE_WIDTH * this.col; 28 | this.display.y = this.row ? Tile.TILE_WIDTH * this.row : -Tile.TILE_HEIGHT; 29 | } 30 | public setPosition(col: number, row: number): void { 31 | this.col = col; 32 | this.row = row; 33 | } 34 | public toString(): string { 35 | return "piece_id_" + this.pieceId + "_type_" + this._pieceType + "_col_" + this.col + "_row_" + this.row; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/SwapModel.ts: -------------------------------------------------------------------------------- 1 | import { injectable } from "@robotlegsjs/core"; 2 | 3 | import { Tile } from "./Tile"; 4 | import { TouchPhase } from "./TouchPhase"; 5 | 6 | @injectable() 7 | export class SwapModel { 8 | public static SWAP = "swap"; 9 | public static WAIT = "wait"; 10 | public static ROLLBACK = "rollback"; 11 | public static VALIDATE = "validate"; 12 | public static HORIZONTAL = "horizontal"; 13 | public static VERTICAL = "vertical"; 14 | 15 | public status: string; 16 | 17 | private _first: Tile; 18 | private _second: Tile; 19 | private _maxCols: number; 20 | private _maxRows: number; 21 | 22 | constructor() { 23 | this._first = new Tile(); 24 | this._second = new Tile(); 25 | } 26 | public setMaxValues(maxCols: number, maxRows: number): void { 27 | this._maxCols = maxCols; 28 | this._maxRows = maxRows; 29 | } 30 | public setPosition(phase: string, col: number, row: number): void { 31 | let position: Tile; 32 | TouchPhase.BEGAN === phase ? (position = this.first) : (position = this._second); 33 | position.col = this.solveRanger(col, this._maxCols); 34 | position.row = this.solveRanger(row, this._maxRows); 35 | } 36 | public get swapDirection(): string { 37 | return this.first.col === this.second.col ? SwapModel.VERTICAL : SwapModel.HORIZONTAL; 38 | } 39 | public get first(): Tile { 40 | return this._first; 41 | } 42 | public get second(): Tile { 43 | return this._second; 44 | } 45 | public updateStatus(): void { 46 | this.status === SwapModel.SWAP ? (this.status = SwapModel.VALIDATE) : (this.status = ""); 47 | } 48 | private solveRanger(value: number, max: number): number { 49 | return Math.max(Math.min(value, max - 1), 0); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/Tile.ts: -------------------------------------------------------------------------------- 1 | export class Tile { 2 | public static TILE_WIDTH = 36; 3 | public static TILE_HEIGHT = 36; 4 | 5 | public col: number; 6 | public row: number; 7 | 8 | constructor(col = 0, row = 0) { 9 | this.col = col; 10 | this.row = row; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/models/TouchPhase.ts: -------------------------------------------------------------------------------- 1 | export class TouchPhase { 2 | public static BEGAN = "mousedown"; 3 | public static ENDED = "mouseup"; 4 | } 5 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/AnimationUtils.ts: -------------------------------------------------------------------------------- 1 | import { TimelineLite, TweenLite } from "gsap"; 2 | 3 | import { PieceData } from "./../models/PieceData"; 4 | import { Tile } from "./../models/Tile"; 5 | 6 | export class AnimationUtils { 7 | public static createMoveTween(piece: PieceData): TweenLite { 8 | return new TweenLite(piece.display, 0.1, { x: piece.col * Tile.TILE_WIDTH, y: piece.row * Tile.TILE_HEIGHT }); 9 | } 10 | public static createRemoveTween(piece: PieceData, destroyDisplay: Function): TweenLite { 11 | return new TweenLite(piece.display, 0.25, { 12 | alpha: 0, 13 | onComplete: destroyDisplay, 14 | onCompleteParams: [piece.display], 15 | scaleX: 1.3, 16 | scaleY: 1.3 17 | }); 18 | } 19 | public static applyAnimation(animationList: TweenLite[], complete: Function): void { 20 | const timeline: TimelineLite = new TimelineLite({ onComplete: complete }); 21 | timeline.insertMultiple(animationList); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/LevelRepository.ts: -------------------------------------------------------------------------------- 1 | import { injectable } from "@robotlegsjs/core"; 2 | 3 | import { LevelInfo } from "./../models/LevelInfo"; 4 | 5 | @injectable() 6 | export class LevelsRepository { 7 | private levels: LevelInfo[]; 8 | 9 | constructor() { 10 | this.setupLevels(); 11 | } 12 | public getLevelInfoById(levelId: number): LevelInfo { 13 | return this.levels[levelId] || this.levels[0]; 14 | } 15 | public updateHiScore(levelId: number, hiScore: number): void { 16 | this.getLevelInfoById(levelId).hiScore = hiScore; 17 | } 18 | public getLevels(): LevelInfo[] { 19 | return this.levels; 20 | } 21 | private setupLevels() { 22 | this.levels = new Array(); 23 | this.levels.push(new LevelInfo(0, 5, 7, LevelInfo.MOVE_TYPE, [4200, 5000, 6000], 10)); // 35 24 | this.levels.push(new LevelInfo(1, 6, 8, LevelInfo.TIMER_TYPE, [8000, 9000, 10000], 0, 80)); // 48 25 | this.levels.push(new LevelInfo(2, 6, 9, LevelInfo.MOVE_TYPE, [8000, 10000, 12000], 20)); // 54 26 | this.levels.push(new LevelInfo(3, 8, 6, LevelInfo.MOVE_TYPE, [8000, 9000, 10000], 15)); // 48 27 | this.levels.push(new LevelInfo(4, 7, 7, LevelInfo.TIMER_TYPE, [16000, 18000, 20000], 0, 120)); // 49 28 | this.levels.push(new LevelInfo(5, 9, 5, LevelInfo.TIMER_TYPE, [42000, 48000, 55000], 0, 300)); // 45 29 | this.levels.push(new LevelInfo(6, 5, 5, LevelInfo.MOVE_TYPE, [1800, 2600, 3200], 5)); // 25 30 | this.levels.push(new LevelInfo(7, 6, 8, LevelInfo.MOVE_TYPE, [16000, 21000, 26000], 30)); // 48 31 | this.levels.push(new LevelInfo(8, 6, 7, LevelInfo.TIMER_TYPE, [24500, 28200, 32000], 0, 180)); // 45 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/PieceDisplayPool.ts: -------------------------------------------------------------------------------- 1 | import { Sprite } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../../utils/AtlasKeys"; 4 | 5 | export class PixiSpritePool { 6 | public static spriteList: Map; 7 | public static init(): void { 8 | this.spriteList = new Map(); 9 | } 10 | public static getImage(assetId: string): Sprite { 11 | if (this.spriteList.get(assetId) === undefined) { 12 | this.spriteList.set(assetId, new Array()); 13 | } 14 | 15 | const list: Sprite[] = this.spriteList.get(assetId); 16 | let piece: Sprite; 17 | if (list.length === 0) { 18 | const texture = AtlasKeys.getTexture(assetId); 19 | piece = new Sprite(texture); 20 | piece.anchor.set(0.5); 21 | } else { 22 | piece = list.shift(); 23 | } 24 | piece.visible = true; 25 | piece.alpha = 1; 26 | piece.scale.set(1); 27 | 28 | return piece; 29 | } 30 | public static back(piece: Sprite): void { 31 | const assetId = (piece.texture).textureCacheIds[0]; 32 | const list: Sprite[] = this.spriteList.get(assetId); 33 | piece.visible = false; 34 | 35 | if (list.indexOf(piece) === -1) { 36 | list.push(piece); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/PieceIds.ts: -------------------------------------------------------------------------------- 1 | export class PieceIds { 2 | public static EMPTY = 0; 3 | 4 | public static BLUE = 1; 5 | public static GREEN = 2; 6 | public static ORANGE = 3; 7 | public static YELLOW = 4; 8 | public static PINK = 5; 9 | public static LIGHT_BLUE = 6; 10 | 11 | public static RAINBOW = 7; 12 | 13 | public static ALL_NORMAL_IDS: number[] = [ 14 | PieceIds.BLUE, 15 | PieceIds.ORANGE, 16 | PieceIds.GREEN, 17 | PieceIds.YELLOW, 18 | PieceIds.PINK, 19 | PieceIds.LIGHT_BLUE 20 | ]; 21 | } 22 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/PieceType.ts: -------------------------------------------------------------------------------- 1 | export class PieceType { 2 | public static EMPTY = "empty"; 3 | 4 | public static NORMAL = "normal"; 5 | public static ROW = "row"; 6 | public static COL = "col"; 7 | public static RAINBOW = "rainbow"; 8 | } 9 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/PowerUpUtils.ts: -------------------------------------------------------------------------------- 1 | import { GridData } from "./../models/GridData"; 2 | import { PieceData } from "./../models/PieceData"; 3 | import { GridUtils } from "./GridUtils"; 4 | import { PieceIds } from "./PieceIds"; 5 | import { PieceType } from "./PieceType"; 6 | 7 | export class PowerUpUtils { 8 | public static getPiecesAffectedByPowerUp(piece: PieceData, grid: GridData): PieceData[] { 9 | let piecesToRemove: PieceData[] = new Array(); 10 | if (piece.pieceType === PieceType.ROW) { 11 | piecesToRemove = piecesToRemove.concat(GridUtils.getRow(grid, piece.row)); 12 | } else if (piece.pieceType === PieceType.COL) { 13 | piecesToRemove = piecesToRemove.concat(GridUtils.getCol(grid, piece.col)); 14 | } else if (piece.pieceType === PieceType.RAINBOW && piece.pieceId === PieceIds.RAINBOW) { 15 | piecesToRemove = piecesToRemove.concat(GridUtils.getRow(grid, piece.row)); 16 | piecesToRemove = piecesToRemove.concat(GridUtils.getCol(grid, piece.col)); 17 | } else if (piece.pieceType === PieceType.RAINBOW && PieceIds.ALL_NORMAL_IDS.indexOf(piece.pieceId) !== -1) { 18 | piecesToRemove = piecesToRemove.concat(GridUtils.getAllPiecesById(grid, piece.pieceId)); 19 | } 20 | 21 | return piecesToRemove; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/game/utils/ScoreUtils.ts: -------------------------------------------------------------------------------- 1 | export class ScoreUtils { 2 | public static getNumStars(score: number, scoreStars: number[]): number { 3 | let numStars = 0; 4 | for (const scoreStar of scoreStars) { 5 | if (score >= scoreStar) { 6 | numStars++; 7 | } 8 | } 9 | return numStars; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/AlertPopupMediator.ts: -------------------------------------------------------------------------------- 1 | import { injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { AlertPopup } from "./../views/AlertPopup"; 5 | 6 | @injectable() 7 | export class AlertPopupMediator extends Mediator { 8 | public initialize(): void { 9 | this.eventMap.mapListener(this.view.confirmButton, "click", this.confirmButton_onTriggeredHandler, this); 10 | this.eventMap.mapListener(this.view.cancelButton, "click", this.cancelButton_onTriggeredHandler, this); 11 | } 12 | 13 | public destroy(): void { 14 | this.eventMap.unmapListeners(); 15 | } 16 | private confirmButton_onTriggeredHandler(e: any): void { 17 | this.view.parent.removeChild(this.view); 18 | } 19 | private cancelButton_onTriggeredHandler(e: any): void { 20 | this.view.parent.removeChild(this.view); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/GameOverPopupMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { FlowService } from "./../services/FlowService"; 5 | import { GameService } from "./../services/GameService"; 6 | import { GameOverPopup } from "./../views/GameOverPopup"; 7 | 8 | @injectable() 9 | export class GameOverPopupMediator extends Mediator { 10 | @inject(FlowService) private flowService: FlowService; 11 | @inject(GameService) private gameService: GameService; 12 | 13 | public initialize(): void { 14 | this.eventMap.mapListener(this.view.retryButton, "click", this.retryButton_onTriggeredHandler, this); 15 | this.eventMap.mapListener( 16 | this.view.levelSelectButton, 17 | "click", 18 | this.levelSelectButton_onTriggeredHandler, 19 | this 20 | ); 21 | } 22 | public destroy(): void { 23 | this.eventMap.unmapListeners(); 24 | } 25 | private retryButton_onTriggeredHandler(e: any): void { 26 | this.flowService.closePopup(); 27 | this.gameService.retryCommand(); 28 | } 29 | private levelSelectButton_onTriggeredHandler(e: any): void { 30 | this.flowService.closePopup(); 31 | this.flowService.setLevelSelectView(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/GameViewMediator.ts: -------------------------------------------------------------------------------- 1 | import { GameView } from "./../views/GameView"; 2 | 3 | import { injectable, inject } from "@robotlegsjs/core"; 4 | import { Mediator } from "@robotlegsjs/pixi"; 5 | 6 | @injectable() 7 | export class GameViewMediator extends Mediator { 8 | public initialize(): void { 9 | this.view.createComponents(); 10 | } 11 | public destroy(): void { 12 | this.view.destroy(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/HomeViewMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { FlowService } from "./../services/FlowService"; 5 | import { HomeView } from "./../views/HomeView"; 6 | 7 | @injectable() 8 | export class HomeViewMediator extends Mediator { 9 | @inject(FlowService) private flowService: FlowService; 10 | 11 | public initialize(): void { 12 | this.eventMap.mapListener(this.view.playButton, "click", this.playButton_onClick, this); 13 | this.eventMap.mapListener(this.view.optionsButton, "click", this.optionsButton_onClick, this); 14 | } 15 | public destroy(): void { 16 | this.eventMap.unmapListeners(); 17 | } 18 | private playButton_onClick(e: any): void { 19 | this.flowService.setLevelSelectView(); 20 | } 21 | private optionsButton_onClick(e: any): void { 22 | this.flowService.setOptionsView(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/IntroViewMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { IntroView } from "../views/IntroView"; 5 | import { FlowService } from "./../services/FlowService"; 6 | 7 | @injectable() 8 | export class IntroViewMediator extends Mediator { 9 | @inject(FlowService) private flowService: FlowService; 10 | 11 | public initialize(): void { 12 | setTimeout(this.onTimerOut.bind(this), 3000); 13 | } 14 | public destroy(): void { 15 | this.eventMap.unmapListeners(); 16 | } 17 | private onTimerOut() { 18 | this.flowService.setHomeView(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/OptionsViewMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { FlowService } from "./../services/FlowService"; 5 | import { OptionsView } from "./../views/OptionsView"; 6 | 7 | @injectable() 8 | export class OptionsViewMediator extends Mediator { 9 | @inject(FlowService) private flowService: FlowService; 10 | 11 | public initialize(): void { 12 | this.eventMap.mapListener(this.view.backButton, "click", this.backButton_onClick, this); 13 | this.eventMap.mapListener(this.view.deleteButton, "click", this.deleteButton_onClick, this); 14 | } 15 | public destroy(): void { 16 | this.eventMap.unmapListeners(); 17 | } 18 | private backButton_onClick(e: any, thisObject: any): void { 19 | this.flowService.setHomeView(); 20 | } 21 | private deleteButton_onClick(e: any): void { 22 | this.flowService.showAlertPopup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/PausePopupMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { FlowService } from "./../services/FlowService"; 5 | import { GameService } from "./../services/GameService"; 6 | import { PausePopup } from "./../views/PausePopup"; 7 | 8 | @injectable() 9 | export class PausePopupMediator extends Mediator { 10 | @inject(FlowService) private flowService: FlowService; 11 | @inject(GameService) private gameService: GameService; 12 | 13 | public initialize(): void { 14 | this.eventMap.mapListener(this.view.levelSelectButton, "click", this.levelSelectButton_onClick, this); 15 | this.eventMap.mapListener(this.view.resumeButton, "click", this.resumeButton_onClick, this); 16 | this.eventMap.mapListener(this.view.retryButton, "click", this.retryButton_onClick, this); 17 | } 18 | public destroy(): void { 19 | this.eventMap.unmapListeners(); 20 | } 21 | private levelSelectButton_onClick(e: any): void { 22 | this.flowService.setLevelSelectView(); 23 | this.flowService.closePopup(); 24 | } 25 | private resumeButton_onClick(e: any): void { 26 | this.flowService.closePopup(); 27 | this.flowService.showStartingPopup(); 28 | } 29 | private retryButton_onClick(e: any): void { 30 | this.flowService.closePopup(); 31 | this.gameService.retryCommand(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/StartingPopupMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { FlowService } from "./../services/FlowService"; 5 | import { GameService } from "./../services/GameService"; 6 | import { StartingPopup } from "./../views/StartingPopup"; 7 | 8 | @injectable() 9 | export class StartingPopupMediator extends Mediator { 10 | @inject(GameService) private gameService: GameService; 11 | @inject(FlowService) private flowService: FlowService; 12 | 13 | private _count: number; 14 | 15 | public initialize(): void { 16 | this._count = 4; 17 | 18 | this.tick(this); 19 | } 20 | public destroy(): void { 21 | this.eventMap.unmapListeners(); 22 | } 23 | private tick(obThis: any = this) { 24 | obThis._count -= 1; 25 | if (obThis._count > 0) { 26 | obThis.view.changeNumber(obThis._count); 27 | setTimeout(obThis.tick, 300, obThis); 28 | } else { 29 | obThis.tick_onComplete(); 30 | } 31 | } 32 | private tick_onComplete(): void { 33 | this.gameService.resume(); 34 | this.flowService.closePopup(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/mediators/YouWinPopupMediator.ts: -------------------------------------------------------------------------------- 1 | import { inject, injectable } from "@robotlegsjs/core"; 2 | import { Mediator } from "@robotlegsjs/pixi"; 3 | 4 | import { LevelModel } from "./../game/models/LevelModel"; 5 | import { FlowService } from "./../services/FlowService"; 6 | import { GameService } from "./../services/GameService"; 7 | import { YouWinPopup } from "./../views/YouWinPopup"; 8 | 9 | @injectable() 10 | export class YouWinPopupMediator extends Mediator { 11 | @inject(LevelModel) private levelModel: LevelModel; 12 | @inject(FlowService) private flowService: FlowService; 13 | @inject(GameService) private gameService: GameService; 14 | 15 | public initialize(): void { 16 | this.view.createStars(this.levelModel.numStars); 17 | this.view.updateValues(String(this.levelModel.score), String(this.levelModel.levelInfo.hiScore)); 18 | 19 | this.eventMap.mapListener(this.view.retryButton, "click", this.retryButton_onTriggeredHandler, this); 20 | this.eventMap.mapListener( 21 | this.view.levelSelectButton, 22 | "click", 23 | this.levelSelectButton_onTriggeredHandler, 24 | this 25 | ); 26 | } 27 | public destroy(): void { 28 | this.eventMap.unmapListeners(); 29 | } 30 | private retryButton_onTriggeredHandler(e: any): void { 31 | this.flowService.closePopup(); 32 | this.gameService.retryCommand(); 33 | } 34 | private levelSelectButton_onTriggeredHandler(e: any): void { 35 | this.flowService.closePopup(); 36 | this.flowService.setLevelSelectView(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/services/FlowService.ts: -------------------------------------------------------------------------------- 1 | import { EventDispatcher, IEventDispatcher, inject, injectable } from "@robotlegsjs/core"; 2 | import { PalidorEvent } from "@robotlegsjs/pixi-palidor/lib"; 3 | 4 | import { FlowEvent } from "./../events/FlowEvent"; 5 | 6 | @injectable() 7 | export class FlowService { 8 | @inject(IEventDispatcher) private eventDispatcher: IEventDispatcher; 9 | 10 | // Views 11 | public setHomeView(): void { 12 | this.dispatchEventWith(FlowEvent.SHOW_HOME_VIEW); 13 | } 14 | public setGameView(): void { 15 | this.dispatchEventWith(FlowEvent.SHOW_GAME_VIEW); 16 | } 17 | public setLevelSelectView(): void { 18 | this.dispatchEventWith(FlowEvent.SHOW_LEVEL_SELECT_VIEW); 19 | } 20 | public setOptionsView(): void { 21 | this.dispatchEventWith(FlowEvent.SHOW_OPTIONS_VIEW); 22 | } 23 | // Floating Views 24 | public showAlertPopup(): void { 25 | this.dispatchEventWith(FlowEvent.SHOW_ALERT_POPUP); 26 | } 27 | public showPausePopup(): void { 28 | this.dispatchEventWith(FlowEvent.SHOW_PAUSE_POPUP); 29 | } 30 | public showStartingPopup(): void { 31 | this.dispatchEventWith(FlowEvent.SHOW_STARTING_POPUP); 32 | } 33 | public showGameOverPopup(): void { 34 | this.dispatchEventWith(FlowEvent.SHOW_GAME_OVER_POPUP); 35 | } 36 | public showYouWinPopup(): void { 37 | this.dispatchEventWith(FlowEvent.SHOW_YOU_WIN_POPUP); 38 | } 39 | // extras 40 | public closePopup(): void { 41 | this.dispatchEventWith(PalidorEvent.REMOVE_LAST_FLOATING_VIEW_ADDED); 42 | } 43 | public dispatchEventWith(type: string): void { 44 | (this.eventDispatcher).dispatchEventWith(type); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/services/GameService.ts: -------------------------------------------------------------------------------- 1 | import { EventDispatcher, IEventDispatcher, inject, injectable } from "@robotlegsjs/core"; 2 | 3 | import { GameEvent } from "./../events/GameEvent"; 4 | import { GameStatus } from "./../game/models/GameStatus"; 5 | 6 | @injectable() 7 | export class GameService { 8 | @inject(IEventDispatcher) public eventDispatcher: IEventDispatcher; 9 | @inject(GameStatus) public gameStatus: GameStatus; 10 | 11 | // Commands 12 | public createLevel(levelId: number): void { 13 | const event: GameEvent = new GameEvent(GameEvent.CREATE_LEVEL_COMMAND); 14 | event.extra = { levelId }; 15 | this.eventDispatcher.dispatchEvent(event); 16 | } 17 | public retryCommand(): void { 18 | this.dispatchEventWith(GameEvent.RETRY_GAME_COMMAND); 19 | } 20 | public swapPiecesCommand(phase: String, col: number, row: number): void { 21 | const event: GameEvent = new GameEvent(GameEvent.SWAP_PIECES_COMMAND); 22 | event.extra = { 23 | col, // 24 | phase, // 25 | row // 26 | }; 27 | this.eventDispatcher.dispatchEvent(event); 28 | } 29 | public swapPiecesConfirmCommand(): void { 30 | this.dispatchEventWith(GameEvent.SWAP_PIECES_CONFIRM_COMMAND); 31 | } 32 | public gameOverCommand(): void { 33 | this.dispatchEventWith(GameEvent.GAME_OVER_COMMAND); 34 | } 35 | // Game 36 | public start(): void { 37 | this.gameStatus.start(); 38 | } 39 | public pause(): void { 40 | this.gameStatus.pause(); 41 | this.dispatchEventWith(GameEvent.PAUSE); 42 | } 43 | public resume(): void { 44 | this.gameStatus.resume(); 45 | this.dispatchEventWith(GameEvent.RESUME); 46 | } 47 | public gameOver(): void { 48 | this.gameStatus.gameOver(); 49 | } 50 | // UPDATE_GRID 51 | public updateHUDData(): void { 52 | this.dispatchEventWith(GameEvent.UPDATE_HUD_DATA); 53 | } 54 | public clearGridField(): void { 55 | this.dispatchEventWith(GameEvent.CLEAR_GRID); 56 | } 57 | public updateGridField(): void { 58 | this.dispatchEventWith(GameEvent.UPDATE_GRID); 59 | } 60 | public dispatchEventWith(type: string): void { 61 | (this.eventDispatcher).dispatchEventWith(type); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/utils/AtlasKeys.ts: -------------------------------------------------------------------------------- 1 | import { PieceUtils } from "../game/utils/PieceUtils"; 2 | import { Texture } from "pixi.js"; 3 | 4 | export class AtlasKeys { 5 | public static ATLAS_XML = "./assets/matchthree-pixijs-atlas.json"; 6 | public static ATLAS_PNG = "./assets/matchthree-pixijs-atlas.png"; 7 | 8 | public static FONT_FNT = "./assets/fonts/BerlinSansDemi.fnt"; 9 | 10 | /* ATLAS PREFIX */ 11 | public static LOGO_SETZER = "logo_setzer.png"; 12 | public static LOGO_TYPESCRIPT = "./assets/logo_typescript.png"; 13 | 14 | public static PIECE_NORMAL = "piece_normal"; 15 | public static PIECE_ROW = "piece_row"; 16 | public static PIECE_COL = "piece_col"; 17 | public static PIECE_RAINBOW = "piece_rainbow"; 18 | 19 | /* BUTTONS */ 20 | public static BUTTON_SMALL = "button_small"; 21 | public static BUTTON_SMALL_DANGER = "button_small_danger"; 22 | public static BUTTON_MEDIUM = "button_medium"; 23 | 24 | /* ICONS */ 25 | public static ICON_LEVEL_SELECT = "icon_level_select.png"; 26 | public static ICON_PAUSE = "icon_pause.png"; 27 | public static ICON_RESUME = "icon_resume.png"; 28 | public static ICON_DELETE = "icon_delete.png"; 29 | public static ICON_RETRY = "icon_retry.png"; 30 | public static ICON_CONFIG = "icon_config.png"; 31 | public static ICON_HOME = "icon_home.png"; 32 | 33 | public static ICON_CONFIRM = "icon_confirm.png"; 34 | public static ICON_CLOSE = "icon_close.png"; 35 | 36 | /* Others */ 37 | public static POPUP_STAR = "popup_star"; 38 | public static STAR_HUD_DISPLAY = "star_hud_display_"; 39 | public static LEVEL_SELECT_SMALL_STAR = "level_select_small_star"; 40 | public static LOGO_MATCH_THREE = "logo_matchthree.png"; 41 | 42 | public static BG_IMAGE = "./assets/backgrounds/background.png"; 43 | public static BG_POPUP_IMAGE = "./assets/backgrounds/background_popup.png"; 44 | public static BG_HUD_IMAGE = "./assets/backgrounds/background_hud.png"; 45 | 46 | private static resources: any; 47 | private static textureCache: any; 48 | 49 | public static update(textureCache: any): void { 50 | this.textureCache = textureCache; 51 | } 52 | public static getTexture(atlasKey): Texture { 53 | return this.textureCache[atlasKey]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/utils/MagicValues.ts: -------------------------------------------------------------------------------- 1 | export class MagicValues { 2 | /* FONT */ 3 | public static FONT_FAMILY = "BerlinSansFBDemi"; 4 | 5 | public static SHARED_OBJECT_NAME = "Match3Palidor"; 6 | 7 | public static SIZE_TITLE = 42; 8 | public static SIZE_DEFAULT = 32; 9 | public static SIZE_HUD = 22; 10 | 11 | public static BORDER_OFFSET = 18; 12 | public static BORDER_OFFSET_BOTTOM = 120; 13 | public static BORDER_OFFSET_POPUP = 60; 14 | public static BORDER_OFFSET_HUD = 10; 15 | 16 | public static convertTime(secs: number): string { 17 | const m = Math.floor((secs % 3600) / 60); 18 | const s = Math.max(Math.floor((secs % 3600) % 60), 0); 19 | return m.toString() + ": " + (s < 10 ? "0" + s.toString() : s.toString()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/utils/Texts.ts: -------------------------------------------------------------------------------- 1 | export class Texts { 2 | public static DEVELOPER = "RONALDO SANTIAGO"; 3 | 4 | /* HUD */ 5 | public static SCORE = "Score:"; 6 | public static HI_SCORE = "Hi-Score:"; 7 | public static MOVES = "Moves"; 8 | public static TIME = "Time"; 9 | 10 | /* Alerts */ 11 | public static CONFIRM_DELETE = "Would like to reset\nAll Hi-Scores?"; 12 | 13 | /* Buttons */ 14 | public static BUTTON_PLAY = "Play"; 15 | public static BUTTON_CONFIG = "Options"; 16 | public static BUTTON_BACK = "Back"; 17 | 18 | /* Titles */ 19 | public static LEVEL_SELECT = "Level Select"; 20 | public static OPTIONS = "Options"; 21 | public static ALERT = "Alert ! !"; 22 | public static GAME_OVER = "Game Over"; 23 | public static PAUSED = "Paused"; 24 | public static YOU_WIN = "You Win ! !"; 25 | } 26 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/utils/ViewPortSize.ts: -------------------------------------------------------------------------------- 1 | export class ViewPortSize { 2 | public static MAX_WIDTH = 340; 3 | public static MAX_HEIGHT = 480; 4 | public static HALF_WIDTH = 170; 5 | public static HALF_HEIGHT = 240; 6 | } 7 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/AlertPopup.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { MagicValues } from "./../utils/MagicValues"; 5 | import { PixiFactory } from "./../utils/PixiFactory"; 6 | import { Texts } from "./../utils/Texts"; 7 | import { ViewPortSize } from "./../utils/ViewPortSize"; 8 | import { IconButton } from "./components/IconButton"; 9 | 10 | export class AlertPopup extends Container { 11 | private _cancelButton: IconButton; 12 | private _confirmButton: IconButton; 13 | 14 | public get confirmButton(): IconButton { 15 | return this._confirmButton; 16 | } 17 | public get cancelButton(): IconButton { 18 | return this._cancelButton; 19 | } 20 | 21 | constructor() { 22 | super(); 23 | 24 | this.createBackground(); 25 | this.createText(); 26 | this.createButtons(); 27 | } 28 | private createBackground(): void { 29 | this.addChild(PixiFactory.getShadowBackground(0.9)); 30 | } 31 | private createText(): void { 32 | this.addChild(PixiFactory.getTitle(Texts.ALERT)); 33 | 34 | const alert: Container = PixiFactory.getText(Texts.CONFIRM_DELETE); 35 | alert.x = ViewPortSize.HALF_WIDTH; 36 | alert.y = ViewPortSize.HALF_HEIGHT; 37 | alert.pivot.x = alert.width * 0.5; 38 | alert.pivot.y = alert.height * 0.5; 39 | this.addChild(alert); 40 | } 41 | private createButtons(): void { 42 | this._confirmButton = PixiFactory.getIconButton(AtlasKeys.ICON_CONFIRM); 43 | this._confirmButton.x = ViewPortSize.HALF_WIDTH - this._confirmButton.width * 0.5 - 4; 44 | this._confirmButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 45 | this.addChild(this._confirmButton); 46 | 47 | this._cancelButton = PixiFactory.getIconButton(AtlasKeys.ICON_CLOSE); 48 | this._cancelButton.x = ViewPortSize.HALF_WIDTH + this._cancelButton.width * 0.5 + 4; 49 | this._cancelButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 50 | this.addChild(this._cancelButton); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/GameOverPopup.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { MagicValues } from "./../utils/MagicValues"; 5 | import { PixiFactory } from "./../utils/PixiFactory"; 6 | import { Texts } from "./../utils/Texts"; 7 | import { ViewPortSize } from "./../utils/ViewPortSize"; 8 | import { IconButton } from "./components/IconButton"; 9 | 10 | export class GameOverPopup extends Container { 11 | private _levelSelectButton: IconButton; 12 | private _retryButton: IconButton; 13 | public get retryButton(): IconButton { 14 | return this._retryButton; 15 | } 16 | 17 | public get levelSelectButton(): IconButton { 18 | return this._levelSelectButton; 19 | } 20 | constructor() { 21 | super(); 22 | 23 | this.createBackground(); 24 | this.createText(); 25 | this.createButtons(); 26 | } 27 | private createBackground(): void { 28 | this.addChild(PixiFactory.getShadowBackground(0.9)); 29 | } 30 | private createText(): void { 31 | this.addChild(PixiFactory.getTitle(Texts.GAME_OVER)); 32 | } 33 | private createButtons(): void { 34 | this._retryButton = PixiFactory.getIconButton(AtlasKeys.ICON_RETRY); 35 | this._retryButton.x = ViewPortSize.HALF_WIDTH - this._retryButton.width * 0.5 - 4; 36 | this._retryButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 37 | this.addChild(this._retryButton); 38 | 39 | this._levelSelectButton = PixiFactory.getIconButton(AtlasKeys.ICON_LEVEL_SELECT); 40 | this._levelSelectButton.x = ViewPortSize.HALF_WIDTH + this._levelSelectButton.width * 0.5 + 4; 41 | this._levelSelectButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 42 | this.addChild(this._levelSelectButton); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/GameView.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { PixiFactory } from "./../utils/PixiFactory"; 4 | import { GridFieldComponent } from "./components/GridFieldComponent"; 5 | import { HUDGameComponent } from "./components/HUDGameComponent"; 6 | 7 | export class GameView extends Container { 8 | private _gridField: GridFieldComponent; 9 | private _hudComponent: HUDGameComponent; 10 | public get gridField(): GridFieldComponent { 11 | return this._gridField; 12 | } 13 | 14 | constructor() { 15 | super(); 16 | this.createBackground(); 17 | } 18 | public destroy(): void { 19 | this.removeChild(this._gridField); 20 | this.removeChild(this._hudComponent); 21 | 22 | this._gridField = null; 23 | this._hudComponent = null; 24 | } 25 | public createComponents(): void { 26 | this._hudComponent = new HUDGameComponent(); 27 | this.addChild(this._hudComponent); 28 | 29 | this._gridField = new GridFieldComponent(); 30 | this.addChild(this._gridField); 31 | } 32 | private createBackground(): void { 33 | this.addChild(PixiFactory.getBackground()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/HomeView.ts: -------------------------------------------------------------------------------- 1 | import { Container, Sprite } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { MagicValues } from "./../utils/MagicValues"; 5 | import { PixiFactory } from "./../utils/PixiFactory"; 6 | import { ViewPortSize } from "./../utils/ViewPortSize"; 7 | import { IconButton } from "./components/IconButton"; 8 | 9 | export class HomeView extends Container { 10 | private _playButton: IconButton; 11 | private _optionsButton: IconButton; 12 | public get playButton(): IconButton { 13 | return this._playButton; 14 | } 15 | public get optionsButton(): IconButton { 16 | return this._optionsButton; 17 | } 18 | 19 | constructor() { 20 | super(); 21 | 22 | this.createBackground(); 23 | this.createImages(); 24 | this.createButtons(); 25 | } 26 | private createBackground(): void { 27 | this.addChild(PixiFactory.getBackground()); 28 | } 29 | private createImages(): void { 30 | const logo: Sprite = PixiFactory.getImage(AtlasKeys.LOGO_MATCH_THREE); 31 | logo.x = ViewPortSize.HALF_WIDTH; 32 | logo.y = ViewPortSize.MAX_HEIGHT * 0.3; 33 | logo.anchor.set(0.5); 34 | this.addChild(logo); 35 | 36 | const logoSetzer: Sprite = PixiFactory.getImage(AtlasKeys.LOGO_SETZER); 37 | logoSetzer.x = MagicValues.BORDER_OFFSET; 38 | logoSetzer.y = ViewPortSize.MAX_HEIGHT - 30; 39 | this.addChild(logoSetzer); 40 | } 41 | private createButtons(): void { 42 | this._playButton = PixiFactory.getIconButton(AtlasKeys.ICON_RESUME, IconButton.TYPE_MEDIUM); 43 | this._playButton.x = ViewPortSize.HALF_WIDTH; 44 | this._playButton.y = ViewPortSize.MAX_HEIGHT - 50 - MagicValues.BORDER_OFFSET_BOTTOM; 45 | this.addChild(this._playButton); 46 | 47 | this._optionsButton = PixiFactory.getIconButton(AtlasKeys.ICON_CONFIG, IconButton.TYPE_MEDIUM); 48 | this._optionsButton.x = ViewPortSize.HALF_WIDTH; 49 | this._optionsButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 50 | this.addChild(this._optionsButton); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/IntroView.ts: -------------------------------------------------------------------------------- 1 | import { Container, Sprite, Text } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { PixiFactory } from "./../utils/PixiFactory"; 5 | import { Texts } from "./../utils/Texts"; 6 | import { ViewPortSize } from "./../utils/ViewPortSize"; 7 | 8 | export class IntroView extends Container { 9 | constructor() { 10 | super(); 11 | 12 | this.setupBackground(); 13 | this.setupImages(); 14 | this.setupText(); 15 | } 16 | private setupBackground(): void { 17 | this.addChild(PixiFactory.getColorBackground(0x204d63)); 18 | } 19 | private setupImages(): void { 20 | const logo: Sprite = PIXI.Sprite.fromImage(AtlasKeys.LOGO_TYPESCRIPT); 21 | logo.anchor.x = 0.5; 22 | logo.x = ViewPortSize.HALF_WIDTH; 23 | logo.y = ViewPortSize.MAX_HEIGHT - 64; 24 | this.addChild(logo); 25 | } 26 | private setupText(): void { 27 | const style = new PIXI.TextStyle({ 28 | align: "center", 29 | fill: 0xb5d6e6, 30 | fontFamily: "Arial", 31 | fontSize: 28, 32 | fontWeight: "bold" 33 | }); 34 | const title: Text = new PIXI.Text(Texts.DEVELOPER, style); 35 | title.anchor.set(0.5); 36 | title.x = ViewPortSize.HALF_WIDTH; 37 | title.y = ViewPortSize.HALF_HEIGHT; 38 | this.addChild(title); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/LevelSelectView.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { MagicValues } from "./../utils/MagicValues"; 5 | import { PixiFactory } from "./../utils/PixiFactory"; 6 | import { Texts } from "./../utils/Texts"; 7 | import { ViewPortSize } from "./../utils/ViewPortSize"; 8 | import { IconButton } from "./components/IconButton"; 9 | import { LevelSelectButton } from "./components/LevelSelectButton"; 10 | 11 | export class LevelSelectView extends Container { 12 | private _backButton: IconButton; 13 | public get backButton(): IconButton { 14 | return this._backButton; 15 | } 16 | 17 | constructor() { 18 | super(); 19 | 20 | this.createBackground(); 21 | this.createText(); 22 | this.createButton(); 23 | } 24 | public createLevelButton(text: string): LevelSelectButton { 25 | const level: LevelSelectButton = PixiFactory.getLevelSelectButton(); 26 | level.setText(text); 27 | this.addChild(level); 28 | 29 | return level; 30 | } 31 | private createBackground(): void { 32 | this.addChild(PixiFactory.getBackground()); 33 | this.addChild(PixiFactory.getBackgroundPopup()); 34 | } 35 | private createText(): void { 36 | this.addChild(PixiFactory.getTitle(Texts.LEVEL_SELECT)); 37 | } 38 | private createButton(): void { 39 | this._backButton = PixiFactory.getIconButton(AtlasKeys.ICON_HOME, IconButton.TYPE_MEDIUM); 40 | this._backButton.x = ViewPortSize.HALF_WIDTH; 41 | this._backButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 42 | this._backButton.anchor.set(0.5); 43 | this.addChild(this._backButton); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/OptionsView.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { MagicValues } from "./../utils/MagicValues"; 5 | import { PixiFactory } from "./../utils/PixiFactory"; 6 | import { Texts } from "./../utils/Texts"; 7 | import { ViewPortSize } from "./../utils/ViewPortSize"; 8 | import { IconButton } from "./components/IconButton"; 9 | 10 | export class OptionsView extends Container { 11 | private _deleteButton: IconButton; 12 | private _backButton: IconButton; 13 | public get deleteButton(): IconButton { 14 | return this._deleteButton; 15 | } 16 | public get backButton(): IconButton { 17 | return this._backButton; 18 | } 19 | 20 | constructor() { 21 | super(); 22 | 23 | this.createBackgrounds(); 24 | this.createTexts(); 25 | this.createButtons(); 26 | } 27 | private createBackgrounds(): void { 28 | this.addChild(PixiFactory.getBackground()); 29 | this.addChild(PixiFactory.getBackgroundPopup()); 30 | } 31 | private createTexts(): void { 32 | this.addChild(PixiFactory.getTitle(Texts.OPTIONS)); 33 | 34 | const hiScore: Container = PixiFactory.getText(Texts.HI_SCORE); 35 | hiScore.x = MagicValues.BORDER_OFFSET_POPUP; 36 | hiScore.y = 180; 37 | this.addChild(hiScore); 38 | } 39 | private createButtons(): void { 40 | this._deleteButton = PixiFactory.getIconButton(AtlasKeys.ICON_DELETE, IconButton.TYPE_SMALL_DANGER); 41 | this._deleteButton.x = ViewPortSize.MAX_WIDTH - MagicValues.BORDER_OFFSET_POPUP - 25; 42 | this._deleteButton.y = 200; 43 | this.addChild(this._deleteButton); 44 | 45 | this._backButton = PixiFactory.getIconButton(AtlasKeys.ICON_HOME, IconButton.TYPE_MEDIUM); 46 | this._backButton.x = ViewPortSize.HALF_WIDTH; 47 | this._backButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 48 | this.addChild(this._backButton); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/PausePopup.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../utils/AtlasKeys"; 4 | import { MagicValues } from "./../utils/MagicValues"; 5 | import { PixiFactory } from "./../utils/PixiFactory"; 6 | import { Texts } from "./../utils/Texts"; 7 | import { ViewPortSize } from "./../utils/ViewPortSize"; 8 | import { IconButton } from "./components/IconButton"; 9 | 10 | export class PausePopup extends Container { 11 | private _levelSelectButton: IconButton; 12 | private _resumeButton: IconButton; 13 | private _retryButton: IconButton; 14 | public get levelSelectButton(): IconButton { 15 | return this._levelSelectButton; 16 | } 17 | public get resumeButton(): IconButton { 18 | return this._resumeButton; 19 | } 20 | public get retryButton(): IconButton { 21 | return this._retryButton; 22 | } 23 | 24 | constructor() { 25 | super(); 26 | 27 | this.interactive = true; 28 | 29 | this.setupBackgrounds(); 30 | this.setupButtons(); 31 | this.setupText(); 32 | } 33 | private setupBackgrounds(): void { 34 | this.addChild(PixiFactory.getShadowBackground(0.9)); 35 | } 36 | private setupButtons(): void { 37 | this._levelSelectButton = PixiFactory.getIconButton(AtlasKeys.ICON_LEVEL_SELECT); 38 | this._levelSelectButton.x = ViewPortSize.HALF_WIDTH + this._levelSelectButton.width * 0.5 + 4; 39 | this._levelSelectButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 40 | this.addChild(this._levelSelectButton); 41 | 42 | this._resumeButton = PixiFactory.getIconButton(AtlasKeys.ICON_RESUME); 43 | this._resumeButton.x = ViewPortSize.MAX_WIDTH - MagicValues.BORDER_OFFSET_HUD - 30; 44 | this._resumeButton.y = MagicValues.BORDER_OFFSET_HUD + 20; 45 | this.addChild(this._resumeButton); 46 | 47 | this._retryButton = PixiFactory.getIconButton(AtlasKeys.ICON_RETRY); 48 | this._retryButton.x = ViewPortSize.HALF_WIDTH - this._retryButton.width * 0.5 - 4; 49 | this._retryButton.y = ViewPortSize.MAX_HEIGHT - MagicValues.BORDER_OFFSET_BOTTOM; 50 | this.addChild(this._retryButton); 51 | } 52 | private setupText(): void { 53 | this.addChild(PixiFactory.getTitle(Texts.PAUSED)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/StartingPopup.ts: -------------------------------------------------------------------------------- 1 | import { Container, Graphics } from "pixi.js"; 2 | 3 | import { MagicValues } from "./../utils/MagicValues"; 4 | import { PixiFactory } from "./../utils/PixiFactory"; 5 | import { ViewPortSize } from "./../utils/ViewPortSize"; 6 | 7 | export class StartingPopup extends Container { 8 | private _decreasingNumber; 9 | private _background: Graphics; 10 | 11 | constructor() { 12 | super(); 13 | 14 | this.interactive = true; 15 | 16 | this.setupBackgrounds(); 17 | this.setupTexts(); 18 | } 19 | public changeNumber(n: number): void { 20 | this._background.alpha -= 0.1; 21 | this._decreasingNumber.text = String(n); 22 | } 23 | private setupBackgrounds(): void { 24 | this._background = PixiFactory.getShadowBackground(); 25 | this.addChild(this._background); 26 | } 27 | private setupTexts(): void { 28 | this._decreasingNumber = PixiFactory.getText("3", MagicValues.SIZE_DEFAULT + 6); 29 | this._decreasingNumber.anchor.set(0.5); 30 | this._decreasingNumber.scale.set(1.2); 31 | this._decreasingNumber.x = ViewPortSize.HALF_WIDTH; 32 | this._decreasingNumber.y = ViewPortSize.HALF_HEIGHT; 33 | this.addChild(this._decreasingNumber); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/components/GridFieldComponent.ts: -------------------------------------------------------------------------------- 1 | import { Container, Graphics } from "pixi.js"; 2 | 3 | import { BlankedCell } from "./../../game/displays/BlankedCell"; 4 | import { Tile } from "./../../game/models/Tile"; 5 | import { ViewPortSize } from "./../../utils/ViewPortSize"; 6 | 7 | export class GridFieldComponent extends Container { 8 | constructor() { 9 | super(); 10 | 11 | this.setupValues(); 12 | } 13 | public generateGrid(maxCols, maxRows): void { 14 | const gridSize = maxCols * Tile.TILE_WIDTH; 15 | const newX = (ViewPortSize.MAX_WIDTH - gridSize) * 0.5; 16 | this.x = newX + Tile.TILE_WIDTH * 0.5; 17 | 18 | for (let row = 0; row < maxRows; row++) { 19 | for (let col = 0; col < maxCols; col++) { 20 | const cell: Graphics = new BlankedCell(); 21 | cell.x = Tile.TILE_WIDTH * col; 22 | cell.y = Tile.TILE_HEIGHT * row; 23 | this.addChild(cell); 24 | } 25 | } 26 | } 27 | private setupValues(): void { 28 | this.x = 10 + Tile.TILE_WIDTH * 0.5; 29 | this.y = 130 + Tile.TILE_HEIGHT * 0.5; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/components/IconButton.ts: -------------------------------------------------------------------------------- 1 | import { Sprite, Texture } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../../utils/AtlasKeys"; 4 | 5 | export class IconButton extends Sprite { 6 | public static TYPE_SMALL = "button_small"; 7 | public static TYPE_MEDIUM = "button_medium"; 8 | public static TYPE_SMALL_DANGER = "button_small_danger"; 9 | 10 | private _downState: Texture; 11 | private _overState: Texture; 12 | private _upState: Texture; 13 | 14 | private _isDown: boolean; 15 | private _isOver: boolean; 16 | 17 | private _ico: Sprite; 18 | 19 | constructor(shapeType: String = IconButton.TYPE_SMALL) { 20 | super(AtlasKeys.getTexture(shapeType + "_up.png")); 21 | 22 | const downStateTexture: Texture = AtlasKeys.getTexture(shapeType + "_down.png"); 23 | const upStateTexture: Texture = AtlasKeys.getTexture(shapeType + "_up.png"); 24 | 25 | this._downState = downStateTexture; 26 | this._overState = downStateTexture; 27 | this._upState = upStateTexture; 28 | 29 | this.setInitialValues(); 30 | this.setupInteractions(); 31 | } 32 | public setIco(name: string): void { 33 | if (this._ico) { 34 | this.removeChild(this._ico); 35 | } 36 | 37 | this._ico = new Sprite(AtlasKeys.getTexture(name)); 38 | this._ico.anchor.set(0.5); 39 | this.addChild(this._ico); 40 | } 41 | private setInitialValues(): void { 42 | this.anchor.set(0.5); 43 | this.interactive = true; 44 | this.buttonMode = true; 45 | } 46 | private setupInteractions(): void { 47 | this.on("pointerup", this.onButtonUp); 48 | this.on("pointerupoutside", this.onButtonUp); 49 | this.on("pointerdown", this.onButtonDown); 50 | this.on("pointerover", this.onButtonOver); 51 | this.on("pointerout", this.onButtonOut); 52 | } 53 | private onButtonDown(): void { 54 | this._isDown = true; 55 | this.texture = this._downState; 56 | this.scale.set(0.95, 0.95); 57 | } 58 | private onButtonOut(): void { 59 | this._isOver = false; 60 | this.texture = this._upState; 61 | this.scale.set(1, 1); 62 | } 63 | private onButtonOver(): void { 64 | this._isOver = true; 65 | this.texture = this._overState; 66 | } 67 | private onButtonUp(): void { 68 | this._isDown = false; 69 | this.scale.set(1, 1); 70 | 71 | this.texture = this._isOver ? this._overState : this._upState; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/components/LevelSelectButton.ts: -------------------------------------------------------------------------------- 1 | import { AtlasKeys } from "./../../utils/AtlasKeys"; 2 | import { PixiFactory } from "./../../utils/PixiFactory"; 3 | import { IconButton } from "./IconButton"; 4 | 5 | export class LevelSelectButton extends IconButton { 6 | constructor() { 7 | super(); 8 | } 9 | 10 | public setText(text: string): void { 11 | const label = PixiFactory.getText(text); 12 | label.pivot.x = label.width * 0.5; 13 | label.pivot.y = label.height; 14 | this.addChild(label); 15 | } 16 | public setStars(numStars: number): void { 17 | for (let i = 0; i < numStars; i++) { 18 | const star = PixiFactory.getImage(AtlasKeys.LEVEL_SELECT_SMALL_STAR); 19 | star.x = i * 15 + 7; 20 | star.y = this.height - 14; 21 | this.addChild(star); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/components/SingleStart.ts: -------------------------------------------------------------------------------- 1 | import { Sprite, Texture } from "pixi.js"; 2 | 3 | import { AtlasKeys } from "./../../utils/AtlasKeys"; 4 | 5 | export class SingleStar extends Sprite { 6 | private textures: Texture[]; 7 | public get numFrames(): number { 8 | return this.textures.length; 9 | } 10 | 11 | constructor() { 12 | super(AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "00.png")); 13 | this.textures = [ 14 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "00.png"), 15 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "01.png"), 16 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "02.png"), 17 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "03.png"), 18 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "04.png"), 19 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "05.png"), 20 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "06.png"), 21 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "07.png"), 22 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "08.png"), 23 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "09.png"), 24 | AtlasKeys.getTexture(AtlasKeys.STAR_HUD_DISPLAY + "10.png") 25 | ]; 26 | } 27 | public currentFrame(value: number): void { 28 | this.texture = this.textures[value]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /typescript-match3/src/matchthree/views/components/StarDisplayComponent.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "pixi.js"; 2 | 3 | import { SingleStar } from "./SingleStart"; 4 | 5 | export class StarDisplayComponent extends Container { 6 | private _stars: SingleStar[]; 7 | 8 | constructor() { 9 | super(); 10 | this.createStarts(); 11 | } 12 | public update(score: number, scoreStarts: number[]): void { 13 | let nextFrame: number; 14 | let scoreStarsPrevious = 0; 15 | let scoreIni: number; 16 | let scoreEnd: number; 17 | let star: SingleStar; 18 | 19 | for (let i = 0; i < scoreStarts.length; i++) { 20 | scoreIni = score - scoreStarsPrevious; 21 | scoreEnd = scoreStarts[i] - scoreStarsPrevious; 22 | star = this._stars[i]; 23 | 24 | nextFrame = Math.min(Math.floor(scoreIni / scoreEnd * 10), star.numFrames - 1); 25 | nextFrame = Math.max(nextFrame, 0); 26 | 27 | star.currentFrame(nextFrame); 28 | scoreStarsPrevious = scoreStarts[i]; 29 | } 30 | } 31 | private createStarts(): void { 32 | this._stars = new Array(); 33 | this._stars.push(this.createSingleStar(-36, -6)); 34 | this._stars.push(this.createSingleStar(0, 0)); 35 | this._stars.push(this.createSingleStar(36, -6)); 36 | } 37 | private createSingleStar(x: number, y: number): SingleStar { 38 | const star: SingleStar = new SingleStar(); 39 | star.anchor.set(0.5); 40 | star.x = x; 41 | star.y = y; 42 | this.addChild(star); 43 | 44 | return star; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /typescript-match3/test/entry.test.ts: -------------------------------------------------------------------------------- 1 | import "reflect-metadata"; 2 | import "es6-symbol/implement"; 3 | import "es6-map/implement"; 4 | -------------------------------------------------------------------------------- /typescript-match3/test/matchthree/game/models/GridData.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | 3 | import { PieceData } from "../../../../src/matchthree/game/models/PieceData"; 4 | import { GridData } from "./../../../../src/matchthree/game/models/GridData"; 5 | 6 | describe("Grid", () => { 7 | let grid: GridData; 8 | 9 | beforeEach(() => { 10 | grid = new GridData(5, 8); 11 | }); 12 | 13 | afterEach(() => { 14 | grid = undefined; 15 | }); 16 | 17 | it("Constructor: Default values", () => { 18 | const maxCols = 8; 19 | const maxRows = 8; 20 | grid = new GridData(); 21 | assert.equal(maxCols, grid.maxCols); 22 | assert.equal(maxRows, grid.maxRows); 23 | }); 24 | 25 | it("Constructor: Setting new values to col and row", () => { 26 | const maxCols = 9; 27 | const maxRows = 19; 28 | grid = new GridData(maxCols, maxRows); 29 | assert.equal(maxCols, grid.maxCols); 30 | assert.equal(maxRows, grid.maxRows); 31 | }); 32 | 33 | it("GetPiece", () => { 34 | const col = 2; 35 | const row = 2; 36 | let piece = new PieceData(col, row); 37 | grid.setPiece(piece); 38 | piece = grid.getPiece(col, row); 39 | 40 | assert.isTrue(piece.col === col && piece.row === row); 41 | }); 42 | 43 | it("GetPiece: Returns undefined when the values are more than grid size ", () => { 44 | const piece = grid.getPiece(60, 60); 45 | 46 | assert.equal(undefined, piece); 47 | }); 48 | 49 | it("SetPiece", () => { 50 | const col = 0; 51 | const row = 0; 52 | const piece = new PieceData(col, row); 53 | grid.setPiece(piece); 54 | assert.deepEqual(piece, grid.getPiece(col, row)); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /typescript-match3/test/matchthree/game/models/LevelInfo.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | 3 | import { LevelInfo } from "./../../../../src/matchthree/game/models/LevelInfo"; 4 | 5 | describe("LevelInfo", () => { 6 | it("Constructor: When the type is MOVE_TYPE", () => { 7 | const scoreStars = [100, 200, 300]; 8 | const levelId = 2; 9 | const maxCols = 4; 10 | const maxRows = 6; 11 | const type = LevelInfo.MOVE_TYPE; 12 | const numMoves = 10; 13 | 14 | const levelInfo = new LevelInfo(levelId, maxCols, maxRows, type, scoreStars, numMoves); 15 | assert.equal(levelId, levelInfo.levelId); 16 | assert.equal(maxCols, levelInfo.maxCols); 17 | assert.equal(maxRows, levelInfo.maxRows); 18 | assert.equal(type, levelInfo.levelType); 19 | assert.equal(scoreStars, levelInfo.scoreStarts); 20 | assert.equal(numMoves, levelInfo.numMoves); 21 | }); 22 | 23 | it("Constructor: When the type is TIMER_TYPE", () => { 24 | const scoreStars = [1100, 2100, 3100]; 25 | const levelId = 3; 26 | const maxCols = 5; 27 | const maxRows = 7; 28 | const type = LevelInfo.TIMER_TYPE; 29 | const numMoves = 0; 30 | const time = 10; 31 | 32 | const levelInfo = new LevelInfo(levelId, maxCols, maxRows, type, scoreStars, numMoves, time); 33 | assert.equal(levelId, levelInfo.levelId); 34 | assert.equal(maxCols, levelInfo.maxCols); 35 | assert.equal(maxRows, levelInfo.maxRows); 36 | assert.equal(type, levelInfo.levelType); 37 | assert.equal(scoreStars, levelInfo.scoreStarts); 38 | assert.equal(numMoves, levelInfo.numMoves); 39 | assert.equal(time, levelInfo.time); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /typescript-match3/test/matchthree/game/models/Tile.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | 3 | import { Tile } from "./../../../../src/matchthree/game/models/Tile"; 4 | 5 | describe("Tile", () => { 6 | it("Constructor", () => { 7 | const col = 5; 8 | const row = 6; 9 | const tile = new Tile(col, row); 10 | assert.equal(col, tile.col); 11 | assert.equal(row, tile.row); 12 | }); 13 | 14 | it("Constructor: Default Values", () => { 15 | const tile = new Tile(); 16 | assert.equal(0, tile.col); 17 | assert.equal(0, tile.row); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /typescript-match3/test/matchthree/utils/AtlasKeys.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import { Texture } from "pixi.js"; 3 | 4 | import { AtlasKeys } from "./../../../src/matchthree/utils/AtlasKeys"; 5 | 6 | describe("AtlasKeys", () => { 7 | it("GetTexture", () => { 8 | const key = "./assets/atlas/game/piece_normal_3.png"; 9 | const texture: Texture = Texture.fromImage(key); 10 | const textureCache: any = { "./assets/atlas/game/piece_normal_3.png": texture }; 11 | AtlasKeys.update(textureCache); 12 | assert.equal(texture, AtlasKeys.getTexture(key)); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /typescript-match3/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "outDir": "dist/", 5 | "strictNullChecks": false, 6 | "baseUrl": "src/", 7 | "noImplicitAny": false, 8 | "removeComments": true, 9 | "preserveConstEnums": true, 10 | "target": "es5", 11 | "lib": ["es6", "dom"], 12 | "types": ["reflect-metadata", "mocha"], 13 | "declaration": true, 14 | "moduleResolution": "node", 15 | "sourceMap": true, 16 | "watch": true, 17 | "experimentalDecorators": true, 18 | "emitDecoratorMetadata": true 19 | }, 20 | "include": [ 21 | "src/*", 22 | "*" 23 | ], 24 | "exclude": [ 25 | "node_modules", 26 | "test/*" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /typescript-match3/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "tslint:latest", 4 | "tslint-config-prettier" 5 | ], 6 | "rules": { 7 | "ban-types": [ false ], 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "forin": true, 15 | "label-position": true, 16 | "member-access": true, 17 | "member-ordering": [ 18 | true, { 19 | "order": [ 20 | "static-field", 21 | "instance-field", 22 | "constructor", 23 | "public-instance-method", 24 | "protected-instance-method", 25 | "private-instance-method" 26 | ] 27 | } 28 | ], 29 | "no-angle-bracket-type-assertion": false, 30 | "no-arg": true, 31 | "no-bitwise": true, 32 | "no-console": [ 33 | true, 34 | "debug", 35 | "info", 36 | "time", 37 | "timeEnd", 38 | "trace" 39 | ], 40 | "no-construct": true, 41 | "no-debugger": true, 42 | "no-duplicate-variable": true, 43 | "no-empty": true, 44 | "no-eval": true, 45 | "no-implicit-dependencies": false, 46 | "no-inferrable-types": false, 47 | "no-shadowed-variable": true, 48 | "no-string-literal": true, 49 | "no-switch-case-fall-through": false, 50 | "no-this-assignment": false, 51 | "no-unused-expression": true, 52 | "no-unused-variable": true, 53 | "no-unreachable": true, 54 | "no-use-before-declare": true, 55 | "no-var-keyword": true, 56 | "object-literal-sort-keys": true, 57 | "ordered-imports": false, 58 | "only-arrow-functions": [ false ], 59 | "prefer-const": true, 60 | "radix":true, 61 | "trailing-comma": [ 62 | false 63 | ], 64 | "triple-equals": [ 65 | true, 66 | "allow-null-check" 67 | ], 68 | "variable-name": false 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /typescript-match3/webpack.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | 5 | module.exports = (function (options) { 6 | return { 7 | entry: { 8 | main: path.resolve("src/index.ts") 9 | }, 10 | 11 | output: { 12 | path: __dirname + "/dist", 13 | filename: "bundle.js" 14 | }, 15 | 16 | devtool: 'source-map', 17 | 18 | module: { 19 | rules: [{ 20 | test: /\.ts$/, 21 | loader: "ts-loader" 22 | }, 23 | { 24 | test: /^(.(?!\.test))*\.ts$/, 25 | loader: "istanbul-instrumenter-loader", 26 | enforce: "post" 27 | } 28 | ] 29 | }, 30 | 31 | plugins: [new HtmlWebpackPlugin() ], 32 | 33 | resolve: { 34 | extensions: ['.ts', '.js', '.json'] 35 | } 36 | 37 | } 38 | })(); 39 | -------------------------------------------------------------------------------- /typescript-match3/webpack.setzer.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | 5 | module.exports = (function (options) { 6 | return { 7 | entry: { 8 | main: path.resolve("src/index.ts") 9 | }, 10 | 11 | output: { 12 | path: __dirname + "/dist", 13 | filename: "bundle.js" 14 | }, 15 | 16 | devtool: 'source-map', 17 | 18 | module: { 19 | rules: [{ 20 | test: /\.ts$/, 21 | loader: "ts-loader" 22 | } 23 | ] 24 | }, 25 | 26 | plugins: [new HtmlWebpackPlugin()], 27 | 28 | resolve: { 29 | extensions: ['.ts', '.js', '.json'] 30 | } 31 | 32 | } 33 | })(); 34 | --------------------------------------------------------------------------------