private void SetTransporterPosition(CarrierView carrierView, TransporterRemoteData transporterRemoteData) { float width = _path.rect.width; float unitDistance = width / Constants.WarehouseDistance; carrierView.RectTransform.anchoredPosition = new Vector2(width - transporterRemoteData.CurrentLocation * unitDistance, 0f); }
// TODO: Not the best place to do this. Add respective Facades and then do this there. // For now doing it here. private void TransporterTick(TransporterRemoteData transporter, float interval) { switch (transporter.TransporterState) { case ETransporterState.Idle: if (!string.IsNullOrEmpty(WarehouseRemoteData.Manager)) { transporter.TransporterState = ETransporterState.WalkingToElevator; } break; case ETransporterState.WalkingToElevator: if ((transporter.CurrentLocation += WarehouseRemoteData.WarehouseLevelData.WalkSpeed * interval) >= _staticDataModel.MetaData.WarehouseDistance) { transporter.TransporterState = ETransporterState.Loading; } break; case ETransporterState.WalkingToWarehouse: if ((transporter.CurrentLocation -= (int)WarehouseRemoteData.WarehouseLevelData.WalkSpeed * interval) <= 0) { AddCash(transporter.LoadedCash); transporter.LoadedCash = 0; transporter.TransporterState = WarehouseRemoteData.Manager == null ? ETransporterState.Idle : ETransporterState.WalkingToElevator; } break; case ETransporterState.Loading: double cashToLoad = WarehouseRemoteData.WarehouseLevelData.LoadingSpeed * interval; if (transporter.LoadedCash + cashToLoad > WarehouseRemoteData.WarehouseLevelData.LoadPerTransporter) { cashToLoad = WarehouseRemoteData.WarehouseLevelData.LoadPerTransporter - transporter.LoadedCash; } double cashLoaded = _remoteDataModel.Elevator.RemoveStoredCash(cashToLoad); transporter.LoadedCash += cashLoaded; if (Math.Abs(cashToLoad - cashLoaded) > 0.1f || transporter.LoadedCash >= WarehouseRemoteData.WarehouseLevelData.LoadPerTransporter) { transporter.TransporterState = ETransporterState.WalkingToWarehouse; } break; } //UnityEngine.Debug.LogError(string.Format("State: {0}, Location: {1}, Loaded: {2}", transporter.TransporterState.ToString(), transporter.CurrentLocation, transporter.LoadedCash)); }