unit uWorld;

interface
uses
  vectorgeometry,vectortypes,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, GLWin32Viewer, GLCrossPlatform, BaseClasses, GLScene, jpeg,
  GLFilePNG, glKeyboard, GLDCE,
  GLHUDObjects, GLObjects, GLCoordinates, GLSound, GLMaterial, GLCadencer;

Type
TMap=class
private
Stena,Budka,Dom,Zavod: TGLCube;
public
MissionNumber: integer;
StenaList,DomList,BudkaList,ZavodList: TList;
DomLife: array [0..200] of integer;
DestroyedDom: array[0..200] of boolean;
DestroyedZavod: boolean;
DD_Kol_Vo: integer;
ZavodLife: Integer;
Procedure CreateMap;
Procedure Check_Life(num: integer);
end;


implementation
Uses Unit1;

{ TMap }

procedure TMap.Check_Life(num: integer);
var i: integer;
  vzriv: TGLSprite;
begin
DomLife[num]:=DomLife[num]-10;
if DomLife[num]<=0 then DestroyedDom[num]:=true;
if DestroyedDom[num]=true then begin
DD_Kol_Vo:=DD_Kol_Vo+1;
TGLCube(DomList[num-60]).position.y:=100;
Vzriv:=TGLSprite.CreateAsChild(Form1.GLScene1.Objects);
with Vzriv do begin
Position.AsAffineVector:=AffineVectorMAke(TGLCube(DomList[num-60]).Position.X,0.11,TGLCube(DomList[num-60]).Position.Z);
Width:=5;
Height:=5;
Material.Texture.Disabled:=false;
Material.MaterialLibrary:=Form1.GLMaterialLibrary1;
Material.LibMaterialName:='Vzriv';
end;

end;

end;

procedure TMap.CreateMap;
var i,x,xe: integer;
begin
DD_Kol_Vo:=0;
//Stena1, 2
If missionNumber=1 then begin
x:=30;
for i:=1 to 2 do begin
Stena:=TGLCube.CreateAsChild(form1.glscene1.objects);
with stena do begin
CubeWidth:=20;
CubeHeight:=0;
position.AsAffineVector:=affinevectorMake(x,0,0);
Tag:=24;
Material.FrontProperties:=Form1.Downsizer.Material.FrontProperties;
end;
StenaList.Add(Stena);
x:=x-60;
end;
//--

//Budki
for i:=1 to 13 do begin
Budka:=TGLCube.CreateAsChild(form1.glscene1.objects);
with Budka do begin
CubeWidth:=3;
CubeDepth:=3;
CubeHeight:=0;
position.AsAffineVector:=affinevectorMake(20,0,0);
Tag:=23;
Material.FrontProperties:=Form1.Downsizer.Material.FrontProperties;
end;
BudkaList.Add(Budka);
end;
TGLCube(Budkalist[1]).position.x:=-20;
TGLCube(Budkalist[2]).position.x:=-10;
TGLCube(Budkalist[2]).position.z:=115; //
TGLCube(Budkalist[3]).position.x:=0;
TGLCube(Budkalist[3]).position.z:=115; //
TGLCube(Budkalist[4]).position.x:=10;
TGLCube(Budkalist[4]).position.z:=115;  //
TGLCube(Budkalist[5]).position.x:=-30;  //
TGLCube(Budkalist[5]).position.z:=100;   //
TGLCube(Budkalist[6]).position.x:=-30;   //
TGLCube(Budkalist[6]).position.z:=90;    //
TGLCube(Budkalist[7]).position.x:=-30;   //
TGLCube(Budkalist[7]).position.z:=80;    //
TGLCube(Budkalist[8]).position.x:=20;
TGLCube(Budkalist[8]).position.z:=15;
TGLCube(Budkalist[9]).position.x:=20;
TGLCube(Budkalist[9]).position.z:=40;
TGLCube(Budkalist[10]).position.x:=20;
TGLCube(Budkalist[10]).position.z:=65;
TGLCube(Budkalist[11]).position.x:=20;
TGLCube(Budkalist[11]).position.z:=90;
TGLCube(Budkalist[12]).position.x:=20;
TGLCube(Budkalist[12]).position.z:=115;


//---


