procedure TPlayScene.DrawMap(layer: TMapLayer);
var
x, y, xoff, yoff: Integer;
surface: TTexture;
begin
for y := m_clientRect.Top to m_clientRect.Bottom + MAP_GRID_HEIGHT * 2 do begin
for x := m_clientRect.Left - 4 to m_clientRect.Right + 4 do begin
surface := Map.GetTextureAtLayer(x, y, layer, xoff, yoff);
if surface <> nil then begin
surface.Draw((x - m_clientRect.Left) * UNITX + xoff - g_MySelf.m_nShiftX,
(y - m_clientRect.Top) * UNITY + yoff - g_MySelf.m_nShiftY);
end;
end;
end;
end;
procedure TPlayScene.DrawObjLayer;
var
x, y, i, j, px, py, xoff, yoff: Integer;
actor: TActor;
surface: TTexture;
ev: TEvent;
meff: TMagicEff;
list: TList;
dropItem: pTDropItem;
showItem: PTShowItem;
name: string;
rect: TRect;
width, height: Integer;
begin
for y := m_clientRect.Top to m_clientRect.Bottom + MAP_GRID_HEIGHT * 2 do begin
{ 渲染建筑 }
for x := m_clientRect.Left - 4 to m_clientRect.Right + 4 do begin
surface := Map.GetTextureAtLayer(x, y, ML_OBJ, xoff, yoff);
if surface <> nil then begin
surface.Draw((x - m_clientRect.Left) * UNITX + xoff - g_MySelf.m_nShiftX,
(y - m_clientRect.Top) * UNITY + yoff - g_MySelf.m_nShiftY);
end;
end;
{ 渲染事件 }
g_eventRenderMgr.Render(y);
// for i := 0 to EventMan.EventList.Count - 1 do begin
// ev := TEvent(EventMan.EventList[i]);
// if ev.m_nY = y then begin
// ev.DrawEvent(m_ObjSurface,
// (ev.m_nX - m_clientRect.Left) * UNITX,
// (ev.m_nY - m_clientRect.Top) * UNITX
// );
// end;
// end;
{ 渲染掉落物品 }
if g_boDrawDropItem then begin
g_DropedItemList.Lock;
try
for i := 0 to g_DropedItemList.Count - 1 do begin
list := TList(g_DropedItemList[i]);
if list.Count <= 0 then Break;
dropItem := pTDropItem(list[0]);
if (dropItem = nil) or (y <> (dropItem.Y)) then Continue;
if dropItem.Looks in [1, 2, 3] then
surface := g_dropitems.Images['掉落_' + RES_BOOKS[dropItem.Looks - 1]]
else
if dropItem.Name = g_sGoldName then
surface := g_dropitems.Images['掉落_金币大.png']
else
surface := g_dropitems.Images['掉落_' + dropItem.Name + '.png'];
if surface = nil then Continue;
px := (dropItem.X - m_ClientRect.Left) * UNITX - surface.Width div 2 - g_MySelf.m_nShiftX - HALFX;
py := (dropItem.Y - m_ClientRect.Top) * UNITY - surface.Height div 2 - g_MySelf.m_nShiftY - HALFY;
surface.Draw(px, py);
{显示掉落物品名}
if g_boDropItemFlash then begin
width := TextWidth(dropItem.Name) + 4;
height := TextHeight(dropItem.Name) + 2;
rect.Left := px + (surface.Width - width) div 2;
rect.Top := py - height - 4;
rect.Right := rect.Left + width;
rect.Bottom := rect.Top + height;
surface.FillRectAlpha(rect, $00004C4C, 125);
ImageDraw.TextOut(rect.Left + 2, rect.Top + 1, dropItem.Name);
end;
end
finally
g_DropedItemList.UnLock;
end;
end;
{ 渲染生物 }
for i := 0 to m_actorList.Count - 1 do begin
actor := TActor(m_ActorList.Items[i]);
if (actor.m_nRy = y) then begin
if actor = g_AttackLockActor{g_MagicLockActor} then
begin
if not g_AttackLockActor.m_boDeath then begin
DrawSelEffect(actor);
end else begin
g_AttackLockActor := nil;
end;
end;
if (not g_boDrawMonsterDead) and actor.m_boDeath then Continue;
actor.Render(
(actor.m_nRx - m_ClientRect.Left) * UNITX + actor.m_nShiftX - g_MySelf.m_nShiftX,
(actor.m_nRy - m_ClientRect.Top) * UNITY + actor.m_nShiftY - g_MySelf.m_nShiftY
);
end;
end;
{ 绘制生物特效 }
for i := 0 to m_ActorList.Count - 1 do begin
Actor := m_ActorList[i];
Actor.DrawEff(m_ObjSurface,
(Actor.m_nRx - m_ClientRect.Left) * UNITX,
(Actor.m_nRy - m_ClientRect.Top - 1) * UNITY);
end;
end;
{ 绘制武功特效 }
for i := 0 to m_EffectList.Count - 1 do begin
meff := TMagicEff(m_EffectList[i]);
meff.DrawEff(m_ObjSurface);
end;
{ 渲染飞行特效 }
for i := 0 to m_FlyList.Count - 1 do begin
meff := TMagicEff(m_FlyList.Items[i]);
if j = (meff.ry - Map.BlockTop) then begin
meff.DrawEff(m_ObjSurface);
end;
end;
// if g_NewStatus = sConfusion then begin
// msgstr := Format('You are confused, will return to normal in %d seconds. ', [g_NewStatusDelayTime]);
// with m_ObjSurface do begin
// FontSize := MainForm.Canvas.Font.Size;
// MainForm.Canvas.Font.Size := 18;
// m_ObjSurface.BoldTextOut((SCREENWIDTH - m_ObjSurface.TextWidth(msgstr)) div 2, (SCREENHEIGHT - 600) + 200, msgstr,
// clRed, clWhite);
// MainForm.Canvas.Font.Size := FontSize;
// end;
// end;
end;
function TPlayScene.calcShowActorNameY(actor: TActor; var iShowY: Integer) : Integer;
begin
//计算Y坐标 用于显示 人物名
if g_boShowNameOnHead then begin
Result := iShowY;
end else begin
Result := actor.m_nSayY + actor.SayOff div 2;
end;
end;
procedure TPlayScene.DrawActorInfo;
var
i: Integer;
actor: TActor;
name: string;
color: TColor;
iShowNameY, iTmp: Integer;
iShowNameX: Integer;
begin
for i := 0 to m_ActorList.Count - 1 do begin
actor := TActor(m_ActorList[i]);
iShowNameY := actor.m_nSayY;
if not actor.m_boDeath then begin
if g_NewStatus = sBlind then Continue;
{ 绘制血条 }
if not (actor.m_btRace in [RCC_MERCHANT, RC_DAIKATANAGUARD]) then
actor.RenderHealth(iShowNameY);
{NPC 只显示名字}
if (actor.m_btRace in [RCC_MERCHANT, RC_DAIKATANAGUARD, RC_ARROWGUARD]) then begin
if g_boExtrudeNPC then
color := clLime
else color := actor.m_nNameColor;
actor.NameTextOut(actor.m_sUserName, actor.m_nSayX, calcShowActorNameY(actor, iShowNameY), color);
if (actor.m_btRace <> RC_ARROWGUARD) then Continue; //跳过,下一角色
end;
if{怪物} (actor.m_btRace <> 0) and (actor.m_btRace <> 1) then begin
if g_boDrawMonsterName then begin
if g_boExtrudeMonsterName then begin
if actor.m_btRace in [RC_SKULLPET, RC_DEITYPET]{道士宠物} then
color := clLime
else color := clRed;
end else color := actor.m_nNameColor;
actor.NameTextOut(actor.m_sUserName, actor.m_nSayX, calcShowActorNameY(actor, iShowNameY), color);
end;
end
else {玩家} if (actor.m_btRace = RCC_USERHUMAN{男}) or (actor.m_btRace = 1{女}) then begin
if (Actor = g_MySelf) and g_boExtrudeSelf then
color := clLime
else color := actor.m_nNameColor;
{角色名}
iTmp := 0;
name := ''; {鼠标指向角色 - 显示名称}
if g_boDrawName or ((actor <> g_MySelf) and (actor = g_FocusCret)){其他玩家} or
((actor = g_MySelf) and IsSelectMyself(g_nMouseX, g_nMouseY)) {自己} then begin
name := actor.m_sUserName;
end;
if name <> '' then begin
//iTmp为人名显示Y坐标 - 16 iShowNameY - 为头顶坐标
iTmp := actor.NameTextOut(name, actor.m_nSayX, calcShowActorNameY(actor, iShowNameY), color);
if g_boShowNameOnHead then iShowNameY := iTmp;
end;
{行会名}
if g_boShowNameOnHead then begin
if (iTmp = 0) then iTmp := iShowNameY;
if not g_boShowGuildNickNameOnHead then iTmp := actor.m_nSayY + actor.SayOff div 2;
end else begin
if g_boShowGuildNickNameOnHead then iTmp := iShowNameY
else if iTmp = 0 then iTmp := actor.m_nSayY + actor.SayOff div 2;
end;
name := '';
if (g_boDrawGuildName) and (actor.m_sDescGuildName <> '') then begin
if actor.m_sDescRankName = '' then
name := actor.m_sDescGuildName + '\' + name
else
name := actor.m_sDescGuildName + '[' + actor.m_sDescRankName + ']' + '\' + name;
end;
if name <> '' then begin
iTmp := actor.NameTextOut(name, actor.m_nSayX, iTmp, color);
if g_boShowGuildNickNameOnHead then iShowNameY := iTmp;
end;
{摆摊:商铺名}
if actor.m_boStartStore then begin
iShowNameX := actor.m_nSayX - (TextWidth(actor.m_sMyStoreName) + g_UIStoreName.Width + 2) div 2;
g_UIStoreName.Draw(iShowNameX, iShowNameY - 5);
ImageDraw.TextOut(iShowNameX + g_UIStoreName.Width + 2, iShowNameY, actor.m_sMyStoreName, clLime, ColorContour);
Dec(iShowNameY, 23);
end;
end;
{ 绘制生命改变 攻击/毒等扣血值}
if g_boDrawHurtNum and (g_NewStatus <> sBlind) then begin
Actor.ShowHealthStatus;
end;
end;
{ 显示角色说话文字 }
if g_NewStatus <> sBlind then begin
Actor.ShowSayMsg(m_ObjSurface, iShowNameY);
end;
end;
if (g_nAreaStateValue and $04) <> 0 then begin
m_ObjSurface.BoldTextOut(SCREENWIDTH div 2 - 60, 0, '[攻城区]');
end;
if (g_nAreaStateValue and $05) <> 0 then begin
m_ObjSurface.BoldTextOut(SCREENWIDTH div 2 - 20, 0, '[决斗区]');
end;
if (g_nAreaStateValue and $06) <> 0 then begin
m_ObjSurface.BoldTextOut(SCREENWIDTH div 2 - 50, 0, '[安全区]');
end;
end;
procedure TPlayScene.ClearDropItem;
var
I, II: Integer;
List: TList;
DropItem: pTDropItem;
begin
{
if not CanDraw then Exit;
}
g_DropedItemList.Lock;
try
for I := g_DropedItemList.Count - 1 downto 0 do begin
List := TList(g_DropedItemList.Items[I]);
if List.Count > 0 then begin
DropItem := List.Items[0];
if (abs(DropItem.X - g_MySelf.m_nCurrX) > 30) and (abs(DropItem.Y - g_MySelf.m_nCurrY) > 30) then begin
for II := 0 to List.Count - 1 do begin
DropItem := List.Items[II];
Dispose(DropItem);
end;
List.Free;
g_DropedItemList.Delete(I);
end;
end;
end;
finally
g_DropedItemList.UnLock;
end;
end;
procedure TPlayScene.Run(RunSelf: Boolean);
var
I, k: Integer;
movetick: Boolean;
evn: TEvent;
Actor: TActor;
meff: TMagicEff;
effectRender: TEffectRender;
dwCheckTime, dwTestCheckTime: LongWord;
nIdx: Integer;
boCheckTimeLimit: Boolean;
dwStepMoveTime: LongWord;
dwTickTime: LongWord;
begin
if (g_MySelf = nil) then Exit;
g_boDoFastFadeOut := False;
{
m_nAniCount: 控制动画渲染 ? ? ?
}
if GetTickCount - m_dwAniTime >= 50 then begin
m_dwAniTime := GetTickCount;
Inc(m_nAniCount);
if m_nAniCount > 100000 then m_nAniCount := 0;
end;
{ Ryan - Some Serious Problem Here I Think, Needs Looking Into }
try
nIdx := 0;
dwCheckTime := g_sysTimeTick;
boCheckTimeLimit := False;
while True do begin
if nIdx >= m_ActorList.Count then Break;
Actor := TActor(m_ActorList.Items[nIdx]);
if (not RunSelf) and (Actor = g_MySelf) then begin
Inc(nIdx);
Continue;
end;
dwTestCheckTime := g_sysTimeTick;
movetick := Actor.CanMove;
if movetick then begin
Actor.m_boLockEndFrame := False;
end;
if not Actor.m_boLockEndFrame then begin
Actor.ProcMsg;
Actor.Run;
if movetick then begin
if Actor.Move(Actor.m_nMoveStepCount) then begin
Inc(nIdx);
Continue;
end;
end;
if Actor <> g_MySelf then
Actor.ProcHurryMsg;
end;
if Actor = g_MySelf then Actor.ProcHurryMsg;
if Actor.m_nWaitForRecogId <> 0 then begin
if Actor.IsIdle then begin
DelChangeFace(Actor.m_nWaitForRecogId);
NewActor(Actor.m_nWaitForRecogId, Actor.m_nCurrX, Actor.m_nCurrY, Actor.m_btDir, Actor.m_nWaitForFeature, Actor.m_nWaitForStatus);
Actor.m_nWaitForRecogId := 0;
Actor.m_boDelActor := True;
end;
end;
if Actor.m_boDelActor then begin
m_ActorList.Delete(nIdx);
UpDataFreeActorList(Actor);
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;
end
else begin
Inc(nIdx);
end;
end;
except
DebugOutStr('Error 1: PlayerSence.Run');
end;
try
{ 处理地面特效 }
nIdx := 0;
while True do begin
if nIdx >= m_GroundEffectList.Count then Break;
meff := m_GroundEffectList[nIdx];
if meff.m_boActive then begin
if not meff.Run then begin
m_GroundEffectList.Delete(nIdx);
meff.Free;
Continue;
end;
end;
Inc(nIdx);
end;
{ 处理特武功效 }
nIdx := 0;
while True do begin
if nIdx >= m_effectRenderList.Count then Break;
effectRender := m_effectRenderList[nIdx];
if not effectRender.Running then begin
effectRender.Free;
m_effectRenderList.Delete(nIdx);
end;
Inc(nIdx);
end;
{ 处理特武功效 }
nIdx := 0;
while True do begin
if nIdx >= m_EffectList.Count then Break;
meff := m_EffectList[nIdx];
if meff.m_boActive then begin
if not meff.Run then begin
meff.Free;
m_EffectList.Delete(nIdx);
Continue;
end;
end;
Inc(nIdx);
end;
{ 处理飞行特效 }
nIdx := 0;
while True do begin
if nIdx >= m_FlyList.Count then Break;
meff := m_FlyList[nIdx];
if meff.m_boActive then begin
if not meff.Run then begin
meff.Free;
m_FlyList.Delete(nIdx);
Continue;
end;
end;
Inc(nIdx);
end;
{ 执行事件逻辑 }
g_eventRenderMgr.Update;
EventMan.Execute;
except
DebugOutStr('Error 2: PlayerSence.Run');
end;
try
{ 清除超过显示范围的物品数据 }
ClearDropItem();
{ 清除超过显示范围的魔法数据 }
for k := 0 to EventMan.EventList.Count - 1 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) then begin
evn.Free;
EventMan.EventList.Delete(k);
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_8] 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
DebugOutStr('Error 3: PlayerSence.Run');
end;
g_dwRefreshMessagesTick := g_sysTimeTick;
end;
procedure TPlayScene.PlayScene(MSurface: TTexture);
var
msgstr: string;
nSnowX, nSnowY: Integer;
FontSize: Integer;
surface: TTexture;
mode: Integer;
rect: TRect;
width, height, i: Integer;
s,s1: Int64;
begin
{ 角色加载中 }
if (g_MySelf = nil) then begin
Exit;
end;
if Assigned(g_PlugInfo.HookPlayScene) then begin
if g_PlugInfo.HookPlayScene(MSurface) then Exit;
end;
Run(True);
{ 失明状态 }
if g_NewStatus = sBlind then begin
msgstr := Format('你已进入失明状态,持续%d秒...', [g_NewStatusDelayTime]);
with MSurface do begin
FontSize := MainForm.Canvas.Font.Size;
MainForm.Canvas.Font.Size := 18;
BoldTextOut((SCREENWIDTH - TextWidth(msgstr)) div 2, (SCREENHEIGHT - 600) + 200, msgstr);
MainForm.Canvas.Font.Size := FontSize;
end;
Exit;
end;
{ 画面震动 }
if g_boVibration then begin
g_nVibrationX := g_nVibrationX + g_VibrationValue[g_nVibrationPos].X;
g_nVibrationY := g_nVibrationY + g_VibrationValue[g_nVibrationPos].Y;
Inc(g_nVibrationPos);
if g_nVibrationPos >= Length(g_VibrationValue) then begin
g_nVibrationPos := 0;
Inc(g_nVibrationCount);
end;
g_boVibration := g_nVibrationCount < g_nVibrationTotal;
end;
{ 客户端窗口定位 }
with m_clientRect do begin
Top := g_MySelf.m_nRy - (SCREENHEIGHT div UNITY + 1) div 2;
Left := g_MySelf.m_nRx - (SCREENWIDTH div UNITX + 1) div 2;
Right := g_MySelf.m_nRx + (SCREENWIDTH div UNITX - 1) div 2;
Bottom := g_MySelf.m_nRy + (SCREENHEIGHT div UNITY - 1) div 2;
end;
m_nOldCurrX := m_nCurrX;
m_nOldCurrY := m_nCurrY;
m_nCurrX := g_MySelf.m_nShiftX;
m_nCurrY := g_MySelf.m_nShiftY;
if m_nCurrX < 0 then m_nCurrX := 0;
if m_nCurrY < 0 then m_nCurrY := 0;
nSnowX := m_nCurrX;
nSnowY := m_nCurrY;
{ 更新地图块 }
Map.UpdateMapBlock(g_MySelf.m_nRx, g_MySelf.m_nRy);
Map.UpdateSceneMgr;
{ 绘制地下表层 }
DrawMap(ML_GROUND);
{ 绘制地表层 }
DrawMap(ML_SURFACE);
{ 绘制上地表层 }
DrawMap(ML_TILE);
{ 绘制对象层 }
DrawObjLayer;
{ 绘制天空层 }
DrawMap(ML_SKY);
if (g_MySelf <> nil) and IsValidActor(g_MySelf) and (g_MySelf.m_nState and $00800000 = 0) then begin
g_MySelf.Render((g_MySelf.m_nRx - m_ClientRect.Left) * UNITX,
(g_MySelf.m_nRy - m_ClientRect.Top) * UNITY, True, 110);
end;
if (g_FocusCret <> nil) and IsValidActor(g_FocusCret) and (g_FocusCret <> g_MySelf) and
(g_FocusCret.m_nState and $00800000 = 0) then begin
g_FocusCret.Render(
(g_FocusCret.m_nRx - m_ClientRect.Left) * UNITX + g_FocusCret.m_nShiftX - g_MySelf.m_nShiftX,
(g_FocusCret.m_nRy - m_ClientRect.Top) * UNITY + g_FocusCret.m_nShiftY - g_MySelf.m_nShiftY,
True, 110
);
end;
if (g_MagicTarget <> nil) and IsValidActor(g_MagicTarget) and (g_MagicTarget <> g_MySelf) and
(g_MagicTarget.m_nState and $00800000 = 0) then begin
g_MagicTarget.Render(
(g_MagicTarget.m_nRx - m_ClientRect.Left) * UNITX + g_MagicTarget.m_nShiftX - g_MySelf.m_nShiftX,
(g_MagicTarget.m_nRy - m_ClientRect.Top) * UNITY + g_MagicTarget.m_nShiftY - g_MySelf.m_nShiftY,
True, 110
);
end;
{掉落物品名字}
if g_FocusItem <> nil then begin
if g_FocusItem.Looks in [1, 2, 3] then
surface := g_dropitems.Images['掉落_' + RES_BOOKS[g_FocusItem.Looks - 1]]
else
if g_FocusItem.Name = g_sGoldName then
surface := g_dropitems.Images['掉落_金币大.png']
else
surface := g_dropitems.Images['掉落_' + g_FocusItem.Name + '.png'];
if surface <> nil then begin
nSnowX := (g_FocusItem.X - m_ClientRect.Left) * UNITX - surface.Width div 2 - g_MySelf.m_nShiftX - HALFX;
nSnowY := (g_FocusItem.Y - m_ClientRect.Top) * UNITY - surface.Height div 2 - g_MySelf.m_nShiftY - HALFY;
surface.Draw(nSnowX, nSnowY);
surface.DrawEff(nSnowX, nSnowY, ceBright, 170);
width := TextWidth(g_FocusItem.Name) + 4;
height := TextHeight(g_FocusItem.Name) + 2;
rect.Left := nSnowX + (surface.Width - width) div 2;
rect.Top := nSnowY - height - 4;
rect.Right := rect.Left + width;
rect.Bottom := rect.Top + height;
surface.FillRectAlpha(rect, $00004C4C, 125);
ImageDraw.TextOut(rect.Left + 2, rect.Top + 1, g_FocusItem.Name);
end;
end;
{ 绘制名字、血条等}
DrawActorInfo;
DrawTargetHP();
{ 绘制武功特效 }
for i := 0 to m_effectRenderList.Count - 1 do begin
TEffectRender(m_effectRenderList[i]).Render;
end;
{ 地图掩盖层 }
if (Map.Name = 'jjc') or (Map.Name = 'mq0') or (Map.Name = 'mz0') or (Map.Name = 'shatu') then begin
surface := nil;
end
else begin
surface := g_resUi.Images['map_mask.png'];
end;
if surface <> nil then begin
surface.Draw(0, 0);
end;
DrawBloodBox();
if g_jjrelive then begin
s := Round((GetTickCount - g_jjreliveTick) div 1000);
if s <= 10 then begin
ImageDraw.TextOut(100, 100, IntToStr(s));
end else begin
frmMain.SendMerchantDlgSelect(g_nCurMerchant, '@revivejjc');
g_jjrelive := False;
end;
end;
if g_startplay then begin
s1 := Round((GetTickCount - g_starttime) div 1000);
if s1 < 5 then begin
g_timepic[4-s1].Draw((SCREENWIDTH - g_timepic[4-s1].Width) div 2, (SCREENHEIGHT - g_timepic[4-s1].Height) div 2);
end else begin
if s1 = 5 then begin
g_timepic[s1].Draw((SCREENWIDTH - g_timepic[s1].Width) div 2, (SCREENHEIGHT - g_timepic[s1].Height) div 2);
end else begin
g_startplay := False;
end;
end;
end;
end;
{-------------------------------------------------------}
声明:本文系互联网搜索百度而收集整理,不以盈利性为目的,文字、图文资料源于互联网且共享于互联网。
如有侵权,请联系 hzy98999#qq.com (#改@) 删除。
如有侵权,请联系 hzy98999#qq.com (#改@) 删除。