-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] add new lua version bufcnt & add subplay fw
- Loading branch information
Showing
10 changed files
with
249 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
local start_pos = CGeoPoint(0,0) | ||
local dist = 1000 | ||
local rotateSpeed = 1 -- rad/s | ||
|
||
local runPos = function() | ||
local angle = rotateSpeed * vision:getCycle() / param.frameRate | ||
return start_pos + Utils.Polar2Vector(dist, angle) | ||
end | ||
local subScript = false | ||
local DSS_FLAG = bit:_or(flag.allow_dss, flag.dodge_ball) | ||
|
||
local PLAY_NAME = "" | ||
return { | ||
|
||
__init__ = function(name, args) | ||
print("in __init__ func : ",name, args) | ||
start_pos = args.pos or CGeoPoint(0,0) | ||
dist = args.dist or 1000 | ||
subScript = true | ||
PLAY_NAME = name | ||
end, | ||
|
||
firstState = "init", | ||
["init"] = { | ||
switch = function() | ||
if bufcnt(true,30) then | ||
if not subScript then | ||
gSubPlay.new(PLAY_NAME .. "task1", "TestSubScript", {pos=start_pos + Utils.Polar2Vector(2*dist, math.pi/4), dist=2000}) | ||
gSubPlay.new(PLAY_NAME .. "task2", "TestSubScript", {pos=start_pos + Utils.Polar2Vector(2*dist, -math.pi/4*3), dist=500}) | ||
rotateSpeed = -1 | ||
end | ||
return "run" | ||
end | ||
end, | ||
Leader = task.stop(), | ||
match = "[L]" | ||
}, | ||
["run"] = { | ||
switch = function() | ||
-- print("markdebug : ",gSubPlayFiles) | ||
-- for key, value in pairs(gSubPlayFiles) do | ||
-- print("printFileTable: ", key, value) | ||
-- end | ||
end, | ||
Assister = gSubPlay.roleTask("task1","Leader"), | ||
Fronter = gSubPlay.roleTask("task2","Leader"), | ||
Leader = task.goCmuRush(runPos, 0, nil, DSS_FLAG), | ||
match = "(LAF)" | ||
}, | ||
|
||
name = "TestSubScript", | ||
applicable = { | ||
exp = "a", | ||
a = true | ||
}, | ||
attribute = "attack", | ||
timeout = 99999 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ gRoleNum = { | |
["z"] = -1 | ||
} | ||
|
||
|
||
gLastRoleNum = { | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
SubPlay = { | ||
} | ||
function SubPlay.pack(name, play, param) | ||
local curState = play.firstState | ||
if play.__init__ ~= nil then | ||
play.__init__(name, param) | ||
end | ||
return { | ||
name = name, | ||
roleMapping = {}, | ||
play = play, | ||
curState = curState, | ||
lastState = nil, | ||
} | ||
end | ||
|
||
gSubPlay = { | ||
playTable = {}, | ||
curScope = "", | ||
} | ||
gSubPlayFiles = {} | ||
|
||
function gSubPlay.new(name, playName, initParam) | ||
print("in initPlay : ", name, initParam) | ||
if gSubPlay.playTable[name] ~= nil then | ||
warning("subPlay exist, reinit a new one - ", name) | ||
end | ||
if gSubPlayFiles[playName] == nil then | ||
warning(string.format("subPlay file not exist - %s", playName)) | ||
return | ||
end | ||
spec = dofile(gSubPlayFiles[playName]) | ||
gSubPlay.playTable[name] = SubPlay.pack(name, spec, initParam) | ||
end | ||
|
||
function gSubPlay.step() | ||
local debugX = -2000 | ||
local debugY = param.pitchWidth/2+200 | ||
local step = -130 | ||
for key, play in pairs(gSubPlay.playTable) do | ||
gSubPlay.curScope = key | ||
local _subPlay = play.play | ||
local curState = play.curState | ||
curState = _RunPlaySwitch(_subPlay, curState) | ||
local isStateSwitched = false | ||
if curState ~= nil then | ||
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") | ||
play.lastState = play.curState | ||
play.curState = curState | ||
isStateSwitched = true | ||
PlayFSMClearAll() | ||
end | ||
-- print("ID : , play : , curState :", key, _subPlay.name, play.curState) | ||
gSubPlay.curScope = "" | ||
debugEngine:gui_debug_msg_fix(CGeoPoint(debugX, debugY), key .. " - " .. play.curState, param.GREEN, 0,100) | ||
debugY = debugY + step | ||
end | ||
end | ||
|
||
function gSubPlay.getState(name) | ||
if gSubPlay.playTable[name] == nil then | ||
warning("(call gSubPlay.getState) subPlay not exist - ", name) | ||
return nil | ||
end | ||
return gSubPlay.playTable[name].curState | ||
end | ||
|
||
function gSubPlay.roleTask(name, role) | ||
return function() | ||
if gSubPlay.playTable[name] == nil then | ||
warning("roleTask not exist - ", name, role) | ||
return | ||
end | ||
local _subPlayState = gSubPlay.playTable[name].play[gSubPlay.playTable[name].curState] | ||
return _subPlayState[role] | ||
end | ||
end | ||
|
||
-- function gSubPlay.getRoleNum(roleName) | ||
-- print("in getRoleNum : ", roleName) | ||
-- if gSubPlay.curScope == nil then | ||
-- return gRoleNum[roleName] | ||
-- end | ||
-- return -1 | ||
-- end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.