├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── values.xml
│ │ │ │ ├── ad_info.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── update_strings.xml
│ │ │ │ ├── ids.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── material_colors.xml
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── launcher_filecat.png
│ │ │ │ ├── launcher_wikicat.png
│ │ │ │ ├── launcher_redchain.png
│ │ │ │ ├── launcher_white_only.png
│ │ │ │ └── launcher_baconmasher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── launcher_filecat.png
│ │ │ │ ├── launcher_wikicat.png
│ │ │ │ ├── launcher_redchain.png
│ │ │ │ ├── launcher_white_only.png
│ │ │ │ └── launcher_baconmasher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── launcher_filecat.png
│ │ │ │ ├── launcher_redchain.png
│ │ │ │ ├── launcher_wikicat.png
│ │ │ │ ├── launcher_baconmasher.png
│ │ │ │ └── launcher_white_only.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── launcher_filecat.png
│ │ │ │ ├── launcher_redchain.png
│ │ │ │ ├── launcher_wikicat.png
│ │ │ │ ├── launcher_white_only.png
│ │ │ │ └── launcher_baconmasher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── launcher_filecat.png
│ │ │ │ ├── launcher_wikicat.png
│ │ │ │ ├── launcher_redchain.png
│ │ │ │ ├── launcher_baconmasher.png
│ │ │ │ └── launcher_white_only.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_action_mail.png
│ │ │ │ ├── ic_action_rate.png
│ │ │ │ ├── ic_action_web.png
│ │ │ │ ├── ic_action_github.png
│ │ │ │ ├── ic_action_twitter.png
│ │ │ │ ├── ic_trophy_black_48dp.png
│ │ │ │ └── ic_touch_app_black_48dp.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_action_mail.png
│ │ │ │ ├── ic_action_rate.png
│ │ │ │ ├── ic_action_web.png
│ │ │ │ ├── ic_action_github.png
│ │ │ │ ├── ic_action_twitter.png
│ │ │ │ ├── ic_trophy_black_48dp.png
│ │ │ │ └── ic_touch_app_black_48dp.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_action_web.png
│ │ │ │ ├── ic_action_github.png
│ │ │ │ ├── ic_action_mail.png
│ │ │ │ ├── ic_action_rate.png
│ │ │ │ ├── ic_action_twitter.png
│ │ │ │ ├── ic_trophy_black_48dp.png
│ │ │ │ └── ic_touch_app_black_48dp.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_action_mail.png
│ │ │ │ ├── ic_action_rate.png
│ │ │ │ ├── ic_action_web.png
│ │ │ │ ├── ic_action_github.png
│ │ │ │ ├── ic_action_twitter.png
│ │ │ │ ├── ic_trophy_black_48dp.png
│ │ │ │ └── ic_touch_app_black_48dp.png
│ │ │ ├── drawable
│ │ │ │ ├── man_in_mirror_smaller_still.png
│ │ │ │ ├── spacer_grad.xml
│ │ │ │ ├── ic_play_arrow_24dp.xml
│ │ │ │ ├── ic_pause_24dp.xml
│ │ │ │ ├── ic_dehaze_24dp.xml
│ │ │ │ ├── ic_grade_24dp.xml
│ │ │ │ ├── ic_play_circle_outline_192dp.xml
│ │ │ │ ├── ic_highlight_remove_24dp.xml
│ │ │ │ └── ic_help_24dp.xml
│ │ │ ├── raw
│ │ │ │ └── blockelganger_how_to_play_step1.mp4
│ │ │ ├── layout
│ │ │ │ ├── row_space.xml
│ │ │ │ ├── row_btn.xml
│ │ │ │ ├── row_signin.xml
│ │ │ │ ├── activity_game.xml
│ │ │ │ ├── blockelganger_game_board.xml
│ │ │ │ ├── fragment_dialog_how_to_play.xml
│ │ │ │ └── activity_single_player.xml
│ │ │ └── values-w820dp
│ │ │ │ └── dimens.xml
│ │ ├── ic_launcher-web.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── hotpodata
│ │ │ │ └── blockelganger
│ │ │ │ ├── interfaces
│ │ │ │ └── IGooglePlayGameServicesProvider.kt
│ │ │ │ ├── adapter
│ │ │ │ ├── viewholder
│ │ │ │ │ ├── SpacerViewHolder.kt
│ │ │ │ │ ├── BtnViewHolder.kt
│ │ │ │ │ └── SignInViewHolder.kt
│ │ │ │ ├── BlockelgangerSideBarAdapter.kt
│ │ │ │ └── StartupAdapter.kt
│ │ │ │ ├── BlockelgangerApplication.kt
│ │ │ │ ├── helpers
│ │ │ │ ├── ColorBlockDrawer.kt
│ │ │ │ ├── GameHelper.kt
│ │ │ │ ├── GridTouchListener.kt
│ │ │ │ └── GameGridHelper.kt
│ │ │ │ ├── fragment
│ │ │ │ ├── DialogUpdateFragment.kt
│ │ │ │ └── DialogHowToPlayFragment.kt
│ │ │ │ ├── AnalyticsMaster.kt
│ │ │ │ ├── SettingsMaster.kt
│ │ │ │ ├── utils
│ │ │ │ └── BaseGameUtils.kt
│ │ │ │ ├── activity
│ │ │ │ └── GameActivity.kt
│ │ │ │ └── view
│ │ │ │ └── BlockelgangerGameBoard.kt
│ │ └── AndroidManifest.xml
│ ├── pro
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ └── google-services.json
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── hotpodata
│ │ │ └── blockelganger
│ │ │ └── ExampleUnitTest.java
│ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── hotpodata
│ │ │ └── blockelganger
│ │ │ └── ApplicationTest.java
│ └── free
│ │ └── google-services.json
├── proguard-rules.pro
├── google-services.json
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── readmedata
└── blockelganger_shrunk.gif
├── .gitmodules
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':BlockLib', ':common'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/readmedata/blockelganger_shrunk.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/readmedata/blockelganger_shrunk.gif
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_mail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_action_mail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_rate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_action_rate.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_action_web.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_mail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_action_mail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_rate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_action_rate.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_action_web.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_action_web.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/launcher_filecat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-hdpi/launcher_filecat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/launcher_wikicat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-hdpi/launcher_wikicat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/launcher_filecat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-mdpi/launcher_filecat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/launcher_wikicat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-mdpi/launcher_wikicat.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_action_twitter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_action_twitter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_mail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_action_mail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_rate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_action_rate.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_mail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_mail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_rate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_rate.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_web.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/launcher_redchain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-hdpi/launcher_redchain.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/launcher_white_only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-hdpi/launcher_white_only.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/launcher_redchain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-mdpi/launcher_redchain.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/launcher_white_only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-mdpi/launcher_white_only.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/launcher_filecat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xhdpi/launcher_filecat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/launcher_redchain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xhdpi/launcher_redchain.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/launcher_wikicat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xhdpi/launcher_wikicat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/launcher_filecat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxhdpi/launcher_filecat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/launcher_redchain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxhdpi/launcher_redchain.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/launcher_wikicat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxhdpi/launcher_wikicat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/launcher_filecat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxxhdpi/launcher_filecat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/launcher_wikicat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxxhdpi/launcher_wikicat.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_action_twitter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_twitter.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/launcher_baconmasher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-hdpi/launcher_baconmasher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/launcher_baconmasher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-mdpi/launcher_baconmasher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/launcher_baconmasher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xhdpi/launcher_baconmasher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/launcher_white_only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xhdpi/launcher_white_only.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/launcher_white_only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxhdpi/launcher_white_only.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/launcher_redchain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxxhdpi/launcher_redchain.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_trophy_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_trophy_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_trophy_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_trophy_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_trophy_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_trophy_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_trophy_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_trophy_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/man_in_mirror_smaller_still.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable/man_in_mirror_smaller_still.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/launcher_baconmasher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxhdpi/launcher_baconmasher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/launcher_baconmasher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxxhdpi/launcher_baconmasher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/launcher_white_only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/mipmap-xxxhdpi/launcher_white_only.png
--------------------------------------------------------------------------------
/app/src/main/res/raw/blockelganger_how_to_play_step1.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/raw/blockelganger_how_to_play_step1.mp4
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_touch_app_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-hdpi/ic_touch_app_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_touch_app_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-mdpi/ic_touch_app_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_touch_app_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xhdpi/ic_touch_app_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_touch_app_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hotpodata/Blockelganger/HEAD/app/src/main/res/drawable-xxhdpi/ic_touch_app_black_48dp.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "BlockLib"]
2 | path = BlockLib
3 | url = git@github.com:hotpodata/BlockLib.git
4 | [submodule "common"]
5 | path = common
6 | url = git@github.com:hotpodata/common.git
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ad_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ca-app-pub-6516548691974971/7869504649
4 |
--------------------------------------------------------------------------------
/app/src/pro/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sign in to share your high scores, earn badges, and view the leader
3 | board!
4 |
5 | Blockelgänger Pro
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/row_space.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/spacer_grad.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/interfaces/IGooglePlayGameServicesProvider.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.interfaces
2 |
3 | /**
4 | * Created by jdrotos on 1/6/16.
5 | */
6 | interface IGooglePlayGameServicesProvider {
7 | fun isLoggedIn(): Boolean
8 | fun login()
9 | fun logout()
10 | fun showLeaderBoard()
11 | fun showAchievements()
12 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_arrow_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pause_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_dehaze_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 | 72dp
4 |
5 | 40dp
6 | 24dp
7 |
8 | 96dp
9 | 112dp
10 | 192dp
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hotpodata/blockelganger/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/adapter/viewholder/SpacerViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.adapter.viewholder
2 |
3 | import android.support.v7.widget.RecyclerView
4 | import android.view.View
5 |
6 | /**
7 | * Created by jdrotos on 1/30/16.
8 | */
9 | class SpacerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
10 | val spacer: View
11 | get(){
12 | return itemView
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_grade_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_circle_outline_192dp.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hotpodata/blockelganger/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/adapter/viewholder/BtnViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.adapter.viewholder
2 |
3 | import android.support.v7.widget.RecyclerView
4 | import android.view.View
5 | import android.widget.Button
6 | import com.hotpodata.blockelganger.R
7 |
8 | /**
9 | * Created by jdrotos on 1/30/16.
10 | */
11 | class BtnViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
12 | val btn: Button
13 | get() {
14 | return itemView.findViewById(R.id.btn) as Button
15 | }
16 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/BlockelgangerApplication.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger
2 |
3 | import android.support.multidex.MultiDexApplication
4 | import timber.log.Timber
5 |
6 | /**
7 | * Created by jdrotos on 1/4/16.
8 | */
9 | class BlockelgangerApplication : MultiDexApplication() {
10 | public override fun onCreate() {
11 | super.onCreate()
12 | if (BuildConfig.LOGGING_ENABLED) {
13 | Timber.plant(Timber.DebugTree())
14 | }
15 | //Required
16 | SettingsMaster.context = this
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_highlight_remove_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/adapter/viewholder/SignInViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.adapter.viewholder
2 |
3 | import android.support.v7.widget.RecyclerView
4 | import android.view.View
5 | import com.google.android.gms.common.SignInButton
6 | import com.hotpodata.blockelganger.R
7 |
8 |
9 | /**
10 | * Created by jdrotos on 1/21/15.
11 | */
12 | class SignInViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
13 | var signInBtn: SignInButton
14 |
15 | init {
16 | signInBtn = itemView.findViewById(R.id.row_sign_in_button) as SignInButton
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_help_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | /*/build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Eclipse project files
30 | .classpath
31 | .project
32 |
33 | # Android Studio
34 | .idea/
35 | .gradle
36 | /*/local.properties
37 | /*/out
38 | /*/*/build
39 | /*/*/production
40 | *.iml
41 | *.iws
42 | *.ipr
43 | *~
44 | *.swp
45 | .DS_Store
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/helpers/ColorBlockDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.helpers
2 |
3 | import android.graphics.Canvas
4 | import android.graphics.Color
5 | import android.graphics.Paint
6 | import android.graphics.RectF
7 | import com.hotpodata.blocklib.view.GridBinderView
8 |
9 | /**
10 | * Created by jdrotos on 1/9/16.
11 | */
12 | class ColorBlockDrawer(color: Int) : GridBinderView.IBlockDrawer {
13 | var paint = Paint()
14 |
15 | init {
16 | paint.color = color
17 | }
18 |
19 | override fun drawBlock(canvas: Canvas, blockCoords: RectF, data: Any) {
20 | canvas.drawRect(blockCoords, paint)
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Blockelgänger
2 |
3 | You can't speak with it. You can't reason with it. You must crash into it.
4 |
5 | Blockelgänger is a game written in Kotlin using standard views and Animators.
6 |
7 | The Kotlin plugin is required to get this app running in AndroidStudio
8 |
9 | ##How to play
10 | - Press the big play button.
11 | - Tap the top area to carve a shape that will fit with the randomly generated bottom piece.
12 | - When timer finishes your shape will fall to meet the bottom shape. If the shapes fit together you proceed to the next round.
13 | - Repeat.
14 |
15 | ### Play Store
16 |
17 | https://play.google.com/store/apps/details?id=com.hotpodata.blockelganger
18 |
19 | 
20 |
21 | ### Proooomoooo
22 |
23 | Web: http://www.hotpodata.com
24 |
25 | Twitter: https://twitter.com/hotpodata
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/row_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
20 |
21 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/values/update_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | What\'s new in v%1$s?
5 |
6 |
7 | \u2022 Misc bug fixes and improvements!
8 |
9 |
10 | \u2022 New: Tap to fire! No more waiting while the clock ticks down!
11 | \u2022 New: A new level of play has been added! Multi-directional gängers are here!
12 | \u2022 New: Unlock 6 brand new achievements!
13 |
14 | - @string/v3_tap_to_fire
15 | - @string/v3_chapter_four_added
16 | - @string/v3_new_achievements
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 590087097485
4 | CgkIjZm6n5YREAIQAA
5 | CgkIjZm6n5YREAIQAw
6 | CgkIjZm6n5YREAIQBQ
7 | CgkIjZm6n5YREAIQBA
8 | CgkIjZm6n5YREAIQBw
9 | CgkIjZm6n5YREAIQBg
10 |
11 | CgkIjZm6n5YREAIQDQ
12 | CgkIjZm6n5YREAIQDg
13 | CgkIjZm6n5YREAIQDw
14 | CgkIjZm6n5YREAIQEA
15 | CgkIjZm6n5YREAIQEQ
16 | CgkIjZm6n5YREAIQEg
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/row_signin.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/fragment/DialogUpdateFragment.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.fragment
2 |
3 | import android.app.Dialog
4 | import android.content.Context
5 | import android.os.Bundle
6 | import android.support.v4.app.DialogFragment
7 | import android.support.v7.app.AlertDialog
8 | import com.hotpodata.blockelganger.R
9 | import com.hotpodata.common.utils.AndroidUtils
10 | import java.util.*
11 |
12 | /**
13 | * Created by jdrotos on 12/28/15.
14 | */
15 | class DialogUpdateFragment(val backToVersion: Int) : DialogFragment() {
16 |
17 | fun genUpdatesStrings(ctx: Context): Array {
18 | var updateItems = ArrayList()
19 | if (backToVersion < 3) {
20 | updateItems.addAll(ctx.resources.getStringArray(R.array.v3_updates))
21 | }
22 | updateItems.add(ctx.getString(R.string.bug_fixes_and_improvements))
23 | return updateItems.toTypedArray()
24 | }
25 |
26 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog? {
27 | var version = AndroidUtils.getVersionName(context)
28 | var builder = AlertDialog.Builder(context)
29 | builder.setTitle(context?.getString(R.string.whats_new_title_TEMPLATE, version))
30 | builder.setItems(genUpdatesStrings(context), null)
31 | builder.setCancelable(true)
32 | builder.setNeutralButton(R.string.got_it, null)
33 | return builder.create()
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @color/material_deep_orange
4 | #E64A19
5 | #1E88E5
6 | @color/white
7 | #FFFFFF
8 |
9 | @color/settings_row_subtitle_color
10 | #00000000
11 | @color/white
12 |
13 | @color/colorPrimary
14 | @color/white
15 | @color/colorPrimary
16 | @color/white
17 |
18 | @color/colorPrimary
19 | @color/material_deep_purple
20 | @color/material_pink
21 | @color/material_indigo
22 |
23 |
24 | @color/white
25 | @color/white
26 | @color/white
27 | #33000000
28 | @color/sidebar_text_color
29 |
30 | #B6B6B6
31 | #0F0F0F
32 | #5F5F5F
33 |
34 | @color/colorPrimary
35 | @color/white
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
19 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/AnalyticsMaster.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger
2 |
3 | import android.content.Context
4 | import com.google.android.gms.analytics.GoogleAnalytics
5 | import com.google.android.gms.analytics.Tracker
6 | import com.hotpodata.common.interfaces.IAnalyticsProvider
7 |
8 | /**
9 | * Created by jdrotos on 11/18/15.
10 | */
11 | object AnalyticsMaster : IAnalyticsProvider{
12 |
13 | //SCREENS
14 | val SCREEN_SINGLE_PLAYER = "SinglePlayerGameScreen"
15 | val SCREEN_LANDING = "LandingScreen"
16 |
17 | //CATEGORIES
18 | val CATEGORY_ACTION = "Action"
19 |
20 | //ACTIONS
21 | val ACTION_START_GAME = "StartGame"
22 | val ACTION_GAME_OVER = "GameOver"
23 | val ACTION_PAUSE = "Pause"
24 | val ACTION_RESUME = "Resume"
25 | val ACTION_START_OVER = "StartOver"
26 | val ACTION_HELP = "Help"
27 | val ACTION_UPDATE_FRAG = "UpdateFragment"
28 | val ACTION_OPEN_DRAWER = "OpenDrawer"
29 | val ACTION_SIGN_IN = "SignInClicked"
30 | val ACTION_ACHIEVEMENTS = "AchievementsClicked"
31 | val ACTION_LEADERBOARD = "LeaderBoardClicked"
32 | val ACTION_LEVEL_COMPLETE = "LevelComplete"
33 | val ACTION_EARLY_SMASH = "EarlySmash"
34 |
35 | //Labels
36 | val LABEL_LEVEL = "Level"
37 | val LABEL_LAUNCH_COUNT = "LaunchCount"
38 | val LABEL_SECONDS_REMAINING = "SecondsRemaining"
39 |
40 | private var tracker: Tracker? = null
41 | public override fun getTracker(context: Context): Tracker {
42 | val t = tracker ?:
43 | GoogleAnalytics.getInstance(context).newTracker(R.xml.global_tracker).apply {
44 | enableExceptionReporting(true)
45 | enableAdvertisingIdCollection(true)
46 | }
47 | tracker = t
48 | return t
49 | }
50 | }
--------------------------------------------------------------------------------
/app/src/free/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_id": "blockelganger-58934997",
4 | "project_number": "590087097485",
5 | "name": "Blockelganger"
6 | },
7 | "client": [
8 | {
9 | "client_info": {
10 | "mobilesdk_app_id": "1:590087097485:android:6642f329fec6a74a",
11 | "client_id": "android:com.hotpodata.blockelganger",
12 | "client_type": 1,
13 | "android_client_info": {
14 | "package_name": "com.hotpodata.blockelganger"
15 | }
16 | },
17 | "oauth_client": [
18 | {
19 | "client_id": "590087097485-rhudpqs38dm94gr6oeh2e7886n74neo0.apps.googleusercontent.com",
20 | "client_type": 1,
21 | "android_info": {
22 | "package_name": "com.hotpodata.blockelganger",
23 | "certificate_hash": "9E847FF30F99E5EC5A7CDDAA487E7AD3CCABB7B2"
24 | }
25 | },
26 | {
27 | "client_id": "590087097485-3mh61popmenvln3g2umve955bqnd3n1u.apps.googleusercontent.com",
28 | "client_type": 1,
29 | "android_info": {
30 | "package_name": "com.hotpodata.blockelganger",
31 | "certificate_hash": "FBC6290B0355C362A8BEC13503D11C52761DA042"
32 | }
33 | }
34 | ],
35 | "api_key": [],
36 | "services": {
37 | "analytics_service": {
38 | "status": 2,
39 | "analytics_property": {
40 | "tracking_id": "UA-70379200-12"
41 | }
42 | },
43 | "cloud_messaging_service": {
44 | "status": 1,
45 | "apns_config": []
46 | },
47 | "appinvite_service": {
48 | "status": 1,
49 | "other_platform_oauth_client": []
50 | },
51 | "google_signin_service": {
52 | "status": 1
53 | },
54 | "ads_service": {
55 | "status": 1
56 | }
57 | }
58 | }
59 | ],
60 | "client_info": [],
61 | "ARTIFACT_VERSION": "1"
62 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/SettingsMaster.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger
2 |
3 | import android.content.Context
4 |
5 | /**
6 | * Created by jdrotos on 1/30/16.
7 | */
8 | object SettingsMaster {
9 |
10 | val APP_PREFS = "APP_PREFS"
11 | val STORAGE_KEY_LAUNCH_COUNT = "STORAGE_KEY_LAUNCH_COUNT"
12 | val STORAGE_KEY_LAST_SEEN_VERSION = "STORAGE_KEY_LAST_SEEN_VERSION"
13 | val STORAGE_KEY_AUTO_SIGN_IN = "STORAGE_KEY_AUTO_SIGN_IN"
14 |
15 | var context: Context? = null
16 |
17 | var launchCount: Int
18 | set(launches: Int) {
19 | context?.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE)?.edit()?.let {
20 | it.putInt(STORAGE_KEY_LAUNCH_COUNT, launches);
21 | it.commit()
22 | }
23 | }
24 | get() {
25 | return context?.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE)?.let {
26 | it.getInt(STORAGE_KEY_LAUNCH_COUNT, 0)
27 | } ?: 0
28 | }
29 |
30 | var lastSeenVersionCode: Int
31 | set(launches: Int) {
32 | context?.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE)?.edit()?.let {
33 | it.putInt(STORAGE_KEY_LAST_SEEN_VERSION, launches);
34 | it.commit()
35 | }
36 | }
37 | get() {
38 | return context?.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE)?.let {
39 | it.getInt(STORAGE_KEY_LAST_SEEN_VERSION, 0)
40 | } ?: 0
41 | }
42 |
43 | var autoStartSignInFlow: Boolean
44 | set(signInOnStart: Boolean) {
45 | context?.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE)?.edit()?.let {
46 | it.putBoolean(STORAGE_KEY_AUTO_SIGN_IN, signInOnStart);
47 | it.commit()
48 | }
49 | }
50 | get() {
51 | return context?.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE)?.let {
52 | it.getBoolean(STORAGE_KEY_AUTO_SIGN_IN, false)
53 | } ?: false
54 | }
55 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/material_colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F44336
4 | #E91E63
5 | #9C27B0
6 | #673AB7
7 | #3F51B5
8 | #2196F3
9 | #03A9F4
10 | #00BCD4
11 | #009688
12 | #4CAF50
13 | #8BC34A
14 | #CDDC39
15 | #FFEB3B
16 | #FFC107
17 | #FF9800
18 | #FF5722
19 | #795548
20 | #9E9E9E
21 | #607D8B
22 |
23 |
24 | - @color/material_red
25 | - @color/material_pink
26 | - @color/material_purple
27 | - @color/material_deep_purple
28 | - @color/material_indigo
29 | - @color/material_blue
30 | - @color/material_light_blue
31 | - @color/material_cyan
32 | - @color/material_teal
33 | - @color/material_green
34 |
35 |
36 |
37 | - @color/material_amber
38 | - @color/material_orange
39 | - @color/material_deep_orange
40 | - @color/material_brown
41 | - @color/material_blue_grey
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/jdrotos/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 |
20 | #Support app compat
21 | -keep public class android.support.v7.widget.** { *; }
22 | -keep public class android.support.v7.internal.widget.** { *; }
23 | -keep public class android.support.v7.internal.view.menu.** { *; }
24 |
25 | -keep public class * extends android.support.v4.view.ActionProvider {
26 | public (android.content.Context);
27 | }
28 |
29 | -dontwarn com.google.common.util.concurrent.ServiceManager
30 |
31 | #Kotlin
32 | -dontwarn kotlin.**
33 | -dontwarn org.w3c.dom.events.*
34 |
35 | #Design support
36 | # support design
37 | -dontwarn android.support.design.**
38 | -keep class android.support.design.** { *; }
39 | -keep interface android.support.design.** { *; }
40 | -keep public class android.support.design.R$* { *; }
41 | -keep public class * extends android.support.design.widget.CoordinatorLayout$Behavior {
42 | public (android.content.Context, android.util.AttributeSet);
43 | }
44 |
45 |
46 | #Rx
47 | -dontwarn sun.misc.**
48 | -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
49 | long producerIndex;
50 | long consumerIndex;
51 | }
52 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
53 | rx.internal.util.atomic.LinkedQueueNode producerNode;
54 | }
55 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
56 | rx.internal.util.atomic.LinkedQueueNode consumerNode;
57 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_game.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
21 |
22 |
28 |
29 |
39 |
40 |
41 |
42 |
43 |
52 |
53 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Blockelgänger
3 | @string/app_name
4 | Level:%1$d
5 | Points:%1$d
6 |
7 | Single Player
8 | Quick Battle
9 | Invite Players
10 | Show Invitations
11 |
12 | This block must be carved with your finger to fit together with the shape on the bottom.
13 | A new shape will be generated here every turn!
14 |
15 | Paused
16 | Game Over!
17 | The only tip: Shape the top piece to fit together with the bottom piece!
18 | Pause
19 | Leader Board
20 | Achievements
21 | Play
22 | Resume
23 | Continue Game
24 | Start Over
25 | + %1$d
26 | Sign in to share your high scores, earn badges, view the leader board, and see FEWER ADS!
27 | You must be signed in to perform this action!
28 | Game
29 | Sign Out
30 | Thanks for being signed in! No ad for you!
31 | Got it!
32 | Help
33 |
34 | How to defeat your blockelgänger
35 | •When the clock starts counting down, carve your block(s) to FIT TOGETHER WITH the blockelgänger block.
36 | •Repeat! Now go crush your blockelgänger!
37 |
38 | Error signing in!
39 | Failed to sign in. Please check your network connection and try again.
40 | The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.
41 | License check failed.
42 | Unknown error.
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_id": "blockelganger-58934997",
4 | "project_number": "590087097485",
5 | "name": "Blockelganger"
6 | },
7 | "client": [
8 | {
9 | "client_info": {
10 | "mobilesdk_app_id": "1:590087097485:android:6642f329fec6a74a",
11 | "client_id": "android:com.hotpodata.blockelganger",
12 | "client_type": 1,
13 | "android_client_info": {
14 | "package_name": "com.hotpodata.blockelganger"
15 | }
16 | },
17 | "oauth_client": [
18 | {
19 | "client_id": "590087097485-rhudpqs38dm94gr6oeh2e7886n74neo0.apps.googleusercontent.com",
20 | "client_type": 1,
21 | "android_info": {
22 | "package_name": "com.hotpodata.blockelganger",
23 | "certificate_hash": "9E847FF30F99E5EC5A7CDDAA487E7AD3CCABB7B2"
24 | }
25 | },
26 | {
27 | "client_id": "590087097485-3mh61popmenvln3g2umve955bqnd3n1u.apps.googleusercontent.com",
28 | "client_type": 1,
29 | "android_info": {
30 | "package_name": "com.hotpodata.blockelganger",
31 | "certificate_hash": "FBC6290B0355C362A8BEC13503D11C52761DA042"
32 | }
33 | }
34 | ],
35 | "api_key": [],
36 | "services": {
37 | "analytics_service": {
38 | "status": 2,
39 | "analytics_property": {
40 | "tracking_id": "UA-70379200-12"
41 | }
42 | },
43 | "cloud_messaging_service": {
44 | "status": 1,
45 | "apns_config": []
46 | },
47 | "appinvite_service": {
48 | "status": 1,
49 | "other_platform_oauth_client": []
50 | },
51 | "google_signin_service": {
52 | "status": 1
53 | },
54 | "ads_service": {
55 | "status": 1
56 | }
57 | }
58 | },
59 | {
60 | "client_info": {
61 | "mobilesdk_app_id": "1:590087097485:android:89baa03a2d02610c",
62 | "client_id": "android:com.hotpodata.blockelganger.pro",
63 | "client_type": 1,
64 | "android_client_info": {
65 | "package_name": "com.hotpodata.blockelganger.pro"
66 | }
67 | },
68 | "oauth_client": [],
69 | "api_key": [],
70 | "services": {
71 | "analytics_service": {
72 | "status": 2,
73 | "analytics_property": {
74 | "tracking_id": "UA-70379200-12"
75 | }
76 | },
77 | "cloud_messaging_service": {
78 | "status": 1,
79 | "apns_config": []
80 | },
81 | "appinvite_service": {
82 | "status": 1,
83 | "other_platform_oauth_client": []
84 | },
85 | "google_signin_service": {
86 | "status": 1
87 | },
88 | "ads_service": {
89 | "status": 1
90 | }
91 | }
92 | }
93 | ],
94 | "client_info": [],
95 | "ARTIFACT_VERSION": "1"
96 | }
--------------------------------------------------------------------------------
/app/src/pro/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_id": "blockelganger-58934997",
4 | "project_number": "590087097485",
5 | "name": "Blockelganger"
6 | },
7 | "client": [
8 | {
9 | "client_info": {
10 | "mobilesdk_app_id": "1:590087097485:android:6642f329fec6a74a",
11 | "client_id": "android:com.hotpodata.blockelganger",
12 | "client_type": 1,
13 | "android_client_info": {
14 | "package_name": "com.hotpodata.blockelganger"
15 | }
16 | },
17 | "oauth_client": [
18 | {
19 | "client_id": "590087097485-rhudpqs38dm94gr6oeh2e7886n74neo0.apps.googleusercontent.com",
20 | "client_type": 1,
21 | "android_info": {
22 | "package_name": "com.hotpodata.blockelganger",
23 | "certificate_hash": "9E847FF30F99E5EC5A7CDDAA487E7AD3CCABB7B2"
24 | }
25 | },
26 | {
27 | "client_id": "590087097485-3mh61popmenvln3g2umve955bqnd3n1u.apps.googleusercontent.com",
28 | "client_type": 1,
29 | "android_info": {
30 | "package_name": "com.hotpodata.blockelganger",
31 | "certificate_hash": "FBC6290B0355C362A8BEC13503D11C52761DA042"
32 | }
33 | }
34 | ],
35 | "api_key": [],
36 | "services": {
37 | "analytics_service": {
38 | "status": 2,
39 | "analytics_property": {
40 | "tracking_id": "UA-70379200-12"
41 | }
42 | },
43 | "cloud_messaging_service": {
44 | "status": 1,
45 | "apns_config": []
46 | },
47 | "appinvite_service": {
48 | "status": 1,
49 | "other_platform_oauth_client": []
50 | },
51 | "google_signin_service": {
52 | "status": 1
53 | },
54 | "ads_service": {
55 | "status": 1
56 | }
57 | }
58 | },
59 | {
60 | "client_info": {
61 | "mobilesdk_app_id": "1:590087097485:android:89baa03a2d02610c",
62 | "client_id": "android:com.hotpodata.blockelganger.pro",
63 | "client_type": 1,
64 | "android_client_info": {
65 | "package_name": "com.hotpodata.blockelganger.pro"
66 | }
67 | },
68 | "oauth_client": [],
69 | "api_key": [],
70 | "services": {
71 | "analytics_service": {
72 | "status": 2,
73 | "analytics_property": {
74 | "tracking_id": "UA-70379200-12"
75 | }
76 | },
77 | "cloud_messaging_service": {
78 | "status": 1,
79 | "apns_config": []
80 | },
81 | "appinvite_service": {
82 | "status": 1,
83 | "other_platform_oauth_client": []
84 | },
85 | "google_signin_service": {
86 | "status": 1
87 | },
88 | "ads_service": {
89 | "status": 1
90 | }
91 | }
92 | }
93 | ],
94 | "client_info": [],
95 | "ARTIFACT_VERSION": "1"
96 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/blockelganger_game_board.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
14 |
15 |
20 |
21 |
27 |
28 |
37 |
38 |
47 |
48 |
57 |
58 |
63 |
64 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/fragment/DialogHowToPlayFragment.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.fragment
2 |
3 | import android.app.Dialog
4 | import android.content.Context
5 | import android.content.DialogInterface
6 | import android.media.MediaPlayer
7 | import android.net.Uri
8 | import android.os.Bundle
9 | import android.support.v4.app.DialogFragment
10 | import android.view.LayoutInflater
11 | import android.view.View
12 | import android.view.ViewGroup
13 | import android.view.Window
14 | import com.hotpodata.blockelganger.R
15 | import kotlinx.android.synthetic.main.fragment_dialog_how_to_play.*
16 | import rx.Observable
17 | import rx.Subscription
18 | import rx.android.schedulers.AndroidSchedulers
19 | import timber.log.Timber
20 | import java.util.concurrent.TimeUnit
21 |
22 | /**
23 | * Created by jdrotos on 12/28/15.
24 | */
25 | class DialogHowToPlayFragment : DialogFragment() {
26 |
27 | public interface IDialogHowToPlayListener {
28 | fun onHelpDialogDismissed()
29 | }
30 |
31 | var dialogLisetner: IDialogHowToPlayListener? = null
32 | var timerSub: Subscription? = null
33 |
34 | override fun onAttach(context: Context?) {
35 | super.onAttach(context)
36 | dialogLisetner = context as? IDialogHowToPlayListener
37 | }
38 |
39 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog? {
40 | val dialog = super.onCreateDialog(savedInstanceState)
41 | // request a window without the title
42 | dialog.window.requestFeature(Window.FEATURE_NO_TITLE)
43 | dialog.setCanceledOnTouchOutside(true)
44 | return dialog
45 | }
46 |
47 | override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
48 | return inflater?.inflate(R.layout.fragment_dialog_how_to_play, container, false)
49 | }
50 |
51 | override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
52 | super.onViewCreated(view, savedInstanceState)
53 | btn_got_it.setOnClickListener {
54 | Timber.d("Calling dismiss()")
55 | dismiss()
56 | }
57 |
58 | step_one_video.setZOrderOnTop(true)
59 | }
60 |
61 | override fun onResume() {
62 | super.onResume()
63 | val uriPath = "android.resource://" + getActivity().getPackageName() + "/" + R.raw.blockelganger_how_to_play_step1
64 | val uri = Uri.parse(uriPath)
65 |
66 | step_one_video.setVideoURI(uri)
67 | step_one_video.setOnCompletionListener(MediaPlayer.OnCompletionListener {
68 | timerSub = Observable.timer(3, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe {
69 | if (isResumed && isAdded) {
70 | step_one_video.start()
71 | }
72 | }
73 | })
74 | step_one_video.start()
75 | }
76 |
77 | override fun onPause() {
78 | super.onPause()
79 | timerSub?.unsubscribe()
80 | step_one_video.stopPlayback()
81 | }
82 |
83 | override fun onDismiss(dialog: DialogInterface) {
84 | super.onDismiss(dialog)
85 | Timber.d("OnDismissListener firing!")
86 | dialogLisetner?.onHelpDialogDismissed()
87 | }
88 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/adapter/BlockelgangerSideBarAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.adapter
2 |
3 | import android.content.Context
4 | import android.support.v7.widget.RecyclerView
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import com.hotpodata.blockelganger.AnalyticsMaster
9 | import com.hotpodata.blockelganger.BuildConfig
10 | import com.hotpodata.blockelganger.R
11 | import com.hotpodata.blockelganger.adapter.viewholder.SignInViewHolder
12 | import com.hotpodata.blockelganger.interfaces.IGooglePlayGameServicesProvider
13 | import com.hotpodata.common.adapter.SideBarAdapter
14 | import com.hotpodata.common.data.App
15 | import com.hotpodata.common.enums.HotPoDataApps
16 | import com.hotpodata.common.enums.Libraries
17 | import java.util.*
18 |
19 | /**
20 | * Created by jdrotos on 11/7/15.
21 | */
22 | class BlockelgangerSideBarAdapter(ctx: Context, val playGameServicesProvider: IGooglePlayGameServicesProvider) : SideBarAdapter(ctx, AnalyticsMaster, App.Factory.createApp(ctx, HotPoDataApps.BLOCKELGANGER), BuildConfig.IS_PRO, true, Libraries.AutoFitTextView, Libraries.RxAndroid, Libraries.RxJava, Libraries.RxKotlin, Libraries.Timber) {
23 |
24 | private val ROW_TYPE_SIGN_IN = 100
25 |
26 | init {
27 | rebuildRowSet()
28 | }
29 |
30 | override fun genCustomRows(): List {
31 | var sideBarRows = ArrayList()
32 | sideBarRows.add(ctx.resources.getString(R.string.game))
33 | if (playGameServicesProvider.isLoggedIn()) {
34 | sideBarRows.add(RowSettings(ctx.resources.getString(R.string.leader_board), "", View.OnClickListener {
35 | playGameServicesProvider.showLeaderBoard()
36 | }, R.drawable.ic_trophy_black_48dp))
37 | sideBarRows.add(RowDiv(true))
38 | sideBarRows.add(RowSettings(ctx.resources.getString(R.string.achievements), "", View.OnClickListener {
39 | playGameServicesProvider.showAchievements()
40 | }, R.drawable.ic_grade_24dp))
41 | sideBarRows.add(RowDiv(true))
42 | sideBarRows.add(RowSettings(ctx.resources.getString(R.string.sign_out), "", View.OnClickListener {
43 | playGameServicesProvider.logout()
44 | }, R.drawable.ic_highlight_remove_24dp))
45 | } else {
46 | sideBarRows.add(RowSignIn(View.OnClickListener {
47 | playGameServicesProvider.login()
48 | }))
49 | }
50 | return sideBarRows
51 | }
52 |
53 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder? {
54 | return when (viewType) {
55 | ROW_TYPE_SIGN_IN -> {
56 | val inflater = LayoutInflater.from(parent.context)
57 | val v = inflater.inflate(R.layout.row_signin, parent, false)
58 | SignInViewHolder(v)
59 | }
60 | else -> super.onCreateViewHolder(parent, viewType)
61 | }
62 | }
63 |
64 | @Suppress("DEPRECATION")
65 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
66 | val type = getItemViewType(position)
67 | val objData = mRows[position]
68 | when (type) {
69 | ROW_TYPE_SIGN_IN -> {
70 | val vh = holder as SignInViewHolder
71 | val data = objData as RowSignIn
72 | vh.signInBtn.setOnClickListener(data.onClickListener)
73 | }
74 | else -> super.onBindViewHolder(holder, position)
75 | }
76 | }
77 |
78 | override fun getItemViewType(position: Int): Int {
79 | val data = mRows[position]
80 | return when (data) {
81 | is RowSignIn -> ROW_TYPE_SIGN_IN
82 | else -> super.getItemViewType(position)
83 | }
84 | }
85 |
86 | class RowSignIn(val onClickListener: View.OnClickListener)
87 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_dialog_how_to_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
32 |
33 |
38 |
39 |
46 |
47 |
54 |
55 |
63 |
64 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
88 |
89 |
97 |
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/adapter/StartupAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.adapter
2 |
3 | import android.content.Context
4 | import android.support.v7.widget.RecyclerView
5 | import android.view.LayoutInflater
6 | import android.view.ViewGroup
7 | import com.hotpodata.blockelganger.BuildConfig
8 | import com.hotpodata.blockelganger.R
9 | import com.hotpodata.blockelganger.activity.SinglePlayerActivity
10 | import com.hotpodata.blockelganger.adapter.viewholder.BtnViewHolder
11 | import com.hotpodata.blockelganger.adapter.viewholder.SpacerViewHolder
12 | import com.hotpodata.blockelganger.interfaces.IGooglePlayGameServicesProvider
13 | import com.hotpodata.common.data.App
14 | import com.hotpodata.common.enums.HotPoDataApps
15 | import java.util.*
16 |
17 | /**
18 | * Created by jdrotos on 1/30/16.
19 | */
20 | class StartupAdapter(val ctx: Context) : RecyclerView.Adapter() {
21 |
22 | val ROWTYPE_SPACER = 0
23 | val ROWTYPE_BTN = 1
24 |
25 | class DataSpace {}
26 | abstract class DataBtn(val label: String) {
27 | abstract fun onClick()
28 | }
29 |
30 |
31 | var rows = ArrayList()
32 | var spacerHeight: Int = 256
33 | set(h: Int) {
34 | field = h
35 | rebuildRowSet()
36 | }
37 | var googleServicesProvider: IGooglePlayGameServicesProvider? = null
38 | set(prov: IGooglePlayGameServicesProvider?) {
39 | field = prov
40 | rebuildRowSet()
41 | }
42 |
43 |
44 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
45 | var data = rows.get(position)
46 | if (holder is BtnViewHolder && data is DataBtn) {
47 | holder.btn.setText(data.label)
48 | holder.btn.setOnClickListener {
49 | data.onClick()
50 | }
51 | }
52 | if (holder is SpacerViewHolder && data is DataSpace) {
53 | holder.spacer.layoutParams?.let {
54 | it.height = spacerHeight
55 | holder.spacer.layoutParams = it
56 | }
57 | }
58 | }
59 |
60 | override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder? {
61 | var inflater = LayoutInflater.from(ctx)
62 | return when (viewType) {
63 | ROWTYPE_BTN -> BtnViewHolder(inflater.inflate(R.layout.row_btn, parent, false))
64 | ROWTYPE_SPACER -> SpacerViewHolder(inflater.inflate(R.layout.row_space, parent, false))
65 | else -> null
66 | }
67 | }
68 |
69 | override fun getItemViewType(position: Int): Int {
70 | var data = rows.get(position)
71 | if (data is DataSpace) {
72 | return ROWTYPE_SPACER
73 | }
74 | if (data is DataBtn) {
75 | return ROWTYPE_BTN
76 | }
77 | return super.getItemViewType(position)
78 | }
79 |
80 | override fun getItemCount(): Int {
81 | return rows.size
82 | }
83 |
84 | fun rebuildRowSet() {
85 | var newRows = ArrayList()
86 | newRows.add(DataSpace())
87 | //Single player
88 | newRows.add(object : DataBtn(ctx.getString(R.string.single_player)) {
89 | override fun onClick() {
90 | ctx.startActivity(SinglePlayerActivity.IntentGenerator.generateIntent(ctx))
91 | }
92 | })
93 |
94 | //Multiplayer
95 | newRows.add(object : DataBtn(ctx.getString(R.string.quick_battle)) {
96 | override fun onClick() {
97 |
98 | }
99 | })
100 | newRows.add(object : DataBtn(ctx.getString(R.string.invite_players)) {
101 | override fun onClick() {
102 |
103 | }
104 | })
105 | newRows.add(object : DataBtn(ctx.getString(R.string.show_invitations)) {
106 | override fun onClick() {
107 |
108 | }
109 | })
110 |
111 | //Promo
112 | if (!BuildConfig.IS_PRO) {
113 | newRows.add(object : DataBtn(ctx.getString(R.string.go_pro)) {
114 | override fun onClick() {
115 | var app = App.Factory.createApp(ctx, HotPoDataApps.BLOCKELGANGER)
116 | app.firePlayStoreIntent(ctx, true)
117 | }
118 | })
119 | }
120 |
121 | rows = newRows
122 | notifyDataSetChanged()
123 | }
124 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/helpers/GameHelper.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.helpers
2 |
3 | import android.animation.FloatEvaluator
4 | import android.content.Context
5 | import android.view.animation.DecelerateInterpolator
6 | import com.hotpodata.blockelganger.R
7 |
8 | /**
9 | * Created by jdrotos on 1/21/16.
10 | */
11 | object GameHelper {
12 |
13 | val CHAPTER_ONE_LEVEL_THRESH = 0
14 | val CHAPTER_TWO_LEVEL_THRESH = 5
15 | val CHAPTER_THREE_LEVEL_THRESH = 10
16 | val CHAPTER_FOUR_LEVEL_THRESH = 20
17 |
18 | val MIN_SECONDS_DIVISOR = 1.0f
19 | val MAX_SECONDS_DIVISOR = 2.5f
20 |
21 | val secondsInterpolator = DecelerateInterpolator()
22 | val secondsEvaluator = FloatEvaluator()
23 |
24 | enum class Chapter {
25 | ONE,
26 | TWO,
27 | THREE,
28 | FOUR
29 | }
30 |
31 | fun levelIsChapterStart(lvl: Int): Boolean {
32 | for (chap in Chapter.values()) {
33 | if (lvl - 1 == threshForChap(chap)) {
34 | return true
35 | }
36 | }
37 | return false
38 | }
39 |
40 | fun colorForChapter(ctx: Context, chapter: GameHelper.Chapter): Int {
41 | return when (chapter) {
42 | GameHelper.Chapter.ONE -> ctx.resources.getColor(R.color.chapter_one_color)
43 | GameHelper.Chapter.TWO -> ctx.resources.getColor(R.color.chapter_two_color)
44 | GameHelper.Chapter.THREE -> ctx.resources.getColor(R.color.chapter_three_color)
45 | GameHelper.Chapter.FOUR -> ctx.resources.getColor(R.color.chapter_four_color)
46 | }
47 | }
48 |
49 | fun threshForLevel(lvl: Int): Int {
50 | return threshForChap(chapterForLevel(lvl))
51 | }
52 |
53 | fun threshForChap(chap: Chapter): Int {
54 | return when (chap) {
55 | Chapter.ONE -> CHAPTER_ONE_LEVEL_THRESH
56 | Chapter.TWO -> CHAPTER_TWO_LEVEL_THRESH
57 | Chapter.THREE -> CHAPTER_THREE_LEVEL_THRESH
58 | Chapter.FOUR -> CHAPTER_FOUR_LEVEL_THRESH
59 | }
60 | }
61 |
62 | fun chapterForLevel(lvl: Int): Chapter {
63 | if (lvl > CHAPTER_FOUR_LEVEL_THRESH) {
64 | return Chapter.FOUR
65 | } else if (lvl > CHAPTER_THREE_LEVEL_THRESH) {
66 | return Chapter.THREE
67 | } else if (lvl > CHAPTER_TWO_LEVEL_THRESH) {
68 | return Chapter.TWO
69 | } else {
70 | return Chapter.ONE
71 | }
72 | }
73 |
74 |
75 | fun gangerDepthForLevel(lvl: Int): Int {
76 | if (chapterForLevel(lvl) == Chapter.TWO) {
77 | return gridDepthForLevel(lvl) * 2 - 1
78 | } else {
79 | return gridDepthForLevel(lvl)
80 | }
81 | }
82 |
83 | fun gangerBreadthForLevel(lvl: Int): Int {
84 | return gridBreadthForLevel(lvl)
85 | }
86 |
87 | /**
88 | * How tall should our grids be given the arg level
89 | */
90 | fun gridDepthForLevel(lvl: Int): Int {
91 | if (lvl > 0) {
92 | var workingLevel = (lvl - 1).toDouble()//zero-indexed level
93 | workingLevel = workingLevel - (threshForLevel(lvl))//distance from thresh
94 | return Math.floor(Math.sqrt(workingLevel)).toInt() + 2
95 | } else {
96 | return 1
97 | }
98 | }
99 |
100 | /**
101 | * How wide should our grids be given the arg level
102 | */
103 | fun gridBreadthForLevel(lvl: Int): Int {
104 | //6,4,6,8,6,8,10,12,14,16
105 | if (lvl > 0) {
106 | var workingLevel = lvl - (threshForLevel(lvl))
107 | return workingLevel * 2 + (4 - ((gridDepthForLevel(lvl) - 2) * 4))
108 | } else {
109 | return 1
110 | }
111 | }
112 |
113 | /**
114 | * How much time in seconds should we have to solve the puzzle given the arg level
115 | */
116 | fun secondsForLevel(lvl: Int): Int {
117 | var activeBlocks = (gridDepthForLevel(lvl) - 1) * gridBreadthForLevel(lvl)
118 | var multiplier = when (chapterForLevel(lvl)) {
119 | Chapter.FOUR -> 5
120 | Chapter.TWO -> 2
121 | else -> 1
122 | }
123 | activeBlocks *= multiplier
124 | return ((activeBlocks / secondsEvaluator.evaluate(secondsInterpolator.getInterpolation(Math.min(CHAPTER_THREE_LEVEL_THRESH, lvl) / CHAPTER_THREE_LEVEL_THRESH.toFloat()), MIN_SECONDS_DIVISOR, MAX_SECONDS_DIVISOR)).toInt())
125 | }
126 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'com.google.gms.google-services'
4 |
5 | android {
6 | compileSdkVersion 23
7 | buildToolsVersion "23.0.2"
8 |
9 | defaultConfig {
10 | minSdkVersion 19
11 | targetSdkVersion 23
12 | versionCode 3
13 | versionName "1.2"
14 | multiDexEnabled true
15 | }
16 |
17 | buildTypes {
18 | debug {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | buildConfigField "boolean", "LOGGING_ENABLED", "true"
22 | buildConfigField "boolean", "IS_DEBUG_BUILD", "true"
23 | }
24 | release {
25 | minifyEnabled true
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | buildConfigField "boolean", "LOGGING_ENABLED", "false"
28 | buildConfigField "boolean", "IS_DEBUG_BUILD", "false"
29 | }
30 | }
31 |
32 | signingConfigs {
33 | def provDir = System.getenv("BLOCKELGANGER_KEYSTORE_DIRECTORY") ?: ""
34 | def blockelgangerKeystorePass = System.getenv("BLOCKELGANGER_KEYSTORE_PASS") ?: ""
35 | def blockelgangerProPass = System.getenv("BLOCKELGANGER_PRO_PASS") ?: ""
36 | blockelgangerProRelease {
37 | storeFile file("${provDir}/blockelganger.keystore")
38 | storePassword blockelgangerKeystorePass
39 | keyAlias "blockelganger-pro-release"
40 | keyPassword blockelgangerProPass
41 | }
42 |
43 | def blockelgangerFreePass = System.getenv("BLOCKELGANGER_FREE_PASS") ?: ""
44 | blockelgangerFreeRelease {
45 | storeFile file("${provDir}/blockelganger.keystore")
46 | storePassword blockelgangerKeystorePass
47 | keyAlias "blockelganger-release"
48 | keyPassword blockelgangerFreePass
49 | }
50 | }
51 | productFlavors {
52 | def freeSigning = signingConfigs.blockelgangerFreeRelease
53 | def proSigning = signingConfigs.blockelgangerProRelease
54 | Free {
55 | applicationId "com.hotpodata.blockelganger"
56 | buildConfigField "boolean", "IS_PRO", "false"
57 | signingConfig freeSigning
58 | }
59 | Pro {
60 | applicationId "com.hotpodata.blockelganger.pro"
61 | buildConfigField "boolean", "IS_PRO", "true"
62 | signingConfig proSigning
63 | }
64 | }
65 |
66 | sourceSets {
67 | main.java.srcDirs += 'src/main/kotlin'
68 | }
69 | }
70 | dependencies {
71 | compile fileTree(dir: 'libs', include: ['*.jar'])
72 | compile project(':BlockLib')
73 | compile project(':common')
74 | compile 'com.android.support:appcompat-v7:23.1.0'
75 | compile 'com.android.support:design:23.1.0'
76 | compile 'com.android.support:recyclerview-v7:23.1.0'
77 | compile 'com.google.android.gms:play-services-games:8.3.0'
78 | compile 'com.google.android.gms:play-services-ads:8.3.0'
79 | compile 'com.google.android.gms:play-services-analytics:8.3.0'
80 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
81 | compile 'com.android.support:multidex:1.0.0'
82 | compile 'com.jakewharton.timber:timber:3.1.0'
83 | compile 'io.reactivex:rxandroid:1.0.1'
84 | compile 'io.reactivex:rxkotlin:0.30.1'
85 | compile 'io.reactivex:rxjava:1.0.16'
86 | compile 'me.grantland:autofittextview:0.2.+'
87 | }
88 | task switchToFree(type: Copy) {
89 | description = 'Switches to FREE google-services.json'
90 | from "src/free"
91 | include "google-services.json"
92 | into "."
93 | }
94 |
95 | task switchToPro(type: Copy) {
96 | description = 'Switches to PRO google-services.json'
97 | from "src/pro"
98 | include "google-services.json"
99 | into "."
100 | }
101 | buildscript {
102 | ext.kotlin_version = '1.0.0-beta-4589'
103 | repositories {
104 | mavenCentral()
105 | }
106 | dependencies {
107 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
108 | classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
109 | }
110 | }
111 | repositories {
112 | mavenCentral()
113 | }
114 | afterEvaluate {
115 | processFreeDebugGoogleServices.dependsOn switchToFree
116 | processFreeReleaseGoogleServices.dependsOn switchToFree
117 | processProDebugGoogleServices.dependsOn switchToPro
118 | processProReleaseGoogleServices.dependsOn switchToPro
119 | }
120 |
121 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/helpers/GridTouchListener.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.helpers
2 |
3 | import android.view.MotionEvent
4 | import android.view.View
5 | import com.hotpodata.blocklib.Grid
6 | import com.hotpodata.blocklib.view.GridBinderView
7 |
8 | /**
9 | * Created by jdrotos on 1/21/16.
10 | */
11 | class GridTouchListener(val touchCoordinator: ITouchCoordinator, val gridChangeListener: IGridChangedListener) : View.OnTouchListener {
12 |
13 | public interface ITouchCoordinator {
14 | fun onGridTouched(view: View)
15 | fun allowGridTouch(view: View): Boolean
16 | }
17 |
18 | public interface IGridChangedListener {
19 | fun onGridChanged(grid: Grid)
20 | }
21 |
22 | var touchCoords: Pair? = null
23 | var touchModeIsAdd = false
24 |
25 | /**
26 | * Set coords filled, return true if change was made
27 | */
28 | fun addCoords(grid: Grid, coords: Pair): Boolean {
29 | if (gridCoordsValid(grid, coords)) {
30 | if (grid.at(coords.first, coords.second) == null) {
31 | grid.put(coords.first, coords.second, true)
32 | gridChangeListener.onGridChanged(grid)
33 | return true
34 | }
35 | }
36 | return false
37 | }
38 |
39 | /**
40 | * Set coords empty, return true if change was made
41 | */
42 | fun subtractCoords(grid: Grid, coords: Pair): Boolean {
43 | if (gridCoordsValid(grid, coords)) {
44 | if (grid.at(coords.first, coords.second) != null) {
45 | grid.put(coords.first, coords.second, null)
46 | gridChangeListener.onGridChanged(grid)
47 | return true
48 | }
49 | }
50 | return false
51 | }
52 |
53 | /**
54 | * Check if the coordinates at the given top grid are filled
55 | */
56 | fun gridCoordsFilled(grid: Grid, coords: Pair): Boolean {
57 | return gridCoordsValid(grid, coords) && grid.at(coords.first, coords.second) != null
58 | }
59 |
60 | /**
61 | * Check validity of coords in the top grid
62 | */
63 | fun gridCoordsValid(grid: Grid, coords: Pair): Boolean {
64 | return coords.first >= 0 && coords.first < grid.width && coords.second >= 0 && coords.second < grid.height
65 | }
66 |
67 | /**
68 | * The actual touch handling
69 | */
70 | override fun onTouch(gridView: View?, motionEvent: MotionEvent?): Boolean {
71 | if (gridView != null && touchCoordinator.allowGridTouch(gridView) && motionEvent != null && gridView is GridBinderView) {
72 | var grid = gridView.grid
73 | if (grid != null) {
74 | touchCoordinator.onGridTouched(gridView)
75 | when (motionEvent.actionMasked) {
76 | MotionEvent.ACTION_DOWN -> {
77 | //Figure out where the touch happened and if this is to be an additive or subractive touch event
78 | var gridCoords = gridView.getGridCoords(motionEvent.x, motionEvent.y)
79 | if (gridCoordsValid(grid, gridCoords)) {
80 | touchCoords = gridCoords
81 | touchModeIsAdd = !gridCoordsFilled(grid, gridCoords)
82 | if (touchModeIsAdd) {
83 | addCoords(grid, gridCoords)
84 | } else {
85 | subtractCoords(grid, gridCoords)
86 | }
87 | }
88 | }
89 | MotionEvent.ACTION_UP -> {
90 | touchCoords = null
91 | }
92 | MotionEvent.ACTION_CANCEL -> {
93 | touchCoords = null
94 | }
95 | MotionEvent.ACTION_MOVE -> {
96 | //If we've moved, we either add or subtract depending on the down event
97 | var gridCoords = gridView.getGridCoords(motionEvent.x, motionEvent.y)
98 | if (gridCoordsValid(grid, gridCoords)) {
99 | if (touchCoords == null) {
100 | touchCoords = gridCoords
101 | touchModeIsAdd = !gridCoordsFilled(grid, gridCoords)
102 | }
103 | if (touchModeIsAdd) {
104 | addCoords(grid, gridCoords)
105 | } else {
106 | subtractCoords(grid, gridCoords)
107 | }
108 | }
109 | }
110 | }
111 | return true
112 | }
113 | }
114 | return false
115 | }
116 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/helpers/GameGridHelper.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.helpers
2 |
3 | import com.hotpodata.blocklib.Grid
4 | import com.hotpodata.blocklib.GridHelper
5 | import timber.log.Timber
6 | import java.util.*
7 |
8 | /**
9 | * Created by jdrotos on 1/21/16.
10 | */
11 | object GameGridHelper {
12 |
13 | var random = Random()
14 |
15 | /**
16 | * Build a base grid for a playable block given the level
17 | */
18 | fun genGridForLevel(lvl: Int): Grid {
19 | if (lvl <= 0) {
20 | return GameGridHelper.genFullGrid(1, 1, true)
21 | } else {
22 | return genFullGrid(GameHelper.gridBreadthForLevel(lvl), GameHelper.gridDepthForLevel(lvl), true)
23 | }
24 | }
25 |
26 | /**
27 | * Build a blockelganger block for the given level
28 | */
29 | fun genGangerForLevel(lvl: Int): Grid {
30 | if (lvl <= 0) {
31 | return GameGridHelper.genFullGrid(1, 1, true)
32 | } else {
33 | return when (GameHelper.chapterForLevel(lvl)) {
34 | GameHelper.Chapter.FOUR -> {
35 | var top = GameGridHelper.generateOpenTopGangerGrid(GameHelper.gangerBreadthForLevel(lvl), GameHelper.gridDepthForLevel(lvl), true)
36 | var btm = GameGridHelper.generateOpenBottomGangerGrid(GameHelper.gangerBreadthForLevel(lvl), GameHelper.gridDepthForLevel(lvl), true)
37 | btm = GridHelper.copyGridPortion(btm, 0, 1, btm.width, btm.height)
38 | GameGridHelper.combineShapesVert(top, btm)
39 | }
40 | GameHelper.Chapter.THREE -> {
41 | return generateOpenTopGangerGrid(GameHelper.gangerBreadthForLevel(lvl), GameHelper.gangerDepthForLevel(lvl), true).rotate(false)
42 | }
43 | GameHelper.Chapter.TWO -> {
44 | var tHeight = GameHelper.gangerDepthForLevel(lvl) / 2 + 1
45 | var bHeight = GameHelper.gangerDepthForLevel(lvl) / 2 + 1
46 | var top = generateOpenTopGangerGrid(GameHelper.gangerBreadthForLevel(lvl), tHeight, true)
47 | var btm = generateOpenBottomGangerGrid(GameHelper.gangerBreadthForLevel(lvl), bHeight, true)
48 | btm = GridHelper.copyGridPortion(btm, 0, 1, btm.width, btm.height)
49 | combineShapesVert(top, btm)
50 | }
51 | GameHelper.Chapter.ONE -> {
52 | return generateOpenTopGangerGrid(GameHelper.gangerBreadthForLevel(lvl), GameHelper.gangerDepthForLevel(lvl), true)
53 | }
54 | }
55 | }
56 | }
57 |
58 | fun genGangerTwoForLevel(lvl: Int, gangerOneGrid: Grid): Grid {
59 | if (GameHelper.chapterForLevel(lvl) == GameHelper.Chapter.FOUR) {
60 | var workingGangerGridTwo = GameGridHelper.generateOpenTopGangerGrid(gangerOneGrid.height + 2, gangerOneGrid.width / 2, true).rotate(false)
61 | for (i in workingGangerGridTwo.width downTo 1) {
62 | GridHelper.subtractGrid(workingGangerGridTwo, gangerOneGrid, i, (workingGangerGridTwo.height - gangerOneGrid.height) / 2)
63 | }
64 | return workingGangerGridTwo
65 | } else {
66 | return Grid(1, 1)
67 | }
68 | }
69 |
70 |
71 | /**
72 | * Generate a new grid of specified size filled with fillData
73 | */
74 | fun genFullGrid(width: Int, height: Int, fillData: Any?): Grid {
75 | var grid = Grid(width, height)
76 | for (i in 0..width - 1) {
77 | for (j in 0..height - 1) {
78 | grid.put(i, j, fillData)
79 | }
80 | }
81 | return grid
82 | }
83 |
84 | /**
85 | * Generate a jagged grid where the contours are on top
86 | */
87 | fun generateOpenTopGangerGrid(width: Int, height: Int, filledVal: Any?): Grid {
88 | var grid = Grid(width, height)
89 | while ((width > 1 && grid.rowFull(0)) || grid.rowEmpty(0)) {
90 | for (i in grid.slots.indices) {
91 | val dip = random.nextInt(grid.slots[i].size)
92 | Timber.d("Dip:" + dip)
93 | for (j in grid.slots[i].indices) {
94 | if (j >= dip ) {
95 | grid.put(i, j, filledVal)
96 | } else {
97 | grid.put(i, j, null)
98 | }
99 | }
100 | }
101 | }
102 | return grid
103 | }
104 |
105 | /**
106 | * Generate a jagged grid where the contours are on top
107 | */
108 | fun generateOpenBottomGangerGrid(width: Int, height: Int, filledVal: Any?): Grid {
109 | return generateOpenTopGangerGrid(width, height, filledVal).rotate(true).rotate(true)
110 | }
111 |
112 |
113 | /**
114 | * Use this function to smash together two grids into one
115 | */
116 | fun combineShapesVert(topG: Grid, btmG: Grid): Grid {
117 | var yOffset = 0
118 | var workingBoard = Grid(topG.width, topG.height + btmG.height)
119 | GridHelper.addGrid(workingBoard, topG, 0, 0)
120 | while (GridHelper.gridInBounds(workingBoard, btmG, 0, workingBoard.height - btmG.height - (yOffset + 1)) && !GridHelper.gridsCollide(workingBoard, btmG, 0, workingBoard.height - btmG.height - (yOffset + 1))) {
121 | yOffset++
122 | }
123 | GridHelper.addGrid(workingBoard, btmG, 0, workingBoard.height - btmG.height - yOffset)
124 |
125 | //This is the shape after the things have been smashed together
126 | var combinedShape = GridHelper.copyGridPortion(workingBoard, 0, 0, workingBoard.width, workingBoard.height - yOffset)
127 | return combinedShape
128 | }
129 |
130 | /**
131 | * Use this function to smash together two grids into one
132 | */
133 | fun combineShapesHoriz(leftG: Grid, rightG: Grid): Grid {
134 | var xOffset = 0
135 | var workingBoard = Grid(leftG.width + rightG.width, leftG.height)
136 | GridHelper.addGrid(workingBoard, leftG, 0, 0)
137 | while (GridHelper.gridInBounds(workingBoard, rightG, workingBoard.width - rightG.width - (xOffset + 1), 0) && !GridHelper.gridsCollide(workingBoard, rightG, workingBoard.width - rightG.width - (xOffset + 1), 0)) {
138 | xOffset++
139 | }
140 | GridHelper.addGrid(workingBoard, rightG, workingBoard.width - rightG.width - xOffset, 0)
141 | //This is the shape after the things have been smashed together
142 | var combinedShape = GridHelper.copyGridPortion(workingBoard, 0, 0, workingBoard.width - xOffset, workingBoard.height)
143 | return combinedShape
144 | }
145 |
146 |
147 | /**
148 | * This checks if a shape is solid.
149 | * When we smash our top and bottom grid together our shape should be solid, so gameover if not solid.
150 | */
151 | fun combinedShapeIsGameOver(grid: Grid): Boolean {
152 | var gameOver = false
153 | for (i in 0..grid.width - 1) {
154 | if (!grid.colFull(i)) {
155 | gameOver = true
156 | break
157 | }
158 | }
159 | return gameOver
160 | }
161 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/utils/BaseGameUtils.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.utils
2 |
3 |
4 | import android.app.Activity
5 | import android.app.AlertDialog
6 | import android.app.Dialog
7 | import android.content.IntentSender
8 | import android.util.Log
9 |
10 | import com.google.android.gms.common.ConnectionResult
11 | import com.google.android.gms.common.GooglePlayServicesUtil
12 | import com.google.android.gms.common.api.GoogleApiClient
13 | import com.google.android.gms.games.GamesActivityResultCodes
14 | import com.hotpodata.blockelganger.R
15 |
16 | object BaseGameUtils {
17 |
18 | /**
19 | * Show an [android.app.AlertDialog] with an 'OK' button and a message.
20 |
21 | * @param activity the Activity in which the Dialog should be displayed.
22 | * *
23 | * @param message the message to display in the Dialog.
24 | */
25 | fun showAlert(activity: Activity, message: String) {
26 | AlertDialog.Builder(activity).setMessage(message).setNeutralButton(android.R.string.ok, null).create().show()
27 | }
28 |
29 | /**
30 | * Resolve a connection failure from
31 | * [com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener.onConnectionFailed]
32 |
33 | * @param activity the Activity trying to resolve the connection failure.
34 | * *
35 | * @param client the GoogleAPIClient instance of the Activity.
36 | * *
37 | * @param result the ConnectionResult received by the Activity.
38 | * *
39 | * @param requestCode a request code which the calling Activity can use to identify the result
40 | * * of this resolution in onActivityResult.
41 | * *
42 | * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
43 | * *
44 | * @return true if the connection failure is resolved, false otherwise.
45 | */
46 | fun resolveConnectionFailure(activity: Activity,
47 | client: GoogleApiClient?, result: ConnectionResult?, requestCode: Int,
48 | fallbackErrorMessage: String): Boolean {
49 |
50 | if (result?.hasResolution() ?: false) {
51 | try {
52 | result?.startResolutionForResult(activity, requestCode)
53 | return true
54 | } catch (e: IntentSender.SendIntentException) {
55 | // The intent was canceled before it was sent. Return to the default
56 | // state and attempt to connect to get an updated ConnectionResult.
57 | client?.connect()
58 | return false
59 | }
60 |
61 | } else {
62 | // not resolvable... so show an error message
63 | val errorCode = result?.errorCode ?: 1
64 | val dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
65 | activity, requestCode)
66 | if (dialog != null) {
67 | dialog.show()
68 | } else {
69 | // no built-in dialog: show the fallback error message
70 | showAlert(activity, fallbackErrorMessage)
71 | }
72 | return false
73 | }
74 | }
75 |
76 | /**
77 | * For use in sample code only. Checks if the sample was set up correctly,
78 | * including changing the package name to a non-Google package name and
79 | * replacing the placeholder IDs. Shows alert dialogs to notify about problems.
80 | * DO NOT call this method from a production app, it's meant only for samples!
81 |
82 | * @param resIds the resource IDs to check for placeholders
83 | * *
84 | * @return true if sample is set up correctly; false otherwise.
85 | */
86 | fun verifySampleSetup(activity: Activity, vararg resIds: Int): Boolean {
87 | val problems = StringBuilder()
88 | var problemFound = false
89 | problems.append("The following set up problems were found:\n\n")
90 |
91 | // Did the developer forget to change the package name?
92 | if (activity.packageName.startsWith("com.google.example.games")) {
93 | problemFound = true
94 | problems.append("- Package name cannot be com.google.*. You need to change the " + "sample's package name to your own package.").append("\n")
95 | }
96 |
97 | for (i in resIds) {
98 | if (activity.getString(i).toLowerCase().contains("replaceme")) {
99 | problemFound = true
100 | problems.append("- You must replace all " + "placeholder IDs in the ids.xml file by your project's IDs.").append("\n")
101 | break
102 | }
103 | }
104 |
105 | if (problemFound) {
106 | problems.append("\n\nThese problems may prevent the app from working properly.")
107 | showAlert(activity, problems.toString())
108 | return false
109 | }
110 |
111 | return true
112 | }
113 |
114 | /**
115 | * Show a [android.app.Dialog] with the correct message for a connection error.
116 |
117 | * @param activity the Activity in which the Dialog should be displayed.
118 | * *
119 | * @param requestCode the request code from onActivityResult.
120 | * *
121 | * @param actResp the response code from onActivityResult.
122 | * *
123 | * @param errorDescription the resource id of a String for a generic error message.
124 | */
125 | fun showActivityResultError(activity: Activity?, requestCode: Int, actResp: Int, errorDescription: Int) {
126 | if (activity == null) {
127 | Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!")
128 | return
129 | }
130 | var errorDialog: Dialog?
131 |
132 | when (actResp) {
133 | GamesActivityResultCodes.RESULT_APP_MISCONFIGURED -> errorDialog = makeSimpleDialog(activity,
134 | activity.getString(R.string.app_misconfigured))
135 | GamesActivityResultCodes.RESULT_SIGN_IN_FAILED -> errorDialog = makeSimpleDialog(activity,
136 | activity.getString(R.string.sign_in_failed))
137 | GamesActivityResultCodes.RESULT_LICENSE_FAILED -> errorDialog = makeSimpleDialog(activity,
138 | activity.getString(R.string.license_failed))
139 | else -> {
140 | // No meaningful Activity response code, so generate default Google
141 | // Play services dialog
142 | val errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity)
143 | errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
144 | activity, requestCode, null)
145 | if (errorDialog == null) {
146 | // get fallback dialog
147 | Log.e("BaseGamesUtils",
148 | "No standard error dialog available. Making fallback dialog.")
149 | errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription))
150 | }
151 | }
152 | }
153 |
154 | errorDialog.show()
155 | }
156 |
157 | /**
158 | * Create a simple [Dialog] with an 'OK' button and a message.
159 |
160 | * @param activity the Activity in which the Dialog should be displayed.
161 | * *
162 | * @param text the message to display on the Dialog.
163 | * *
164 | * @return an instance of [android.app.AlertDialog]
165 | */
166 | fun makeSimpleDialog(activity: Activity, text: String): Dialog {
167 | return AlertDialog.Builder(activity).setMessage(text).setNeutralButton(android.R.string.ok, null).create()
168 | }
169 |
170 | /**
171 | * Create a simple [Dialog] with an 'OK' button, a title, and a message.
172 |
173 | * @param activity the Activity in which the Dialog should be displayed.
174 | * *
175 | * @param title the title to display on the dialog.
176 | * *
177 | * @param text the message to display on the Dialog.
178 | * *
179 | * @return an instance of [android.app.AlertDialog]
180 | */
181 | fun makeSimpleDialog(activity: Activity, title: String, text: String): Dialog {
182 | return AlertDialog.Builder(activity).setTitle(title).setMessage(text).setNeutralButton(android.R.string.ok, null).create()
183 | }
184 |
185 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/activity/GameActivity.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.activity
2 |
3 | import android.content.Intent
4 | import android.content.res.Configuration
5 | import android.os.Bundle
6 | import android.support.v7.app.ActionBarDrawerToggle
7 | import android.support.v7.widget.LinearLayoutManager
8 | import android.support.v7.widget.RecyclerView
9 | import android.view.MenuItem
10 | import android.view.View
11 | import android.view.animation.DecelerateInterpolator
12 | import android.widget.Toast
13 | import com.google.android.gms.analytics.HitBuilders
14 | import com.google.android.gms.common.ConnectionResult
15 | import com.google.android.gms.common.api.GoogleApiClient
16 | import com.google.android.gms.games.Games
17 | import com.hotpodata.blockelganger.AnalyticsMaster
18 | import com.hotpodata.blockelganger.R
19 | import com.hotpodata.blockelganger.SettingsMaster
20 | import com.hotpodata.blockelganger.adapter.BlockelgangerSideBarAdapter
21 | import com.hotpodata.blockelganger.adapter.StartupAdapter
22 | import com.hotpodata.blockelganger.fragment.DialogHowToPlayFragment
23 | import com.hotpodata.blockelganger.fragment.DialogUpdateFragment
24 | import com.hotpodata.blockelganger.interfaces.IGooglePlayGameServicesProvider
25 | import com.hotpodata.blockelganger.utils.BaseGameUtils
26 | import com.hotpodata.common.activity.ChameleonActivity
27 | import com.hotpodata.common.view.SizeAwareFrameLayout
28 | import kotlinx.android.synthetic.main.activity_game.*
29 | import timber.log.Timber
30 |
31 | class GameActivity : ChameleonActivity(), GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, IGooglePlayGameServicesProvider {
32 |
33 | val REQUEST_LEADERBOARD = 1
34 | val REQUEST_ACHIEVEMENTS = 2
35 | val RC_SIGN_IN = 9001
36 |
37 |
38 | val FTAG_HOW_TO_PLAY = "FTAG_HOW_TO_PLAY"
39 | val FTAG_UPDATES = "FTAG_UPDATES"
40 |
41 | var sideBarAdapter: BlockelgangerSideBarAdapter? = null
42 | var startupAdapter: StartupAdapter? = null
43 | var drawerToggle: ActionBarDrawerToggle? = null
44 |
45 | //Sign in stuff
46 | var resolvingConnectionFailure = false
47 | var signInClicked = false;
48 | var _googleApiClient: GoogleApiClient? = null
49 | val googleApiClient: GoogleApiClient
50 | get() {
51 | if (_googleApiClient == null) {
52 | _googleApiClient = GoogleApiClient.Builder(this)
53 | .addConnectionCallbacks(this)
54 | .addOnConnectionFailedListener(this)
55 | .addApi(Games.API)
56 | .addScope(Games.SCOPE_GAMES)
57 | .build();
58 | }
59 | return _googleApiClient!!
60 | }
61 |
62 |
63 | override fun onCreate(savedInstanceState: Bundle?) {
64 | super.onCreate(savedInstanceState)
65 | setContentView(R.layout.activity_game)
66 |
67 | drawerToggle = object : ActionBarDrawerToggle(this, drawer_layout, R.string.drawer_open, R.string.drawer_closed) {
68 | override fun onDrawerOpened(drawerView: View?) {
69 | try {
70 | AnalyticsMaster.getTracker(this@GameActivity).send(HitBuilders.EventBuilder()
71 | .setCategory(AnalyticsMaster.CATEGORY_ACTION)
72 | .setAction(AnalyticsMaster.ACTION_OPEN_DRAWER)
73 | .build());
74 | } catch(ex: Exception) {
75 | Timber.e(ex, "Analytics Exception");
76 | }
77 | }
78 |
79 | override fun onDrawerClosed(drawerView: View?) {
80 | }
81 | }
82 | drawer_layout.setDrawerListener(drawerToggle)
83 | sidebar_drawer_btn.setOnClickListener {
84 | if (drawer_layout.isDrawerOpen(left_drawer)) {
85 | drawer_layout.closeDrawer(left_drawer)
86 | } else {
87 | drawer_layout.openDrawer(left_drawer)
88 | }
89 | }
90 |
91 | setUpLeftDrawer()
92 | setUpStartUpAdapter()
93 |
94 | body_container.sizeChangeListener = object : SizeAwareFrameLayout.ISizeChangeListener {
95 | override fun onSizeChange(w: Int, h: Int, oldw: Int, oldh: Int) {
96 | if (h != oldh) {
97 | startupAdapter?.spacerHeight = 2 * h / 3
98 | }
99 | }
100 | }
101 |
102 |
103 | start_options_recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
104 | var dyInterpolatr = DecelerateInterpolator()
105 | override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
106 | super.onScrolled(recyclerView, dx, dy)
107 | //man_in_mirror.scaleX = (man_in_mirror.scaleX + )
108 | var scaleChange = dy / (body_container.height / 2f)
109 | man_in_mirror.scaleY = Math.max(1f, Math.min(1.2f, man_in_mirror.scaleY + scaleChange))
110 | man_in_mirror.scaleX = Math.max(1f, Math.min(1.2f, man_in_mirror.scaleX + scaleChange))
111 | man_in_mirror.translationY = (man_in_mirror.translationY - dy / 2f)
112 | }
113 |
114 | override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
115 | super.onScrollStateChanged(recyclerView, newState)
116 | }
117 | })
118 |
119 | }
120 |
121 | override fun onPostCreate(savedInstanceState: Bundle?) {
122 | super.onPostCreate(savedInstanceState)
123 | // Sync the toggle state after onRestoreInstanceState has occurred.
124 | drawerToggle?.syncState()
125 | }
126 |
127 | override fun onStart() {
128 | super.onStart()
129 | if (SettingsMaster.autoStartSignInFlow) {
130 | googleApiClient.connect();
131 | }
132 | }
133 |
134 | override fun onResume() {
135 | super.onResume()
136 | AnalyticsMaster.getTracker(this).setScreenName(AnalyticsMaster.SCREEN_LANDING);
137 | AnalyticsMaster.getTracker(this).send(HitBuilders.ScreenViewBuilder().build());
138 | }
139 |
140 | override fun onPause() {
141 | super.onPause()
142 | }
143 |
144 | override fun onStop() {
145 | super.onStop()
146 | googleApiClient.disconnect()
147 | }
148 |
149 | override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
150 | super.onActivityResult(requestCode, resultCode, intent)
151 | if (requestCode == RC_SIGN_IN) {
152 | signInClicked = false;
153 | resolvingConnectionFailure = false;
154 | if (resultCode == RESULT_OK) {
155 | googleApiClient.connect();
156 | } else {
157 | BaseGameUtils.showActivityResultError(this,
158 | requestCode, resultCode, R.string.signin_error);
159 | }
160 | }
161 | }
162 |
163 | override fun onConfigurationChanged(newConfig: Configuration) {
164 | super.onConfigurationChanged(newConfig)
165 | drawerToggle?.onConfigurationChanged(newConfig)
166 | }
167 |
168 | override fun onBackPressed() {
169 | if (drawer_layout.isDrawerOpen(left_drawer) ?: false ) {
170 | drawer_layout.closeDrawers()
171 | } else {
172 | super.onBackPressed()
173 | }
174 | }
175 |
176 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
177 | return drawerToggle?.onOptionsItemSelected(item) ?: false
178 | }
179 |
180 |
181 | /**
182 | * Sets up the left drawer adapter and adds it to the recyclerview
183 | */
184 | fun setUpLeftDrawer() {
185 | if (sideBarAdapter == null) {
186 | sideBarAdapter = with(BlockelgangerSideBarAdapter(this, this)) {
187 | setAccentColor(android.support.v4.content.ContextCompat.getColor(this@GameActivity, R.color.colorPrimary))
188 | this
189 | }
190 | left_drawer.adapter = sideBarAdapter
191 | left_drawer.layoutManager = LinearLayoutManager(this)
192 | }
193 | }
194 |
195 | fun setUpStartUpAdapter() {
196 | if (startupAdapter == null) {
197 | startupAdapter = with(StartupAdapter(this)) {
198 | googleServicesProvider = this@GameActivity
199 | rebuildRowSet()
200 | this
201 | }
202 | start_options_recycler.adapter = startupAdapter
203 | start_options_recycler.layoutManager = LinearLayoutManager(this)
204 | }
205 | }
206 |
207 |
208 | fun showHowToPlayDialog() {
209 | var frag: DialogHowToPlayFragment? = supportFragmentManager.findFragmentByTag(FTAG_HOW_TO_PLAY) as DialogHowToPlayFragment?
210 | if (frag == null) {
211 | frag = DialogHowToPlayFragment()
212 | }
213 | if (!frag.isAdded) {
214 | frag.show(supportFragmentManager, FTAG_HOW_TO_PLAY)
215 | }
216 |
217 | try {
218 | AnalyticsMaster.getTracker(this).send(HitBuilders.EventBuilder()
219 | .setCategory(AnalyticsMaster.CATEGORY_ACTION)
220 | .setAction(AnalyticsMaster.ACTION_HELP)
221 | .build());
222 | } catch(ex: Exception) {
223 | Timber.e(ex, "Analytics Exception");
224 | }
225 | }
226 |
227 | fun showUpdatesDialog(backToVersion: Int) {
228 | var frag: DialogUpdateFragment? = supportFragmentManager.findFragmentByTag(FTAG_UPDATES) as DialogUpdateFragment?
229 | if (frag == null) {
230 | frag = DialogUpdateFragment(backToVersion)
231 | }
232 | if (!frag.isAdded) {
233 | frag.show(supportFragmentManager, FTAG_UPDATES)
234 | }
235 |
236 | try {
237 | AnalyticsMaster.getTracker(this).send(HitBuilders.EventBuilder()
238 | .setCategory(AnalyticsMaster.CATEGORY_ACTION)
239 | .setAction(AnalyticsMaster.ACTION_UPDATE_FRAG)
240 | .build());
241 | } catch(ex: Exception) {
242 | Timber.e(ex, "Analytics Exception");
243 | }
244 | }
245 |
246 |
247 | /**
248 | * IGoolgePlayGameServicesProvider
249 | */
250 |
251 | override fun isLoggedIn(): Boolean {
252 | return googleApiClient.isConnected
253 | }
254 |
255 | override fun login() {
256 | signInClicked = true
257 | SettingsMaster.autoStartSignInFlow = true
258 | googleApiClient.connect();
259 | try {
260 | AnalyticsMaster.getTracker(this@GameActivity).send(HitBuilders.EventBuilder()
261 | .setCategory(AnalyticsMaster.CATEGORY_ACTION)
262 | .setAction(AnalyticsMaster.ACTION_SIGN_IN)
263 | .setLabel(AnalyticsMaster.LABEL_LAUNCH_COUNT)
264 | .setValue(SettingsMaster.launchCount.toLong())
265 | .build());
266 | } catch(ex: Exception) {
267 | Timber.e(ex, "Analytics Exception");
268 | }
269 | }
270 |
271 | override fun logout() {
272 | signInClicked = false
273 | SettingsMaster.autoStartSignInFlow = false
274 | if (isLoggedIn()) {
275 | Games.signOut(googleApiClient)
276 | googleApiClient.disconnect()
277 | sideBarAdapter?.rebuildRowSet()
278 | }
279 | }
280 |
281 | override fun showLeaderBoard() {
282 | if (isLoggedIn()) {
283 | startActivityForResult(Games.Leaderboards.getLeaderboardIntent(googleApiClient,
284 | getString(R.string.leaderboard_scores)), REQUEST_LEADERBOARD);
285 | } else {
286 | Toast.makeText(this, R.string.you_must_be_signed_in, Toast.LENGTH_SHORT).show()
287 | }
288 | try {
289 | AnalyticsMaster.getTracker(this@GameActivity).send(HitBuilders.EventBuilder()
290 | .setCategory(AnalyticsMaster.CATEGORY_ACTION)
291 | .setAction(AnalyticsMaster.ACTION_LEADERBOARD)
292 | .setLabel(AnalyticsMaster.LABEL_LAUNCH_COUNT)
293 | .setValue(SettingsMaster.launchCount.toLong())
294 | .build());
295 | } catch(ex: Exception) {
296 | Timber.e(ex, "Analytics Exception");
297 | }
298 | }
299 |
300 | override fun showAchievements() {
301 | if (isLoggedIn()) {
302 | startActivityForResult(Games.Achievements.getAchievementsIntent(googleApiClient),
303 | REQUEST_ACHIEVEMENTS);
304 | } else {
305 | Toast.makeText(this, R.string.you_must_be_signed_in, Toast.LENGTH_SHORT).show()
306 | }
307 | try {
308 | AnalyticsMaster.getTracker(this@GameActivity).send(HitBuilders.EventBuilder()
309 | .setCategory(AnalyticsMaster.CATEGORY_ACTION)
310 | .setAction(AnalyticsMaster.ACTION_ACHIEVEMENTS)
311 | .setLabel(AnalyticsMaster.LABEL_LAUNCH_COUNT)
312 | .setValue(SettingsMaster.launchCount.toLong())
313 | .build());
314 | } catch(ex: Exception) {
315 | Timber.e(ex, "Analytics Exception");
316 | }
317 | }
318 |
319 |
320 | /**
321 | * SIGN IN STUFF
322 | */
323 |
324 | override fun onConnected(connectionHint: Bundle?) {
325 | Timber.d("SignIn - onConnected")
326 | sideBarAdapter?.rebuildRowSet()
327 | }
328 |
329 | override fun onConnectionSuspended(p0: Int) {
330 | Timber.d("SignIn - onConnectionSuspended")
331 | googleApiClient.connect()
332 | }
333 |
334 | override fun onConnectionFailed(result: ConnectionResult?) {
335 | Timber.d("SignIn - onConnectionFailed")
336 | if (resolvingConnectionFailure) {
337 | // already resolving
338 | return
339 | }
340 |
341 | // if the sign-in button was clicked or if auto sign-in is enabled,
342 | // launch the sign-in flow
343 | if (signInClicked || SettingsMaster.autoStartSignInFlow) {
344 | SettingsMaster.autoStartSignInFlow = false
345 | signInClicked = false
346 | resolvingConnectionFailure = true
347 |
348 | // Attempt to resolve the connection failure using BaseGameUtils.
349 | // The R.string.signin_other_error value should reference a generic
350 | // error string in your strings.xml file, such as "There was
351 | // an issue with sign-in, please try again later."
352 | if (!BaseGameUtils.resolveConnectionFailure(this,
353 | googleApiClient, result,
354 | RC_SIGN_IN, getString(R.string.sign_in_failed))) {
355 | resolvingConnectionFailure = false
356 | }
357 | }
358 | }
359 |
360 |
361 | }
362 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_single_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
20 |
21 |
25 |
26 |
33 |
34 |
42 |
43 |
51 |
52 |
60 |
61 |
69 |
70 |
71 |
78 |
79 |
86 |
87 |
98 |
99 |
109 |
110 |
111 |
112 |
113 |
126 |
127 |
140 |
141 |
142 |
143 |
147 |
148 |
153 |
154 |
159 |
160 |
164 |
165 |
173 |
174 |
175 |
176 |
181 |
182 |
187 |
188 |
196 |
197 |
213 |
214 |
226 |
227 |
228 |
229 |
230 |
231 |
239 |
240 |
247 |
248 |
254 |
255 |
265 |
266 |
267 |
268 |
274 |
275 |
286 |
287 |
288 |
299 |
300 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
328 |
329 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hotpodata/blockelganger/view/BlockelgangerGameBoard.kt:
--------------------------------------------------------------------------------
1 | package com.hotpodata.blockelganger.view
2 |
3 | import android.animation.Animator
4 | import android.animation.AnimatorListenerAdapter
5 | import android.animation.AnimatorSet
6 | import android.animation.ObjectAnimator
7 | import android.annotation.TargetApi
8 | import android.content.Context
9 | import android.graphics.PorterDuff
10 | import android.graphics.RectF
11 | import android.os.Build
12 | import android.util.AttributeSet
13 | import android.view.Gravity
14 | import android.view.LayoutInflater
15 | import android.view.View
16 | import android.view.ViewGroup
17 | import android.view.animation.AccelerateInterpolator
18 | import android.view.animation.DecelerateInterpolator
19 | import android.view.animation.OvershootInterpolator
20 | import android.widget.FrameLayout
21 | import com.hotpodata.blockelganger.BuildConfig
22 | import com.hotpodata.blockelganger.R
23 | import com.hotpodata.blockelganger.helpers.ColorBlockDrawer
24 | import com.hotpodata.blockelganger.helpers.GameGridHelper
25 | import com.hotpodata.blockelganger.helpers.GameHelper
26 | import com.hotpodata.blockelganger.helpers.GridTouchListener
27 | import com.hotpodata.blocklib.Grid
28 | import com.hotpodata.blocklib.GridHelper
29 | import com.hotpodata.blocklib.view.GridBinderView
30 | import com.hotpodata.common.view.SizeAwareFrameLayout
31 | import kotlinx.android.synthetic.main.blockelganger_game_board.view.*
32 | import timber.log.Timber
33 | import java.util.*
34 |
35 | /**
36 | * Created by jdrotos on 1/29/16.
37 | *
38 | * This is the class that manages positioning and sizing the various grids.
39 | * It also handles animating between board states
40 | *
41 | */
42 | class BlockelgangerGameBoard : SizeAwareFrameLayout, GridTouchListener.ITouchCoordinator {
43 |
44 | interface IGangerTouchListener {
45 | fun onGangerTouched()
46 | }
47 |
48 | var gridOne = GameGridHelper.genFullGrid(1, 1, true)
49 | set(grd: Grid) {
50 | field = grd
51 | gridbinderview_one.grid = grd
52 | }
53 |
54 | var gridTwo = GameGridHelper.genFullGrid(1, 1, true)
55 | set(grd: Grid) {
56 | field = grd
57 | gridbinderview_two.grid = grd
58 | }
59 |
60 | var gangerOneGrid = GameGridHelper.genFullGrid(1, 1, true)
61 | set(grd: Grid) {
62 | field = grd
63 | gridbinderview_blockelganger_one.grid = grd
64 | }
65 |
66 | var gangerTwoGrid = GameGridHelper.genFullGrid(1, 1, true)
67 | set(grd: Grid) {
68 | field = grd
69 | gridbinderview_blockelganger_two.grid = grd
70 | }
71 |
72 | private var chapter: GameHelper.Chapter = GameHelper.Chapter.ONE
73 | var touchHintAnims = HashMap()
74 |
75 | var parentTouchCoordinator: GridTouchListener.ITouchCoordinator? = null
76 | var gangerTouchListener: IGangerTouchListener? = null
77 |
78 | constructor(context: Context) : super(context) {
79 | init(context)
80 | }
81 |
82 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
83 | init(context)
84 | }
85 |
86 | constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
87 | init(context)
88 | }
89 |
90 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
91 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
92 | init(context)
93 | }
94 |
95 | fun init(context: Context) {
96 | var inflater = LayoutInflater.from(context)
97 | inflater.inflate(R.layout.blockelganger_game_board, this, true);
98 |
99 | gridbinderview_one.blockDrawer = ColorBlockDrawer(resources.getColor(R.color.top_grid))
100 | gridbinderview_two.blockDrawer = ColorBlockDrawer(resources.getColor(R.color.btm_grid))
101 | gridbinderview_animation_coordinator.blockDrawer = ColorBlockDrawer(resources.getColor(R.color.ganger_grid))
102 | gridbinderview_blockelganger_one.blockDrawer = ColorBlockDrawer(resources.getColor(R.color.ganger_grid))
103 | gridbinderview_blockelganger_two.blockDrawer = ColorBlockDrawer(resources.getColor(R.color.ganger_grid))
104 |
105 | gridbinderview_one.setOnTouchListener(GridTouchListener(this, object : GridTouchListener.IGridChangedListener {
106 | override fun onGridChanged(grid: Grid) {
107 | gridOne = grid
108 | }
109 | }))
110 | gridbinderview_two.setOnTouchListener(GridTouchListener(this, object : GridTouchListener.IGridChangedListener {
111 | override fun onGridChanged(grid: Grid) {
112 | gridTwo = grid
113 | }
114 | }))
115 |
116 | gridbinderview_blockelganger_one.setOnClickListener {
117 | gangerTouchListener?.onGangerTouched()
118 | }
119 | gridbinderview_blockelganger_two.setOnClickListener {
120 | gangerTouchListener?.onGangerTouched()
121 | }
122 | }
123 |
124 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
125 | super.onSizeChanged(w, h, oldw, oldh)
126 | prepareGridViews()
127 | }
128 |
129 | /**
130 | * GridTouchListener.ITouchCoordinator
131 | */
132 | override fun onGridTouched(view: View) {
133 | if (view == gridbinderview_one) {
134 | if (chapter == GameHelper.Chapter.THREE) {
135 | setTouchHintShowing(touch_hint_right, false)
136 | } else {
137 | setTouchHintShowing(touch_hint_top, false)
138 | }
139 | }
140 | if (view == gridbinderview_two) {
141 | setTouchHintShowing(touch_hint_btm, false)
142 | }
143 |
144 | parentTouchCoordinator?.onGridTouched(view)
145 | }
146 |
147 | override fun allowGridTouch(view: View): Boolean {
148 | return parentTouchCoordinator?.allowGridTouch(view) ?: false
149 | }
150 |
151 | /**
152 | * SET DATA FOR A GIVEN CHAPTER
153 | */
154 |
155 | fun chapterOne(playerGrid: Grid, gangerGrid: Grid) {
156 | chapter = GameHelper.Chapter.ONE
157 | gridOne = playerGrid
158 | gridTwo = Grid(1, 1)
159 | gangerOneGrid = gangerGrid
160 | gangerTwoGrid = Grid(1, 1)
161 | prepareGridViews()
162 | }
163 |
164 | fun chapterTwo(playerGridTop: Grid, playerGridBtm: Grid, gangerGrid: Grid) {
165 | chapter = GameHelper.Chapter.TWO
166 | gridOne = playerGridTop
167 | gridTwo = playerGridBtm
168 | gangerOneGrid = gangerGrid
169 | gangerTwoGrid = Grid(1, 1)
170 | prepareGridViews()
171 | }
172 |
173 | fun chapterThree(playerGrid: Grid, gangerGrid: Grid) {
174 | chapter = GameHelper.Chapter.THREE
175 | gridOne = playerGrid
176 | gridTwo = Grid(1, 1)
177 | gangerOneGrid = gangerGrid
178 | gangerTwoGrid = Grid(1, 1)
179 | prepareGridViews()
180 | }
181 |
182 | fun chapterFour(playerGridTop: Grid, playerGridBtm: Grid, gangerGridCenter: Grid, gangerGridLeft: Grid) {
183 | chapter = GameHelper.Chapter.FOUR
184 | gridOne = playerGridTop
185 | gridTwo = playerGridBtm
186 | gangerOneGrid = gangerGridCenter
187 | gangerTwoGrid = gangerGridLeft
188 | prepareGridViews()
189 | }
190 |
191 | /**
192 | *
193 | */
194 | fun setAccentColor(color: Int) {
195 | touch_hint_top.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
196 | touch_hint_btm.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
197 | touch_hint_right.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
198 | }
199 |
200 | fun findPositionInGridBinder(outerGrid: Grid, targetGrid: Grid, gridBinderView: GridBinderView): RectF? {
201 | return GridHelper.findInGrid(outerGrid, targetGrid)?.let {
202 | var vPadding = GridHelper.numEmptyRowsTopBtm(targetGrid)
203 | var hPadding = GridHelper.numEmptyColsLeftRight(targetGrid)
204 | var xOffset = it.left - hPadding.first
205 | var yOffset = it.top - vPadding.first
206 | gridBinderView.getSubGridPosition(targetGrid, xOffset, yOffset)
207 | }
208 | }
209 |
210 | fun genBoardsCollideAnim(combined: Grid): Animator {
211 | var animMoves = AnimatorSet()
212 | var coordinatorGrid = when (chapter) {
213 | GameHelper.Chapter.FOUR -> Grid(gangerOneGrid.width + gangerTwoGrid.width, gridOne.height + gridTwo.height + gangerOneGrid.height)
214 | GameHelper.Chapter.THREE -> Grid(gangerOneGrid.width + gridOne.width, gangerOneGrid.height)
215 | GameHelper.Chapter.TWO -> Grid(gridOne.width, gridOne.height + gridTwo.height + gangerOneGrid.height)
216 | GameHelper.Chapter.ONE -> Grid(gridOne.width, gridOne.height + gangerOneGrid.height)
217 | }
218 |
219 | GridHelper.addGrid(coordinatorGrid, combined, (coordinatorGrid.width - combined.width) / 2, (coordinatorGrid.height - combined.height) / 2)
220 | gridbinderview_animation_coordinator.grid = coordinatorGrid
221 |
222 | if (BuildConfig.IS_DEBUG_BUILD) {
223 | var combPrintStr = coordinatorGrid.getPrintString(" - ", { x ->
224 | when (x) {
225 | gridOne -> " 1 "
226 | gridTwo -> " 2 "
227 | gangerOneGrid -> " A "
228 | gangerTwoGrid -> " B "
229 | else -> " ? "
230 | }
231 | })
232 | Timber.d("coordinatorGrid:\n" + combPrintStr)
233 | }
234 |
235 |
236 | var verticalAnimators = ArrayList()
237 | var horizontalAnimators = ArrayList()
238 | findPositionInGridBinder(coordinatorGrid, gridOne, gridbinderview_animation_coordinator)?.let {
239 | //it is now the coorinates for gridOne inside the coordinator
240 | var transX = gridbinderview_animation_coordinator.left + it.left - gridbinderview_one.left
241 | var transY = gridbinderview_animation_coordinator.top + it.top - gridbinderview_one.top
242 | if (transX != 0f) {
243 | horizontalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_one, "translationX", 0f, transX))
244 | }
245 | if (transY != 0f) {
246 | verticalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_one, "translationY", 0f, transY))
247 | }
248 | }
249 | findPositionInGridBinder(coordinatorGrid, gridTwo, gridbinderview_animation_coordinator)?.let {
250 | //it is now the coorinates for gridTwo inside the coordinator
251 | var transX = gridbinderview_animation_coordinator.left + it.left - gridbinderview_two.left
252 | var transY = gridbinderview_animation_coordinator.top + it.top - gridbinderview_two.top
253 | if (transX != 0f) {
254 | horizontalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_two, "translationX", 0f, transX))
255 | }
256 | if (transY != 0f) {
257 | verticalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_two, "translationY", 0f, transY))
258 | }
259 | }
260 | findPositionInGridBinder(coordinatorGrid, gangerOneGrid, gridbinderview_animation_coordinator)?.let {
261 | //it is now the coorinates for gangerOneGrid inside the coordinator
262 | var transX = gridbinderview_animation_coordinator.left + it.left - gridbinderview_blockelganger_one.left
263 | var transY = gridbinderview_animation_coordinator.top + it.top - gridbinderview_blockelganger_one.top
264 | if (transX != 0f) {
265 | horizontalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_blockelganger_one, "translationX", 0f, transX))
266 | }
267 | if (transY != 0f) {
268 | verticalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_blockelganger_one, "translationY", 0f, transY))
269 | }
270 | }
271 | findPositionInGridBinder(coordinatorGrid, gangerTwoGrid, gridbinderview_animation_coordinator)?.let {
272 | //it is now the coorinates for gangerTwoGrid inside the coordinator
273 | var transX = gridbinderview_animation_coordinator.left + it.left - gridbinderview_blockelganger_two.left
274 | var transY = gridbinderview_animation_coordinator.top + it.top - gridbinderview_blockelganger_two.top
275 | if (transX != 0f) {
276 | horizontalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_blockelganger_two, "translationX", 0f, transX))
277 | }
278 | if (transY != 0f) {
279 | verticalAnimators.add(ObjectAnimator.ofFloat(gridbinderview_blockelganger_two, "translationY", 0f, transY))
280 | }
281 | }
282 |
283 | var vertAnim = AnimatorSet()
284 | vertAnim.playTogether(verticalAnimators)
285 | var horizAnim = AnimatorSet()
286 | horizAnim.playTogether(horizontalAnimators)
287 |
288 |
289 | if (verticalAnimators.size > 0 && horizontalAnimators.size > 0) {
290 | animMoves.playSequentially(vertAnim, horizAnim)
291 | } else {
292 | animMoves.playTogether(vertAnim, horizAnim)
293 | }
294 | animMoves.setDuration(350L)
295 | animMoves.interpolator = AccelerateInterpolator()
296 | animMoves.addListener(object : AnimatorListenerAdapter() {
297 | override fun onAnimationEnd(animation: Animator?) {
298 | gridbinderview_animation_coordinator.visibility = View.VISIBLE
299 | gridbinderview_one.visibility = View.INVISIBLE
300 | gridbinderview_two.visibility = View.INVISIBLE
301 | gridbinderview_blockelganger_one.visibility = View.INVISIBLE
302 | gridbinderview_blockelganger_two.visibility = View.INVISIBLE
303 | }
304 | })
305 | return animMoves
306 | }
307 |
308 | fun genBoardsShrinkAnim(): Animator {
309 | var endGameScale = if (chapter == GameHelper.Chapter.THREE || chapter == GameHelper.Chapter.FOUR) 0.25f else 0.5f
310 | var gameScaleX = ObjectAnimator.ofFloat(grid_container, "scaleX", 1f, endGameScale)
311 | var gameScaleY = ObjectAnimator.ofFloat(grid_container, "scaleY", 1f, endGameScale)
312 | var scaleDownBoardsAnim = AnimatorSet()
313 | scaleDownBoardsAnim.playTogether(gameScaleX, gameScaleY)
314 | scaleDownBoardsAnim.interpolator = AccelerateInterpolator()
315 | scaleDownBoardsAnim.setDuration(450)
316 | return scaleDownBoardsAnim
317 | }
318 |
319 | fun genBoardsHideAnim(): Animator {
320 | var endScale = 0.2f
321 | var gridsZoomX = ObjectAnimator.ofFloat(grid_container, "scaleX", grid_container.scaleX, endScale)
322 | var gridsZoomY = ObjectAnimator.ofFloat(grid_container, "scaleY", grid_container.scaleY, endScale)
323 | var gridsAlpha = ObjectAnimator.ofFloat(grid_container, "alpha", grid_container.alpha, 0f)
324 | var animGridsOut = AnimatorSet()
325 | animGridsOut.playTogether(gridsZoomX, gridsZoomY, gridsAlpha)
326 | animGridsOut.interpolator = AccelerateInterpolator()
327 | animGridsOut.setDuration(450)
328 | return animGridsOut
329 | }
330 |
331 | fun genBoardsEnterAnim(chap: GameHelper.Chapter): Animator {
332 | var animReenter = AnimatorSet()
333 | var gangerReturn = when (chap) {
334 | GameHelper.Chapter.ONE -> {
335 | var anim = ObjectAnimator.ofFloat(gridbinderview_blockelganger_one, "translationY", height - gridbinderview_blockelganger_one.top.toFloat(), 0f)
336 | anim.addListener(object : AnimatorListenerAdapter() {
337 | override fun onAnimationStart(animation: Animator?) {
338 | gridbinderview_blockelganger_one.translationX = 0f
339 | }
340 | })
341 | anim
342 | }
343 | GameHelper.Chapter.TWO -> {
344 | var anim = ObjectAnimator.ofFloat(gridbinderview_blockelganger_one, "translationX", width.toFloat(), 0f)
345 | anim.addListener(object : AnimatorListenerAdapter() {
346 | override fun onAnimationStart(animation: Animator?) {
347 | gridbinderview_blockelganger_one.translationY = 0f
348 | }
349 | })
350 | anim
351 | }
352 | GameHelper.Chapter.THREE -> {
353 | var anim = ObjectAnimator.ofFloat(gridbinderview_blockelganger_one, "translationY", height.toFloat(), 0f)
354 | anim.addListener(object : AnimatorListenerAdapter() {
355 | override fun onAnimationStart(animation: Animator?) {
356 | gridbinderview_blockelganger_one.translationX = 0f
357 | }
358 | })
359 | anim
360 | }
361 | GameHelper.Chapter.FOUR -> {
362 | var gangerOne = ObjectAnimator.ofFloat(gridbinderview_blockelganger_one, "translationX", width.toFloat(), 0f)
363 | var gangerTwo = ObjectAnimator.ofFloat(gridbinderview_blockelganger_two, "translationY", height.toFloat(), 0f)
364 | var anim = AnimatorSet()
365 | anim.playTogether(gangerOne, gangerTwo)
366 | anim.addListener(object : AnimatorListenerAdapter() {
367 | override fun onAnimationStart(animation: Animator?) {
368 | gridbinderview_blockelganger_one.translationY = 0f
369 | gridbinderview_blockelganger_two.translationX = 0f
370 | }
371 | })
372 | anim
373 | }
374 | }
375 |
376 | var playablePieceReturn = when (chapter) {
377 | GameHelper.Chapter.ONE -> {
378 | var anim = ObjectAnimator.ofFloat(gridbinderview_one, "translationY", -gridbinderview_one.bottom.toFloat(), 0f)
379 | anim.addListener(object : AnimatorListenerAdapter() {
380 | override fun onAnimationStart(animation: Animator?) {
381 | gridbinderview_one.translationX = 0f
382 | }
383 | })
384 | anim
385 | }
386 | GameHelper.Chapter.TWO -> {
387 | var topAnim = ObjectAnimator.ofFloat(gridbinderview_one, "translationY", -gridbinderview_one.bottom.toFloat(), 0f)
388 | var btmAnim = ObjectAnimator.ofFloat(gridbinderview_two, "translationY", height - gridbinderview_two.top.toFloat(), 0f)
389 | var anim = AnimatorSet()
390 | anim.playTogether(topAnim, btmAnim)
391 | anim.addListener(object : AnimatorListenerAdapter() {
392 | override fun onAnimationStart(animation: Animator?) {
393 | gridbinderview_one.translationX = 0f
394 | gridbinderview_two.translationX = 0f
395 | }
396 | })
397 | anim
398 | }
399 | GameHelper.Chapter.THREE -> {
400 | var anim = ObjectAnimator.ofFloat(gridbinderview_one, "translationY", -height.toFloat(), 0f)
401 | anim.addListener(object : AnimatorListenerAdapter() {
402 | override fun onAnimationStart(animation: Animator?) {
403 | gridbinderview_one.translationX = 0f
404 | }
405 | })
406 | anim
407 | }
408 | GameHelper.Chapter.FOUR -> {
409 | var topAnim = ObjectAnimator.ofFloat(gridbinderview_one, "translationY", -gridbinderview_one.bottom.toFloat(), 0f)
410 | var btmAnim = ObjectAnimator.ofFloat(gridbinderview_two, "translationY", height - gridbinderview_two.top.toFloat(), 0f)
411 | var anim = AnimatorSet()
412 | anim.playTogether(topAnim, btmAnim)
413 | anim.addListener(object : AnimatorListenerAdapter() {
414 | override fun onAnimationStart(animation: Animator?) {
415 | gridbinderview_one.translationX = 0f
416 | gridbinderview_two.translationX = 0f
417 | }
418 | })
419 | anim
420 | }
421 | }
422 |
423 | animReenter.playTogether(playablePieceReturn, gangerReturn)
424 | animReenter.interpolator = DecelerateInterpolator()
425 | animReenter.addListener(object : AnimatorListenerAdapter() {
426 | override fun onAnimationStart(animation: Animator?) {
427 | grid_container.scaleX = 1f
428 | grid_container.scaleY = 1f
429 | grid_container.alpha = 1f
430 | prepareGridViews()
431 | }
432 | })
433 | return animReenter
434 | }
435 |
436 |
437 | fun pauseAllTouchHintAnims() {
438 | for (anim in touchHintAnims.values) {
439 | anim.pause()
440 | }
441 | }
442 |
443 | fun resumePausedTouchHintAnims() {
444 | for (anim in touchHintAnims.values) {
445 | anim.resume()
446 | }
447 | }
448 |
449 | fun setTouchHintsShowing(showing: Boolean) {
450 | if (showing) {
451 | when (chapter) {
452 | GameHelper.Chapter.FOUR -> {
453 | setTouchHintShowing(touch_hint_top, true)
454 | setTouchHintShowing(touch_hint_btm, true)
455 | }
456 | GameHelper.Chapter.THREE -> {
457 | setTouchHintShowing(touch_hint_right, true)
458 | }
459 | GameHelper.Chapter.TWO -> {
460 | setTouchHintShowing(touch_hint_top, true)
461 | setTouchHintShowing(touch_hint_btm, true)
462 | }
463 | GameHelper.Chapter.ONE -> {
464 | setTouchHintShowing(touch_hint_top, true)
465 | }
466 | }
467 | } else {
468 | setTouchHintShowing(touch_hint_top, false)
469 | setTouchHintShowing(touch_hint_btm, false)
470 | setTouchHintShowing(touch_hint_right, false)
471 | }
472 | }
473 |
474 |
475 | private fun setTouchHintShowing(hintView: View, showing: Boolean, delay: Long = 0) {
476 | if (showing) {
477 | var wiggle = ObjectAnimator.ofFloat(hintView, "rotation", 0f, -5f, 0f, 5f, 0f)
478 | wiggle.addListener(object : AnimatorListenerAdapter() {
479 | override fun onAnimationStart(animation: Animator?) {
480 | hintView.visibility = View.VISIBLE
481 | }
482 |
483 | override fun onAnimationCancel(animation: Animator?) {
484 | hintView.visibility = View.INVISIBLE
485 | touchHintAnims.remove(hintView)
486 | }
487 |
488 | override fun onAnimationEnd(animation: Animator?) {
489 | if (touchHintAnims.containsKey(hintView)) {
490 | touchHintAnims.remove(hintView)
491 | setTouchHintShowing(hintView, true, 1000)
492 | }
493 | }
494 | })
495 | wiggle.interpolator = OvershootInterpolator()
496 | wiggle.setDuration(650)
497 | wiggle.startDelay = delay
498 | touchHintAnims.put(hintView, wiggle)
499 | wiggle.start()
500 | } else {
501 | touchHintAnims.get(hintView)?.cancel()
502 | touchHintAnims.remove(hintView)
503 | hintView.visibility = View.INVISIBLE
504 | }
505 | }
506 |
507 | fun resetAnimationChanges() {
508 | var views = ArrayList()
509 | views.add(grid_container)
510 | for (i in 0..grid_container.childCount - 1) {
511 | views.add(grid_container.getChildAt(i))
512 | }
513 | for (v in views) {
514 | v.translationX = 0f
515 | v.translationY = 0f
516 | v.scaleX = 1f
517 | v.scaleY = 1f
518 | v.alpha = 1f
519 | }
520 | }
521 |
522 | fun prepareGridViews() {
523 | gridbinderview_animation_coordinator.visibility = View.INVISIBLE
524 |
525 | //var thirdHeight = usableHeight / 3f
526 | var fifthHeight = height / 5f
527 | var thirdWidth = width / 3f
528 |
529 | when (chapter) {
530 | GameHelper.Chapter.ONE -> {
531 | (gridbinderview_one.layoutParams as? FrameLayout.LayoutParams)?.let {
532 | it.height = fifthHeight.toInt()
533 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
534 | it.gravity = Gravity.TOP
535 | gridbinderview_one.layoutParams = it
536 | touch_hint_top.layoutParams = FrameLayout.LayoutParams(it)
537 | }
538 |
539 | (gridbinderview_blockelganger_one.layoutParams as? FrameLayout.LayoutParams)?.let {
540 | it.height = fifthHeight.toInt()
541 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
542 | it.gravity = Gravity.BOTTOM
543 | gridbinderview_blockelganger_one.layoutParams = it
544 | }
545 |
546 | gridbinderview_animation_coordinator.layoutParams?.let {
547 | it.height = fifthHeight.toInt() * 2
548 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
549 | gridbinderview_animation_coordinator.layoutParams = it
550 | }
551 | gridbinderview_one.visibility = View.VISIBLE
552 | gridbinderview_two.visibility = View.INVISIBLE
553 | gridbinderview_blockelganger_one.visibility = View.VISIBLE
554 | gridbinderview_blockelganger_two.visibility = View.INVISIBLE
555 | }
556 | GameHelper.Chapter.TWO -> {
557 | (gridbinderview_one.layoutParams as? FrameLayout.LayoutParams)?.let {
558 | it.height = fifthHeight.toInt()
559 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
560 | it.gravity = Gravity.TOP
561 | gridbinderview_one.layoutParams = it
562 | touch_hint_top.layoutParams = FrameLayout.LayoutParams(it)
563 | }
564 | (gridbinderview_two.layoutParams as? FrameLayout.LayoutParams)?.let {
565 | it.height = fifthHeight.toInt()
566 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
567 | it.gravity = Gravity.BOTTOM
568 | gridbinderview_two.layoutParams = it
569 | touch_hint_btm.layoutParams = FrameLayout.LayoutParams(it)
570 | }
571 |
572 | var gangerHeight = (gridbinderview_one.getSubGridPosition(Grid(1, 1), 0, 0).height() * gangerOneGrid.height).toInt()
573 | (gridbinderview_blockelganger_one.layoutParams as? FrameLayout.LayoutParams)?.let {
574 | it.height = gangerHeight
575 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
576 | it.gravity = Gravity.CENTER_VERTICAL
577 | gridbinderview_blockelganger_one.layoutParams = it
578 | }
579 | gridbinderview_animation_coordinator.layoutParams?.let {
580 | it.height = fifthHeight.toInt() * 2 + gangerHeight
581 | it.width = ViewGroup.LayoutParams.MATCH_PARENT
582 | gridbinderview_animation_coordinator.layoutParams = it
583 | }
584 |
585 | gridbinderview_one.visibility = View.VISIBLE
586 | gridbinderview_two.visibility = View.VISIBLE
587 | gridbinderview_blockelganger_one.visibility = View.VISIBLE
588 | gridbinderview_blockelganger_two.visibility = View.INVISIBLE
589 | }
590 | GameHelper.Chapter.THREE -> {
591 | (gridbinderview_one.layoutParams as? FrameLayout.LayoutParams)?.let {
592 | it.height = ViewGroup.LayoutParams.MATCH_PARENT
593 | it.width = thirdWidth.toInt()
594 | it.gravity = Gravity.RIGHT
595 | gridbinderview_one.layoutParams = it
596 | touch_hint_right.layoutParams = FrameLayout.LayoutParams(it)
597 | }
598 |
599 | (gridbinderview_blockelganger_one.layoutParams as? FrameLayout.LayoutParams)?.let {
600 | it.height = ViewGroup.LayoutParams.MATCH_PARENT
601 | it.width = thirdWidth.toInt()
602 | it.gravity = Gravity.LEFT
603 | gridbinderview_blockelganger_one.layoutParams = it
604 | }
605 |
606 | gridbinderview_animation_coordinator.layoutParams?.let {
607 | it.height = ViewGroup.LayoutParams.MATCH_PARENT
608 | it.width = thirdWidth.toInt() * 2
609 | gridbinderview_animation_coordinator.layoutParams = it
610 | }
611 |
612 | gridbinderview_one.visibility = View.VISIBLE
613 | gridbinderview_two.visibility = View.INVISIBLE
614 | gridbinderview_blockelganger_one.visibility = View.VISIBLE
615 | gridbinderview_blockelganger_two.visibility = View.INVISIBLE
616 | }
617 | GameHelper.Chapter.FOUR -> {
618 | var totalBlocksW = gridOne.width + 2 + gangerTwoGrid.width
619 | var totalBlocksH = gridOne.height + 2 + gangerOneGrid.height + 2 + gridTwo.height
620 |
621 | var blockW = width / totalBlocksW.toFloat()
622 | var blockH = height / totalBlocksH.toFloat()
623 |
624 | (gridbinderview_one.layoutParams as? FrameLayout.LayoutParams)?.let {
625 | it.height = (gridOne.height * blockH).toInt()
626 | it.width = (gridOne.width * blockW).toInt()
627 | it.gravity = Gravity.TOP or Gravity.RIGHT
628 | gridbinderview_one.layoutParams = it
629 | touch_hint_top.layoutParams = FrameLayout.LayoutParams(it)
630 | }
631 |
632 | (gridbinderview_two.layoutParams as? FrameLayout.LayoutParams)?.let {
633 | it.height = (gridTwo.height * blockH).toInt()
634 | it.width = (gridTwo.width * blockW).toInt()
635 | it.gravity = Gravity.BOTTOM or Gravity.RIGHT
636 | gridbinderview_two.layoutParams = it
637 | touch_hint_btm.layoutParams = FrameLayout.LayoutParams(it)
638 | }
639 |
640 | (gridbinderview_blockelganger_one.layoutParams as? FrameLayout.LayoutParams)?.let {
641 | it.height = (gangerOneGrid.height * blockH).toInt()
642 | it.width = (gangerOneGrid.width * blockW).toInt()
643 | it.gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
644 | gridbinderview_blockelganger_one.layoutParams = it
645 | }
646 |
647 | (gridbinderview_blockelganger_two.layoutParams as? FrameLayout.LayoutParams)?.let {
648 | it.height = (gangerTwoGrid.height * blockH).toInt()
649 | it.width = (gangerTwoGrid.width * blockW).toInt()
650 | it.gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
651 | gridbinderview_blockelganger_two.layoutParams = it
652 | }
653 |
654 | //We set the layout to match the total of all of our gridviews, so it can fit all of them, and the grids should be the same measured size
655 | gridbinderview_animation_coordinator.layoutParams?.let {
656 | it.height = (gridOne.height + gridTwo.height + gangerOneGrid.height) * blockH.toInt()
657 | it.width = (gangerOneGrid.width + gangerTwoGrid.width) * blockW.toInt()
658 | gridbinderview_animation_coordinator.layoutParams = it
659 | }
660 |
661 | gridbinderview_one.visibility = View.VISIBLE
662 | gridbinderview_two.visibility = View.VISIBLE
663 | gridbinderview_blockelganger_one.visibility = View.VISIBLE
664 | gridbinderview_blockelganger_two.visibility = View.VISIBLE
665 | }
666 | }
667 | }
668 |
669 |
670 | fun combineGrids(): Grid {
671 | //We copy our grids and mask them so the cells point to the grids they represent
672 | var gridTop = GridHelper.maskGrid(gridOne, gridOne)
673 | var gridBtm = GridHelper.maskGrid(gridTwo, gridTwo)
674 | var gangCenter = GridHelper.maskGrid(gangerOneGrid, gangerOneGrid)
675 | var gangLeft = GridHelper.maskGrid(gangerTwoGrid, gangerTwoGrid)
676 |
677 | //Combine our grids
678 | var combined = when (chapter) {
679 | GameHelper.Chapter.ONE -> GameGridHelper.combineShapesVert(gridTop, gangCenter)
680 | GameHelper.Chapter.TWO -> {
681 | GameGridHelper.combineShapesVert(GameGridHelper.combineShapesVert(gridTop, gangCenter), gridBtm)
682 | }
683 | GameHelper.Chapter.THREE -> {
684 | GameGridHelper.combineShapesHoriz(gangCenter, gridTop)
685 | }
686 | GameHelper.Chapter.FOUR -> {
687 | //The left ganger's height is the center ganger's height + 2
688 | var gangerVertPadding = GridHelper.numEmptyRowsTopBtm(gangCenter)
689 | var gangerAndTop = GameGridHelper.combineShapesVert(gridTop, gangCenter)
690 | var gangerAndTopAndBtm = GameGridHelper.combineShapesVert(gangerAndTop, gridBtm)
691 |
692 | //Calculate the offset of the left ganger relative to the combined shape
693 | var leftGangerTopOffset = gangerAndTop.height - (gangCenter.height - gangerVertPadding.first - gangerVertPadding.second) - 1
694 |
695 | var gangerAndTopAndBtmAdjusted = Grid(gangerAndTopAndBtm.width, Math.max(gangerAndTopAndBtm.height, gangLeft.height) + Math.abs(leftGangerTopOffset))
696 | var leftGangerAdjusted = Grid(gangLeft.width, gangerAndTopAndBtmAdjusted.height)
697 |
698 | if (leftGangerTopOffset > 0) {
699 | GridHelper.addGrid(gangerAndTopAndBtmAdjusted, gangerAndTopAndBtm, 0, 0)
700 | GridHelper.addGrid(leftGangerAdjusted, gangLeft, 0, leftGangerTopOffset)
701 | } else if (leftGangerTopOffset < 0) {
702 | GridHelper.addGrid(gangerAndTopAndBtmAdjusted, gangerAndTopAndBtm, 0, Math.abs(leftGangerTopOffset))
703 | GridHelper.addGrid(leftGangerAdjusted, gangLeft, 0, 0)
704 | } else {
705 | GridHelper.addGrid(gangerAndTopAndBtmAdjusted, gangerAndTopAndBtm, 0, 0)
706 | GridHelper.addGrid(leftGangerAdjusted, gangLeft, 0, 0)
707 | }
708 | GameGridHelper.combineShapesHoriz(leftGangerAdjusted, gangerAndTopAndBtmAdjusted)
709 | }
710 | }
711 | combined = GridHelper.trim(combined)
712 | return combined
713 | }
714 |
715 | }
--------------------------------------------------------------------------------