⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rltgame.pas

📁 一般的数据库管理系统 uses Classes, SConnectEx, TltConst, ExtCtrls, MMSystem, Types, windows, TltLogic , Sy
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit rltgame;

interface

uses
  Classes, Types, DXInput, DXDraws, Graphics, Windows, SysUtils, TltConst,
  math, ULoading, Forms;

type
 TPlayData = record
    //PlayData : array[0..60000] of Byte;   //PlayData  60001
    Name : string[3];                     //Name          4
    playerType : Byte;                    //Type          1
    score : LongInt;                      //score         4
    Dif : shortint;                       //难度        1
//    State : TPlayerState;                         //Stage         1     = 60012
  end;

  TRlt = class
  private
    FHasInit : boolean;
    FCurrentRoundNo: integer;
    FRoundScord: TRoundScord;
//    FCountDown: integer;
    FRoundBeginTime : DWord;
    FRealWheelParams : TWheelParams;
    WheelParamChanged : boolean;
    procedure DoBeting;
    procedure DoBeforeWheel;
    procedure DoPaused;
    procedure DoWheeling;
    procedure DoScore;
    procedure DoDemo;
    procedure DoStop;
    function GetCountDown: integer;
    procedure SetCurrentRoundNo(const Value: integer);
  public
    Round : TRound;
    ErrorCode : Byte;
    TimeSetting : TTimeSetting;
    WheelParams : TWheelParams;
    CurrentWheelParam : TWheelParam;
    procedure Draw;
    procedure Update;
    constructor Create();
    function DoInit: boolean;
    procedure DoFinit;
    procedure UpdateWheelParams;
    procedure UpdateWheel;
    procedure SetRound(const Value: TRound);
  published
    property CurrentRoundNo : integer read FCurrentRoundNo write SetCurrentRoundNo;
    property CountDown : integer read GetCountDown;
//    property RoundState : TRound read FRoundState write FRoundState;
  end;

  TPlayerPanelState = (ppsNoBody, ppsLogining, ppsLoginError, ppsActive, ppsLoginOtherWay, ppsUnknow);
  TPlayer = class
  private
    FRBet : LongInt;
    FBBet : LongInt;
    FGBet : LongInt;
    function GetBBet: LongInt;
    function GetGBet: LongInt;
    function GetRBet: LongInt;
    procedure SetBBet(const Value: LongInt);
    procedure SetGBet(const Value: LongInt);
    procedure SetRBet(const Value: LongInt);
  public
    UserID : String;
    Password : String;
    money : LongInt;
    State : TPlayerState;
    Modified : boolean;
    procedure ClearBets;
    procedure Update;
    property RBet : LongInt read GetRBet write SetRBet;
    property BBet : LongInt read GetBBet write SetBBet;
    property GBet : LongInt read GetGBet write SetGBet;
    procedure Clear;
  end;

  TPlayerPanel = class
  private
    //page1
    LoginButtomRect : TRect;
    //page2
    UserIDBox : TRect;
    PasswordBox : TRect;
    OKButtomRect : TRect;
    CancelButtomRect : TRect;
    LogoutButtomRect : TRect;
    //page3
    UserIDLabel : TRect;
    ScoreLabel : TRect;
    MsgLable : TRect;
    Msg2Lable : TRect;
    RBox : TRect;
    BBox : TRect;
    GBox : TRect;
    //LogoutButtomRect : TRect;
    //page4
    ErrorLabel : TRect;
    InputCount : integer;
    Cursor : TPoint;
    procedure SetState(const Value: TPlayerPanelState);
  public
    UserName : String;
    Password : String;
    Player : TPlayer;
    FouceID : byte;
    FState : TPlayerPanelState;
    BoundsRect : TRect;
    ClientRect : TRect;
    Eabled : boolean;
    procedure Update(CursorPos : TPoint; MouseState : byte; Key : Word);
    procedure Draw(DestSurface : TDirectDrawSurface; PlayPanelFrame,ItemsSurface : TDirectDrawSurface);
    property State : TPlayerPanelState read FState write SetState;
    constructor Create(Player : TPlayer);
    function OverButton(CursorPos: TPoint; R : TRect): boolean ;
  end;

  TChipPanel = class
  private
    FCursorPos : TPoint;
    ChipRect : array [0..4] of TRect;
    FSelectedChip: longint;
    procedure SetSelectedChip(const Value: longint);
    function GetSelectedChipValue: longint;
    function OverButton(CursorPos: TPoint; R: TRect): boolean;
  public
    BoundsRect : TRect;
    ClientRect : TRect;
    property SelectedChip : longint read FSelectedChip write SetSelectedChip;
    property SelectedChipValue : longint read GetSelectedChipValue;
    procedure Update(CursorPos : TPoint; MouseState : byte; Key : Word);
    procedure Draw(DestSurface, ChipPanelSurface, ItemsSurface : TDirectDrawSurface);
    constructor Create();
  end;

  TTimePanel = class
    Time : integer;
    BoundsRect : TRect;
    ClientRect : TRect;
    TimeLabelRect : TRect;
    RoundLabelRect : TRect;
    Color : TColor;
    procedure Update(CursorPos : TPoint; MouseState : byte; Key : Word);
    procedure Draw(DestSurface, PanelSurface, ItemsSurface : TDirectDrawSurface);
    constructor Create();
  end;

  THistoryPanel = class
    BoundsRect : TRect;
    ClientRect : TRect;
    procedure Update(CursorPos : TPoint; MouseState : byte; Key : Word);
    procedure Draw(DestSurface, PanelSurface, ItemsSurface : TDirectDrawSurface);
    constructor Create();
  end;