for i:=0 to Budkalist.Count-1 do begin
With GetOrCreateDCEDynamic(TGLCube(Budkalist[i])) do begin
Manager:=Form1.GLDCEManager1;
Size.SetVector(1,1,1);
end;
end;

for i:=0 to Stenalist.Count-1 do begin
With GetOrCreateDCEDynamic(TGLCube(Stenalist[i])) do begin
Manager:=Form1.GLDCEManager1;
Size.SetVector(10,1,1);
end;
end;

//Doma
xe:=60;
for i:=0 to 5 do begin
Dom:=TGLCube.CreateAsChild(form1.GLScene1.Objects);
with dom do begin
CubeWidth:=5;
CubeDepth:=6;
CubeHeight:=0;
Up.SetVector(0,1,0);
Direction.SetVector(0,0,1);
Tag:=xe+i;
Material.Texture.Disabled:=false;
Material.MaterialLibrary:=Form1.GLMaterialLibrary1;
Material.LibMaterialName:='Doma';
end;
DomLife[xe+i]:=10;
DestroyedDom[xe+i]:=false;
DomList.Add(Dom);
 With GetOrCreateDCEDynamic(TGLCube(Domlist[i])) do begin
Manager:=Form1.GLDCEManager1;
Size.SetVector(5,1,6);
end;
end;

for i:=0 to DomList.Count-1 do begin
TGLCube(DomList[0]).position.x:=30;
TGLCube(DomList[0]).position.z:=10;

TGLCube(DomList[1]).position.x:=30;
TGLCube(DomList[1]).position.z:=35;

TGLCube(DomList[2]).position.x:=30;
TGLCube(DomList[2]).position.z:=60;

TGLCube(DomList[3]).position.x:=30;
TGLCube(DomList[3]).position.z:=85;

TGLCube(DomList[5]).position.x:=30;
TGLCube(DomList[5]).position.z:=110;
//;;;;

TGLCube(DomList[4]).position.x:=-30;
TGLCube(DomList[4]).position.z:=120;
end;
//----

//ZAVOD
Zavod:=TGLCube.CreateAsChild(form1.GLScene1.Objects);
With Zavod do begin
CubeWidth:=20;
CubeDepth:=35;
CubeHeight:=0;
Position.AsAffineVector:=AffineVectorMake(-28,0,20);
Up.SetVector(0,1,0);
Direction.SetVector(0,0,1);
ZavodList.Add(Zavod);
 Material.Texture.Disabled:=false;
Material.MaterialLibrary:=Form1.GLMaterialLibrary1;
Material.LibMaterialName:='Zav';
ZavodLife:=100;
DestroyedZavod:=false;
Tag:=22;
end;

end;
//----




//II Mission
If missionNumber=2 then begin

Stena:=TGLCube.CreateAsChild(form1.glscene1.objects);
with stena do begin
CubeWidth:=15;
CubeHeight:=0;
position.AsAffineVector:=affinevectorMake(20,0,0);
Tag:=24;
Material.FrontProperties:=Form1.Downsizer.Material.FrontProperties;
end;
StenaList.Add(Stena);


for i:=0 to Stenalist.Count-1 do begin
With GetOrCreateDCEDynamic(TGLCube(Stenalist[i])) do begin
Manager:=Form1.GLDCEManager1;
Size.SetVector(15,1,1);
end;
end;

TGLCube(StenaList[0]).position.asaffineVector:=AffineVectorMAke(-20,0,0);
TGLCube(StenaList[0]).direction.setVector(-0.5,0,-0.5);


Form1.DownSizer.CubeWidth:=60;
Form1.DownSizer.Position.Z:=-28;

Form1.UpSizer.CubeWidth:=60;
Form1.UpSizer.Position.Z:=92;

Form1.LeftSizer.CubeDepth:=120;
Form1.LeftSizer.Position.x:=-30;

Form1.RightSizer.CubeDepth:=120;
Form1.RightSizer.Position.x:=30;

UPlayerTAnk.Player.Position.AsAffineVector:=affinevectormake(-10,0,-10);
UPlayerTAnk.Player2.Position.AsAffineVector:=affinevectormake(0,0,-10);
UPlayerTAnk.Player3.Position.AsAffineVector:=affinevectormake(10,0,-10);

end;


Form1.MainBar.MoveLast;

end;


end.
