levelCfgs = null;
65 | private Level[] levels = null;
66 | }
67 |
--------------------------------------------------------------------------------
/Linkup/src/com/znv/linkup/view/indicator/PageIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Patrik Akerfeldt
3 | * Copyright (C) 2011 Jake Wharton
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.znv.linkup.view.indicator;
19 |
20 | import android.support.v4.view.ViewPager;
21 |
22 | /**
23 | * A PageIndicator is responsible to show an visual indicator on the total views number and the current visible view.
24 | */
25 | public interface PageIndicator extends ViewPager.OnPageChangeListener {
26 | /**
27 | * Bind the indicator to a ViewPager.
28 | *
29 | * @param view
30 | */
31 | void setViewPager(ViewPager view);
32 |
33 | /**
34 | * Bind the indicator to a ViewPager.
35 | *
36 | * @param view
37 | * @param initialPosition
38 | */
39 | void setViewPager(ViewPager view, int initialPosition);
40 |
41 | /**
42 | *
43 | * Set the current page of both the ViewPager and indicator.
44 | *
45 | *
46 | *
47 | * This must be used if you need to set the page before the views are drawn on screen (e.g., default start page).
48 | *
49 | *
50 | * @param item
51 | */
52 | void setCurrentItem(int item);
53 |
54 | /**
55 | * Set a page change listener which will receive forwarded events.
56 | *
57 | * @param listener
58 | */
59 | void setOnPageChangeListener(ViewPager.OnPageChangeListener listener);
60 |
61 | /**
62 | * Notify the indicator that the fragment list has changed.
63 | */
64 | void notifyDataSetChanged();
65 | }
66 |
--------------------------------------------------------------------------------
/Linkup/src/com/znv/linkup/wxapi/WXEntryActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * 官网地站:http://www.ShareSDK.cn
3 | * 技术支持QQ: 4006852216
4 | * 官方微信:ShareSDK (如果发布新版本的话,我们将会第一时间通过微信将版本更新内容推送给您。如果使用过程中有任何问题,也可以通过微信与我们取得联系,我们将会在24小时内给予回复)
5 | *
6 | * Copyright (c) 2013年 ShareSDK.cn. All rights reserved.
7 | */
8 |
9 | package com.znv.linkup.wxapi;
10 |
11 | import android.content.Intent;
12 | import android.widget.Toast;
13 | import cn.sharesdk.wechat.utils.WXAppExtendObject;
14 | import cn.sharesdk.wechat.utils.WXMediaMessage;
15 | import cn.sharesdk.wechat.utils.WechatHandlerActivity;
16 |
17 | /** 微信客户端回调activity示例 */
18 | public class WXEntryActivity extends WechatHandlerActivity {
19 |
20 | /**
21 | * 处理微信发出的向第三方应用请求app message
22 | *
23 | * 在微信客户端中的聊天页面有“添加工具”,可以将本应用的图标添加到其中
24 | * 此后点击图标,下面的代码会被执行。Demo仅仅只是打开自己而已,但你可
25 | * 做点其他的事情,包括根本不打开任何页面
26 | */
27 | public void onGetMessageFromWXReq(WXMediaMessage msg) {
28 | Intent iLaunchMyself = getPackageManager().getLaunchIntentForPackage(getPackageName());
29 | startActivity(iLaunchMyself);
30 | }
31 |
32 | /**
33 | * 处理微信向第三方应用发起的消息
34 | *
35 | * 此处用来接收从微信发送过来的消息,比方说本demo在wechatpage里面分享
36 | * 应用时可以不分享应用文件,而分享一段应用的自定义信息。接受方的微信
37 | * 客户端会通过这个方法,将这个信息发送回接收方手机上的本demo中,当作
38 | * 回调。
39 | *
40 | * 本Demo只是将信息展示出来,但你可做点其他的事情,而不仅仅只是Toast
41 | */
42 | public void onShowMessageFromWXReq(WXMediaMessage msg) {
43 | if (msg != null && msg.mediaObject != null
44 | && (msg.mediaObject instanceof WXAppExtendObject)) {
45 | WXAppExtendObject obj = (WXAppExtendObject) msg.mediaObject;
46 | Toast.makeText(this, obj.extInfo, Toast.LENGTH_SHORT).show();
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/LinkupCore/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/LinkupCore/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Linkup.Core
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LinkupCore/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/LinkupCore/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/LinkupCore/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/LinkupCore/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/GameSettings.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core;
2 |
3 | /**
4 | * 游戏相关的设置
5 | *
6 | * @author yzb
7 | *
8 | */
9 | public class GameSettings {
10 |
11 | /**
12 | * 地板卡片值
13 | */
14 | public static byte GroundCardValue = 0;
15 |
16 | /**
17 | * 游戏卡片值,用于地图模版
18 | */
19 | public static byte GameCardValue = 1;
20 |
21 | /**
22 | * 障碍卡片值
23 | */
24 | public static byte ObstacleCardValue = -1;
25 |
26 | /**
27 | * 空卡片值
28 | */
29 | public static byte EmptyCardValue = -2;
30 |
31 | /**
32 | * 消除卡片获得的积分,消除一对卡片得10分
33 | */
34 | public static int CardScore = 5;
35 |
36 | /**
37 | * 连击延时时间,2000ms
38 | */
39 | public static int ComboDelay = 2000;
40 |
41 | /**
42 | * 连击间隔,3连击,6连击,9连击。。。
43 | */
44 | public static int ComboMod = 3;
45 |
46 | /**
47 | * 连击分数,3连击则3*10=30
48 | */
49 | public static int ComboScore = 10;
50 |
51 | /**
52 | * 剩余时间奖励分数,剩余10s,则奖励40分
53 | */
54 | public static int TimeScore = 4;
55 |
56 | /**
57 | * 路径转弯奖励分数,直线不奖励,一个弯奖励5分,2个弯奖励10分
58 | */
59 | public static int CornerScore = 5;
60 |
61 | /**
62 | * 消除一对卡片奖励的时间,0s
63 | */
64 | public static int RewardTime = 0;
65 |
66 | /**
67 | * 减少时间奖励,补偿分数
68 | */
69 | public static int RewardScoreMax = 5;
70 |
71 | /**
72 | * 任务系数
73 | */
74 | public static int TaskFactor = 10;
75 |
76 | /**
77 | * 重排时尝试次数,默认5次
78 | */
79 | public static int RefreshTryCount = 5;
80 |
81 | /**
82 | * 星星的比例
83 | */
84 | public static float StarRatio = 0.4f;
85 | }
86 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/IGameAction.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 | import com.znv.linkup.core.card.path.LinkInfo;
5 | import com.znv.linkup.core.status.IGameStatus;
6 |
7 | /**
8 | * 游戏操作接口,继承自游戏状态接口,界面实现此接口以响应相应逻辑
9 | *
10 | * @author yzb
11 | *
12 | */
13 | public interface IGameAction extends IGameStatus {
14 |
15 | /**
16 | * 选择卡片时的处理
17 | *
18 | * @param piece
19 | * 选择的卡片信息
20 | */
21 | void onCheck(Piece piece);
22 |
23 | /**
24 | * 取消选择时的处理
25 | *
26 | * @param piece
27 | * 取消选择的卡片信息
28 | */
29 | void onUnCheck(Piece piece);
30 |
31 | /**
32 | * 游戏卡片变换时的处理
33 | */
34 | void onTranslate();
35 |
36 | /**
37 | * 对连接路径的处理
38 | *
39 | * @param linkInfo
40 | */
41 | void onLinkPath(LinkInfo linkInfo);
42 |
43 | /**
44 | * 消除后的处理,用于自动检测死锁
45 | */
46 | void onErase();
47 |
48 | /**
49 | * 游戏步数变化时的处理
50 | *
51 | * @param step
52 | * 游戏步数
53 | */
54 | void onStepChanged(int step);
55 |
56 | /**
57 | * 游戏星星变化时的处理
58 | *
59 | * @param star
60 | * 收集的星星数
61 | */
62 | void onStarChanged(int star);
63 | }
64 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/PiecePair.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card;
2 |
3 | /**
4 | * 卡片对,用于游戏提示
5 | *
6 | * @author yzb
7 | *
8 | */
9 | public class PiecePair {
10 | public PiecePair(Piece p1, Piece p2) {
11 | pieceOne = p1;
12 | pieceTwo = p2;
13 | }
14 |
15 | /**
16 | * 将卡片对排序,序号小的为pieceOne
17 | */
18 | public void sort() {
19 | if (pieceOne == null || pieceTwo == null) {
20 | return;
21 | }
22 |
23 | if (pieceOne.getIndex() > pieceTwo.getIndex()) {
24 | // 交换卡片对的位置
25 | Piece p = pieceOne;
26 | pieceOne = pieceTwo;
27 | pieceTwo = p;
28 | }
29 | }
30 |
31 | public Piece getPieceOne() {
32 | return pieceOne;
33 | }
34 |
35 | public void setPieceOne(Piece pieceOne) {
36 | this.pieceOne = pieceOne;
37 | }
38 |
39 | public Piece getPieceTwo() {
40 | return pieceTwo;
41 | }
42 |
43 | public void setPieceTwo(Piece pieceTwo) {
44 | this.pieceTwo = pieceTwo;
45 | }
46 |
47 | private Piece pieceOne;
48 | private Piece pieceTwo;
49 | }
50 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignBase.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 |
5 | /**
6 | * 卡片聚集的基类
7 | *
8 | * @author yzb
9 | *
10 | */
11 | abstract class AlignBase {
12 |
13 | protected Piece[][] pieces;
14 |
15 | public AlignBase(Piece[][] pieces) {
16 | this.pieces = pieces;
17 | }
18 |
19 | /**
20 | * 消除卡片后的变换
21 | *
22 | * @param p1
23 | * 消除的卡片1
24 | * @param p2
25 | * 消除的卡片2
26 | */
27 | public abstract void Translate(Piece p1, Piece p2);
28 |
29 | /**
30 | * 交换卡片信息
31 | *
32 | * @param p1
33 | * 卡片1
34 | * @param p2
35 | * 卡片2
36 | */
37 | protected void ExchangePiece(Piece p1, Piece p2) {
38 | if (p1 == null || p2 == null) {
39 | return;
40 | }
41 |
42 | p1.exchange(p2);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignContext.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import java.util.Random;
4 |
5 | import com.znv.linkup.core.card.Piece;
6 | import com.znv.linkup.core.config.GameAlign;
7 |
8 | /**
9 | * 游戏卡片聚集的处理类
10 | *
11 | * @author yzb
12 | *
13 | */
14 | public class AlignContext {
15 | private AlignBase gAlign = null;
16 | private Piece[][] pieces;
17 |
18 | public AlignContext(Piece[][] pieces, GameAlign align) {
19 | this.pieces = pieces;
20 | this.gAlign = CreateAlign(align);
21 | }
22 |
23 | /**
24 | * 根据消除的卡片实现变换
25 | *
26 | * @param p1
27 | * 消除的卡片1
28 | * @param p2
29 | * 消除的卡片2
30 | */
31 | public void Translate(Piece p1, Piece p2) {
32 | if (gAlign != null) {
33 | gAlign.Translate(p1, p2);
34 | }
35 | }
36 |
37 | /**
38 | * 根据游戏对齐方式创建聚集类对象
39 | *
40 | * @param align
41 | * 对齐方式
42 | * @return 聚集基类对象
43 | */
44 | private AlignBase CreateAlign(GameAlign align) {
45 | AlignBase gAlign = null;
46 | switch (align) {
47 | case AlignDown:
48 | gAlign = new AlignDown(pieces);
49 | break;
50 | case AlignLeft:
51 | gAlign = new AlignLeft(pieces);
52 | break;
53 | case AlignUp:
54 | gAlign = new AlignUp(pieces);
55 | break;
56 | case AlignRight:
57 | gAlign = new AlignRight(pieces);
58 | break;
59 | case AlignRandom:
60 | Random ran = new Random((int) System.currentTimeMillis());
61 | gAlign = CreateAlign(GameAlign.valueOf(ran.nextInt(5)));
62 | break;
63 | default:
64 | gAlign = new AlignNone(pieces);
65 | break;
66 | }
67 | return gAlign;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignDown.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 | import com.znv.linkup.core.card.PiecePair;
5 |
6 | /**
7 | * 向下聚集
8 | *
9 | * @author yzb
10 | *
11 | */
12 | class AlignDown extends AlignBase {
13 |
14 | public AlignDown(Piece[][] pieces) {
15 | super(pieces);
16 | }
17 |
18 | @Override
19 | /**
20 | * 向下聚集的变换
21 | */
22 | public void Translate(Piece p1, Piece p2) {
23 | PiecePair pair = new PiecePair(p1, p2);
24 | pair.sort();
25 |
26 | // 先变换p1,再变换p2
27 | TranslatePiece(p1);
28 |
29 | TranslatePiece(p2);
30 | }
31 |
32 | private void TranslatePiece(Piece p) {
33 | int indexX = p.getIndexX();
34 | int curIndexY = p.getIndexY();
35 | int nextIndexY = curIndexY - 1;
36 | // 填补游戏块前面的空块
37 | while (curIndexY + 1 < pieces.length - 1) {
38 | Piece lastPiece = pieces[curIndexY + 1][indexX];
39 | if (!Piece.hasImage(lastPiece)) {
40 | curIndexY += 1;
41 | } else {
42 | break;
43 | }
44 | }
45 | while (curIndexY > 0) {
46 | Piece curPiece = pieces[curIndexY][indexX];
47 | if (!Piece.hasImage(curPiece)) {
48 | nextIndexY = Math.min(nextIndexY, curIndexY - 1);
49 | while (nextIndexY > 0) {
50 | Piece nextPiece = pieces[nextIndexY][indexX];
51 | if (Piece.hasImage(nextPiece)) {
52 | // 游戏卡片则交换
53 | if (Piece.canSelect(nextPiece)) {
54 | ExchangePiece(curPiece, nextPiece);
55 | nextIndexY--;
56 | break;
57 | } else {
58 | // 障碍卡片则停止交换
59 | nextIndexY = 0;
60 | }
61 | } else {
62 | nextIndexY--;
63 | }
64 | }
65 | if (nextIndexY == 0) {
66 | break;
67 | }
68 | }
69 | curIndexY--;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignLeft.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 | import com.znv.linkup.core.card.PiecePair;
5 |
6 | /**
7 | * 向左聚集
8 | *
9 | * @author yzb
10 | *
11 | */
12 | class AlignLeft extends AlignBase {
13 |
14 | public AlignLeft(Piece[][] pieces) {
15 | super(pieces);
16 | }
17 |
18 | @Override
19 | /**
20 | * 向左聚集的变换
21 | */
22 | public void Translate(Piece p1, Piece p2) {
23 | PiecePair pair = new PiecePair(p1, p2);
24 | pair.sort();
25 |
26 | // 先变换p2,再变换p1
27 | TranslatePiece(p2);
28 |
29 | TranslatePiece(p1);
30 | }
31 |
32 | private void TranslatePiece(Piece p) {
33 | int indexY = p.getIndexY();
34 | int curIndexX = p.getIndexX();
35 | int nextIndexX = curIndexX + 1;
36 | // 填补游戏块前面的空块
37 | while (curIndexX - 1 > 0) {
38 | Piece lastPiece = pieces[indexY][curIndexX - 1];
39 | if (!Piece.hasImage(lastPiece)) {
40 | curIndexX -= 1;
41 | } else {
42 | break;
43 | }
44 | }
45 | while (curIndexX < pieces[indexY].length - 1) {
46 | Piece curPiece = pieces[indexY][curIndexX];
47 | if (!Piece.hasImage(curPiece)) {
48 | nextIndexX = Math.max(nextIndexX, curIndexX + 1);
49 | while (nextIndexX < pieces[indexY].length - 1) {
50 | Piece nextPiece = pieces[indexY][nextIndexX];
51 | if (Piece.hasImage(nextPiece)) {
52 | if (Piece.canSelect(nextPiece)) {
53 | // 游戏卡片则交换
54 | ExchangePiece(curPiece, nextPiece);
55 | nextIndexX++;
56 | break;
57 | } else {
58 | // 遇到障碍则停止
59 | nextIndexX = pieces[indexY].length - 1;
60 | }
61 | } else {
62 | nextIndexX++;
63 | }
64 | }
65 | if (nextIndexX == pieces[indexY].length - 1) {
66 | break;
67 | }
68 | }
69 | curIndexX++;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignNone.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 |
5 | /**
6 | * 不聚集
7 | *
8 | * @author yzb
9 | *
10 | */
11 | class AlignNone extends AlignBase {
12 |
13 | public AlignNone(Piece[][] pieces) {
14 | super(pieces);
15 | }
16 |
17 | @Override
18 | public void Translate(Piece p1, Piece p2) {
19 |
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignRight.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 | import com.znv.linkup.core.card.PiecePair;
5 |
6 | /**
7 | * 向右聚集
8 | *
9 | * @author yzb
10 | *
11 | */
12 | class AlignRight extends AlignBase {
13 |
14 | public AlignRight(Piece[][] pieces) {
15 | super(pieces);
16 | }
17 |
18 | @Override
19 | /**
20 | * 向右聚集变换
21 | */
22 | public void Translate(Piece p1, Piece p2) {
23 | PiecePair pair = new PiecePair(p1, p2);
24 | pair.sort();
25 |
26 | // 先变换p1,再变换p2
27 | TranslatePiece(p1);
28 |
29 | TranslatePiece(p2);
30 | }
31 |
32 | private void TranslatePiece(Piece p) {
33 | int indexY = p.getIndexY();
34 | int curIndexX = p.getIndexX();
35 | int nextIndexX = curIndexX - 1;
36 | // 填补游戏块前面的空块
37 | while (curIndexX + 1 < pieces[indexY].length - 1) {
38 | Piece lastPiece = pieces[indexY][curIndexX + 1];
39 | if (!Piece.hasImage(lastPiece)) {
40 | curIndexX += 1;
41 | } else {
42 | break;
43 | }
44 | }
45 | while (curIndexX > 0) {
46 | Piece curPiece = pieces[indexY][curIndexX];
47 | if (!Piece.hasImage(curPiece)) {
48 | nextIndexX = Math.min(nextIndexX, curIndexX - 1);
49 | while (nextIndexX > 0) {
50 | Piece nextPiece = pieces[indexY][nextIndexX];
51 | if (Piece.hasImage(nextPiece)) {
52 | if (Piece.canSelect(nextPiece)) {
53 | // 游戏卡片则交换
54 | ExchangePiece(curPiece, nextPiece);
55 | nextIndexX--;
56 | break;
57 | } else {
58 | // 遇到障碍则结束
59 | nextIndexX = 0;
60 | }
61 | } else {
62 | nextIndexX--;
63 | }
64 | }
65 | if (nextIndexX == 0) {
66 | break;
67 | }
68 | }
69 | curIndexX--;
70 | }
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/align/AlignUp.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.align;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 | import com.znv.linkup.core.card.PiecePair;
5 |
6 | /**
7 | * 向上聚集
8 | *
9 | * @author yzb
10 | *
11 | */
12 | class AlignUp extends AlignBase {
13 |
14 | public AlignUp(Piece[][] pieces) {
15 | super(pieces);
16 | }
17 |
18 | @Override
19 | /**
20 | * 向上聚集变换
21 | */
22 | public void Translate(Piece p1, Piece p2) {
23 | PiecePair pair = new PiecePair(p1, p2);
24 | pair.sort();
25 |
26 | // 先变换p2,再变换p1
27 | TranslatePiece(p2);
28 |
29 | TranslatePiece(p1);
30 | }
31 |
32 | private void TranslatePiece(Piece p) {
33 | int indexX = p.getIndexX();
34 | int curIndexY = p.getIndexY();
35 | int nextIndexY = curIndexY + 1;
36 | // 填补游戏块前面的空块
37 | while(curIndexY - 1 > 0) {
38 | Piece lastPiece = pieces[curIndexY - 1][indexX];
39 | if (!Piece.hasImage(lastPiece)) {
40 | curIndexY -= 1;
41 | }else {
42 | break;
43 | }
44 | }
45 | while (curIndexY < pieces.length - 1) {
46 | Piece curPiece = pieces[curIndexY][indexX];
47 | if (!Piece.hasImage(curPiece)) {
48 | nextIndexY = Math.max(nextIndexY, curIndexY + 1);
49 | while (nextIndexY < pieces.length - 1) {
50 | Piece nextPiece = pieces[nextIndexY][indexX];
51 | if (Piece.hasImage(nextPiece)) {
52 | if (Piece.canSelect(nextPiece)) {
53 | // 游戏卡片则交换
54 | ExchangePiece(curPiece, nextPiece);
55 | nextIndexY++;
56 | break;
57 | } else {
58 | // 遇到障碍则停止变换
59 | nextIndexY = pieces.length - 1;
60 | }
61 | } else {
62 | nextIndexY++;
63 | }
64 | }
65 | if (nextIndexY == pieces.length - 1) {
66 | break;
67 | }
68 | }
69 | curIndexY++;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/path/LinkInfo.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.path;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.znv.linkup.core.card.Piece;
7 |
8 | /**
9 | * 卡片连击路径信息,记录起点,终点和转弯点,
10 | *
11 | * @author yzb
12 | *
13 | */
14 | public class LinkInfo {
15 | private List linkPieces = new ArrayList();
16 |
17 | public LinkInfo(Piece p1, Piece p2) {
18 | linkPieces.add(p1);
19 | linkPieces.add(p2);
20 | }
21 |
22 | public LinkInfo(Piece p1, Piece p2, Piece p3) {
23 | this(p1, p2);
24 | linkPieces.add(p3);
25 | }
26 |
27 | public LinkInfo(Piece p1, Piece p2, Piece p3, Piece p4) {
28 | this(p1, p2, p3);
29 | linkPieces.add(p4);
30 | }
31 |
32 | public List getLinkPieces() {
33 | return linkPieces;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/card/path/TwoCorner.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.card.path;
2 |
3 | import com.znv.linkup.core.card.Piece;
4 |
5 | /**
6 | * 两个弯的路径卡片信息,包括起点,转弯点1,转弯点2和终点,便于对比路径长度
7 | *
8 | * @author yzb
9 | *
10 | */
11 | public class TwoCorner {
12 | private Piece start;
13 | private Piece cornerOne;
14 | private Piece cornerTwo;
15 | private Piece stop;
16 |
17 | public TwoCorner(Piece start, Piece one, Piece two, Piece stop) {
18 | this.start = start;
19 | this.cornerOne = one;
20 | this.cornerTwo = two;
21 | this.stop = stop;
22 | }
23 |
24 | /**
25 | * 判断当期路径与待比较的路径哪个更短
26 | *
27 | * @param other
28 | * 待比较的路径
29 | * @return 当期路径短则返回true
30 | */
31 | public boolean isShorterThan(TwoCorner other) {
32 | if (other == null) {
33 | return true;
34 | }
35 | int dist1 = this.getDistance();
36 | int dist2 = other.getDistance();
37 | return dist1 < dist2;
38 | }
39 |
40 | /**
41 | * 获取路径距离
42 | *
43 | * @return 路径距离
44 | */
45 | public int getDistance() {
46 | return Piece.getDistance(start, cornerOne) + Piece.getDistance(cornerOne, cornerTwo) + Piece.getDistance(cornerTwo, stop);
47 | }
48 |
49 | public Piece getCornerOne() {
50 | return cornerOne;
51 | }
52 |
53 | public void setCornerOne(Piece cornerOne) {
54 | this.cornerOne = cornerOne;
55 | }
56 |
57 | public Piece getCornerTwo() {
58 | return cornerTwo;
59 | }
60 |
61 | public void setCornerTwo(Piece cornerTwo) {
62 | this.cornerTwo = cornerTwo;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/config/GameAlign.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.config;
2 |
3 | /**
4 | * 游戏聚集对齐方式
5 | *
6 | * @author yzb
7 | *
8 | */
9 | public enum GameAlign {
10 | AlignNone(0), AlignDown(1), AlignUp(2), AlignLeft(3), AlignRight(4), AlignRandom(5);
11 |
12 | private int value;
13 |
14 | GameAlign(int value) {
15 | this.value = value;
16 | }
17 |
18 | public static GameAlign valueOf(int align) {
19 | switch (align) {
20 | case 0:
21 | return AlignNone;
22 | case 1:
23 | return AlignDown;
24 | case 2:
25 | return AlignUp;
26 | case 3:
27 | return AlignLeft;
28 | case 4:
29 | return AlignRight;
30 | case 5:
31 | return AlignRandom;
32 | default:
33 | return AlignNone;
34 | }
35 | }
36 |
37 | public int value() {
38 | return this.value;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/config/GameMode.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.config;
2 |
3 | /**
4 | * 游戏模式
5 | *
6 | * @author yzb
7 | *
8 | */
9 | public enum GameMode {
10 | Level, Time, ScoreTask, TimeTask, Star, Endless;
11 |
12 | public static GameMode valueOf(int mode) {
13 | switch (mode) {
14 | case 1:
15 | return Time;
16 | case 2:
17 | return ScoreTask;
18 | case 3:
19 | return TimeTask;
20 | case 4:
21 | return Star;
22 | case 5:
23 | return Endless;
24 | default:
25 | return Level;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/config/GlobalCfg.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.config;
2 |
3 | /**
4 | * 游戏全局设置
5 | *
6 | * @author yzb
7 | *
8 | */
9 | public class GlobalCfg {
10 | // 是否播放游戏音效
11 | private boolean gameSound = true;
12 | // 是否播放背景音乐
13 | private boolean gameBgMusic = true;
14 | // 提示数
15 | private int promptNum;
16 | // 重排数
17 | private int refreshNum;
18 | // 加时间的数目
19 | private int addTimeNum;
20 |
21 | /**
22 | * 从字符串解析出全局配置信息
23 | *
24 | * @param globalCfgStr
25 | * 配置信息字符串
26 | * @return 全局配置信息
27 | */
28 | public static GlobalCfg parse(String globalCfgStr) {
29 | String[] cfgs = globalCfgStr.split(";");
30 | try {
31 | GlobalCfg globalCfg = new GlobalCfg();
32 | globalCfg.setGameSound(cfgs[0].equals("1"));
33 | globalCfg.setGameBgMusic(cfgs[1].equals("1"));
34 | globalCfg.setPromptNum(Integer.parseInt(cfgs[2]));
35 | globalCfg.setRefreshNum(Integer.parseInt(cfgs[3]));
36 | if (cfgs.length > 4) {
37 | globalCfg.setAddTimeNum(Integer.parseInt(cfgs[4]));
38 | } else {
39 | // 默认3次
40 | globalCfg.setAddTimeNum(3);
41 | }
42 | return globalCfg;
43 | } catch (Exception ex) {
44 | return null;
45 | }
46 | }
47 |
48 | /**
49 | * 转化为配置信息字符串
50 | */
51 | @Override
52 | public String toString() {
53 | String soundStr = gameSound ? "1" : "0";
54 | String musicStr = gameBgMusic ? "1" : "0";
55 | return String.format("%s;%s;%s;%s;%s;", soundStr, musicStr, promptNum, refreshNum, addTimeNum);
56 | }
57 |
58 | public boolean isGameSound() {
59 | return gameSound;
60 | }
61 |
62 | public void setGameSound(boolean gameSound) {
63 | this.gameSound = gameSound;
64 | }
65 |
66 | public boolean isGameBgMusic() {
67 | return gameBgMusic;
68 | }
69 |
70 | public void setGameBgMusic(boolean gameBgMusic) {
71 | this.gameBgMusic = gameBgMusic;
72 | }
73 |
74 | public int getPromptNum() {
75 | return promptNum;
76 | }
77 |
78 | public void setPromptNum(int promptNum) {
79 | this.promptNum = promptNum;
80 | }
81 |
82 | public int getRefreshNum() {
83 | return refreshNum;
84 | }
85 |
86 | public void setRefreshNum(int refreshNum) {
87 | this.refreshNum = refreshNum;
88 | }
89 |
90 | public int getAddTimeNum() {
91 | return addTimeNum;
92 | }
93 |
94 | public void setAddTimeNum(int addTimeNum) {
95 | this.addTimeNum = addTimeNum;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/config/ModeCfg.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.config;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * 游戏模式,闯关模式,计时模式,任务模式等
8 | *
9 | * @author yzb
10 | *
11 | */
12 | public class ModeCfg {
13 |
14 | public ModeCfg(String modeName) {
15 | this.modeName = modeName;
16 | }
17 |
18 | public String getModeId() {
19 | return modeId;
20 | }
21 |
22 | public void setModeId(String modeId) {
23 | this.modeId = modeId;
24 | }
25 |
26 | public String getModeName() {
27 | return modeName;
28 | }
29 |
30 | public void setModeName(String modeName) {
31 | this.modeName = modeName;
32 | }
33 |
34 | public List getRankInfos() {
35 | return rankInfos;
36 | }
37 |
38 | private String modeId;
39 | private String modeName;
40 | private List rankInfos = new ArrayList();
41 | }
42 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/config/RankCfg.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.config;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | /**
8 | * 游戏等级信息
9 | *
10 | * @author yzb
11 | *
12 | */
13 | public class RankCfg implements Serializable {
14 |
15 | private static final long serialVersionUID = -5068249504885791712L;
16 |
17 | public RankCfg(String rankName) {
18 | this.rankName = rankName;
19 | }
20 |
21 | /**
22 | * 获取游戏等级下的关卡最高分只和
23 | *
24 | * @return
25 | */
26 | public int getRankScore() {
27 | int total = 0;
28 | for (LevelCfg levelCfg : LevelInfos) {
29 | total += levelCfg.getMaxScore();
30 | }
31 | return total;
32 | }
33 |
34 | public String getRankId() {
35 | return rankId;
36 | }
37 |
38 | public void setRankId(String rankId) {
39 | this.rankId = rankId;
40 | }
41 |
42 | public String getRankName() {
43 | return rankName;
44 | }
45 |
46 | public void setRankName(String rankName) {
47 | this.rankName = rankName;
48 | }
49 |
50 | public String getGameSkin() {
51 | return gameSkin;
52 | }
53 |
54 | public void setGameSkin(String gameSkin) {
55 | this.gameSkin = gameSkin;
56 | }
57 |
58 | public List getLevelInfos() {
59 | return LevelInfos;
60 | }
61 |
62 | public void setLevelInfos(List levelInfos) {
63 | LevelInfos = levelInfos;
64 | }
65 |
66 | public int getRankBackground() {
67 | return rankBackground;
68 | }
69 |
70 | public void setRankBackground(int rankBackground) {
71 | this.rankBackground = rankBackground;
72 | }
73 |
74 | private String rankId;
75 | private String rankName;
76 | private String gameSkin;
77 | private int rankBackground;
78 | private List LevelInfos = new ArrayList();
79 | }
80 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/map/BaseMap.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.map;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 | import java.util.List;
7 |
8 | /**
9 | * 游戏地图基类,处理地图模版和地图
10 | *
11 | * @author yzb
12 | *
13 | */
14 | public class BaseMap implements Serializable {
15 | private static final long serialVersionUID = 7379717910848419154L;
16 |
17 | protected BaseMap() {
18 | }
19 |
20 | protected BaseMap(int ySize, int xSize) {
21 | YSize = ySize;
22 | XSize = xSize;
23 | Data = new Byte[ySize][xSize];
24 | }
25 |
26 | /**
27 | * 随机重排
28 | */
29 | public void randomRefresh() {
30 | int index = 0;
31 | // 获取游戏块的值
32 | List array = new ArrayList();
33 | for (int i = 0; i < YSize; i++) {
34 | for (int j = 0; j < XSize; j++) {
35 | if (isRefresh(i, j)) {
36 | array.add(Data[i][j]);
37 | }
38 | }
39 | }
40 | // 随机打乱
41 | Collections.shuffle(array);
42 | // 重新赋值
43 | index = 0;
44 | for (int i = 0; i < YSize; i++) {
45 | for (int j = 0; j < XSize; j++) {
46 | if (isRefresh(i, j)) {
47 | Data[i][j] = array.get(index++);
48 | }
49 | }
50 | }
51 | }
52 |
53 | protected boolean isRefresh(int i, int j) {
54 | return true;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | StringBuilder strMap = new StringBuilder(String.valueOf(YSize) + "*" + String.valueOf(XSize) + "$");
60 | for (int i = 0; i < YSize; i++) {
61 | for (int j = 0; j < XSize; j++) {
62 | strMap.append(String.valueOf(Data[i][j]) + ",");
63 | }
64 | strMap.replace(strMap.length() - 1, strMap.length(), ";");
65 | }
66 | strMap.deleteCharAt(strMap.length() - 1);
67 | return strMap.toString();
68 | }
69 |
70 | protected int YSize;
71 | protected int XSize;
72 | protected Byte[][] Data;
73 | }
74 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/map/RandomMap.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.map;
2 |
3 | import com.znv.linkup.core.map.template.MapTemplate;
4 | import com.znv.linkup.core.map.template.RandomTemplate;
5 |
6 | /**
7 | * 随机地图类
8 | *
9 | * @author yzb
10 | *
11 | */
12 | public class RandomMap extends GameMap {
13 | private static final long serialVersionUID = -3788653825318577597L;
14 |
15 | public RandomMap(int rows, int cols) {
16 | this(new RandomTemplate(rows, cols));
17 | }
18 |
19 | public RandomMap(MapTemplate template) {
20 | super(template.YSize, template.XSize);
21 | Template = template;
22 |
23 | // 根据模板初始化游戏
24 | initTemplate();
25 |
26 | // 刷新重排
27 | randomRefresh();
28 | }
29 |
30 | private void initTemplate() {
31 | int index = 0;
32 | boolean even = false;
33 | // cardno 必须为偶数
34 | int blockNum = 2 * (YSize > XSize ? XSize - 2 : YSize - 2);
35 | Data = new Byte[YSize][XSize];
36 | for (int i = 0; i < YSize; i++) {
37 | for (int j = 0; j < XSize; j++) {
38 | if (Template.Data[i][j] > 0) {
39 | if (even) {
40 | Data[i][j] = (byte) (index++ % blockNum + 1);
41 | } else {
42 | Data[i][j] = (byte) (index % blockNum + 1);
43 | }
44 | even = !even;
45 | } else {
46 | Data[i][j] = Template.Data[i][j];
47 | }
48 | }
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/map/template/MapTemplate.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.map.template;
2 |
3 | import com.znv.linkup.core.GameSettings;
4 | import com.znv.linkup.core.map.BaseMap;
5 |
6 | /**
7 | * 地图模版类
8 | *
9 | * @author yzb
10 | *
11 | */
12 | public class MapTemplate extends BaseMap {
13 | private static final long serialVersionUID = -8030816635103999967L;
14 |
15 | protected MapTemplate() {
16 | }
17 |
18 | public MapTemplate(int ySize, int xSize) {
19 | this(ySize, xSize, 0, 0);
20 | }
21 |
22 | public MapTemplate(int ySize, int xSize, int empty, int obstacle) {
23 | super(ySize, xSize);
24 | this.EmptyCount = empty;
25 | this.ObstacleCount = obstacle;
26 | this.Data = new Byte[ySize][xSize];
27 |
28 | initTemplate();
29 | }
30 |
31 | protected void initTemplate() {
32 | for (int i = 0; i < YSize; i++) {
33 | for (int j = 0; j < XSize; j++) {
34 | if (i == 0 || i == YSize - 1 || j == 0 || j == XSize - 1) {
35 | Data[i][j] = GameSettings.GroundCardValue;
36 | } else {
37 | Data[i][j] = GameSettings.GameCardValue;
38 | }
39 | }
40 | }
41 | }
42 |
43 | @Override
44 | protected boolean isRefresh(int i, int j) {
45 | return Data[i][j] != GameSettings.GroundCardValue;
46 | }
47 |
48 | /**
49 | * 根据地图模版配置字符串解析出地图模版
50 | *
51 | * @param strMapTemp
52 | * 地图模版配置字符串
53 | * @return 地图模版
54 | */
55 | public static MapTemplate parse(String strMapTemp) {
56 | try {
57 | MapTemplate tpl = new MapTemplate();
58 | String map = strMapTemp;
59 | String[] data = map.split("\\$");
60 | String[] strnm = data[0].split("\\*");
61 | tpl.YSize = Integer.parseInt(strnm[0]);
62 | tpl.XSize = Integer.parseInt(strnm[1]);
63 | tpl.Data = new Byte[tpl.YSize][tpl.XSize];
64 | String[] rowData = data[1].split(";");
65 | String[] cellData = null;
66 | for (int i = 0; i < rowData.length; i++) {
67 | cellData = rowData[i].split(",");
68 | for (int j = 0; j < cellData.length; j++) {
69 | tpl.Data[i][j] = convertValue(Byte.parseByte(cellData[j]));
70 | }
71 | }
72 | return tpl;
73 | } catch (Exception ex) {
74 | ex.printStackTrace();
75 | }
76 | return null;
77 | }
78 |
79 | public static Byte convertValue(Byte bValue) {
80 | return (byte) (bValue > 0 ? 1 : (bValue < 0 ? bValue : 0));
81 | }
82 |
83 | protected int EmptyCount;
84 | protected int ObstacleCount;
85 | }
86 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/map/template/RandomTemplate.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.map.template;
2 |
3 | import com.znv.linkup.core.GameSettings;
4 |
5 | /**
6 | * 随机地图模版
7 | *
8 | * @author yzb
9 | *
10 | */
11 | public class RandomTemplate extends MapTemplate {
12 | private static final long serialVersionUID = -4260503758055093714L;
13 |
14 | public RandomTemplate(int ySize, int xSize) {
15 | super(ySize, xSize);
16 | }
17 |
18 | public RandomTemplate(int ySize, int xSize, int emptyCount, int obstacleCount) {
19 | super(ySize, xSize, emptyCount, obstacleCount);
20 | }
21 |
22 | @Override
23 | /**
24 | * 随机产生可以成功配对消除完成的地图模版
25 | */
26 | protected void initTemplate() {
27 | int empty = EmptyCount;
28 | int obstacle = ObstacleCount;
29 | // 必须保证 Rows * Colomns - EmptyCount - ObstacleCount 为偶数
30 | if (empty + obstacle < YSize * XSize) {
31 | for (int i = 0; i < YSize; i++) {
32 | for (int j = 0; j < XSize; j++) {
33 | if (i == 0 || i == YSize - 1 || j == 0 || j == XSize - 1) {
34 | Data[i][j] = GameSettings.GroundCardValue;
35 | } else {
36 | if (empty > 0) {
37 | Data[i][j] = GameSettings.EmptyCardValue;
38 | empty--;
39 | } else if (obstacle > 0) {
40 | Data[i][j] = GameSettings.ObstacleCardValue;
41 | obstacle--;
42 | } else {
43 | Data[i][j] = GameSettings.GameCardValue;
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
50 | // 随机排列
51 | randomRefresh();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/status/GameCombo.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.status;
2 |
3 | import com.znv.linkup.core.GameSettings;
4 |
5 | /**
6 | * 游戏连击处理
7 | *
8 | * @author yzb
9 | *
10 | */
11 | class GameCombo {
12 |
13 | public GameCombo() {
14 | this(null);
15 | }
16 |
17 | public GameCombo(IGameStatus listener) {
18 | combo = 0;
19 | preRemoveTime = System.currentTimeMillis();
20 | this.listener = listener;
21 | }
22 |
23 | public void clearCombo() {
24 | combo = 0;
25 | }
26 |
27 | public void addCombo() {
28 | combo++;
29 | }
30 |
31 | /**
32 | * 获取连击得分
33 | *
34 | * @return 连击奖励分数
35 | */
36 | public int getComboScore() {
37 | long curTime = System.currentTimeMillis();
38 | long span = curTime - preRemoveTime;
39 | // 毫秒数
40 | int diff = (int) span - GameSettings.ComboDelay;
41 | if (diff <= 0) {
42 | combo++;
43 | } else {
44 | combo = 1;
45 | }
46 | preRemoveTime = curTime;
47 | if (combo != 0) {
48 | if (listener != null) {
49 | listener.onCombo(combo);
50 | }
51 | if (combo % GameSettings.ComboMod == 0) {
52 | return getComboScore(combo);
53 | }
54 | }
55 | return 0;
56 | }
57 |
58 | /**
59 | * 根据连击数获取连击奖励分数
60 | *
61 | * @param combo
62 | * 连击数
63 | * @return 连击奖励分数
64 | */
65 | public static int getComboScore(int combo) {
66 | return combo * GameSettings.ComboScore;
67 | }
68 |
69 | public int getGameCombo() {
70 | return combo;
71 | }
72 |
73 | private long preRemoveTime;
74 | private int combo;
75 | private IGameStatus listener;
76 | }
77 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/status/GameScore.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.status;
2 |
3 | import com.znv.linkup.core.GameSettings;
4 | import com.znv.linkup.core.card.path.LinkInfo;
5 |
6 | /**
7 | * 游戏得分处理
8 | *
9 | * @author yzb
10 | *
11 | */
12 | class GameScore {
13 |
14 | public GameScore() {
15 | this(null);
16 | }
17 |
18 | public GameScore(IGameStatus listener) {
19 | gameScore = 0;
20 | this.listener = listener;
21 | if (listener != null) {
22 | listener.onScoreChanged(gameScore);
23 | }
24 | }
25 |
26 | public void addScore(int score) {
27 | this.gameScore += score;
28 | if (listener != null) {
29 | listener.onScoreChanged(gameScore);
30 | }
31 | }
32 |
33 | /**
34 | * 根据链路获取奖励分数
35 | *
36 | * @param linkInfo
37 | * 连接路径信息
38 | * @return 转弯奖励的分数
39 | */
40 | public int getCornerScore(LinkInfo linkInfo) {
41 | return (linkInfo.getLinkPieces().size() - 2) * GameSettings.CornerScore;
42 | }
43 |
44 | /**
45 | * 根据时间获取奖励分数
46 | *
47 | * @param gameTime
48 | * 游戏时间
49 | * @return
50 | */
51 | public int getRewardScore(int gameTime) {
52 | return gameTime * GameSettings.TimeScore;
53 | }
54 |
55 | public int getGameScore() {
56 | return gameScore;
57 | }
58 |
59 | private int gameScore;
60 | private IGameStatus listener;
61 | }
62 |
--------------------------------------------------------------------------------
/LinkupCore/src/com/znv/linkup/core/status/IGameStatus.java:
--------------------------------------------------------------------------------
1 | package com.znv.linkup.core.status;
2 |
3 | import com.znv.linkup.core.card.PiecePair;
4 |
5 | /**
6 | * 游戏状态处理
7 | *
8 | * @author yzb
9 | *
10 | */
11 | public interface IGameStatus {
12 |
13 | /**
14 | * 连击时的处理
15 | *
16 | * @param combo
17 | * 连击数
18 | */
19 | void onCombo(int combo);
20 |
21 | /**
22 | * 提示时的处理
23 | *
24 | * @param pair
25 | * 提示的卡片对
26 | */
27 | void onPrompt(PiecePair pair);
28 |
29 | /**
30 | * 取消提示的处理
31 | *
32 | * @param pair
33 | * 取消提示的卡片对
34 | */
35 | void onUnPrompt(PiecePair pair);
36 |
37 | /**
38 | * 刷新时的处理
39 | */
40 | void onRefresh();
41 |
42 | /**
43 | * 积分改变时的处理
44 | */
45 | void onScoreChanged(int gameScore);
46 |
47 | /**
48 | * 时间改变时的处理
49 | */
50 | void onTimeChanged(int gameTime);
51 |
52 | /**
53 | * 游戏失败时的处理
54 | */
55 | void onGameFail();
56 |
57 | /**
58 | * 游戏暂停时的处理
59 | */
60 | void onGamePause();
61 |
62 | /**
63 | * 游戏重新开始时的处理
64 | */
65 | void onGameResume();
66 |
67 | /**
68 | * 游戏胜利时的处理
69 | */
70 | void onGameWin();
71 | }
72 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csuyzb/AndroidLinkup/63205743e780656ab194833adf6a75cbd3160c16/README.md
--------------------------------------------------------------------------------
/release.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csuyzb/AndroidLinkup/63205743e780656ab194833adf6a75cbd3160c16/release.txt
--------------------------------------------------------------------------------
/screenshots/pet_180.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csuyzb/AndroidLinkup/63205743e780656ab194833adf6a75cbd3160c16/screenshots/pet_180.jpg
--------------------------------------------------------------------------------
/screenshots/star_180.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csuyzb/AndroidLinkup/63205743e780656ab194833adf6a75cbd3160c16/screenshots/star_180.jpg
--------------------------------------------------------------------------------
/screenshots/top_180.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csuyzb/AndroidLinkup/63205743e780656ab194833adf6a75cbd3160c16/screenshots/top_180.jpg
--------------------------------------------------------------------------------
/screenshots/welcome_180.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csuyzb/AndroidLinkup/63205743e780656ab194833adf6a75cbd3160c16/screenshots/welcome_180.jpg
--------------------------------------------------------------------------------