|
procedure TPlayScene.Run();
var
I, k: Integer;
movetick: Boolean;
evn: TEvent;
Actor: TActor;
meff: TMagicEff;
dwCheckTime, dwTestCheckTime: LongWord;
nIdx: Integer;
boCheckTimeLimit: Boolean;
nCheckCode: Integer;
dwStepMoveTime: LongWord;
dwTickTime: LongWord;
begin
if (g_MySelf = nil) then begin
Exit;
end;
g_boDoFastFadeOut := False;
movetick := False;
if g_ServerConfig.boChgSpeed then begin
//dwStepMoveTime := g_Config.dwStepMoveTime;
dwStepMoveTime := _MAX(100 - Trunc((g_MySelf.m_Abil.MoveSpeed * 100) / 100), 5);
end else begin
dwStepMoveTime := 100;
end;
if GetTickCount - m_dwMoveTime >= dwStepMoveTime then begin
m_dwMoveTime := GetTickCount; //移动开始时间
movetick := TRUE; //允许移动
Inc(m_nMoveStepCount);
if m_nMoveStepCount > 1 then m_nMoveStepCount := 0;
end;
if GetTickCount - m_dwAniTime >= 50 then begin
m_dwAniTime := GetTickCount;
Inc(m_nAniCount);
if m_nAniCount > 100000 then m_nAniCount := 0;
end;
//处理角色一些相关东西
for I := 0 to m_ActorList.Count - 1 do
actor := m_ActorList[i];
try
// nIdx := m_nProcHumIDx;
nIdx := 0;
//dwCheckTime := GetTickCount();
//boCheckTimeLimit := False;
while True do begin
nCheckCode := 0;
if nIdx >= m_ActorList.Count then Break;
Actor := TActor(m_ActorList.Items[nIdx]);
if not Actor.m_boDelActor then begin
nCheckCode := 1;
//dwTestCheckTime := GetTickCount();
//boCanMove := Actor.CanMove;
if movetick then actor.m_boLockEndFrame := FALSE; //可以移动
if not actor.m_boLockEndFrame then begin //没有锁定动作
nCheckCode := 4;
Actor.ProcMsg;//处理角色的消息
nCheckCode := 5;
if movetick then begin
nCheckCode := 6;
if Actor.Move(Actor.m_nMoveStepCount) then begin//角色移动
Inc(nIdx);
nCheckCode := 7;
Continue;
end;
end;
nCheckCode := 8;
Actor.Run;
nCheckCode := 9;
if Actor <> g_MySelf then Actor.ProcHurryMsg;
nCheckCode := 10;
end;
nCheckCode := 11;
if Actor = g_MySelf then Actor.ProcHurryMsg;
nCheckCode := 12;
if Actor.m_nWaitForRecogId <> 0 then begin
nCheckCode := 13;
if Actor.IsIdle then begin
nCheckCode := 14;
DelChangeFace(Actor.m_nWaitForRecogId);
nCheckCode := 15;
NewActor(Actor.m_nWaitForRecogId, Actor.m_nCurrX, Actor.m_nCurrY, Actor.m_btDir, Actor.m_nWaitForFeature, Actor.m_nWaitForStatus);
nCheckCode := 16;
Actor.m_nWaitForRecogId := 0;
Actor.m_boDelActor := True;
end;
end;
end;
nCheckCode := 17;
if Actor.m_boDelActor then begin
nCheckCode := 18;
m_ActorList.Delete(nIdx);
nCheckCode := 19;
UpDataFreeActorList(Actor);
nCheckCode := 20;
if g_TargetCret = Actor then g_TargetCret := nil;
if g_FocusCret = Actor then g_FocusCret := nil;
if g_MagicTarget = Actor then g_MagicTarget := nil;
if g_MyHero = Actor then g_MyHero := nil;
if g_SerieTarget = Actor then g_SerieTarget := nil;
nCheckCode := 21;
end else Inc(nIdx);
end;
except
on E: Exception do begin
DebugOutStr('101 Code:' + IntToStr(nCheckCode));
DebugOutStr('101 ' + E.Message);
if nCheckCode = 4 then
DebugOutStr('101 UserName ' + Actor.m_sUserName);
end;
end;
//地面物体运动的计算
nCheckCode := 22;
try
nIdx := 0;
while True do begin
nCheckCode := 23;
if nIdx >= m_GroundEffectList.Count then Break;
nCheckCode := 24;
meff := m_GroundEffectList[nIdx];
nCheckCode := 25;
if meff.m_boActive then begin
nCheckCode := 26;
if not meff.Run then begin
nCheckCode := 27;
m_GroundEffectList.Delete(nIdx);
nCheckCode := 28;
meff.Free;
nCheckCode := 29;
Continue;
end;
end;
Inc(nIdx);
end;
nCheckCode := 30;//特效物体运动属性的计算
nIdx := 0;
while True do begin
nCheckCode := 31;
if nIdx >= m_EffectList.Count then Break;
nCheckCode := 32;
meff := m_EffectList[nIdx];
nCheckCode := 33;
if meff.m_boActive then begin
nCheckCode := 34;
if not meff.Run then begin
nCheckCode := 35;
meff.Free;
nCheckCode := 36;
m_EffectList.Delete(nIdx);
nCheckCode := 37;
Continue;
end;
end;
Inc(nIdx);
end;
nCheckCode := 38;//飞行魔法释放
nIdx := 0;
while True do begin
nCheckCode := 39;
if nIdx >= m_FlyList.Count then Break;
nCheckCode := 40;
meff := m_FlyList[nIdx];
nCheckCode := 41;
if meff.m_boActive then begin
nCheckCode := 42;
if not meff.Run then begin
nCheckCode := 43;
meff.Free;
nCheckCode := 44;
m_FlyList.Delete(nIdx);
nCheckCode := 45;
Continue;
end;
end;
Inc(nIdx);
end;
nCheckCode := 46;
EventMan.Execute;
nCheckCode := 47;
except
on E: Exception do begin
DebugOutStr('102 Code:' + IntToStr(nCheckCode));
DebugOutStr('102 ' + E.Message);
end;
end;
try
//清除超过显示范围的物品数据
//跌落物品消隐
ClearDropItem();
//释放事件的地方
for k := EventMan.EventList.Count - 1 downto 0 do begin
evn := TEvent(EventMan.EventList[k]);
if ((abs(evn.m_nX - g_MySelf.m_nCurrX) > 30) and (abs(evn.m_nY - g_MySelf.m_nCurrY) > 30)) {or (not evn.m_boVisible)} then begin
EventMan.EventList.Delete(k);
evn.Free;
//Break;
end;
end;
{for k := 0 to EventMan.EventList.Count - 1 do begin //播放烟花声音
evn := TEvent(EventMan.EventList[k]);
if (abs(evn.m_nX - g_MySelf.m_nCurrX) <= 15) and (abs(evn.m_nY - g_MySelf.m_nCurrY) <= 15) then begin
if evn.m_nEventType in [ET_FIREFLOWER_1..ET_FIREFLOWER_7] then begin
if TFlowerEvent(evn).m_nExplosionSound > 0 then begin
PlaySound(TFlowerEvent(evn).m_nExplosionSound);
TFlowerEvent(evn).m_nExplosionSound := -2;
end;
end;
end;
end;}
except
on E: Exception do begin
DebugOutStr('103');
DebugOutStr('103 ' + E.Message);
end;
end;
end;
|
|