소스 일정 부분입니다.
0.5초 혹은 1초 주기로 5번 만 딱 반복 실행하려고 합니다.
실행하려는 부분은 RM_MAGSTRUCK 부분이구요
원본은
function TMagicManager.MagBigExplosion(BaseObject: TBaseObject; nPower, nX,
nY: Integer; nRage: Integer): Boolean;
var
I :Integer;
BaseObjectList :TList;
TargeTBaseObject :TBaseObject;
begin
Result := False;
BaseObjectList := TList.Create;
BaseObject.GetMapBaseObjects(BaseObject.m_PEnvir,nX,nY,nRage,BaseObjectList);
if not BaseObject.m_boOnHorse then begin
for I := 0 to BaseObjectList.Count - 1 do begin
TargeTBaseObject:=TBaseObject(BaseObjectList.Items[i]);
if BaseObject.IsProperTarget(TargeTBaseObject) then begin
BaseObject.SetTargetCreat(TargeTBaseObject);
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
Result:=True;
end;
end;
BaseObjectList.Free;
end;
end;
입니다. 이상태에서 timer를 이용하여 했으나 안돼더군요... 무엇이 잘못된거죠?
아래 있는 소스가 위의 소스에서 timer 을 추가하것입니다.~
function TMagicManager.MagBigExplosion(BaseObject: TBaseObject; nPower, nX,
nY: Integer; nRage: Integer): Boolean;
var
I :Integer;
BaseObjectList :TList;
TargeTBaseObject :TBaseObject;
interval, mode : integer;
begin
Result := False;
BaseObjectList := TList.Create;
BaseObject.GetMapBaseObjects(BaseObject.m_PEnvir,nX,nY,nRage,BaseObjectList);
timer1.Enabled := true;
if BaseObject.IsProperTarget(TargeTBaseObject) then begin
BaseObject.SetTargetCreat(TargeTBaseObject);
if (mode <> 1) and (mode <> 2) and (mode <> 3) and (mode <> 4) and (mode <> 5) then mode := 1;
case Mode of
1 :
begin
timer1.interval := 500;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 1;
end;
2 :
begin
timer1.interval := 1000;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 2;
end;
3 :
begin
timer1.interval := 1500;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 3;
end;
4 :
begin
timer1.interval := 2000;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 4;
end;
5 :
begin
timer1.interval := 2500;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 5;
timer1.Enabled := false;
end;
end;
end;
end;
도와주세요~
아래처럼 수정하면..어떨까요?
function TMagicManager.MagBigExplosion(BaseObject: TBaseObject; nPower, nX,
nY: Integer; nRage: Integer): Boolean;
var
I :Integer;
BaseObjectList :TList;
TargeTBaseObject :TBaseObject;
interval, mode : integer;
begin
Result := False;
BaseObjectList := TList.Create;
BaseObject.GetMapBaseObjects(BaseObject.m_PEnvir,nX,nY,nRage,BaseObjectList);
timer1.Enabled := true;
if BaseObject.IsProperTarget(TargeTBaseObject) then begin
BaseObject.SetTargetCreat(TargeTBaseObject);
if (mode <> 1) and (mode <> 2) and (mode <> 3) and (mode <> 4) and (mode <> 5) then mode := 1;
case Mode of
1 :
begin
timer1.interval := 500;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 2;
end;
2 :
begin
timer1.interval := 1000;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 3;
end;
3 :
begin
timer1.interval := 1500;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 4;
end;
4 :
begin
timer1.interval := 2000;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 5;
end;
5 :
begin
timer1.interval := 2500;
TargeTBaseObject.SendMsg(BaseObject,RM_MAGSTRUCK,0,nPower,0,0,'');
mode := 1; //다시 1로 바꾸기...
timer1.Enabled := false;
end;
end;
end;
end;