Beispiel #1
0
        protected override void OnAfterTransition(RegulatorState oldState, RegulatorState newState, object data)
        {
            switch (newState.Name)
            {
            case "StartPurchase":
                if (!Network.CityClient.IsConnected)
                {
                    ThrowErrorAndReset("City server disconnected");
                    return;
                }
                CurrentRequest = data as PurchaseLotRequest;
                AsyncTransition("SendPurchaseRequest");
                break;

            case "SendPurchaseRequest":
                Network.CityClient.Write(new FSO.Server.Protocol.Electron.Packets.PurchaseLotRequest
                {
                    LotLocation_X = CurrentRequest.X,
                    LotLocation_Y = CurrentRequest.Y,
                    Name          = CurrentRequest.Name,
                    StartFresh    = CurrentRequest.StartFresh,
                    MayorMode     = CurrentRequest.Mayor
                });
                break;

            case "ReceivedPurchaseResponse":
                var response = data as FSO.Server.Protocol.Electron.Packets.PurchaseLotResponse;
                if (response.Status == Server.Protocol.Electron.Packets.PurchaseLotStatus.FAILED)
                {
                    //Error
                    ThrowErrorAndReset(response.Reason);
                }
                else
                {
                    AsyncTransition("PurchaseComplete");
                    GameThread.NextUpdate(x => { OnPurchased(response.NewFunds); });
                }
                break;

            case "PurchaseComplete":
                AsyncTransition("Idle");
                break;
            }
        }
Beispiel #2
0
 public void Purchase(PurchaseLotRequest request)
 {
     this.AsyncProcessMessage(request);
 }