实现弹出对话框选择武将

//武将名称列表
string array wujiang_name
//武将名称对应的id列表
integer array wujiang_id
//技能名称1,对应udg_omg1
string array jn_name1
//技能名称2,对应udg_omg2
string array jn_name2
//技能名称3,对应udg_omg3
string array jn_name3
//技能名称4,对应udg_omg4
string array jn_name4
//5个元素组成一个武将。第1,2,3,4,5个元素分别对应武将id,技能1,技能2,技能3,技能4
integer array suijiwujiang
//每个玩家待选武将数量

integer selNum=3

//技能id列表

integer array udg_omg1
integer array udg_omg2
integer array udg_omg3
integer array udg_omg4


//初始化待选武将数组
function init_array_suijiwujiang takes nothing returns nothing
local integer suijiwujiang_maxLength = 10 * selNum
local integer idx = 0
//suijiwujiang ,第1,2,3,4,5个元素分别对应武将id,技能1,技能2,技能3,技能4。最大值分别为:40,39,34,29,32
loop
//随机武将
set suijiwujiang[5*idx+1] = GetRandomInt(1,40)
//随机技能1
set suijiwujiang[5*idx+2] = GetRandomInt(1,39)
//随机技能2
set suijiwujiang[5*idx+3] = GetRandomInt(1,34)
//随机技能3
set suijiwujiang[5*idx+4] = GetRandomInt(1,29)
//随机技能4
set suijiwujiang[5*idx+5] = GetRandomInt(1,32)

//bug技能校验
//动地跺(张飞,典韦)/鬼神之力(吕布)+卧龙光线(诸葛亮)=无限光线
loop
exitwhen suijiwujiang[5*idx+5] != 23  //技能4不是卧龙光线
exitwhen not (suijiwujiang[5*idx+2] == 18 or suijiwujiang[5*idx+3] == 31) //没有动地跺和鬼神之力
set suijiwujiang[5*idx+5] = GetRandomInt(1,32)
endloop
//小分身(太史慈)+大分身(魏延)=无限分身
loop
exitwhen suijiwujiang[5*idx+5] != 31  //技能4不是9分身
exitwhen suijiwujiang[5*idx+3] != 33 //技能2不是影分身
set suijiwujiang[5*idx+5] = GetRandomInt(1,32)
endloop
//动地跺(张飞,典韦)/鬼神之力(吕布)+天崩地裂(徐庶)=无限天崩地裂
loop
exitwhen suijiwujiang[5*idx+5] != 15  //技能4不是天崩地裂
exitwhen not (suijiwujiang[5*idx+2] == 18 or suijiwujiang[5*idx+3] == 31) //没有动地跺和鬼神之力
set suijiwujiang[5*idx+5] = GetRandomInt(1,32)
endloop
//白热(许褚)/狂战士(张飞)+无双(赵云)=30秒白热
loop
exitwhen suijiwujiang[5*idx+2] != 29  //技能1不是白热
exitwhen not (suijiwujiang[5*idx+3] == 18 or suijiwujiang[5*idx+5] == 29) //没有狂战士(张飞)和无双(赵云)
set suijiwujiang[5*idx+2] = GetRandomInt(1,39)
endloop
//9楼不能有五月雨斩,不然掉不下来
loop
exitwhen idx/3 + 1 != 9 //不是9楼
exitwhen suijiwujiang[5*idx+3] != 1  //技能2不是五月雨斩
set suijiwujiang[5*idx+3] = GetRandomInt(1,34)
endloop

set idx = idx + 1
exitwhen idx >= suijiwujiang_maxLength
endloop


endfunction

//点击按钮触发的事件
function dialog_click_Action takes nothing returns nothing
local player player_temp = GetTriggerPlayer()
local integer playerId = GetConvertedPlayerId(player_temp)
local integer wujiang_i = 0
local rect rct_JiDi=null
local unit wujiang_temp = null
if playerId < 7 then 
set  rct_JiDi = gg_rct_SguoJiDi
else
set  rct_JiDi = gg_rct_WguoJiDi
endif
    loop
        if GetClickedButton() == dialog_Button[wujiang_i] then
            exitwhen true
        endif
set wujiang_i = wujiang_i + 1
        exitwhen wujiang_i >= 10*selNum
    endloop
call CreateNUnitsAtLoc( 1, wujiang_id[suijiwujiang[5*wujiang_i + 1]], player_temp, GetRectCenter(rct_JiDi), bj_UNIT_FACING)
set wujiang_temp = GetLastCreatedUnit() 
call SetHeroUnit(playerId,wujiang_temp)
call SelectUnitForPlayerSingle(wujiang_temp,player_temp)
call UnitAddAbilityBJ(udg_omg1[suijiwujiang[5*wujiang_i+2]],wujiang_temp)
call UnitAddAbilityBJ(udg_omg2[suijiwujiang[5*wujiang_i+3]],wujiang_temp)
call UnitAddAbilityBJ(udg_omg3[suijiwujiang[5*wujiang_i+4]],wujiang_temp)
call UnitAddAbilityBJ(udg_omg4[suijiwujiang[5*wujiang_i+5]],wujiang_temp)
//调试捆仙无限水元素
//call UnitAddAbilityBJ(udg_omg1[5],wujiang_temp)
//调试五月雨斩
//call UnitAddAbilityBJ(udg_omg2[1],wujiang_temp)
//调试十字连斩
//call UnitAddAbilityBJ(udg_omg1[35],wujiang_temp)
//call SetHeroLevel(wujiang_temp, 25, true )
//call DisplayTextToPlayer(Player(1),0,0,"你选择英雄")
endfunction

//初始化对话框,并显示给玩家选择英雄
function show_Dialog_wujiang takes nothing returns nothing
local integer idx = 1
local integer selIdx = 0
//待选武将指针
local integer wujiang_i = 0
local player player_temp = null
local integer playerId = 0
call init_array_suijiwujiang()
loop
if idx > 5 then 
set player_temp = Player(idx + 1)
else
set player_temp = Player(idx)
endif
set playerId = GetConvertedPlayerId(player_temp)
set gg_trg_button[playerId] = CreateTrigger()
set dialog_wujiangxuanze[playerId] = DialogCreate()
call DialogSetMessageBJ(dialog_wujiangxuanze[playerId], I2S(idx)+"楼玩家请选择武将")
set selIdx = 0
loop
set dialog_Button[wujiang_i] = DialogAddButtonBJ(dialog_wujiangxuanze[playerId], wujiang_name[suijiwujiang[5*wujiang_i+1]]+ " ( "+jn_name1[suijiwujiang[5*wujiang_i+2]]+" ,"+jn_name2[suijiwujiang[5*wujiang_i+3]]+" ,"+jn_name3[suijiwujiang[5*wujiang_i+4]]+" ,"+jn_name4[suijiwujiang[5*wujiang_i+5]]+" )")
set wujiang_i = wujiang_i + 1
set selIdx = selIdx + 1
exitwhen selIdx >= selNum
endloop
call TriggerRegisterDialogEvent( gg_trg_button[playerId] , dialog_wujiangxuanze[playerId])
call TriggerAddAction(gg_trg_button[playerId],function dialog_click_Action)
//set Cai_Dialog_Action[pid] = TriggerAddAction(Cai_Dialog_Trigger[pid],function Cai_Dialog_Event)
call DialogDisplay( player_temp, dialog_wujiangxuanze[playerId], true )
set idx = idx + 1
exitwhen idx >= 11
endloop

endfunction


最后的效果图:


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值