public Player() { _player = new WMPPlayer(); _provider = new SoundCloudProvider(); _playlist = new DummyPlaylist(); _ui = new DasPlayer(this); // Hook up some _player events _player.StreamPlayerStateChanged += new PlayerStateChange(_player_StreamPlayerStateChanged); // Hook up playlist events _playlist.TrackChanged += new EventHandler(_playlist_TrackChanged); // Hook up some of the Player UI events _ui.ControlButtonPressed += new UIButtonEvent(ui_ControlButtonPressed); _ui.SearchRequested += new SearchRequested(_ui_SearchRequested); // Hook up the background worker for doing searches _bgSearch = new BackgroundWorker(); _bgSearch.WorkerReportsProgress = false; _bgSearch.WorkerSupportsCancellation = false; _bgSearch.DoWork += new DoWorkEventHandler(_backgroundWorker_DoWork); _bgSearch.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted); // We're nice, we'll poll the timer for the UI and make sure it // gets notified when the progress changes _timer = new Timer(); _timer.AutoReset = true; _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); _timer.SynchronizingObject = (Form)_ui; // dirty hackiness }
public Organism(IObservable observable, IMove moveModule, ILifeIndicator indicator, IPlayerUI ui) { this.observable = observable; movement = moveModule; this.indicator = indicator; this.UI = ui; UI.DamageTaked += TakeDamage; observable.Add(this); }
/// <summary> /// Gives derived classes an oppotunity to modify the GameObject /// </summary> /// <param name="playerController">Player controller created</param> /// <param name="playerGameObject">Player associated GameObject created</param> protected override void PlayerPrefabInstantiated(TwitchPlayerController playerController, GameObject playerGameObject) { base.PlayerPrefabInstantiated(playerController, playerGameObject); IPlayerUI playerUI = playerGameObject.GetComponent <IPlayerUI>(); if (playerUI != null) { playerGameObject.GetComponent <IPlayerUI>().playerController = playerController; playerGameObject.name = string.Concat(playerGameObject.name, ".", playerController.nick); } }
/// <summary> /// Creates a new Player and then returnes them. /// </summary> public T createPlayer <T>(Vector3 playerStartPos) where T : IPlayer { if (this.getPlayerCount() >= this.maxPlayers) { throw new Exception("Can not have more than " + this.maxPlayers + " players!"); } T newPlayer = (T)GameObject.Instantiate(this.playerPrefab, playerStartPos, Quaternion.identity).GetComponent <IPlayer>(); newPlayer.getTransform().position = playerStartPos; // Locate an id to use for the player. int freeID = -1; for (int i = 0; i < this.getMaxPlayers(); i++) { if (this.players[i] == null) { freeID = i; break; } } this.players[freeID] = newPlayer; if (this.splitScreen) { this.updateSplitScreenCameraSetup(); } else { // Create the UI for the player. GameObject obj = GameObject.Instantiate(this.uiPrefab, this.uiLocations[freeID]); IPlayerUI ui = obj.GetComponent <IPlayerUI>(); obj.transform.position = this.uiLocations[freeID].position; ui.setPlayer(newPlayer); this.playerUIs[freeID] = null; } return(newPlayer); }
void _ui_SearchRequested(IPlayerUI sender, string searchTerm) { if( _bgSearch.IsBusy) { SystemSounds.Beep.Play(); return; } if (BackgroundSearchChanged != null) { BackgroundSearchChanged(this, true); } _bgSearch.RunWorkerAsync(searchTerm); }
void ui_ControlButtonPressed(IPlayerUI sender, ButtonTypes button) { switch (button) { case ButtonTypes.PlayPause: switch(_player.State) { case StreamPlayerState.Playing: case StreamPlayerState.Paused: _player.Pause(); _timer.Enabled = false; break; case StreamPlayerState.NotPlaying: _player.Play(_playlist.Current.StreamURL); _timer.Enabled = true; break; } break; case ButtonTypes.Forwards: _userChanging = true; _player.Stop(); _timer.Enabled = false; _playlist.MoveForwards(); _player.Play(_playlist.Current.StreamURL); _timer.Enabled = true; break; case ButtonTypes.Back: _userChanging = true; _player.Stop(); _timer.Enabled = false; _playlist.MoveBackwards(); _timer.Enabled = true; break; case ButtonTypes.Quit: _userChanging = true; _player.Stop(); _timer.Enabled = false; ((Form)_ui).Close(); break; case ButtonTypes.Stop: _userChanging = true; _timer.Enabled = false; _player.Stop(); break; } }