Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit mFeld;
- interface
- uses Graphics,ExtCtrls,Forms,Controls,Types,mEinheit;
- type TFeld=class(TPanel)
- protected
- procedure Paint;override;
- private
- zSichtbar : Boolean;
- zPosHor,zPosVer : Integer; // Position im Array
- zEinheit : TEinheit;
- public
- // hImage : TImage;
- constructor Create(pX,pPosHor,pY,pPosVer,pHoehe,pBreite:integer;pImgPath:String;pForm:Tform); virtual;
- procedure setSichtbar; virtual;
- procedure setUnsichtbar; virtual;
- procedure setEinheit(pEinheit:TEinheit);
- procedure removeEinheit;
- function hasEinheit:Boolean;
- function getEinheit:TEinheit;
- function istSichtbar:boolean;
- function getPosHor : Integer;
- function getPosVer : Integer;
- procedure SetImageEventHandler;
- procedure drawImg;
- end;
- implementation
- constructor TFeld.Create(pX,pPosHor,pY,pPosVer,pHoehe,pBreite:integer;pImgPath:String;pForm:Tform);
- begin
- inherited create(pForm);
- // self.BevelInner := bvNone; //Hides Borders, off for dev/debugging
- // self.BevelOuter := bvNone;
- self.Parent:=pForm;
- self.Top:=pY;
- self.Left:=pX;
- self.Width:=pBreite;
- self.Height:=pHoehe;
- { hImage := TImage.Create(pForm);
- hImage.parent:=Self;
- hImage.Picture.LoadFromFile(pImgPath);
- hImage.Stretch:=false;
- hImage.Width:=pBreite;
- hImage.Height:=pHoehe;
- hImage.Visible:=false;}
- zPosHor := pPosHor;
- zPosVer := pPosVer;
- setUnsichtbar;
- zEinheit := nil;
- end;
- procedure TFeld.Paint;
- var bmp : TBitmap;
- begin
- inherited;
- bmp := TBitmap.Create;
- try
- bmp.LoadFromFile('textures\ground.bmp');
- self.Canvas.Draw(0,0,bmp);
- finally
- bmp.Free;
- end;
- end;
- procedure TFeld.SetImageEventHandler;
- begin
- // hImage.OnClick := self.OnClick;
- end;
- procedure TFeld.drawImg;
- var bmp : TBitmap;
- begin
- bmp := TBitmap.Create;
- try
- bmp.LoadFromFile('textures\ground.bmp');
- Canvas.Draw(0,0,bmp);
- finally
- bmp.Free;
- end;
- Canvas.Refresh;
- end;
- procedure TFeld.setSichtbar;
- begin
- zSichtbar:=true;
- self.Color := clWhite;
- // hImage.Visible := True;
- // self.Caption:='X';
- end;
- procedure TFeld.setUnsichtbar;
- var bmp : TBitmap;
- begin
- bmp := TBitmap.Create;
- try
- bmp.LoadFromFile('textures\invisible.bmp');
- self.Canvas.Draw(0,0,bmp);
- finally
- bmp.Free;
- end;
- zSichtbar:=false;
- self.Color := clGray;
- self.Caption:='';
- // hImage.Visible := False;
- end;
- function TFeld.istSichtbar:Boolean;
- begin
- Result := zSichtbar;
- end;
- function TFeld.hasEinheit:Boolean;
- begin
- if zEinheit <> nil then begin
- Result := True;
- end else begin
- Result := False;
- end;
- end;
- function TFeld.getEinheit:TEinheit;
- begin
- Result := zEinheit
- end;
- procedure TFeld.setEinheit(pEinheit:TEinheit);
- var typ : String;
- begin
- zEinheit:=pEinheit;
- typ := zEinheit.getType;
- if typ = 'tank' then begin
- self.Caption := 'T';
- end else if typ = 'melee' then begin
- self.Caption := 'M';
- end else if typ = 'ranged' then begin
- self.Caption := 'R';
- end else if typ = 'scout' then begin
- self.Caption := 'S';
- end;
- end;
- procedure TFeld.removeEinheit;
- begin
- zEinheit := nil;
- self.Caption := '';
- end;
- function TFeld.getPosHor:Integer;
- begin
- Result := zPosHor
- end;
- function TFeld.getPosVer:Integer;
- begin
- Result := zPosVer
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement