unit uQuest;

interface
uses
  LexUtils, zglHeader;

type
  TQuest = class
    Win : Boolean;
    L, LNow : Integer;
  //  qManda, qSnow, qBalls : Integer;
    constructor Create(inL : Integer);
    procedure Draw; virtual;
    function  Update : Boolean; virtual;
  end;

  TQuestRoad = class(TQuest)
    procedure Draw; override;
    function  Update : Boolean; override;
  end;

  TQuestCollect = class(TQuest)
    procedure Draw; override;
  end;

  TQuestCollect1 = class(TQuestCollect)
    procedure Draw; override;
  end;
  TQuestCollect2 = class(TQuestCollect)
    procedure Draw; override;
  end;
  TQuestCollect3 = class(TQuestCollect)
    procedure Draw; override;
  end;

var
  Quest  : TQuest;
  QuestT : Integer;

procedure StartQuest(Q : Integer);

implementation
uses
  uMaterials, uConst;
{ TQuest }

procedure StartQuest(Q : Integer);
begin
  if Quest <> nil then
    Quest.Free;
  case Q of
  1 : begin
        Quest  := TQuestRoad.Create(5000);
        QuestT := 4;
      end;
  2 : begin
        Quest  := TQuestCollect1.Create(21);
        QuestT := 1;
      end;
  3 : begin
        Quest  := TQuestRoad.Create(7000);
        QuestT := 4;
      end;
  4 : begin
        Quest  := TQuestCollect2.Create(70);
        QuestT := 2;
      end;
  5 : begin
        Quest  := TQuestRoad.Create(1800);
        QuestT := 4;
      end;
  6 : begin
        Quest  := TQuestCollect3.Create(30);
        QuestT := 3;
      end;
  7 : begin
        Quest  := TQuestRoad.Create(5000);
        QuestT := 4;
      end;
  end;

end;

constructor TQuest.Create;
begin
  Win := False;
  L := inL;
  LNow := 0;
{  qManda := 0;
  qSnow  := 0;
  qBalls := 0; }
end;

procedure TQuest.Draw;
begin

end;

function TQuest.Update: Boolean;
begin
  Result := LNow >= L;
end;

{ TQuestRoad }

procedure TQuestRoad.Draw;
begin
  ssprite2d_Draw(mQuest1, WinW - 256, WinH - 64, 256, 64, 0, 150);
  ssprite2d_Draw(mQuest1P, WinW - 256 + LNow * 180 / L, WinH - 64, 64, 64, 0, 150);
end;

function TQuestRoad.Update: Boolean;
begin
  LNow := LNow + 1;
  Result := LNow >= L;
end;

{ TQuestCollect }

procedure TQuestCollect.Draw;
begin
  ssprite2d_Draw(mQuest2, WinW - 256, WinH - 64, 256, 64, 0, 150);
  text_Draw(mFont_Ed, WinW - 60, WinH - 28,
  AnsiToUtf8(Int2S(LNow) + ' θη ' + Int2S(L)),
  TEXT_HALIGN_CENTER or TEXT_VALIGN_CENTER);
end;

{ TQuestCollect1 }

procedure TQuestCollect1.Draw;
begin
  inherited;
  asprite2d_Draw(mBonus, WinW - 160 , WinH - 42, 32, 32, 0, 1, 200);
end;

{ TQuestCollect2 }

procedure TQuestCollect2.Draw;
begin
  inherited;
  asprite2d_Draw(mBonus, WinW - 160 , WinH - 42, 32, 32, 0, 2, 200);
end;

{ TQuestCollect3 }

procedure TQuestCollect3.Draw;
begin
  inherited;
  asprite2d_Draw(mBonus, WinW - 169 , WinH - 42, 32, 32, 0, 3, 200);
  asprite2d_Draw(mBonus, WinW - 151 , WinH - 42, 32, 32, 0, 4, 200);
end;





end.
