This commit is contained in:
xiekaidong 2023-04-07 11:24:27 +08:00
parent a4e1d82b24
commit 76ace3a065
23 changed files with 1353 additions and 95 deletions

View File

@ -10,6 +10,13 @@ local card = {
["hp_6"]=150, ["hp_6"]=150,
["hp_7"]=160, ["hp_7"]=160,
["hp_8"]=170, ["hp_8"]=170,
["hp_9"]=180,
["hp_10"]=190,
["hp_11"]=200,
["hp_12"]=210,
["hp_13"]=220,
["hp_14"]=230,
["hp_15"]=240,
["atk_1"]=100, ["atk_1"]=100,
["atk_2"]=110, ["atk_2"]=110,
["atk_3"]=120, ["atk_3"]=120,
@ -17,7 +24,14 @@ local card = {
["atk_5"]=140, ["atk_5"]=140,
["atk_6"]=150, ["atk_6"]=150,
["atk_7"]=160, ["atk_7"]=160,
["atk_8"]=170 ["atk_8"]=170,
["atk_9"]=180,
["atk_10"]=190,
["atk_11"]=200,
["atk_12"]=210,
["atk_13"]=220,
["atk_14"]=230,
["atk_15"]=240
}, },
[2]={ [2]={
["position"]=2, ["position"]=2,
@ -30,6 +44,13 @@ local card = {
["hp_6"]=150, ["hp_6"]=150,
["hp_7"]=160, ["hp_7"]=160,
["hp_8"]=170, ["hp_8"]=170,
["hp_9"]=180,
["hp_10"]=190,
["hp_11"]=200,
["hp_12"]=210,
["hp_13"]=220,
["hp_14"]=230,
["hp_15"]=240,
["atk_1"]=100, ["atk_1"]=100,
["atk_2"]=110, ["atk_2"]=110,
["atk_3"]=120, ["atk_3"]=120,
@ -37,7 +58,14 @@ local card = {
["atk_5"]=140, ["atk_5"]=140,
["atk_6"]=150, ["atk_6"]=150,
["atk_7"]=160, ["atk_7"]=160,
["atk_8"]=170 ["atk_8"]=170,
["atk_9"]=180,
["atk_10"]=190,
["atk_11"]=200,
["atk_12"]=210,
["atk_13"]=220,
["atk_14"]=230,
["atk_15"]=240
}, },
[3]={ [3]={
["position"]=4, ["position"]=4,
@ -50,6 +78,13 @@ local card = {
["hp_6"]=150, ["hp_6"]=150,
["hp_7"]=160, ["hp_7"]=160,
["hp_8"]=170, ["hp_8"]=170,
["hp_9"]=180,
["hp_10"]=190,
["hp_11"]=200,
["hp_12"]=210,
["hp_13"]=220,
["hp_14"]=230,
["hp_15"]=240,
["atk_1"]=100, ["atk_1"]=100,
["atk_2"]=110, ["atk_2"]=110,
["atk_3"]=120, ["atk_3"]=120,
@ -57,7 +92,14 @@ local card = {
["atk_5"]=140, ["atk_5"]=140,
["atk_6"]=150, ["atk_6"]=150,
["atk_7"]=160, ["atk_7"]=160,
["atk_8"]=170 ["atk_8"]=170,
["atk_9"]=180,
["atk_10"]=190,
["atk_11"]=200,
["atk_12"]=210,
["atk_13"]=220,
["atk_14"]=230,
["atk_15"]=240
}, },
[4]={ [4]={
["position"]=5, ["position"]=5,
@ -70,6 +112,13 @@ local card = {
["hp_6"]=150, ["hp_6"]=150,
["hp_7"]=160, ["hp_7"]=160,
["hp_8"]=170, ["hp_8"]=170,
["hp_9"]=180,
["hp_10"]=190,
["hp_11"]=200,
["hp_12"]=210,
["hp_13"]=220,
["hp_14"]=230,
["hp_15"]=240,
["atk_1"]=100, ["atk_1"]=100,
["atk_2"]=110, ["atk_2"]=110,
["atk_3"]=120, ["atk_3"]=120,
@ -77,7 +126,14 @@ local card = {
["atk_5"]=140, ["atk_5"]=140,
["atk_6"]=150, ["atk_6"]=150,
["atk_7"]=160, ["atk_7"]=160,
["atk_8"]=170 ["atk_8"]=170,
["atk_9"]=180,
["atk_10"]=190,
["atk_11"]=200,
["atk_12"]=210,
["atk_13"]=220,
["atk_14"]=230,
["atk_15"]=240
}, },
[5]={ [5]={
["position"]=1, ["position"]=1,
@ -90,6 +146,13 @@ local card = {
["hp_6"]=150, ["hp_6"]=150,
["hp_7"]=160, ["hp_7"]=160,
["hp_8"]=170, ["hp_8"]=170,
["hp_9"]=180,
["hp_10"]=190,
["hp_11"]=200,
["hp_12"]=210,
["hp_13"]=220,
["hp_14"]=230,
["hp_15"]=240,
["atk_1"]=100, ["atk_1"]=100,
["atk_2"]=110, ["atk_2"]=110,
["atk_3"]=120, ["atk_3"]=120,
@ -97,7 +160,14 @@ local card = {
["atk_5"]=140, ["atk_5"]=140,
["atk_6"]=150, ["atk_6"]=150,
["atk_7"]=160, ["atk_7"]=160,
["atk_8"]=170 ["atk_8"]=170,
["atk_9"]=180,
["atk_10"]=190,
["atk_11"]=200,
["atk_12"]=210,
["atk_13"]=220,
["atk_14"]=230,
["atk_15"]=240
}, },
[6]={ [6]={
["position"]=3, ["position"]=3,
@ -110,6 +180,13 @@ local card = {
["hp_6"]=225, ["hp_6"]=225,
["hp_7"]=240, ["hp_7"]=240,
["hp_8"]=255, ["hp_8"]=255,
["hp_9"]=270,
["hp_10"]=285,
["hp_11"]=300,
["hp_12"]=315,
["hp_13"]=330,
["hp_14"]=345,
["hp_15"]=360,
["atk_1"]=150, ["atk_1"]=150,
["atk_2"]=165, ["atk_2"]=165,
["atk_3"]=180, ["atk_3"]=180,
@ -117,7 +194,14 @@ local card = {
["atk_5"]=210, ["atk_5"]=210,
["atk_6"]=225, ["atk_6"]=225,
["atk_7"]=240, ["atk_7"]=240,
["atk_8"]=255 ["atk_8"]=255,
["atk_9"]=270,
["atk_10"]=285,
["atk_11"]=300,
["atk_12"]=315,
["atk_13"]=330,
["atk_14"]=345,
["atk_15"]=360
}, },
[7]={ [7]={
["position"]=2, ["position"]=2,
@ -130,6 +214,13 @@ local card = {
["hp_6"]=225, ["hp_6"]=225,
["hp_7"]=240, ["hp_7"]=240,
["hp_8"]=255, ["hp_8"]=255,
["hp_9"]=270,
["hp_10"]=285,
["hp_11"]=300,
["hp_12"]=315,
["hp_13"]=330,
["hp_14"]=345,
["hp_15"]=360,
["atk_1"]=150, ["atk_1"]=150,
["atk_2"]=165, ["atk_2"]=165,
["atk_3"]=180, ["atk_3"]=180,
@ -137,7 +228,14 @@ local card = {
["atk_5"]=210, ["atk_5"]=210,
["atk_6"]=225, ["atk_6"]=225,
["atk_7"]=240, ["atk_7"]=240,
["atk_8"]=255 ["atk_8"]=255,
["atk_9"]=270,
["atk_10"]=285,
["atk_11"]=300,
["atk_12"]=315,
["atk_13"]=330,
["atk_14"]=345,
["atk_15"]=360
}, },
[8]={ [8]={
["position"]=4, ["position"]=4,
@ -150,6 +248,13 @@ local card = {
["hp_6"]=225, ["hp_6"]=225,
["hp_7"]=240, ["hp_7"]=240,
["hp_8"]=255, ["hp_8"]=255,
["hp_9"]=270,
["hp_10"]=285,
["hp_11"]=300,
["hp_12"]=315,
["hp_13"]=330,
["hp_14"]=345,
["hp_15"]=360,
["atk_1"]=150, ["atk_1"]=150,
["atk_2"]=165, ["atk_2"]=165,
["atk_3"]=180, ["atk_3"]=180,
@ -157,7 +262,14 @@ local card = {
["atk_5"]=210, ["atk_5"]=210,
["atk_6"]=225, ["atk_6"]=225,
["atk_7"]=240, ["atk_7"]=240,
["atk_8"]=255 ["atk_8"]=255,
["atk_9"]=270,
["atk_10"]=285,
["atk_11"]=300,
["atk_12"]=315,
["atk_13"]=330,
["atk_14"]=345,
["atk_15"]=360
}, },
[9]={ [9]={
["position"]=5, ["position"]=5,
@ -170,6 +282,13 @@ local card = {
["hp_6"]=225, ["hp_6"]=225,
["hp_7"]=240, ["hp_7"]=240,
["hp_8"]=255, ["hp_8"]=255,
["hp_9"]=270,
["hp_10"]=285,
["hp_11"]=300,
["hp_12"]=315,
["hp_13"]=330,
["hp_14"]=345,
["hp_15"]=360,
["atk_1"]=150, ["atk_1"]=150,
["atk_2"]=165, ["atk_2"]=165,
["atk_3"]=180, ["atk_3"]=180,
@ -177,7 +296,14 @@ local card = {
["atk_5"]=210, ["atk_5"]=210,
["atk_6"]=225, ["atk_6"]=225,
["atk_7"]=240, ["atk_7"]=240,
["atk_8"]=255 ["atk_8"]=255,
["atk_9"]=270,
["atk_10"]=285,
["atk_11"]=300,
["atk_12"]=315,
["atk_13"]=330,
["atk_14"]=345,
["atk_15"]=360
}, },
[10]={ [10]={
["position"]=1, ["position"]=1,
@ -190,6 +316,13 @@ local card = {
["hp_6"]=225, ["hp_6"]=225,
["hp_7"]=240, ["hp_7"]=240,
["hp_8"]=255, ["hp_8"]=255,
["hp_9"]=270,
["hp_10"]=285,
["hp_11"]=300,
["hp_12"]=315,
["hp_13"]=330,
["hp_14"]=345,
["hp_15"]=360,
["atk_1"]=150, ["atk_1"]=150,
["atk_2"]=165, ["atk_2"]=165,
["atk_3"]=180, ["atk_3"]=180,
@ -197,7 +330,14 @@ local card = {
["atk_5"]=210, ["atk_5"]=210,
["atk_6"]=225, ["atk_6"]=225,
["atk_7"]=240, ["atk_7"]=240,
["atk_8"]=255 ["atk_8"]=255,
["atk_9"]=270,
["atk_10"]=285,
["atk_11"]=300,
["atk_12"]=315,
["atk_13"]=330,
["atk_14"]=345,
["atk_15"]=360
} }
} }
local config = { local config = {

View File

@ -137,6 +137,10 @@ local card_level = {
2500, 2500,
10000 10000
}, },
["cost_3"]={
1500,
10000
},
["cost_4"]={ ["cost_4"]={
320, 320,
10000 10000
@ -147,6 +151,10 @@ local card_level = {
3000, 3000,
10000 10000
}, },
["cost_3"]={
2000,
10000
},
["cost_4"]={ ["cost_4"]={
640, 640,
10000 10000
@ -157,6 +165,10 @@ local card_level = {
4000, 4000,
10000 10000
}, },
["cost_3"]={
3000,
10000
},
["cost_4"]={ ["cost_4"]={
1000, 1000,
10000 10000
@ -167,6 +179,10 @@ local card_level = {
5000, 5000,
10000 10000
}, },
["cost_3"]={
4000,
10000
},
["cost_4"]={ ["cost_4"]={
1500, 1500,
10000 10000

9
lua/app/config/const.lua Normal file
View File

@ -0,0 +1,9 @@
local const = {
["element_combo"]={
["value"]=2
}
}
local config = {
data=const,count=1
}
return config

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6d8697f998fe2b04798c1c18a2b6eb68
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,7 @@
local skill_box = {
}
local config = {
data=skill_box,count=0
}
return config

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b0e5e92c84e063f43b56758577128e37
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,69 @@
local skill_card = {
[10]={
["method"]=2
},
[11]={
["method"]=2
},
[20]={
["method"]=2
},
[21]={
["method"]=2
},
[22]={
["method"]=2
},
[30]={
["method"]=2
},
[40]={
["method"]=2
},
[41]={
["method"]=2
},
[50]={
["method"]=2
},
[51]={
["method"]=2
},
[60]={
["method"]=2
},
[61]={
["method"]=2
},
[70]={
["method"]=1
},
[71]={
["method"]=1
},
[80]={
["method"]=2
},
[81]={
["method"]=2
},
[90]={
["method"]=2
},
[91]={
["method"]=2
},
[100]={
["method"]=2
},
[101]={
},
[102]={
["method"]=2
}
}
local config = {
data=skill_card,count=21
}
return config

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: af9637d329b3bfa4cb0824f4e5a51bae
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,7 @@
local skill_rogue = {
}
local config = {
data=skill_rogue,count=0
}
return config

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 058cd600efafbe74c8af712668807a8d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

835
lua/app/config/stage.lua Normal file
View File

@ -0,0 +1,835 @@
local stage = {
[1]={
["board"]={
{
1,
0
},
{
1,
0
},
{
0,
3
},
{
0,
4
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
2
},
{
0,
5
},
{
0,
2
},
{
0,
2
},
{
0,
4
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
3
},
{
0,
3
},
{
0,
3
},
{
0,
5
},
{
1,
0
},
{
1,
0
},
{
0,
2
},
{
0,
2
},
{
0,
4
},
{
0,
5
},
{
0,
4
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
3
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
}
},
["control_element"]={
3,
2,
3,
3,
4,
5,
5
}
},
[2]={
["board"]={
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
3
},
{
0,
1
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
3
},
{
0,
5
},
{
0,
1
},
{
0,
1
},
{
0,
5
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
3
},
{
0,
5
},
{
0,
3
},
{
0,
5
},
{
1,
0
},
{
1,
0
},
{
0,
1
},
{
0,
1
},
{
0,
3
},
{
0,
4
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
5
},
{
0,
5
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
1,
0
},
{
1,
0
},
{
1,
0
}
},
["control_element"]={
1,
1,
3,
5,
1,
4,
3,
1,
1
}
},
[3]={
["board"]={
{
1,
0
},
{
1,
0
},
{
0,
1
},
{
0,
5
},
{
0,
1
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
5
},
{
0,
4
},
{
0,
1
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
0,
3
},
{
0,
1
},
{
1,
0
},
{
0,
4
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
0,
1
},
{
0,
3
},
{
1,
0
},
{
0,
1
},
{
0,
1
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
1
},
{
1,
0
},
{
0,
3
},
{
0,
5
},
{
1,
0
},
{
1,
0
},
{
0,
3
},
{
0,
3
},
{
0,
1
},
{
0,
3
},
{
0,
5
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
4
},
{
0,
1
},
{
0,
4
},
{
1,
0
},
{
1,
0
}
},
["control_element"]={
3,
1,
5,
3
}
},
[4]={
["board"]={
{
1,
0
},
{
0,
3
},
{
0,
5
},
{
0,
3
},
{
0,
5
},
{
0,
1
},
{
1,
0
},
{
1,
0
},
{
0,
5
},
{
0,
1
},
{
0,
3
},
{
0,
1
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
0,
5
},
{
0,
1
},
{
0,
3
},
{
0,
5
},
{
0,
2
},
{
1,
0
},
{
0,
5
},
{
0,
3
},
{
0,
2
},
{
0,
3
},
{
0,
2
},
{
0,
3
},
{
0,
2
},
{
1,
0
},
{
0,
3
},
{
0,
5
},
{
0,
3
},
{
0,
1
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
2
},
{
0,
5
},
{
0,
1
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
1,
0
},
{
0,
3
},
{
1,
0
},
{
1,
0
},
{
1,
0
}
},
["control_element"]={
0
}
}
}
local config = {
data=stage,count=4
}
return config

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c74f4c0846956944c8e8c94b47d5ee1a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -9,9 +9,13 @@ local struct = {
["parameter2"]="id:int", ["parameter2"]="id:int",
["parameter3"]="num:int", ["parameter3"]="num:int",
["parameter4"]="weight:int" ["parameter4"]="weight:int"
},
["boardrange"]={
["parameter1"]="type:int",
["parameter2"]="range:int"
} }
} }
local config = { local config = {
data=struct,count=2 data=struct,count=3
} }
return config return config

View File

@ -8,7 +8,15 @@ BattleConst.ELIMINATION_MIN_COUNT = 2
BattleConst.GRID_STEP_H = 97 BattleConst.GRID_STEP_H = 97
BattleConst.ROW_STEP = 10 BattleConst.ROW_STEP = 10
BattleConst.ONE_STEP_TIME = 0.2 BattleConst.ONE_STEP_TIME = 0.2
BattleConst.ELEMENT_TYPE_COUNT = 5
BattleConst.ELEMENT_WIGHT = 100
BattleConst.MAX_ELEMENT_WIGHT = 500
BattleConst.BATTLE_TYPE = {
STAGE = 1,
}
---- 格子类型
BattleConst.GRID_TYPE = { BattleConst.GRID_TYPE = {
EMPTY = 0, EMPTY = 0,
OBSTACLE = 1, OBSTACLE = 1,
@ -18,6 +26,28 @@ BattleConst.GRID_TYPE = {
ICE = 5, ICE = 5,
} }
---- 周围格子消除一次后会变成什么格子
BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = {
[BattleConst.GRID_TYPE.SNOW_BOX] = {BattleConst.GRID_TYPE.EMPTY},
[BattleConst.GRID_TYPE.SOLID_SNOW] = {BattleConst.GRID_TYPE.SNOW_BOX},
[BattleConst.GRID_TYPE.ICE] = {BattleConst.GRID_TYPE.EMPTY},
}
---- 不可下落的格子类型
BattleConst.CANT_FALL_GRID_TYPE = {
[BattleConst.GRID_TYPE.VINES] = true,
[BattleConst.GRID_TYPE.ICE] = true,
}
---- 不可链接的格子类型
BattleConst.CANT_LINK_GRID_TYPE = {
[BattleConst.GRID_TYPE.OBSTACLE] = true,
[BattleConst.GRID_TYPE.SNOW_BOX] = true,
[BattleConst.GRID_TYPE.SOLID_SNOW] = true,
[BattleConst.GRID_TYPE.ICE] = true,
}
---- 元素类型
BattleConst.ELEMENT_TYPE = { BattleConst.ELEMENT_TYPE = {
RED = 1, RED = 1,
YELLOW = 2, YELLOW = 2,

View File

@ -1,8 +1,12 @@
local BattleManager = class("BattleManager", BaseModule) local BattleManager = class("BattleManager", BaseModule)
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
local BATTLE_CONTROLLER_BASE = "app/module/battle/controller/battle_controller" local BATTLE_CONTROLLER_BASE = "app/module/battle/controller/battle_controller"
local BATTLE_CONTROLLER = {}
local BATTLE_CONTROLLER = {
[BattleConst.BATTLE_TYPE.STAGE] = "app/module/battle/controller/battle_controller_stage"
}
function BattleManager:getPosInfo(posId) function BattleManager:getPosInfo(posId)
local posInfo = GConst.BattleConst.GRID_POS[posId] local posInfo = GConst.BattleConst.GRID_POS[posId]
@ -23,7 +27,7 @@ end
function BattleManager:getElementIcon(elementType) function BattleManager:getElementIcon(elementType)
local icon = GConst.BattleConst.ELEMENT_ICON[elementType] local icon = GConst.BattleConst.ELEMENT_ICON[elementType]
if not icon then if not icon then
return GConst.ATLAS_PATH.COMMON, "common_algha" return GConst.ATLAS_PATH.COMMON, "common_alpha"
end end
return GConst.ATLAS_PATH.BATTLE, icon return GConst.ATLAS_PATH.BATTLE, icon
end end
@ -31,7 +35,7 @@ end
function BattleManager:getGridTypeIcon(elementType) function BattleManager:getGridTypeIcon(elementType)
local icon = GConst.BattleConst.ELEMENT_ICON[elementType] local icon = GConst.BattleConst.ELEMENT_ICON[elementType]
if not icon then if not icon then
return GConst.ATLAS_PATH.COMMON, "common_algha" return GConst.ATLAS_PATH.COMMON, "common_alpha"
end end
return GConst.ATLAS_PATH.BATTLE, icon return GConst.ATLAS_PATH.BATTLE, icon
end end
@ -73,16 +77,16 @@ function BattleManager:getPosRC(posId)
return BattleConst.POS_ID_2_RC[posId] return BattleConst.POS_ID_2_RC[posId]
end end
function BattleManager:playBattle(params, returnFunc) function BattleManager:playBattle(params, battleType, returnFunc)
if self.battleController then -- 同一时间只能有一场战斗 if self.battleController then -- 同一时间只能有一场战斗
self:clear() self:clear()
end end
self.returnFunc = returnFunc self.returnFunc = returnFunc
UIManager:stopCurrentBGM() UIManager:stopCurrentBGM()
self:_play(params) self:_play(params, battleType)
end end
function BattleManager:_play(params) function BattleManager:_play(params, battleType)
local controllerPath = BATTLE_CONTROLLER[battleType] or BATTLE_CONTROLLER_BASE local controllerPath = BATTLE_CONTROLLER[battleType] or BATTLE_CONTROLLER_BASE
self.battleController = require(controllerPath):create() self.battleController = require(controllerPath):create()
self.battleController:init(params) self.battleController:init(params)

View File

@ -3,20 +3,37 @@ local BattleController = class("BattleController")
local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
-- *************各个子模块的战斗需要重写的方法 START*************
function BattleController:getInitBoard()
return {}
end
function BattleController:getFixedRandomGrid()
return {}
end
-- 战斗对应的ui -- 战斗对应的ui
function BattleController:getBattleUIPath() function BattleController:getBattleUIPath()
return "app/ui/battle/battle_ui" return "app/ui/battle/battle_ui"
end end
-- 战斗结束
function BattleController:controllBattleEnd()
end
-- 不同模块的战斗需要初始化的东西
function BattleController:initOther()
end
-- *************各个子模块的战斗需要重写的方法 START*************
function BattleController:ctor() function BattleController:ctor()
end end
function BattleController:init(params) function BattleController:init(params)
params = params or {} params = params or {}
self.initGridList = params.initGridList or {} DataManager.BattleData:init(self:getInitBoard())
self.randomGridList = params.randomGridList or {}
DataManager.BattleData:init()
UIManager:closeAllUI() UIManager:closeAllUI()
self.battleUI = UIManager:showUI(self:getBattleUIPath()) self.battleUI = UIManager:showUI(self:getBattleUIPath())
@ -75,16 +92,45 @@ function BattleController:onTouchEvent(eventType, posId)
table.insert(cellList, entity:getCell()) table.insert(cellList, entity:getCell())
end end
self.battleUI:eliminationAni(cellList, function() self.battleUI:eliminationAni(cellList, function()
for _, posId in ipairs(sequence) do self:onEliminationAniOver()
local entity = DataManager.BattleData:getGridEntity(posId)
entity:setIsIdle(true)
end
self:fillBoard()
DataManager.BattleData:clearGridSequence()
end) end)
end end
end end
function BattleController:onEliminationAniOver()
local sequence = DataManager.BattleData:getGridSequence()
local count = #sequence
if count < BattleConst.ELIMINATION_MIN_COUNT then
return
end
local boomGridIds = {}
local eliminationPosIds = {}
for _, posId in ipairs(sequence) do
local outline = BattleConst.GRID_OUT_LINE_POS_ID[posId]
for aroundPosId, _ in pairs(outline) do
boomGridIds[aroundPosId] = true
end
local entity = DataManager.BattleData:getGridEntity(posId)
entity:setIsIdle(true)
eliminationPosIds[posId] = true
end
for posId, status in pairs(boomGridIds) do
if not eliminationPosIds[posId] then
local entity = DataManager.BattleData:getGridEntity(posId)
if entity then
entity:addAroundEliminationCount()
end
end
end
DataManager.BattleData:clearGridSequence()
self:fillBoard()
end
function BattleController:fillBoard() function BattleController:fillBoard()
-- todo临时暴力求解 -- todo临时暴力求解
local pathMap = {} local pathMap = {}
@ -180,8 +226,33 @@ function BattleController:fillThisPos(posId, columnCount)
end end
function BattleController:getRandomGridInfo() function BattleController:getRandomGridInfo()
if not self.fixedRandomList then
self.fixedRandomList = {}
for _, elementType in ipairs(self:getFixedRandomGrid()) do
table.insert(self.fixedRandomList, elementType)
end
end
local gridType = 0 local gridType = 0
local elementType = math.random(1, 4) local elementType
if self.fixedRandomList[1] then
elementType = table.remove(self.fixedRandomList, 1)
else
local map = DataManager.BattleData:getElementTypeMap()
local indexs = {}
local typeList = {}
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
local weight = ((map[typeNum] or 0) + 1) * BattleConst.ELEMENT_WIGHT
if weight > BattleConst.MAX_ELEMENT_WIGHT then
weight = BattleConst.MAX_ELEMENT_WIGHT
end
table.insert(indexs, weight)
table.insert(typeList, typeNum)
end
local index = GFunc.getRandomIndex(indexs)
elementType = typeList[index]
end
return {gridType = gridType, elementType = elementType} return {gridType = gridType, elementType = elementType}
end end

View File

@ -0,0 +1,15 @@
local BattleController = require "app/module/battle/controller/battle_controller"
local BattleControllerStage = class("BattleControllerStage", BattleController)
function BattleControllerStage:getInitBoard()
local config = ConfigManager:getConfig("stage")[1]
return config.board
end
function BattleControllerStage:getFixedRandomGrid()
local config = ConfigManager:getConfig("stage")[1]
return config.control_element
end
return BattleControllerStage

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c95a0ad0ae5e4a74dac2537712340fa8
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -4,7 +4,7 @@ local MaincityManager = class("MaincityManager", BaseModule)
function MaincityManager:showMainCityUI(isFirstEnter, targetIndex) function MaincityManager:showMainCityUI(isFirstEnter, targetIndex)
-- local uiObj = UIManager:showUI(UIManager.UI_PATH.MAINCITY_UI, {isFirstEnter = isFirstEnter, targetIndex = targetIndex}) -- local uiObj = UIManager:showUI(UIManager.UI_PATH.MAINCITY_UI, {isFirstEnter = isFirstEnter, targetIndex = targetIndex})
-- return uiObj -- return uiObj
ModuleManager.BattleManager:playBattle() ModuleManager.BattleManager:playBattle(nil, GConst.BattleConst.BATTLE_TYPE.STAGE)
end end
-- 从登录界面第一次进入主城 -- 从登录界面第一次进入主城

View File

@ -64,6 +64,10 @@ function BattleUI:onInitGridCellOver()
self.battleController:onTouchEvent(eventType, entity:getPosId()) self.battleController:onTouchEvent(eventType, entity:getPosId())
end end
end) end)
cell:unBindAll()
cell:bind(entity, "isDirty", function()
cell:refresh(entity)
end)
local pos = entity:getPos() local pos = entity:getPos()
cell:getBaseObject():setAnchoredPosition(pos.x, pos.y) cell:getBaseObject():setAnchoredPosition(pos.x, pos.y)
entity:setCell(cell) entity:setCell(cell)
@ -114,7 +118,6 @@ function BattleUI:fallGrid(listInfo)
local cell = entity:getCell() local cell = entity:getCell()
local posId = entity:getPosId() local posId = entity:getPosId()
if cell then if cell then
cell:refresh(entity)
local gameObject = cell:getGameObject() local gameObject = cell:getGameObject()
gameObject.name = "grid_cell_" .. posId gameObject.name = "grid_cell_" .. posId
if cell.fallSeq then if cell.fallSeq then

View File

@ -10,6 +10,9 @@ function GridCell:refresh(gridEntity, curElement)
uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(curElement and curElement ~= gridEntity:getElementType()) uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(curElement and curElement ~= gridEntity:getElementType())
uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isCantFallType()) uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isCantFallType())
--- 测试代码
uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount())
end end
function GridCell:addTouchListener(func) function GridCell:addTouchListener(func)

View File

@ -3,62 +3,10 @@ local BattleData = class("BattleData", BaseData)
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity" local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity"
local TEST_INIT = { function BattleData:init(board)
{1, 2},
{1, 4},
{1, 1},
{0, 4},
{0, 3},
{0, 3},
{0, 3},
{1, 4},
{1, 3},
{0, 3},
{0, 1},
{0, 4},
{0, 2},
{0, 1},
{1, 1},
{1, 4},
{1, 2},
{1, 3},
{0, 4},
{0, 4},
{1, 4},
{0, 4},
{0, 2},
{1, 4},
{0, 4},
{1, 1},
{0, 3},
{1, 2},
{0, 1},
{0, 1},
{0, 4},
{1, 4},
{0, 3},
{0, 4},
{1, 3},
{1, 1},
{0, 4},
{1, 3},
{0, 3},
{1, 2},
{1, 1},
{0, 4},
{1, 2},
{0, 4},
{0, 3},
{1, 3},
{1, 4},
{0, 4},
{0, 4},
}
function BattleData:init(data)
self:clear() self:clear()
for i, info in ipairs(TEST_INIT) do for i, info in ipairs(board) do
local r = 1 local r = 1
local c = 1 local c = 1
local zheng = i // BattleConst.ROW_COUNT local zheng = i // BattleConst.ROW_COUNT
@ -78,6 +26,9 @@ function BattleData:init(data)
elementType = info[2] elementType = info[2]
} }
self.gridEntities[data.posId] = BATTLE_GRID_ENTITY:create(data) self.gridEntities[data.posId] = BATTLE_GRID_ENTITY:create(data)
if self.gridEntities[data.posId]:canLink() then
self.elementTypeMap[data.elementType] = (self.elementTypeMap[data.elementType] or 0) + 1
end
end end
end end
@ -85,6 +36,11 @@ function BattleData:clear()
self:clearGridSequence() self:clearGridSequence()
self.gridEntities = {} self.gridEntities = {}
self.elementTypeMap = {} -- 同元素得格子数量
end
function BattleData:getElementTypeMap()
return self.elementTypeMap
end end
function BattleData:getGridSequence() function BattleData:getGridSequence()
@ -146,12 +102,23 @@ function BattleData:setGridInfo(posId, gridInfo)
return return
end end
if entity:canLink() then
local elementType = entity:getElementType()
self.elementTypeMap[elementType] = (self.elementTypeMap[elementType] or 0) - 1
if self.elementTypeMap[elementType] < 0 then
self.elementTypeMap[elementType] = 0
end
end
if gridInfo.gridType then if gridInfo.gridType then
entity:setGridType(gridInfo.gridType) entity:setGridType(gridInfo.gridType)
end end
if gridInfo.elementType then if gridInfo.elementType then
entity:setElementType(gridInfo.elementType) entity:setElementType(gridInfo.elementType)
if entity:canLink() then
self.elementTypeMap[gridInfo.elementType] = (self.elementTypeMap[gridInfo.elementType] or 0) + 1
end
end end
end end

View File

@ -1,11 +1,17 @@
local BattleGridEntity = class("BattleGridEntity", BaseData) local BattleGridEntity = class("BattleGridEntity", BaseData)
local BattleConst = GConst.BattleConst
function BattleGridEntity:ctor(data) function BattleGridEntity:ctor(data)
self.posId = data.posId or 0 self.posId = data.posId or 0
self.gridType = data.gridType or GConst.BattleConst.GRID_TYPE.EMPTY self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY
self.elementType = data.elementType or GConst.BattleConst.ELEMENT_TYPE.RED self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED
self.eliminationCount = data.eliminationCount or 0 -- 周围消除次数 self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数
self.isIdle = false self.isIdle = false
self.data.isDirty = false
end
function BattleGridEntity:setDirty()
self.data.isDirty = not self.data.isDirty
end end
function BattleGridEntity:getPosId() function BattleGridEntity:getPosId()
@ -25,11 +31,22 @@ function BattleGridEntity:getElementType()
end end
function BattleGridEntity:isCantFallType() function BattleGridEntity:isCantFallType()
return self.gridType == GConst.BattleConst.GRID_TYPE.OBSTACLE return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false
end end
function BattleGridEntity:getEliminationCount() function BattleGridEntity:getAroundEliminationCount()
return self.eliminationCount return self.aroundEliminationCount
end
function BattleGridEntity:addAroundEliminationCount(count)
count = count or 1
self.aroundEliminationCount = self.aroundEliminationCount + count
local gridTypeList = BattleConst.AROUND_ELIMINATION_TO_EMPTY_TYPE_COUNT[self.gridType]
if gridTypeList and gridTypeList[self.aroundEliminationCount] then
self:setGridType(gridTypeList[self.aroundEliminationCount])
self.aroundEliminationCount = self.aroundEliminationCount - 1
end
self:setDirty()
end end
function BattleGridEntity:getPos() function BattleGridEntity:getPos()
@ -50,15 +67,13 @@ end
function BattleGridEntity:setIsIdle(isIdle) function BattleGridEntity:setIsIdle(isIdle)
self.isIdle = isIdle == true self.isIdle = isIdle == true
if self.isIdle then
self.aroundEliminationCount = 0
end
end end
function BattleGridEntity:canLink() function BattleGridEntity:canLink()
if self:isCantFallType() then return not BattleConst.CANT_LINK_GRID_TYPE[self.gridType]
return false
end
-- 其他类型的一些判定
return true
end end
function BattleGridEntity:addPath(singlePath) function BattleGridEntity:addPath(singlePath)
@ -79,10 +94,13 @@ end
function BattleGridEntity:setGridType(gridType) function BattleGridEntity:setGridType(gridType)
self.gridType = gridType self.gridType = gridType
self.aroundEliminationCount = 0
self:setDirty()
end end
function BattleGridEntity:setElementType(elementType) function BattleGridEntity:setElementType(elementType)
self.elementType = elementType self.elementType = elementType
self:setDirty()
end end
return BattleGridEntity return BattleGridEntity