private void UpdatePlaylist() { Task.Factory.StartNew(() => { playlist = new List <Song>(); for (int x = 0; x < 3; x++) { playlist.AddRange(CurrentStation.GetPlaylist()); } Action act = () => { listPlaylist.Items.Clear(); foreach (var song in playlist) { listPlaylist.Items.Add(song); } }; if (InvokeRequired) { Invoke(act); } else { act(); } }); }
internal void MoveRed() { if (CanMoveRed()) { MoveToNewStation(CurrentStation.RedwardStationLocation()); } }
private IList <StationLocation> AdjacentLocations() { return(new [] { CurrentStation.BluewardStationLocation(), CurrentStation.RedwardStationLocation(), CurrentStation.OppositeStationLocation() } .Where(stationLocation => stationLocation != null) .Select(stationLocation => stationLocation.Value) .ToList()); }
internal void MoveBlue() { if (CanMoveBlue()) { MoveToNewStation(CurrentStation.BluewardStationLocation()); } }
// Use this for initialization void Start() { SpriteRenderer renderer = GetComponent <SpriteRenderer> (); if (renderer == null) { return; } string foregroundName = CurrentStation.GetCurrentStationInfo().Foreground; renderer.sprite = Resources.Load <Sprite> (foregroundName) as Sprite; List <string> itemNames = CurrentStation.GetCurrentStationInfo().SpecialItems; foreach (string itemName in itemNames) { SpecialItemInfo itemInfo = new SpecialItemInfo(itemName); if (Randomizer.GetPercentageBasedBoolean(itemInfo.Probability)) { GameObject prefab = _itemPrefabs.Find(gameObject => { return(gameObject.name == itemName); }); if (prefab != null) { GameObject instantiated = (GameObject)Instantiate(prefab, transform); float x = Random.Range(transform.position.x - (renderer.bounds.size.x * 0.5f), transform.position.x + (renderer.bounds.size.x * 0.5f)); float y = Random.Range(transform.position.y - (renderer.bounds.size.y * 0.5f), transform.position.y + (renderer.bounds.size.y * 0.5f)); Vector3 position = new Vector3(x, y, -1); instantiated.transform.position = position; instantiated.GetComponent <SpawnedSpecialItem> ().SetInventoryScroller(_scroller); instantiated.GetComponent <SpawnedSpecialItem> ().SpecialItem = itemInfo; } } } }
private void btnRemove_Click(object sender, EventArgs e) { if (listSeeds.SelectedItem != null && CurrentStation.Seeds.Count > 1) { CurrentStation.RemoveSeed(((Seed)listSeeds.SelectedItem).SeedID); RefreshItems(); UpdatePlaylist(); } }
// Use this for initialization void Start() { SpriteRenderer renderer = GetComponent <SpriteRenderer> (); if (renderer == null) { return; } string backgroundName = CurrentStation.GetCurrentStationInfo().Background; renderer.sprite = Resources.Load <Sprite> (backgroundName) as Sprite; transform.localScale = new Vector3(1, 1, 1); float width = renderer.sprite.bounds.size.x; float height = renderer.sprite.bounds.size.y; float worldScreenHeight = Camera.main.orthographicSize * 2.0f; float worldScreenWidth = worldScreenHeight / Screen.height * Screen.width; transform.localScale = new Vector3((float)(worldScreenWidth / width), (float)(worldScreenHeight / height), 1); }
internal void MoveToMostPlayers() { var adjacentStations = new[] { new { NewStation = CurrentStation.RedwardStationLocation(), MoveCommand = new Action(MoveRed) }, new { NewStation = CurrentStation.BluewardStationLocation(), MoveCommand = new Action(MoveBlue) }, new { NewStation = CurrentStation.OppositeStationLocation(), MoveCommand = new Action(ChangeDecks) } } .Where(station => station.NewStation != null); var adjacentStationGroupWithMostPlayers = adjacentStations .Select(station => new { Station = station, PlayerCount = SittingDuck.GetPlayerCount(station.NewStation.Value) }) .GroupBy(station => station.PlayerCount) .OrderByDescending(group => group.Key) .First(); if (adjacentStationGroupWithMostPlayers.Count() == 1) { adjacentStationGroupWithMostPlayers.Single().Station.MoveCommand(); } }
private int UpdatePlaylist() { List <Song> result = new List <Song>(); try { result = CurrentStation.GetPlaylist(); } catch (PandoraException ex) { if (ex.Message == "DAILY_SKIP_LIMIT_REACHED") { DailySkipLimitReached = true; DailySkipLimitTime = DateTime.Now; } } if (result.Count == 0 && CurrentStation != null) { result = CurrentStation.GetPlaylist(); } return(_playlist.AddSongs(result)); }
private void txtTitle_Validated(object sender, EventArgs e) { CurrentStation.Rename(txtTitle.Text); }
internal void ChangeDecks() { MoveToNewStation(CurrentStation.OppositeStationLocation()); }
void Start() { _passengerNames = CurrentStation.GetCurrentStationInfo().PassengerNames; _currentPassengersCount = _remainingCount = Randomizer.GetInRange(1, CurrentStation.GetCurrentStationInfo().MaxCharacters); }
public ERRORS Start(PlayerOnEventCb eventcb) { ERRORS ret; ret = dz_player_activate(libcPlayerHndl, new IntPtr(this.GetHashCode())); Console.WriteLine($"dz_player_activate result: {ret}"); this.eventcb = delegate(PLAYER * libcPlayer, PLAYER_EVENT *libcPlayerEvent, IntPtr userdata) { Player player = (Player)refKeeper[userdata]; PlayerEvent playerEvent = PlayerEvent.newFromLibcEvent(libcPlayerEvent); STREAMING_MODE streamingMode; int idx; var result = dz_player_event_get_queuelist_context(libcPlayerEvent, &streamingMode, &idx); if (!result) { streamingMode = STREAMING_MODE.DZ_STREAMING_MODE_ONDEMAND; idx = DZ_INDEX_IN_QUEUELIST_INVALID; } if (playerEvent.eventType == PLAYER_EVENT_TYPE.DZ_PLAYER_EVENT_QUEUELIST_TRACK_SELECTED) { bool isPreview; bool canPauseUnPause; bool canSeek; int numberSkipAllowed; isPreview = dz_player_event_track_selected_is_preview(libcPlayerEvent); var ok = dz_player_event_track_selected_rights(libcPlayerEvent, &canPauseUnPause, &canSeek, &numberSkipAllowed); var songIntPtr = dz_player_event_track_selected_dzapiinfo(libcPlayerEvent); var nextIntPtr = dz_player_event_track_selected_next_track_dzapiinfo(libcPlayerEvent); var currentSongStr = NativeMethods.StringFromNativeUtf8(songIntPtr); var nextSongStr = NativeMethods.StringFromNativeUtf8(nextIntPtr); CurrentSong = JsonConvert.DeserializeObject <Song>(currentSongStr); OnSongChanged(CurrentSong); IsPlaying = true; } else if (playerEvent.eventType == PLAYER_EVENT_TYPE.DZ_PLAYER_EVENT_QUEUELIST_LOADED && CurrentStation.IndexOf("playlist", StringComparison.OrdinalIgnoreCase) >= 0) { Next(); Console.WriteLine("Next song - plalist"); } eventcb.Invoke(player, playerEvent); }; ret = dz_player_set_event_cb(libcPlayerHndl, this.eventcb); Console.WriteLine($"dz_player_set_event_cb result: {ret}"); return(ret); }