var
  rlt : TRlt;
  Players : array [0..3] of TPlayer;
  PlayerPanel : array [0..3] of TPlayerPanel;
  ChipPanel : TChipPanel;
  TimePanel : TTimePanel;
  HistoryPanel : ThistoryPanel;
//  PPD : TPlayData;
  Level1,Level2,Flag1 : Integer;
  Frame1,FrameRate : Integer;
  FrameTime : LongInt;
  LastTime : LongInt;
  MouseState : byte;

implementation

uses rltClient, Main;

{ TRlt }
procedure TRlt.Draw;
begin
  try
    case Round.State of
      rsWaitToBegin, rsPaused:
      begin
        MainForm.DrawRoulette;
        MainForm.DrawHistoryPanel;
        MainForm.DrawPlayerPanels;
        MainForm.DrawPaused;
        MainForm.DrawMouse;
        {draw wait}
      end;
      rsBeting:
      begin
        MainForm.DrawRoulette;
        MainForm.DrawTimePanel;
        MainForm.DrawChipPanel;
        MainForm.DrawPlayerPanels;
        MainForm.DrawHistoryPanel;
        MainForm.DrawMouse;
      end;
      rsBeforeWheel:
      begin
        MainForm.DrawRoulette;
        MainForm.DrawTimePanel;
        MainForm.DrawPlayerPanels;
//        MainForm.DrawChipPanel;
//        MainForm.DrawHistoryPanel;
        MainForm.DrawMouse;
      end;
      rsWheeling:
      begin
        MainForm.DrawRoulette;
        MainForm.DrawScore;
        MainForm.DrawMouse;
      end;
      rsScore:
      begin
        MainForm.DrawRoulette;
        MainForm.DrawMouse;
  //      MainForm.DrawPaused;
      end;
    end;
    //MainForm.DrawFPS;
    MainForm.DXDraw.Flip;
  Except
    if not MainForm.DXDraw.CanDraw then
    begin
      try
        MainForm.DXDraw.Finalize;
        MainForm.DXDraw.Initialize;
      except
      end;
    end;
  end;
end;

var
  ii: integer;

