-- 관계식의 결점을 결정하기 전에 수행
--[[
file name : GameEtNode.lua
author : Clark/
created : 8:30:2011
purpose :
--]]
function Node_NULFun()
--return nil --
--return false -- 。
return true --
end
function ToNodeSet(_fun, _tPar)
function NodeFun()
if nil == _tPar then
return _fun()
end
local dLen = table.getn(_tPar)
if 0 == dLen then
return _fun()
elseif 1 == dLen then
return _fun(_tPar[1])
elseif 2 == dLen then
return _fun(_tPar[1], _tPar[2])
elseif 3 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3])
elseif 4 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4])
elseif 5 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5])
elseif 6 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6])
elseif 7 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7])
elseif 8 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8])
elseif 9 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9])
elseif 10 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10])
elseif 11 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10], _tPar[11])
elseif 12 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10], _tPar[11], _tPar[12])
elseif 13 == dLen then
return _fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10], _tPar[11], _tPar[12], _tPar[13])
else
myPrint("ToNodeFun ",1) --------------------------------------------------------
return true
end
end
return NodeFun
end
--
function ToNodeFun(_fun, _tPar)
function NodeFun()
if nil == _fun then
return true
end
if nil == _tPar then
_fun()
return true
end
local dLen = table.getn(_tPar)
if 0 == dLen then
_fun()
elseif 1 == dLen then
_fun(_tPar[1])
elseif 2 == dLen then
_fun(_tPar[1], _tPar[2])
elseif 3 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3])
elseif 4 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4])
elseif 5 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5])
elseif 6 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6])
elseif 7 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7])
elseif 8 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8])
elseif 9 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9])
elseif 10 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10])
elseif 11 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10], _tPar[11])
elseif 12 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10], _tPar[11], _tPar[12])
elseif 13 == dLen then
_fun(_tPar[1], _tPar[2], _tPar[3], _tPar[4], _tPar[5], _tPar[6], _tPar[7], _tPar[8], _tPar[9], _tPar[10], _tPar[11], _tPar[12], _tPar[13])
else
myPrint("ToNodeFun ",1) --------------------------------------------------------
end
return true
end
return NodeFun
end
--
function s_e_DoingNode(_funGetNode, _tPar)
--API_Trace("s_e_DoingNode")
local bDone = false
local thisProtected = {}
thisProtected.ndTempS = nil
thisProtected.ndTempE = nil
function thisProtected.doNode()
if bDone then
-- ,
return
end
--myPrint("s_e_DoingNode.doNode",1)
thisProtected.fun = ToNodeSet(_funGetNode, _tPar)
bDone = true
thisProtected.ndTempS, thisProtected.ndTempE = thisProtected.fun()
--myPrint("fun ndTempS Count:" .. thisProtected.ndTempS.getNode(), 1)
if nil == thisProtected.ndTempE then
thisProtected.ndTempE = newFunNode()
thisProtected.ndTempS.pushChild(thisProtected.ndTempE)
end
thisProtected.ndS.pushChild(thisProtected.ndTempS)
thisProtected.ndTempE.pushChild(thisProtected.ndE)
end
thisProtected.ndS = newFunNode(ToNodeFun(thisProtected.doNode)) -- doNode ndS
thisProtected.ndE = newFunNode()
local oldFun = thisProtected.ndS.delete
function thisProtected.ndS.delete()
--API_Trace("s_e_DoingNode.delete")
if false == bDone then
--API_Trace("s_e_DoingNode.delete bDone == false")
thisProtected.ndS.pushChild(thisProtected.ndE)
end
oldFun()
end
return thisProtected.ndS, thisProtected.ndE
end
G_NODE_COUNT = 0
function newBaseNode()
G_NODE_COUNT = G_NODE_COUNT + 1
--myPrint(" G_NODE_COUNT: " .. G_NODE_COUNT, 1)
local m_private = { m_tChildNode = {} }
local m_protected = {}
local m_public = {}
function m_public.getSize()
local dSum = 0
local dLen = table.getn(m_private.m_tChildNode)
for i=1, dLen do
if nil ~= m_private.m_tChildNode[i] then
dSum = dSum + m_private.m_tChildNode[i].getSize()
end
end
dSum = dSum + 1
return dSum
end
--
function m_public.init()
--
m_protected.initThis()
m_protected.initChild()
end
function m_protected.initChild()
local dLen = table.getn(m_private.m_tChildNode)
for i=1, dLen do
if nil ~= m_private.m_tChildNode[i] then
m_private.m_tChildNode[i].init()
end
end
end
function m_protected.initThis()
myPrint("initThis ",1) --------------------------------------------------------
end
--
function m_public.run()
--
local bRet = m_protected.bool_runThis()
if bRet then
--myPrint(" ",1)
m_protected.runChild()
else
--myPrint(" ",1)
end
end
function m_protected.runChild()
local dLen = table.getn(m_private.m_tChildNode)
for i=1, dLen do
if nil ~= m_private.m_tChildNode[i] then
m_private.m_tChildNode[i].run()
end
end
end
function m_protected.bool_runThis()
myPrint("bool_runThis ",1) --------------------------------------------------------
return true
end
--
function m_public.pushChild(_nextNode)
local dLen = table.getn(m_private.m_tChildNode)
m_private.m_tChildNode[dLen+1] = _nextNode
end
--
-- , , ( )
function m_public.start()
--myPrint(" ",1)
m_public.init()
m_public.run()
return true
end
function m_public.deleteChild()
local dLen = table.getn(m_private.m_tChildNode)
for i=1, dLen do
if nil ~= m_private.m_tChildNode[i] then
--myPrint("deleteChild",1)
m_private.m_tChildNode[i].delete()
m_private.m_tChildNode[i] = nil
end
end
end
m_private.bNew = true
function m_public.delete()
--myPrint("delete",1)
if m_private.bNew then
m_public.deleteChild()
m_public.init()
G_NODE_COUNT = G_NODE_COUNT - 1
if G_NODE_COUNT <= 0 then
myPrint(" G_NODE_COUNT: " .. G_NODE_COUNT, 1)
end
m_private.bNew = false
end
end
function m_public.setChildNull(_nd)
local dLen = table.getn(m_private.m_tChildNode)
for i=1, dLen do
if _nd == m_private.m_tChildNode[i] then
myPrint("setChildNull",1)
m_private.m_tChildNode[i] = nil
end
end
end
function m_public.getNode()
local iCount = 0
local dLen = table.getn(m_private.m_tChildNode)
for i=1, dLen do
if nil ~= m_private.m_tChildNode[i] then
iCount = iCount + m_private.m_tChildNode[i].getNode()
end
end
iCount = iCount + 1
return iCount
end
return m_public, m_protected
end
--
function newFunNode(_onFun)
_onFun = _onFun or Node_NULFun
local m_public, m_protected = newBaseNode()
function m_protected.initThis()
end
function m_protected.bool_runThis()
--
if nil ~= _onFun then
local bRet = _onFun()
if false == bRet then
return false
end
return true
end
return true
end
return m_public
end
--
function newTgrNode()
local m_public, m_protected = newBaseNode()
m_protected.tgr = nil
--
function m_public.run()
--myPrint("newTgrNode run",1)
m_protected.initThis()
m_protected.bool_runThis()
end
--
function m_protected.initThis()
if nil ~= m_protected.tgr then
--myPrint("initThis: tgr",1)
m_protected.tgr = m_protected.tgr.nil_deleteTrigger()
end
end
function m_protected.bool_runThis()
myPrint(" ",1)
return true
end
return m_public, m_protected
end
-- ( )
function DieTgrPar(_pSomething)
function doDieTgrPar()
return _pSomething
end
return doDieTgrPar
end
--
function newDieTrgNode(_tgrparFun, _onFun)
local m_public, m_protected = newTgrNode()
function m_protected.bool_runThis()
local objSomething = _tgrparFun()
if nil ~= objSomething then
m_protected.tgr = trigger_newGDieTrigger(objSomething, m_protected.doRun)
end
end
function m_protected.doRun(_Type, _FastID, _KillerType, _KillerID, _MonsterID, _MapID, _PosX, _PosY)
-- , _onFun ,
m_protected.initThis()
local bRet = _onFun(_Type, _FastID, _KillerType, _KillerID, _MonsterID, _MapID, _PosX, _PosY)
if nil == bRet then
m_protected.bool_runThis()
elseif bRet then
m_protected.runChild()
end
end
-- LuA , ----
-- ,
function m_public.pause()
m_protected.initThis()
end
function m_public.play()
m_protected.bool_runThis()
end
------------------------------------------------------------------------------------
return m_public
end
-- ( )
function TimeTgrPar(_timeStep)
function doTimeTgrPar()
if type(Node_NULFun) == type(_dtTime) then
_timeStep = _timeStep()
end
return _timeStep
end
return doTimeTgrPar
end
--
function newTimeTrgNode(_tgrparFun, _onFun)
local m_public, m_protected = newTgrNode()
function m_protected.bool_runThis()
local dTimestep = _tgrparFun()
m_protected.tgr = trigger_newGTimerTrigger(dTimestep, m_protected.doRun)
end
function m_protected.doRun()
-- , _onFun ,
m_protected.initThis()
local bRet = _onFun()
if nil == bRet then
m_protected.bool_runThis()
elseif bRet then
m_protected.runChild()
end
end
return m_public
end
-- ( )
function AreaTgrPar(_dMapObj, _dPosX, _dPosY, _dRadius)
function doAreaTgrPar()
return _dMapObj, _dPosX, _dPosY, _dRadius
end
return doAreaTgrPar
end
--
function newHeroToAreaTrgNode(_tgrparFun, _onFun)
local m_public, m_protected = newTgrNode()
function m_protected.bool_runThis()
local dMapObj, dPosX, dPosY, dRadius = _tgrparFun()
m_protected.tgr = trigger_newGHeroAreaTrigger(dMapObj, dPosX, dPosY, dRadius, m_protected.doRun)
end
function m_protected.doRun(_HitID)
--myPrint("_HitType " .. _HitType , 1)
-- , _onFun ,
m_protected.initThis()
local bRet = _onFun(_HitID)
if nil == bRet then
m_protected.bool_runThis()
elseif bRet then
--myPrint("doRun" , 1)
m_protected.runChild()
end
end
return m_public
end
--
function newMonsterToAreaTrgNode(_tgrparFun, _onFun)
local m_public, m_protected = newTgrNode()
function m_protected.bool_runThis()
local dMapObj, dPosX, dPosY, dRadius = _tgrparFun()
m_protected.tgr = trigger_newGMonsterAreaTrigger(dMapObj, dPosX, dPosY, dRadius, m_protected.doRun)
end
function m_protected.doRun(_HitID)
--myPrint("_HitType " .. _HitType, 1)
-- , _onFun ,
m_protected.initThis()
local bRet = _onFun(_HitID)
if nil == bRet then
m_protected.bool_runThis()
elseif bRet then
--myPrint("newMonsterToAreaTrgNode", 1)
m_protected.runChild()
end
end
return m_public
end
--_tNode = {{start1, end1}, {start2, end2}...}
function s_e_AndNode(_tNode)
local m_dLen = table.getn(_tNode)
--myPrint("s_e_AndNode m_dLen " .. m_dLen, 1)
local m_ndCount = {}
local m_ndAnd = {}
function m_ndAnd.initCount()
for i=1, m_dLen do
m_ndCount[i] = false
end
return true
end
function m_ndAnd.SiglePass(_ID)
function doSiglePass()
m_ndCount[_ID] = true
return true
end
return doSiglePass
end
function m_ndAnd.AllPass()
function doAllPass()
local bAllPass = true
for i=1, m_dLen do
if false == m_ndCount[i] then
bAllPass = false
break
end
end
--myPrint("s_e_AndNode m_dLen " .. m_dLen, 1)
return bAllPass
end
return doAllPass
end
local ndHead = newFunNode(m_ndAnd.initCount)
local ndEnd = newFunNode(m_ndAnd.AllPass())
for i=1, m_dLen do
local ndSiglePass = newFunNode(m_ndAnd.SiglePass(i))
ndHead.pushChild(_tNode[i][1])
_tNode[i][2].pushChild(ndSiglePass)
ndSiglePass.pushChild(ndEnd)
end
return ndHead, ndEnd
end
--[[
-- ,
-- ,
function s_e_OrNode(_tNode)
local ndHead = newFunNode()
local ndEnd = newFunNode(ToNodeFun(ndHead.init))
local m_dLen = table.getn(_tNode)
for i=1, m_dLen do
ndHead.pushChild(_tNode[i][1])
_tNode[i][2].pushChild(ndEnd)
end
return ndHead, ndEnd
end
--]]
-- ,
function s_e_OrNodeEx(_tNode, _funPass)
_funPass = _funPass or Node_NULFun
local thisTemp = {}
thisTemp.NoPassed = true
function thisTemp.Init()
--myPrint("s_e_OrNodeEx Init", 1)
thisTemp.NoPassed = true
return true
end
function thisTemp.IsPass()
--myPrint("IsPass", 1)
if thisTemp.NoPassed then
if nil ~= _funPass then
if _funPass() then
thisTemp.NoPassed = false
return true
end
else
thisTemp.NoPassed = false
return true
end
end
return false
end
local ndHead = newFunNode(thisTemp.Init)
local ndEnd = newFunNode(thisTemp.IsPass)
local dLen = table.getn(_tNode)
for i=1, dLen do
if nil ~= _tNode[i][1] and nil ~= _tNode[i][2] then
ndHead.pushChild(_tNode[i][1])
_tNode[i][2].pushChild(ndEnd)
elseif nil ~= _tNode[i] and nil == _tNode[i][1] then
ndHead.pushChild(_tNode[i])
_tNode[i].pushChild(ndEnd)
else
myPrint("s_e_OrNodeEx: _tNode == nil", 1)
end
end
return ndHead, ndEnd
end
--[[
function fun(_szText)
function doFun()
print(_szText, 0)
return true
end
return doFun
end
function funF(_szText)
function doFun()
print(_szText, 0)
return false
end
return doFun
end
function myPrint(_szText, _type)
print(_szText)
end
node1 = newFunNode(fun("1"))
node2 = newFunNode(funF("2"))
node3 = newFunNode(fun("3"))
node4 = newFunNode(fun("4"))
local ndAndS, ndAndE = s_e_AndNode({{node1,node1}, {node2,node2}, {node3,node3}})
ndAndE.pushChild(node4)
ndAndS.start()
ndAndS.delete()
--]]
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SpriteKit은 게임 점프 캐릭터에 높이 표시기를 추가합니다이것은 점프 낙서와 유사한 작은 게임이다. 주인공이 끊임없이 에너지 공을 먹고 점프 에너지를 얻어 더 높은 곳으로 점프한다. 그림에서 블랙홀에 부딪히면 걸린다. 게임 디버깅 과정에서 주인공의 높이를 실시간으로 알았으...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.