diff --git a/CompleteApps/BombGame/README_zh.md b/CompleteApps/BombGame/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..bddfe64a752af0d53984465de8431fa661784f73 --- /dev/null +++ b/CompleteApps/BombGame/README_zh.md @@ -0,0 +1,41 @@ +# 传炸弹 + +##### 简介 + +​ 本示例基于Java开发,可拉起身边小伙伴手机中的游戏加入到对局之中,游戏开始后会在九个方格内随机出现炸弹,小伙伴们需要在规定时间内完成指定操作,才能将炸弹传递给下一位伙伴。 + +##### 使用说明 + +1. 加入对局 + + ​ 所有HarmonyOS手机安装本示例后,须登录同一账号,并处于同一分布式网络下,点击创建游戏,即可拉起周围所有手机中的传炸弹应用并进入到游戏页面。 + +2. 开始游戏 + + ​ 进入到游戏页面,会弹出规则简介弹框,由创建者点击开始游戏即可开始对局,开始后游戏会在9个方块内随机出现炸弹,需要在进度条走完前,对炸弹完成指定操作(单击、双击或长按),且随着游戏的进程,进度条加载会越来越快,完成指定操作后会将炸弹随机传下一位小伙伴,否则将伴随着震动和爆炸音效引爆炸弹,并弹出再来一局弹框等待新一轮游戏开始。 + +##### 约束与限制 + +1. 编译约束 + + 已实名认证的开发者联盟账号 ,实名认证参考[本链接](https://developer.huawei.com/consumer/cn/doc/start/itrna-0000001076878172 )。 + + 安装开发工具:DevEco Studio ,[下载地址](https://developer.harmonyos.com/cn/develop/deveco-studio#download) 。 + + 具体环境搭建请参考[本链接](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/installation_process-0000001071425528) 。 + + 分布式模拟器的使用参考[工具-使用模拟器运行应用 (harmonyos.com)](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/run_simulator-0000001053303709) 。 + + 更多资料请访问[应用开发-HarmonyOS](https://developer.harmonyos.com/cn/) 。 + +2. 使用限制 + + 本示例所有手机须在同一分布式网络同一账号下,可支持多台手机进行游戏。 + +3. 特别说明 + + 本示例使用到了以下第三方组件: + + ohos View Animations 动效组件: https://gitee.com/openharmony-tpc/ohosViewAnimations?_from=gitee_search + + gif动图加载组件: https://github.com/isoftstone-dev/gif_HarmonyOS \ No newline at end of file diff --git a/CompleteApps/BombGame/build.gradle b/CompleteApps/BombGame/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..bdcc1aaaa48521294e0947d0954ec5e5ca0bb002 --- /dev/null +++ b/CompleteApps/BombGame/build.gradle @@ -0,0 +1,38 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 +ohos { + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 5 + } +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.4.2' + classpath 'com.huawei.ohos:decctest:1.2.4.0' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } +} diff --git a/CompleteApps/BombGame/entry/build.gradle b/CompleteApps/BombGame/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..b169c526c2a95b7bd3fe60820bb9548202659d12 --- /dev/null +++ b/CompleteApps/BombGame/entry/build.gradle @@ -0,0 +1,29 @@ +apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 +ohos { + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 5 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + implementation 'io.openharmony.tpc.thirdlib:ohosViewAnimations:1.0.2' + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' +} +decc { + supportType = ['html','xml'] +} diff --git a/CompleteApps/BombGame/entry/libs/giflibrary-debug.har b/CompleteApps/BombGame/entry/libs/giflibrary-debug.har new file mode 100644 index 0000000000000000000000000000000000000000..27928c9e0009c3ff53424625a4bec94072c6a375 Binary files /dev/null and b/CompleteApps/BombGame/entry/libs/giflibrary-debug.har differ diff --git a/CompleteApps/BombGame/entry/src/main/config.json b/CompleteApps/BombGame/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d237287dd68812216d9ef9d6d96914ad00caa0ed --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/config.json @@ -0,0 +1,94 @@ +{ + "app": { + "bundleName": "ohos.samples.bombgame", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.bombgame", + "name": ".MyApplication", + "mainAbility": "ohos.samples.bombgame.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "reqPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC", + "reason": "data change", + "usedScene": { + "ability": [ + "ohos.samples.bombgame.GameAbility", + "ohos.samples.bombgame.MainAbility" + ], + "when": "always" + } + }, + { + "name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE" + }, + { + "name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.VIBRATE", + "reason": "", + "usedScene": { + "ability": [ + ".MainAbility" + ], + "when": "inuse" + } + } + ], + "metaData": { + "customizeData": [ + { + "name": "hwc-theme", + "value": "androidhwext:style/Theme.Emui.Translucent.NoTitleBar" + } + ] + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": "ohos.samples.bombgame.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "name": "ohos.samples.bombgame.GameAbility", + "icon": "$media:icon", + "description": "$string:gameability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ] + } +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/GameAbility.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/GameAbility.java new file mode 100644 index 0000000000000000000000000000000000000000..90b0e3b86d3ca93dbcc54b49c190c1b69bcc6755 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/GameAbility.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.samples.bombgame; + +import ohos.samples.bombgame.slice.GameAbilitySlice; +import ohos.aafwk.ability.Ability; +import ohos.aafwk.content.Intent; + +/** + * GameAbility + * + * @since 2021-08-25 + */ +public class GameAbility extends Ability { + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setMainRoute(GameAbilitySlice.class.getName()); + setTransitionAnimation(0, 0); + } +} diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/MainAbility.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/MainAbility.java new file mode 100644 index 0000000000000000000000000000000000000000..1364f325691140353e3942bf141ea7bbfabc066a --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/MainAbility.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.samples.bombgame; + +import static ohos.security.SystemPermission.DISTRIBUTED_DATASYNC; + +import ohos.bundle.IBundleManager; +import ohos.samples.bombgame.slice.MainAbilitySlice; +import ohos.aafwk.ability.Ability; +import ohos.aafwk.content.Intent; + +/** + * MainAbility + * + * @since 2021-08-25 + */ +public class MainAbility extends Ability { + @Override + public void onStart(Intent intent) { + requestPermission(); + super.onStart(intent); + super.setMainRoute(MainAbilitySlice.class.getName()); + } + + private void requestPermission() { + if (verifySelfPermission(DISTRIBUTED_DATASYNC) != IBundleManager.PERMISSION_GRANTED) { + if (canRequestPermission(DISTRIBUTED_DATASYNC)) { + requestPermissionsFromUser(new String[]{"ohos.permission.DISTRIBUTED_DATASYNC"}, 0); + } + } + } +} diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/MyApplication.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/MyApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..7bb523901e3c29d22c8aff99972da61e6ed9ae2d --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/MyApplication.java @@ -0,0 +1,15 @@ +package ohos.samples.bombgame; + +import ohos.aafwk.ability.AbilityPackage; + +/** + * MyApplication + * + * @since 2021-08-25 + */ +public class MyApplication extends AbilityPackage { + @Override + public void onInitialize() { + super.onInitialize(); + } +} diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/slice/GameAbilitySlice.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/slice/GameAbilitySlice.java new file mode 100644 index 0000000000000000000000000000000000000000..cc34dbe2fab46c1d3f1568fa80e52f2575b38b3d --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/slice/GameAbilitySlice.java @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.samples.bombgame.slice; + +import com.daimajia.ohosanimations.library.Techniques; +import com.daimajia.ohosanimations.library.YoYo; + +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.aafwk.content.Operation; +import ohos.agp.components.AttrHelper; +import ohos.agp.components.Component; +import ohos.agp.components.DirectionalLayout; +import ohos.agp.components.Image; +import ohos.agp.components.LayoutScatter; +import ohos.agp.components.ProgressBar; +import ohos.agp.components.TableLayout; +import ohos.agp.components.Text; +import ohos.agp.window.dialog.CommonDialog; +import ohos.global.resource.BaseFileDescriptor; +import ohos.global.resource.RawFileEntry; +import ohos.media.audio.SoundPlayer; +import ohos.media.player.Player; +import ohos.miscservices.timeutility.Time; +import ohos.samples.bombgame.GameAbility; +import ohos.samples.bombgame.ResourceTable; +import ohos.samples.bombgame.util.Common; +import ohos.samples.bombgame.util.LogUtil; + +import java.io.IOException; +import java.security.SecureRandom; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +/** + * GameAbilitySlice + * + * @since 2021-08-25 + */ +public class GameAbilitySlice extends AbilitySlice { + private static final String TAG = GameAbilitySlice.class.getSimpleName(); + private static final int SLOW_TIME = 2000; + private static final int SLOW_COUNT = 4; + private static final int NORMAL_TIME = 1600; + private static final int NORMAL_COUNT = 8; + private static final int FAST_TIME = 1200; + private static final int TIME_1000 = 1000; + private static final int TIME_1500 = 1500; + private static final float FAIL_MUSIC_VOLUME = .8f; + private static final int DIALOG_RADIUS = 27; + private static final int DIALOG_WIDTH = 280; + private static final int DIALOG_HEIGHT = 280; + private static final int DIALOG_PADDING = 50; + private static final int DESCRIPTION_FAIL_TEXT_SIZE = 40; + private static final int DESCRIPTION_TEXT_SIZE = 25; + private static final int RULE_NUMBER = 3; + private static final int BOMB_BLOCK_NUMBER = 9; + private static final int INTERVAL = 50; + private static final int FULL_PROGRESS = 100; + private static final int INDEX_CLICK = 0; + private static final int INDEX_DOUBLE_CLICK = 1; + private static final int INDEX_LONG_CLICK = 2; + private String[] rules; + private int rulesRandom; + private final SecureRandom random = new SecureRandom(); + private Text description; + private Image bombImage; + private Image failImage; + private Boolean isWaiting; + private Boolean isFail = false; + private ProgressBar progressBar; // countdown + private int progressValue = 0; + private int duration = SLOW_TIME; // bomb duration + private Timer timer; + private int startCount = 0; + + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_ability_game); + + rules = getStringArray(ResourceTable.Strarray_rules); + isFail = false; + isWaiting = intent.getBooleanParam("isWaiting", false); + final boolean isShowRules = intent.getBooleanParam("isShowRules", true); + startCount = intent.getIntParam("startCount", 0); + + failImage = (Image) findComponentById(ResourceTable.Id_game_image_boom); + failImage.setVisibility(Component.HIDE); + + description = (Text) findComponentById(ResourceTable.Id_game_text_description); + description.setText(rules[rulesRandom]); + if (isWaiting) { + description.setText(getString(ResourceTable.String_waiting)); + } else { + description.setText(ResourceTable.String_coming_soon); + } + if (isShowRules) { + createRulesDialog(); + } else { + startGame(); + } + } + + @Override + protected void onInactive() { + super.onInactive(); + } + + private void startGame() { + isFail = false; + rulesRandom = random.nextInt(RULE_NUMBER); + failImage.setVisibility(Component.HIDE); + getAbility().getIntent(); + + // Obtaining Random Numbers + int bombIndex = random.nextInt(BOMB_BLOCK_NUMBER); + TableLayout tableLayout = (TableLayout) findComponentById(ResourceTable.Id_game_tl_table); + DirectionalLayout background = (DirectionalLayout) tableLayout.getComponentAt(bombIndex); + bombImage = (Image) background.getComponentAt(0); + bombImage.setPixelMap(ResourceTable.Media_bomb); + + setBombListener(); + + // set bomb animation + YoYo.with(Techniques.Bounce) + .duration(TIME_1000) + .delay(0) + .playOn(bombImage); + + description.setText(rules[rulesRandom]); + description.setTextSize(AttrHelper.fp2px(DESCRIPTION_TEXT_SIZE, getContext())); + progressBar = (ProgressBar) findComponentById(ResourceTable.Id_game_pb_bar); + + // Set the countdown + setProgressValue(); + } + + private void setProgressValue() { + // The duration is getting shorter and shorter + if (startCount < SLOW_COUNT) { + duration = SLOW_TIME; + } else if (startCount < NORMAL_COUNT) { + duration = NORMAL_TIME; + } else { + duration = FAST_TIME; + } + + LogUtil.info(TAG, "startGame: duration = " + duration + ",startCount = " + startCount); + progressBar.setVisibility(Component.VISIBLE); + progressValue = 0; + timer = new Timer(); + int interval = INTERVAL; + timer.scheduleAtFixedRate(new TimerTask() { + private void updateProgress() { + progressValue += FULL_PROGRESS / (duration / interval); + progressBar.setProgressValue(progressValue); + if (progressValue >= FULL_PROGRESS) { + LogUtil.info(TAG, "game fail"); + gameFail(); + timer.cancel(); + } + } + + public void run() { + getUITaskDispatcher().asyncDispatch(this::updateProgress); + } + }, 0, interval); + } + + private void setBombListener() { + bombImage.setClickedListener(component -> judge(INDEX_CLICK)); + bombImage.setDoubleClickedListener(component -> judge(INDEX_DOUBLE_CLICK)); + bombImage.setLongClickedListener(component -> judge(INDEX_LONG_CLICK)); + } + + /** + * Judge wins or loses + * + * @param rulesIndex rule param + */ + private void judge(int rulesIndex) { + if (isWaiting) { + Common.createTip(getContext(), getString(ResourceTable.String_not_your_turn)); + return; + } + if (isFail) { + Common.createTip(getContext(), getString(ResourceTable.String_your_lost)); + return; + } + + // Click feedback,Play sound + SoundPlayer soundPlayer = new SoundPlayer("packageName"); + soundPlayer.playSound(SoundPlayer.SoundType.KEY_CLICK, 1.0f); + + timer.cancel(); + + // If the operation is incorrect, the game fails + if (rulesRandom != rulesIndex) { + gameFail(); + return; + } + bombImage.setPixelMap(null); + description.setText(getString(ResourceTable.String_waiting)); + isWaiting = true; + List deviceList = Common.getOnLineDeviceId(); + String deviceId = deviceList.get(random.nextInt(deviceList.size())); + Intent intent = new Intent(); + Operation operation = new Intent.OperationBuilder() + .withDeviceId(deviceId) + .withBundleName(getBundleName()) + .withAbilityName(GameAbility.class.getName()) + .withFlags(Intent.FLAG_ABILITYSLICE_MULTI_DEVICE) + .build(); + intent.setOperation(operation); + intent.setParam("isShowRules", false); + intent.setParam("startCount", ++startCount); + LogUtil.info(TAG, "judge: duration = " + duration + ",startCount = " + startCount); + startAbility(intent); + } + + private void gameFail() { + if (isFail) { + return; + } + isFail = true; + progressBar.setVisibility(Component.HIDE); + description.setText(getString(ResourceTable.String_your_lost)); + description.setTextSize(AttrHelper.fp2px(DESCRIPTION_FAIL_TEXT_SIZE, getContext())); + Common.createVibrator(); + failImage.setVisibility(Component.VISIBLE); + bombImage.setPixelMap(null); + + playFailMusic(); + + YoYo.with(Techniques.Swing) + .duration(TIME_1000) + .delay(TIME_1000) + .playOn(failImage); + + // Restart Dialog + Thread thread = new Thread(() -> { + Time.sleep(TIME_1500); + getUITaskDispatcher().asyncDispatch(this::createRestartDialog); + }); + thread.setDaemon(true); + thread.setName("restart-thread" + thread.getId()); + thread.setUncaughtExceptionHandler((t, e) -> + LogUtil.info(TAG, t.getName() + " : " + e.getMessage())); + thread.start(); + } + + private void playFailMusic() { + try { + RawFileEntry rawFileEntry = getResourceManager().getRawFileEntry("resources/rawfile/boom.mp3"); + BaseFileDescriptor baseFileDescriptor = rawFileEntry.openRawFileDescriptor(); + Player sPlayer = new Player(this); + sPlayer.setSource(baseFileDescriptor); + sPlayer.prepare(); + sPlayer.setVolume(FAIL_MUSIC_VOLUME); + sPlayer.enableSingleLooping(false); + sPlayer.play(); + } catch (IOException e) { + LogUtil.error("play music fail", e.getMessage()); + } + } + + private void createRulesDialog() { + CommonDialog commonDialog = new CommonDialog(this); + commonDialog.setCornerRadius(AttrHelper.vp2px(DIALOG_RADIUS, getContext())); + Component component = LayoutScatter.getInstance(getContext()) + .parse(ResourceTable.Layout_dialog_rules, null, true); + + commonDialog.setSize(AttrHelper.vp2px(DIALOG_WIDTH, getContext()), + AttrHelper.vp2px(DIALOG_HEIGHT, getContext())); + component.setPadding(DIALOG_PADDING, DIALOG_PADDING, DIALOG_PADDING, DIALOG_PADDING); + + commonDialog.setContentCustomComponent(component); + commonDialog.show(); + + Image rulesBtn = (Image) component.findComponentById(ResourceTable.Id_dialog_start_btn); + if (!isWaiting && !Common.isChinese()) { + rulesBtn.setPixelMap(ResourceTable.Media_btn_en_start); + } else if (isWaiting) { + if (Common.isChinese()) { + rulesBtn.setPixelMap(ResourceTable.Media_btn_wait); + } else { + rulesBtn.setPixelMap(ResourceTable.Media_btn_en_wait); + } + } + rulesBtn.setClickedListener(comp -> { + commonDialog.destroy(); + if (!isWaiting) { + startGame(); + } + }); + } + + private void createRestartDialog() { + CommonDialog commonDialog = new CommonDialog(this); + commonDialog.setCornerRadius(AttrHelper.vp2px(DIALOG_RADIUS, getContext())); + Component component = LayoutScatter.getInstance(getContext()) + .parse(ResourceTable.Layout_dialog_restart, null, true); + + commonDialog.setSize(AttrHelper.vp2px(DIALOG_WIDTH, getContext()), + AttrHelper.vp2px(DIALOG_HEIGHT, getContext())); + component.setPadding(DIALOG_PADDING, DIALOG_PADDING, DIALOG_PADDING, DIALOG_PADDING); + + commonDialog.setContentCustomComponent(component); + commonDialog.show(); + + Image restart = (Image) component.findComponentById(ResourceTable.Id_dialog_restart_btn); + if (!Common.isChinese()) { + restart.setPixelMap(ResourceTable.Media_btn_en_restart); + } + restart.setClickedListener(comp -> { + commonDialog.destroy(); + startCount = 0; + startGame(); + }); + } + + @Override + public void onActive() { + super.onActive(); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } +} diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/slice/MainAbilitySlice.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/slice/MainAbilitySlice.java new file mode 100644 index 0000000000000000000000000000000000000000..152ecde857bd4396fef2e63b9d240bcc3553a8fe --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/slice/MainAbilitySlice.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.samples.bombgame.slice; + +import static ohos.agp.animation.Animator.CurveType.ACCELERATE_DECELERATE; + +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.aafwk.content.Operation; +import ohos.agp.animation.AnimatorGroup; +import ohos.agp.animation.AnimatorProperty; +import ohos.agp.components.Component; +import ohos.agp.components.Image; +import ohos.bundle.AbilityInfo; +import ohos.bundle.ElementName; +import ohos.rpc.RemoteException; +import ohos.samples.bombgame.GameAbility; +import ohos.samples.bombgame.ResourceTable; +import ohos.samples.bombgame.util.Common; +import ohos.samples.bombgame.util.LogUtil; + +import java.util.List; + +/** + * MainAbilitySlice + * + * @since 2021-08-25 + */ +public class MainAbilitySlice extends AbilitySlice { + private static final String TAG = MainAbilitySlice.class.getSimpleName(); + private static final int DURATION_TIME = 500; + private static final int LOOPED_COUNT = 1000; + private static final int ROTATE = 20; + private static final int DELAY_TIME = 1000; + + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_ability_main); + + Image createGame = (Image) findComponentById(ResourceTable.Id_main_image_create); + createGame.setClickedListener(component -> createGame()); + + // Bomb Animation + Image bombImage = (Image) findComponentById(ResourceTable.Id_main_image_bomb); + AnimatorProperty am1 = bombImage.createAnimatorProperty(); + am1.rotate(ROTATE).setDuration(DURATION_TIME).setDelay(DELAY_TIME).setCurveType(ACCELERATE_DECELERATE); + + AnimatorProperty am2 = bombImage.createAnimatorProperty(); + am2.rotate(-ROTATE).setDuration(DURATION_TIME).setDelay(0).setCurveType(ACCELERATE_DECELERATE); + + AnimatorGroup animatorGroup = new AnimatorGroup(); + animatorGroup.setLoopedCount(LOOPED_COUNT); + animatorGroup.runSerially(am1, am2); + + bombImage.setBindStateChangedListener(new Component.BindStateChangedListener() { + @Override + public void onComponentBoundToWindow(Component component) { + am1.start(); + animatorGroup.start(); + } + + @Override + public void onComponentUnboundFromWindow(Component component) { + animatorGroup.stop(); + } + }); + + languageAdapt(); + } + + private void languageAdapt() { + if (!Common.isChinese()) { + Image logo = (Image) findComponentById(ResourceTable.Id_main_image_logo); + logo.setPixelMap(ResourceTable.Media_pic_en_title); + Image create = (Image) findComponentById(ResourceTable.Id_main_image_create); + create.setPixelMap(ResourceTable.Media_btn_en_createGame); + } + } + + private void createGame() { + List deviceList = Common.getOnLineDeviceId(); + if (deviceList.isEmpty()) { + Common.createTip(getContext(), getString(ResourceTable.String_no_online_device)); + return; + } + for (String deviceId : deviceList) { + Intent intent = new Intent(); + Operation operation = new Intent.OperationBuilder() + .withDeviceId(deviceId) + .withBundleName(getBundleName()) + .withAbilityName(GameAbility.class.getName()) + .withFlags(Intent.FLAG_ABILITYSLICE_MULTI_DEVICE) + .build(); + intent.setOperation(operation); + intent.setParam("isWaiting", true); + try { + List abilityInfoList = getBundleManager().queryAbilityByIntent(intent,0,0); + if (abilityInfoList != null && !abilityInfoList.isEmpty()){ + startAbility(intent); + }else { + LogUtil.info(TAG,"deviceId: " + deviceId + " no GameAbility"); + } + } catch (RemoteException e) { + LogUtil.error(TAG,e.getLocalizedMessage()); + } + } + + Intent gameIntent = new Intent(); + gameIntent.setElement(new ElementName("", + getBundleName(), GameAbility.class.getName())); + startAbility(gameIntent); + terminateAbility(); + } + + @Override + public void onActive() { + super.onActive(); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } +} + diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/util/Common.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/util/Common.java new file mode 100644 index 0000000000000000000000000000000000000000..8b8a1282a23eb6816f13bf4979c2797da7264ac3 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/util/Common.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.samples.bombgame.util; + +import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_CONTENT; +import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT; + +import ohos.agp.colors.RgbColor; +import ohos.agp.components.Component; +import ohos.agp.components.DirectionalLayout; +import ohos.agp.components.Text; +import ohos.agp.components.element.ShapeElement; +import ohos.agp.utils.Color; +import ohos.agp.utils.LayoutAlignment; +import ohos.agp.utils.TextAlignment; +import ohos.agp.window.dialog.ToastDialog; +import ohos.app.Context; +import ohos.distributedschedule.interwork.DeviceInfo; +import ohos.distributedschedule.interwork.DeviceManager; +import ohos.global.icu.util.ULocale; +import ohos.vibrator.agent.VibratorAgent; +import ohos.vibrator.bean.VibrationPattern; + +import java.util.ArrayList; +import java.util.List; + +/** + * Common + * + * @since 2021-08-25 + */ +public class Common { + private static final String TAG = Common.class.getSimpleName(); + private static final VibratorAgent vibratorAgent = new VibratorAgent(); + private static final int VIBRATOR_TIMING = 1000; + private static final int DURATION_TIME = 1000; + private static final int TIP_RADIUS = 20; + private static final int TIP_ALPHA = 153; + private static final int TIP_TEXT_SIZE = 16; + private static final int TIP_PADDING_HORIZONTAL = 40; + private static final int TIP_PADDING_VERTICAL = 25; + + private Common() { + } + + /** + * getOnLineDeviceId + * + * @return return device id list + */ + public static List getOnLineDeviceId() { + List deviceIds = new ArrayList<>(); + List deviceInfoList = DeviceManager.getDeviceList(DeviceInfo.FLAG_GET_ONLINE_DEVICE); + + if (deviceInfoList == null) { + return deviceIds; + } + + if (deviceInfoList.size() == 0) { + LogUtil.info(TAG, "deviceInfoList size = 0"); + return deviceIds; + } + + for (DeviceInfo deviceInfo : deviceInfoList) { + deviceIds.add(deviceInfo.getDeviceId()); + } + return deviceIds; + } + + /** + * createTip + * + * @param context slice context + * @param msg tip message + */ + public static void createTip(Context context, String msg) { + Text text = new Text(context); + text.setWidth(MATCH_CONTENT); + text.setHeight(MATCH_CONTENT); + text.setTextSize(TIP_TEXT_SIZE, Text.TextSizeType.FP); + text.setText(msg); + text.setPadding(TIP_PADDING_HORIZONTAL, TIP_PADDING_VERTICAL, TIP_PADDING_HORIZONTAL, TIP_PADDING_VERTICAL); + text.setMultipleLine(true); + text.setTextColor(Color.WHITE); + text.setTextAlignment(TextAlignment.CENTER); + + ShapeElement element = new ShapeElement(); + element.setShape(ShapeElement.RECTANGLE); + element.setRgbColor(new RgbColor(0, 0, 0, TIP_ALPHA)); + element.setCornerRadius(TIP_RADIUS); + text.setBackground(element); + + DirectionalLayout mainLayout = new DirectionalLayout(context); + mainLayout.setWidth(MATCH_PARENT); + mainLayout.setHeight(MATCH_CONTENT); + mainLayout.setAlignment(LayoutAlignment.CENTER); + mainLayout.addComponent(text); + + ToastDialog toastDialog = new ToastDialog(context); + toastDialog.setSize(MATCH_PARENT, MATCH_CONTENT); + toastDialog.setDuration(DURATION_TIME); + toastDialog.setAutoClosable(true); + toastDialog.setTransparent(true); + toastDialog.setAlignment(LayoutAlignment.CENTER); + toastDialog.setComponent((Component) mainLayout); + toastDialog.show(); + } + + /** + * createVibrator + */ + public static void createVibrator() { + List vibratorList = vibratorAgent.getVibratorIdList(); + if (vibratorList.isEmpty()) { + return; + } + int vibratorId = vibratorList.get(0); + + boolean isSupport = vibratorAgent.isEffectSupport(vibratorId, + VibrationPattern.VIBRATOR_TYPE_CAMERA_CLICK); + + if (!isSupport) { + return; + } + vibratorAgent.startOnce(vibratorId, VIBRATOR_TIMING); + } + + /** + * Determine the language environment + * + * @return isChinese + */ + public static boolean isChinese() { + String language = ULocale.getDefault().getLanguage(); + return ULocale.CHINA.getLanguage().equals(language); + } +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/util/LogUtil.java b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/util/LogUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..95c068a528a98118bcfe3ea36ae38a4d71fdd410 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/java/ohos/samples/bombgame/util/LogUtil.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.samples.bombgame.util; + +import ohos.hiviewdfx.HiLog; +import ohos.hiviewdfx.HiLogLabel; + +/** + * Log Util + * + * @since 2021-01-11 + */ +public class LogUtil { + private static final String TAG_LOG = "LogUtil"; + + private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtil.TAG_LOG); + + private static final String LOG_FORMAT = "%{public}s: %{public}s"; + + private LogUtil() { + } + + /** + * Print info log + * + * @param tag log tag + * @param msg log message + */ + public static void info(String tag, String msg) { + HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); + } + + /** + * Print info log + * + * @param tag log tag + * @param msg log message + */ + public static void error(String tag, String msg) { + HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); + } +} diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/element/string.json b/CompleteApps/BombGame/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..21f9ac0992a8b506fef61bb35346a39f1b65264a --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "Java_Empty Ability" + }, + { + "name": "mainability_HelloWorld", + "value": "Hello World" + }, + { + "name": "gameability_description", + "value": "Java_Empty Ability" + }, + { + "name": "gameability_HelloWorld", + "value": "Hello World" + }, + { + "name": "entry_GameAbility", + "value": "entry_GameAbility" + } + ] +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/layout/ability_game.xml b/CompleteApps/BombGame/entry/src/main/resources/base/layout/ability_game.xml new file mode 100644 index 0000000000000000000000000000000000000000..bd8caac89fa86a5ecb2dd4191b95d2fefc662a96 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/base/layout/ability_game.xml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/layout/ability_main.xml b/CompleteApps/BombGame/entry/src/main/resources/base/layout/ability_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..91c1ac4d77aa1707842f7fba937ad0a5788b27a2 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/base/layout/ability_main.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/layout/dialog_restart.xml b/CompleteApps/BombGame/entry/src/main/resources/base/layout/dialog_restart.xml new file mode 100644 index 0000000000000000000000000000000000000000..2842b71934694fc2c371b8b66ce6176b20495850 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/base/layout/dialog_restart.xml @@ -0,0 +1,35 @@ + + + + + + + + \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/layout/dialog_rules.xml b/CompleteApps/BombGame/entry/src/main/resources/base/layout/dialog_rules.xml new file mode 100644 index 0000000000000000000000000000000000000000..ebd6046a0e231b98bc435ae62c3754a422e769e9 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/base/layout/dialog_rules.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/again.gif b/CompleteApps/BombGame/entry/src/main/resources/base/media/again.gif new file mode 100644 index 0000000000000000000000000000000000000000..1a9467c1f2b2eca8990c2a8ab99e65d6fb1a181b Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/again.gif differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/background.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..380afe991dc7a087adfe19ec53497e4c06b564a3 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/background.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/bigBomb.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/bigBomb.png new file mode 100644 index 0000000000000000000000000000000000000000..337346caca23e6a787794452beda29f5c317871c Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/bigBomb.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/bomb.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/bomb.png new file mode 100644 index 0000000000000000000000000000000000000000..939527bbab473a04482b44aff00f87d351d32bc9 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/bomb.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/boom.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/boom.png new file mode 100644 index 0000000000000000000000000000000000000000..67219d100271825bdacdfd18d5a633ed057a53b4 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/boom.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_createGame.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_createGame.png new file mode 100644 index 0000000000000000000000000000000000000000..a15a5c4993327b821acf48a6b0ffab541e55e361 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_createGame.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_createGame.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_createGame.png new file mode 100644 index 0000000000000000000000000000000000000000..43eeaf60991e5b7db9683181204f1c412f72bbde Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_createGame.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_restart.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_restart.png new file mode 100644 index 0000000000000000000000000000000000000000..3cba33a82bdbf496ab3ab51bf60d36c4eca876df Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_restart.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_start.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_start.png new file mode 100644 index 0000000000000000000000000000000000000000..b17c22003bb7ff3a044f94dc86cffb8aeb23f2b8 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_start.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_wait.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_wait.png new file mode 100644 index 0000000000000000000000000000000000000000..ef72c2b78795ec30d5bab27b3c20b264371e8d62 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_en_wait.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_restart.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_restart.png new file mode 100644 index 0000000000000000000000000000000000000000..e474b829b93dc440d35bfc7657e21630842186c7 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_restart.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_start.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_start.png new file mode 100644 index 0000000000000000000000000000000000000000..67a7cab90ed7f9c0beda48f2ccf3d5995a756314 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_start.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_wait.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_wait.png new file mode 100644 index 0000000000000000000000000000000000000000..b4e7cb1915802aeda579939ec9e34fe9a1a2c701 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/btn_wait.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/close.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/close.png new file mode 100644 index 0000000000000000000000000000000000000000..f11c14a87aa1a54c17121a89d46b023281f42320 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/close.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/icon.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/icon.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/indexBomb.gif b/CompleteApps/BombGame/entry/src/main/resources/base/media/indexBomb.gif new file mode 100644 index 0000000000000000000000000000000000000000..4c562f252203cf4beb3c71ad86b27378307dd8f1 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/indexBomb.gif differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/info.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/info.png new file mode 100644 index 0000000000000000000000000000000000000000..edb0603e47dfe53ff76aaa77288ca92852d62f9b Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/info.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_bg.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..5bfe6950b9e97bb9f30291c5bb4c375663111181 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_bg.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_en_title.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_en_title.png new file mode 100644 index 0000000000000000000000000000000000000000..36e4f56fe0bb0e49a5f60db31deaf41eef1611b0 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_en_title.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_title.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_title.png new file mode 100644 index 0000000000000000000000000000000000000000..f9c07dd04e98a4f06c2422a275bb87ca40e1bfe7 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/pic_title.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/squares.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/squares.png new file mode 100644 index 0000000000000000000000000000000000000000..e4945d5a911ae34f7b4ef620580bc05349a44964 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/squares.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/base/media/title.png b/CompleteApps/BombGame/entry/src/main/resources/base/media/title.png new file mode 100644 index 0000000000000000000000000000000000000000..8d34530170d265ea69149c7bd2408f396a34c2ac Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/base/media/title.png differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/en/element/strarray.json b/CompleteApps/BombGame/entry/src/main/resources/en/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..98ba8b5b84a5f5822e27a8d26345309064ed2ddb --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/en/element/strarray.json @@ -0,0 +1,18 @@ +{ + "strarray": [ + { + "name": "rules", + "value": [ + { + "value": "Click" + }, + { + "value": "Double Click" + }, + { + "value": "Long Click" + } + ] + } + ] +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/en/element/string.json b/CompleteApps/BombGame/entry/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..20ab2da745271ddbe1697b61bfa48c80ad5c41ef --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/en/element/string.json @@ -0,0 +1,56 @@ +{ + "string": [ + { + "name": "no_online_device", + "value": "no online device" + }, + { + "name": "waiting", + "value": "waiting" + }, + { + "name": "coming_soon", + "value": "coming soon" + }, + { + "name": "game_fail", + "value": "Game Fail" + }, + { + "name": "not_your_turn", + "value": "It's not your turn yet" + }, + { + "name": "your_lost", + "value": "You've lost" + }, + { + "name": "app_name", + "value": "Bomb Game" + }, + { + "name": "game_rules", + "value": "The rules of the game" + }, + { + "name": "rules_content", + "value": "You need to complete the specified operation within a specified time to transfer the bomb to the next person." + }, + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "Java_Empty Ability" + }, + { + "name": "entry_GameAbility", + "value": "entry_GameAbility" + }, + { + "name": "gameability_description", + "value": "Java_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/rawfile/boom.mp3 b/CompleteApps/BombGame/entry/src/main/resources/rawfile/boom.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..c6cc9cd8d5e8b3eacb61bec2d31e16787996e1a0 Binary files /dev/null and b/CompleteApps/BombGame/entry/src/main/resources/rawfile/boom.mp3 differ diff --git a/CompleteApps/BombGame/entry/src/main/resources/zh/element/strarray.json b/CompleteApps/BombGame/entry/src/main/resources/zh/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..999a10b5b638867013fdc1727b2d9ef8e37be559 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/zh/element/strarray.json @@ -0,0 +1,18 @@ +{ + "strarray": [ + { + "name": "rules", + "value": [ + { + "value": "单击" + }, + { + "value": "双击" + }, + { + "value": "长按" + } + ] + } + ] +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/main/resources/zh/element/string.json b/CompleteApps/BombGame/entry/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..29d0cd795787539a1babb98843481165b4ce1d2f --- /dev/null +++ b/CompleteApps/BombGame/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,56 @@ +{ + "string": [ + { + "name": "no_online_device", + "value": "没有在线设备" + }, + { + "name": "waiting", + "value": "等待中" + }, + { + "name": "coming_soon", + "value": "即将开始" + }, + { + "name": "game_fail", + "value": "游戏失败" + }, + { + "name": "not_your_turn", + "value": "还没轮到你" + }, + { + "name": "your_lost", + "value": "你已经输了" + }, + { + "name": "app_name", + "value": "传炸弹" + }, + { + "name": "game_rules", + "value": "游戏规则" + }, + { + "name": "rules_content", + "value": "炸弹会随机出现在9个方块内,需要在规定时间内完成指定操作(点击、双击或长按),即可将炸弹传递给下一个人,小心炸弹可是会越来越快的喔!" + }, + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "Java_Empty Ability" + }, + { + "name": "entry_GameAbility", + "value": "entry_GameAbility" + }, + { + "name": "gameability_description", + "value": "Java_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/ohosTest/java/ohos/samples/bombgame/ExampleOhosTest.java b/CompleteApps/BombGame/entry/src/ohosTest/java/ohos/samples/bombgame/ExampleOhosTest.java new file mode 100644 index 0000000000000000000000000000000000000000..36f51989ccb3f0b6c34d47f31c506b5a9ce2e97e --- /dev/null +++ b/CompleteApps/BombGame/entry/src/ohosTest/java/ohos/samples/bombgame/ExampleOhosTest.java @@ -0,0 +1,14 @@ +package ohos.samples.bombgame; + +import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ExampleOhosTest { + @Test + public void testBundleName() { + final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); + assertEquals("ohos.samples.bombgame", actualBundleName); + } +} \ No newline at end of file diff --git a/CompleteApps/BombGame/entry/src/test/java/ohos/samples/bombgame/ExampleTest.java b/CompleteApps/BombGame/entry/src/test/java/ohos/samples/bombgame/ExampleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..11b5dff27f83026b54fed3b301dea3610a12bf22 --- /dev/null +++ b/CompleteApps/BombGame/entry/src/test/java/ohos/samples/bombgame/ExampleTest.java @@ -0,0 +1,9 @@ +package ohos.samples.bombgame; + +import org.junit.Test; + +public class ExampleTest { + @Test + public void onStart() { + } +} diff --git a/CompleteApps/BombGame/screenshort/phone/Bomegame.png b/CompleteApps/BombGame/screenshort/phone/Bomegame.png new file mode 100644 index 0000000000000000000000000000000000000000..94ff07f35ce0376c35346fa2399c11e4ef0dc912 Binary files /dev/null and b/CompleteApps/BombGame/screenshort/phone/Bomegame.png differ diff --git a/CompleteApps/BombGame/settings.gradle b/CompleteApps/BombGame/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/CompleteApps/BombGame/settings.gradle @@ -0,0 +1 @@ +include ':entry'