procedure TRlt.Update;
begin
//update game state;
  if (not FHasInit) and (not DoInit) then Exit;
  case Round.State of
    rsWaitToBegin:
    begin
    {}
    end;
    rsDemo{开始本轮}:
    begin
      DoDemo;
    end;
    rsBeting{下注}:
    begin
      DoBeting;
    end;
    rsBeforeWheel{准备开局}:
    begin
      DoBeforeWheel;
    end;
    rsWheeling{转盘}:
    begin
      DoWheeling;
    end;
    rsScore{分数}:
    begin
      DoScore;
    end;
    rsPaused{系统暂停}:
    begin
      DoPaused;
    end;
    rsStop :
    begin
      DoStop;
    end;
    //, rsSyn{数据同步});
  end;
  MainForm.KeyList.Clear;
  MouseState := 0;
  UpdateWheel;
end;

procedure TRlt.DoBeting;
var
  I, J: integer;
  Key : word;
  P : TPoint;
begin
// 开始新一局
  if Level2 =1 then
  begin
    FRoundBeginTime := LastTime - Round.CountDown*1000 + 1000;//误差
    MainForm.PlaySoundBeginBet;
    Level2 := 2;
  end;

  //update
  GetCursorPos(P);
  P := MainForm.DXDraw.ScreenToClient(P);
  if MainForm.KeyList.Count>0 then begin
    for J := 0 to MainForm.KeyList.Count -1 do begin
      Key := Word(MainForm.KeyList[J]);
      for I := 0 to 3 do begin
        PlayerPanel[I].Update(P,MouseState, Key);
      end;
    end;
  end else begin
    for I := 0 to 3 do begin
      PlayerPanel[I].Update(P,MouseState, 0);
    end;
    ChipPanel.Update(P, MouseState, 0);
    TimePanel.Update(P, MouseState, 0);
    HistoryPanel.Update(P, MouseState, 0);
  end;
end;


constructor TRlt.Create;
begin
  FHasInit := false;
  Round.State := rsWaitToBegin;
  Level2 := 1;
end;

procedure TRlt.DoFinit;
begin

end;

function TRlt.DoInit : boolean;
begin
//1,第一次登入,2掉线后恢复登入
//syn server Roundstate 1.RoundNo, RoundScord,RoundState,PassTime,RoundCounter,
//RoundSetting.
  Result := false;
  if not RltConnection.Connected then Exit;
//  Round := TltInterpreter.CallGetCurrentRound;
//WaitRoundToBegin;
  Round.State := rsWaitToBegin;
  Level2 := 1;
//  FRoundScord := TltInterpreter.CallGetScore(Round.No, Round.WheelNo);
  WheelParams := TltInterpreter.CallGetWheelParams;

  FRoundBeginTime :=LastTime - WheelParams.WheelStartTickCount;
  UpdateWheelParams;
  FHasInit := true;
  Result := true;
end;

procedure TRlt.DoBeforeWheel;
begin
  if Level2 = 1 then begin
    MainForm.PlaySoundStopBet;
    Level2 := 2;
  end;
end;

procedure TRlt.DoPaused;
begin

end;

procedure TRlt.DoScore;
begin
  if Level2 =1 then begin
    MainForm.PlaySoundNum(Round.WheelResult);
    Level2 := 2;
  end;
end;

procedure TRlt.DoWheeling;
begin

end;

procedure TRlt.DoDemo;
begin

end;

function TRlt.GetCountDown: integer;
begin
  Result := TimeSetting.BeforeWheelTimeSet - Round.CountDown;
  if Result <=0 then Result := 0;
end;

procedure TRlt.SetCurrentRoundNo(const Value: integer);
begin
  FCurrentRoundNo := Value;
end;

procedure TRlt.UpdateWheelParams;
begin
  //更新了旋转参数,将速度进行适当的调整,以达到目的结果;
  FRealWheelParams := WheelParams;
  CurrentWheelParam := FRealWheelParams.Params[0];
end;

procedure TRlt.UpdateWheel;
var
  DT : integer;
  i : integer;
  V : single;
  DV : single;
  MaxFrameTime : integer;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -