unit mission;

interface

uses
  Windows, SysUtils, classes, Graphics, trigu,Baseclass,EnemyHeap;

type
  TPlace = (tpTop,tpleft,tpbottom,tpright,tpTopleft,tpTopright,tpbottomleft,tpbottomright,tpu1,tpu2,tpu3,tpu4);

  TMissions = class
   _level:integer;
   _timer:integer;
   _CE:TContenerEnemy;
   procedure Init(var CE:TContenerEnemy);
   procedure Rush(TE:TTypeEnemy; Place:TPlace; _count:integer);
   procedure GetMission(_num:integer);
   procedure process;
  end;

implementation

uses gi;

procedure TMissions.Init(var CE:TContenerEnemy);
begin
 _level:=0;
 _timer:=0;
 _CE:=CE;
end;

procedure TMissions.Rush( TE:TTypeEnemy; Place:TPlace; _count:integer);
var i:integer;
begin
 case Place of 
   tpTop: begin
     for i:=0 to _count-1 do begin
     _ce.adden(random(1280),random(20)-40,te);
     end;
   end;
   tpleft: begin
     for i:=0 to _count-1 do begin
     _ce.adden(random(20)-40,random(1024),te);
     end;
   end;
   tpbottom: begin
     for i:=0 to _count-1 do begin
     _ce.adden(random(1280),random(20)+1024,te);
     end;
   end;
   tpright: begin
     for i:=0 to _count-1 do begin
     _ce.adden(random(20)+1280,random(1024),te);
     end;
   end;
   tpTopleft: begin
     for i:=0 to _count-1 do begin
     case random(2) of
      0:_ce.adden(random(320),random(10)-30,te);
      1:_ce.adden(random(10)-30,random(256),te);
     end; end;
   end;
   tpTopright: begin
     for i:=0 to _count-1 do begin
     case random(2) of
      0:_ce.adden(1280-random(320),random(10)-30,te);
      1:_ce.adden(random(10)+1280,random(256),te);
     end; end;
   end;
   tpbottomleft: begin
     for i:=0 to _count-1 do begin
     case random(2) of
      0:_ce.adden(random(320),random(10)+1024,te);
      1:_ce.adden(random(10)-30,1024-random(256),te);
     end; end;
   end;
   tpbottomright: begin
     for i:=0 to _count-1 do begin
     case random(2) of
      0:_ce.adden(1280-random(320),random(10)+1024,te);
      1:_ce.adden(random(10)+1280,1024-random(256),te);
     end; end;
   end;
   tpu1: begin
     for i:=0 to _count-1 do begin
     _ce.adden(-10,-10,te);
     end;
   end;
   tpu2: begin
     for i:=0 to _count-1 do begin
     _ce.adden(1290,-10,te);
     end;
   end;
   tpu3: begin
     for i:=0 to _count-1 do begin
     _ce.adden(1290,1034,te);
     end;
   end;
   tpu4: begin
     for i:=0 to _count-1 do begin
     _ce.adden(-10,1034,te);
     end;
   end;
 end;
end;

procedure TMissions.GetMission(_num:integer);
begin
//tpTop,tpleft,tpbottom,tpright,tpTopleft,tpTopright,tpbottomleft,tpbottomright,tpu1,tpu2,tpu3,tpu4
//teMeloch,teBugay,teharder
case _num of
  0: begin  Rush(teBugay, tpleft, 1); Rush(teBugay, tpright, 1); _timer:=_timer+300; weapPanel.w3:=true; end;
  1: begin  Rush(teBugay, tpleft, 3); Rush(teBugay, tpright, 2); _timer:=_timer+200; weapPanel.w1:=true; end;
  2: begin  Rush(teBugay, tpleft, 5); Rush(teBugay, tpright, 8); _timer:=_timer+200; end;
  3: begin  Rush(teMeloch, tpu1, 10); Rush(teMeloch, tpu3, 10); weapPanel.w5:=true; _timer:=_timer+600; end;
  4: begin  Rush(teBugay, tpTopleft, 16);Rush(teMeloch, tpTopright, 7);Rush(teMeloch, tpu3, 23);  weapPanel.w4:=true; end;
  5: begin  Rush(teharder, tpleft, 11); Rush(teMeloch, tpu1, 27);  Rush(teharder, tpright, 13); weapPanel.w6:=true; end;
  6: begin  Rush(teMeloch, tpleft, 28); Rush(teBugay, tpleft, 16); weapPanel.w2:=true; end;
  7: begin  Rush(teMeloch, tpright, 42); Rush(teBugay, tpright, 23); Rush(teharder, tpright, 14);  end;

  8: begin  Rush(teMeloch, tpu1, 67);  end;
  9: begin  Rush(teBugay, tpTopright, 16); Rush(teBugay, tpbottomright, 16); Rush(teharder, tpright, 11);  end;
  10: begin  Rush(teMeloch, tpTopleft, 42); Rush(teBugay, tpu4, 23); Rush(teharder, tpright, 14);  end;
  11..99:  begin  Rush(teMeloch, tpbottom, trunc(_level*3)+random(10)); Rush(teBugay, tpu4, trunc(_level*2)+random(20)); Rush(teharder, tpright, trunc(_level*2)+random(16));  end;
end;
end;

procedure  TMissions.process;
begin
if _timer=-1 then exit;
_timer:=_timer+1;   //1400 round
if _timer>1500 then begin
 _timer:=0;
 GetMission(_level);
 _level:=_level+1;
end;
end;

end.

