void Awake () { // singleton example code if (instance != null && instance != this) { //if there is already a music player active //just tell *it* to play our song, and then self-destruct if((playAtStart && !OnlyPlayIfNoMusicPlaying) || (playAtStart && OnlyPlayIfNoMusicPlaying && !instance.audio.isPlaying)) { instance.PlayMusic(this.music, this.loop); } else { instance.music = this.music; } Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); soundSource = gameObject.AddComponent<AudioSource>(); soundSource.loop = loop; if(playAtStart) PlayMusic (music, loop); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { if (dontDestroy) { Destroy(gameObject); } else { Destroy(instance); instance = this; initialized = false; } } if (dontDestroy) { DontDestroyOnLoad(gameObject); } }
public void PlayTrack(Track track) { var path = Path.Combine (NSBundle.MainBundle.ResourcePath, "testsound.mp3"); var data = System.IO.File.ReadAllBytes (path); var url = NSUrl.FromFilename (path); var status = MusicPlayerStatus.Success; player = MusicPlayer.Create (out status); player.MusicSequence = new MusicSequence (); player.MusicSequence.LoadFile (url, MusicSequenceFileTypeID.Any); player.Start (); /*AppDelegate.Player = AVAudioPlayer.FromUrl (url); AppDelegate.Player.NumberOfLoops = 1; var res = AppDelegate.Player.PrepareToPlay (); //player.AddPeriodicTimeObserver (CoreMedia,CMTime.FromSeconds (1, 1), ); var r = AppDelegate.Player.Play (); AppDelegate.Player.DecoderError += (sender, e) => { var a = 3; }; AppDelegate.Player.FinishedPlaying += (sender, e) => { var a = 4; }; AppDelegate.Player.BeginInterruption += (sender, e) => { var a = 5; }; AppDelegate.Player.EndInterruption += (sender, e) => { var a = 6; }; */ }
// Use this for initialization void Start () { musicPlayer = GameObject.FindObjectOfType<MusicPlayer>(); if ( musicPlayer ) { volumeSlider.value = musicPlayer.GetVolume(); } }
// Use this for initialization void Start () { // get all the objects we'll need for the cutscene riftParticles = GameObject.Find ("RiftParticles").GetComponent<ParticleSystem>(); mus = GameObject.Find ("BGM").GetComponent<MusicPlayer>(); playSound(Rain, true); }
// Use this for initialization void Start() { if (instance != null) { Destroy (gameObject); }else{ instance = this; } }
// Use this for initialization void Start () { // get all the objects we'll need for the cutscene LMFB = GameObject.Find ("LMFB"); Daria = GameObject.Find ("Daria"); mus = GameObject.Find ("BGM").GetComponent<MusicPlayer>(); bc = GetComponent<BattleController>(); }
// Use this for initialization void Awake(){ if (instance != null) { Destroy (gameObject); } else { instance = this; GameObject.DontDestroyOnLoad (gameObject); } }
// Use this for initialization void Start() { script = this; DontDestroyOnLoad(this.gameObject); if (!this.GetComponent<AudioSource>()) this.gameObject.AddComponent<AudioSource>(); this.audio.loop = true; }
void Awake () { if ( instance != null ) { Destroy( gameObject ); // Debug.Log( "Destroy music player" ); } else { instance = this; GameObject.DontDestroyOnLoad( gameObject ); } }
// Use this for initialization void Start () { // get all the objects we'll need for the cutscene ChefTony = GameObject.Find ("Chef Tony"); James = GameObject.Find ("James"); mus = GameObject.Find ("BGM").GetComponent<MusicPlayer>(); startTimer(); }
// Use this for initialization void Start () { musicPlayer = GameObject.FindObjectOfType<MusicPlayer>(); if ( musicPlayer ) { volumeSlider.value = musicPlayer.GetVolume(); } difficultySlider.value = PlayerPrefsManager.GetDifficulty(); }
void Awake() { if(Self){ DestroyImmediate(this.gameObject); } else { Self = this; GameObject.DontDestroyOnLoad(this.gameObject); } }
// Use this for initialization void Start () { mp = GameObject.Find("BGM").GetComponent<MusicPlayer>(); bc = GameObject.Find ("Scripts").GetComponent<BattleController>(); chefTony = GameObject.Find ("Chef Tony"); ff = GameObject.Find ("Father Flanagan"); os = GameObject.Find ("Orphan Shield"); shoes = GameObject.Find ("ShoesTie"); }
// Use this for initialization void Start () { if (instance != null){ Destroy (gameObject); print("Duplicated Music Destroyed"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
void Awake () { Debug.Log ("Music player Awake " + GetInstanceID ()); if (instance != null) { Destroy (gameObject); } else { instance = this; GameObject.DontDestroyOnLoad (gameObject); } }
void Awake () { if (m_instance != null) { Destroy(gameObject); Debug.Log ("Destorying gameObject"); } else { m_instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
void Awake () { if (instance != null) { Destroy(gameObject); print("Duplicate music player destroyed"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
// Use this for initialization void Awake() { if(instance != null){ // If an instance of the game object already exists, then destroy. Destroy (gameObject); }else {//if(!Timer.gameStarted){ instance = this; // instance = this is an instance of the global variable. GameObject.DontDestroyOnLoad(gameObject); } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Start() { if (instance != null && instance != this) { Destroy (gameObject); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
void Awake () { if (instance != null) { Destroy(gameObject); Debug.Log("Duplicate MusicPlayer self-destructing!"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
public void Start () { if(instance != null){ DestroyObject(gameObject); print ("Music Player Destroyed."); } else{ instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
/// <summary> /// Constructor /// </summary> public DefaultForm() { InitializeComponent(); music = new MusicPlayer(); random = new Random(); labelShowing = false; iconShowing = false; }
void Awake() { if (instance) { Destroy (gameObject); print ("Duplicate music player self-destructing!"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
// Use this for initialization void Start() { string gradeString = ""; p = FindObjectOfType<MusicPlayer>(); foreach (string s in p.letterGrades) { gradeString += s + "\n"; } GetComponent<TextMesh>().text = gradeString; }
// Use this for initialization void Awake() { clock = GameObject.Find("Clock").GetComponent<ClockManager>(); hourToggle = GameObject.Find("Toggle").GetComponent<Toggle>(); volSlider = GameObject.Find("Slider").GetComponent<Slider>(); if(volSlider != null) volSlider.onValueChanged.AddListener(ChangeVolume); mplayer = GameObject.Find("PersistentDataObject").GetComponent<MusicPlayer>(); LoadPrefs(); }
void Awake() { if(!_instance){ _instance = this; } else{ Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); }
void Awake () { if (instance != null) { Destroy (gameObject); print ("Destroyed duplicate."); } else { instance = this; GameObject.DontDestroyOnLoad (gameObject); } }
// Use this for initialization void Awake() { if (instance != null) { Destroy (gameObject); print ("Destroying new music player"); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
public async Task <MusicPlayer> GetOrCreatePlayer(ulong guildId, IVoiceChannel voiceCh, ITextChannel textCh) { string GetText(string text, params object[] replacements) => _strings.GetText(text, _localization.GetCultureInfo(textCh.Guild), "Music".ToLowerInvariant(), replacements); if (voiceCh == null || voiceCh.Guild != textCh.Guild) { if (textCh != null) { await textCh.SendErrorAsync(GetText("must_be_in_voice")).ConfigureAwait(false); } throw new NotInVoiceChannelException(); } return(MusicPlayers.GetOrAdd(guildId, _ => { var vol = GetDefaultVolume(guildId); if (!_musicSettings.TryGetValue(guildId, out var ms)) { ms = new MusicSettings(); } var mp = new MusicPlayer(this, ms, _google, voiceCh, textCh, vol); IUserMessage playingMessage = null; IUserMessage lastFinishedMessage = null; mp.OnCompleted += async(s, song) => { try { lastFinishedMessage?.DeleteAfter(0); try { lastFinishedMessage = await mp.OutputTextChannel.EmbedAsync(new EmbedBuilder().WithOkColor() .WithAuthor(eab => eab.WithName(GetText("finished_song")).WithMusicIcon()) .WithDescription(song.PrettyName) .WithFooter(ef => ef.WithText(song.PrettyInfo))) .ConfigureAwait(false); } catch { // ignored } var(Index, Current) = mp.Current; if (Current == null && !mp.RepeatCurrentSong && !mp.RepeatPlaylist && !mp.FairPlay && AutoDcServers.Contains(guildId)) { await DestroyPlayer(guildId).ConfigureAwait(false); } } catch { // ignored } }; mp.OnStarted += async(player, song) => { //try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } //catch //{ // // ignored //} var sender = player; if (sender == null) { return; } try { playingMessage?.DeleteAfter(0); playingMessage = await mp.OutputTextChannel.EmbedAsync(new EmbedBuilder().WithOkColor() .WithAuthor(eab => eab.WithName(GetText("playing_song", song.Index + 1)).WithMusicIcon()) .WithDescription(song.Song.PrettyName) .WithFooter(ef => ef.WithText(mp.PrettyVolume + " | " + song.Song.PrettyInfo))) .ConfigureAwait(false); } catch { // ignored } }; mp.OnPauseChanged += async(player, paused) => { try { IUserMessage msg; if (paused) { msg = await mp.OutputTextChannel.SendConfirmAsync(GetText("paused")).ConfigureAwait(false); } else { msg = await mp.OutputTextChannel.SendConfirmAsync(GetText("resumed")).ConfigureAwait(false); } msg?.DeleteAfter(10); } catch { // ignored } }; _log.Info("Done creating"); return mp; })); }
void Awake() { gameData = GameObject.FindObjectOfType <GameData>(); gameHUD = GameObject.FindObjectOfType <GameHUD>(); musicPlayer = GameObject.FindObjectOfType <MusicPlayer>(); }
private void OnDisable() { GameRoom.ShowCamera(); BombActive = false; EnableDisableInput(); bool claimsEnabled = TwitchModule.ClaimsEnabled; TwitchModule.ClearUnsupportedModules(); if (!claimsEnabled) { TwitchModule.ClaimsEnabled = true; } StopAllCoroutines(); Leaderboard.Instance.BombsAttempted++; // ReSharper disable once DelegateSubtraction ParentService.GetComponent <KMGameInfo>().OnLightsChange -= OnLightsChange; TwitchPlaysService.Instance.SetHeaderVisbility(false); LogUploader.Instance.GetBombUrl(); ParentService.StartCoroutine(DelayBombResult()); if (!claimsEnabled) { ParentService.StartCoroutine(SendDelayedMessage(1.1f, "Claims have been enabled.")); } if (ModuleCameras != null) { ModuleCameras.gameObject.SetActive(false); } // Award users who maintained needy modules. Dictionary <string, int> AwardedNeedyPoints = new Dictionary <string, int>(); foreach (TwitchModule twitchModule in Modules) { ModuleInformation ModInfo = twitchModule.Solver.ModInfo; ScoreMethod scoreMethod = ModInfo.scoreMethod; if (scoreMethod == ScoreMethod.Default) { continue; } foreach (var pair in twitchModule.PlayerNeedyStats) { string playerName = pair.Key; var needyStats = pair.Value; int points = ((scoreMethod == ScoreMethod.NeedySolves ? needyStats.Solves : needyStats.ActiveTime) * ModInfo.moduleScore * OtherModes.ScoreMultiplier).RoundToInt(); if (points != 0) { if (!AwardedNeedyPoints.ContainsKey(playerName)) { AwardedNeedyPoints[playerName] = 0; } AwardedNeedyPoints[playerName] += points; Leaderboard.Instance.AddScore(playerName, points); } } } if (AwardedNeedyPoints.Count > 0) { IRCConnection.SendMessage($"These players have been awarded points for managing a needy: {AwardedNeedyPoints.Select(pair => $"{pair.Key} ({pair.Value})").Join(", ")}"); } GameCommands.unclaimedModules = null; DestroyComponentHandles(); MusicPlayer.StopAllMusic(); GameRoom.Instance?.OnDisable(); try { string path = Path.Combine(Application.persistentDataPath, "TwitchPlaysLastClaimed.json"); File.WriteAllText(path, SettingsConverter.Serialize(LastClaimedModule)); } catch (Exception ex) { DebugHelper.LogException(ex, "Couldn't write TwitchPlaysLastClaimed.json:"); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f); for (var r = 0; r < hitInfo.Length; r++) { if (hitInfo[r].collider.gameObject.name == "OptionButton") { Map mapScript = map.GetComponent <Map>(); if (options == false && mapScript.active == true) { options = true; mapScript.active = false; GameObject instance = Instantiate(Resources.Load("OptionsMenu", typeof(GameObject))) as GameObject; OptionsMenu om = instance.GetComponent <OptionsMenu>(); om.map = true; om.mouseCheck = this.gameObject; return; } } } for (var r = 0; r < hitInfo.Length; r++) { if (hitInfo[r].collider != null) { if (hitInfo[r].collider.gameObject.name == "HitTest") { Map mapScript = map.GetComponent <Map>(); if (mapScript.active == true) { Planet planet = hitInfo[r].collider.gameObject.GetComponentInParent <Planet>(); if (planet.unlocked == true) { GameObject instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject; mapScript.active = false; GameVar gv = GameObject.Find("GameVar").GetComponent <GameVar>(); gv.Level = planet.level; gv.planetType = (byte)planet.planetType; } } } else if (hitInfo[r].collider.gameObject.name == "Go") { if (hitInfo[r].collider.transform.parent.FindChild("WeaponSelect").FindChild("ActiveBox1").GetComponent <ActiveBox>().Type != "Empty") { SceneManager.LoadScene(1); MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.ChangeSong = true; mp.nextSong = Random.Range(1, 4); } else { hitInfo[r].collider.gameObject.transform.parent.FindChild("WeaponSelect").FindChild("NoweaponsSelected").GetComponent <Text>().color = new Color(1f, 0f, 0f, 1f); } } else if (hitInfo[r].collider.gameObject.name == "ReturnToMap") { Destroy(hitInfo[r].collider.gameObject.transform.parent.gameObject); Map mapScript = map.GetComponent <Map>(); mapScript.active = true; return; } else if (hitInfo[r].collider.gameObject.name == "UnLockAll") { Map mapScript = map.GetComponent <Map>(); if (mapScript.active == true) { GameObject.Find("GameVar").GetComponent <GameVar>().UnlockAll(); SceneManager.LoadScene(2); } } else { for (int i = 1; i < 4; i++) { if (hitInfo[r].collider.gameObject.name == i.ToString()) { if (GameVar.WeaponsUnlocked[11 + i] == true) { info = GameObject.Find("Info").GetComponent <Info>(); info.ChangeInfo((byte)(12 + i)); } } } string PassiveSlotName; for (int i = 1; i < 13; i++) { PassiveSlotName = "PassiveBox" + i; if (hitInfo[r].collider.gameObject.name == PassiveSlotName) { PassiveBox passiveBox = hitInfo[r].collider.gameObject.GetComponent <PassiveBox>(); passiveBox.AddWeapon(); if (passiveBox.Locked == false) { info = GameObject.Find("Info").GetComponent <Info>(); info.ChangeInfo((byte)passiveBox.num); } } } for (int i = 1; i < 5; i++) { PassiveSlotName = "ActiveBox" + i; if (hitInfo[r].collider.gameObject.name == PassiveSlotName) { ActiveBox activeBox = hitInfo[r].collider.gameObject.GetComponent <ActiveBox>(); activeBox.ResetIcons(); } } } } } } }
public static IEnumerator DefaultCommand(TwitchModule module, string user, string cmd) { if (Votes.Active && Votes.CurrentVoteType == VoteTypes.Solve && Votes.voteModule == module) { IRCConnection.SendMessage($"Sorry @{user}, the module you are trying to interact with is being votesolved."); yield break; } if (cmd.RegexMatch(out Match match, @"(?:(?<zoom>zoom *(?<time>\d*\.?\d+)?)|(?<superzoom>superzoom *(?<factor>\d*\.?\d+) *(?<x>\d*\.?\d+)? *(?<y>\d*\.?\d+)? *(?<stime>\d*\.?\d+)?))? *(?:(?<tilt>tilt *(?<direction>[uptobmdwnlefrigh]+|-?\d+)?)|(?<show>show)?)? *(?:send *to *module)? *(?<command>.+)?")) { var groups = match.Groups; var timed = groups["time"].Success || groups["stime"].Success; var zooming = groups["zoom"].Success || groups["superzoom"].Success; var tilt = groups["tilt"].Success; var show = groups["show"].Success; var command = groups["command"].Success; if (!timed && !zooming && !command && show) { yield return(Show(module, 0.5)); yield break; } // Both a time and a command can't be entered. And either a zoom, show or tilt needs to take place otherwise, we should let the command run normally. if ((!timed || !command) && (zooming || tilt || show)) { MusicPlayer musicPlayer = null; float delay = 2; if (timed) { delay = groups["time"].Value.TryParseInt() ?? groups["stime"].Value.TryParseInt() ?? 2; delay = Math.Max(2, delay); } object toYield = command ? (object)RunModuleCommand(module, user, groups["command"].Value) : delay; IEnumerator routine = null; if (show) { routine = Show(module, toYield); } if (tilt) { routine = Tilt(module, toYield, groups["direction"].Value.ToLowerInvariant()); } if (zooming) { var zoomData = new SuperZoomData( groups["factor"].Value.TryParseFloat() ?? 1, groups["x"].Value.TryParseFloat() ?? 0.5f, groups["y"].Value.TryParseFloat() ?? 0.5f ); routine = Zoom(module, zoomData, routine ?? toYield); } if (delay >= 15) { musicPlayer = MusicPlayer.StartRandomMusic(); } yield return(routine); if (CoroutineCanceller.ShouldCancel) { CoroutineCanceller.ResetCancel(); IRCConnection.SendMessage($"Sorry @{user}, your request to hold up the bomb for {delay} seconds has been cut short."); } if (musicPlayer != null) { musicPlayer.StopMusic(); } yield break; } } yield return(RunModuleCommand(module, user, cmd)); }
// Use this for initialization void Start() { musicPlayer = FindObjectOfType <MusicPlayer>(); }
/// <summary> /// Switch between Pause and Play. /// </summary> public void SwitchPlayPause() { IsPlaying = MusicPlayer.PlayWithPause(IsPlaying); OnPlaySwitch.Invoke(this, IsPlaying); }
private void Start() { Instance = this; transform.Find("Prefabs").gameObject.SetActive(false); twitchGame = GetComponentInChildren <TwitchGame>(true); twitchGame.twitchBombPrefab = GetComponentInChildren <TwitchBomb>(true); twitchGame.twitchModulePrefab = GetComponentInChildren <TwitchModule>(true); twitchGame.moduleCamerasPrefab = GetComponentInChildren <ModuleCameras>(true); TwitchGame.Instance = twitchGame; GameRoom.InitializeSecondaryCamera(); _gameInfo = GetComponent <KMGameInfo>(); _gameInfo.OnStateChange += OnStateChange; CoroutineQueue = GetComponent <CoroutineQueue>(); Leaderboard.Instance.LoadDataFromFile(); LeaderboardController.Install(); ModuleData.LoadDataFromFile(); ModuleData.WriteDataToFile(); AuditLog.SetupLog(); MainThreadQueue.Initialize(); TwitchPlaySettings.LoadDataFromFile(); MusicPlayer.LoadMusic(); IRCConnection.Instance.OnMessageReceived.AddListener(OnMessageReceived); twitchGame.ParentService = this; TwitchPlaysAPI.Setup(); GameObject infoObject = new GameObject("TwitchPlays_Info"); infoObject.transform.parent = gameObject.transform; _publicProperties = infoObject.AddComponent <TwitchPlaysProperties>(); _publicProperties.TwitchPlaysService = this; // TODO: Useless variable? if (TwitchPlaySettings.data.SkipModManagerInstructionScreen || IRCConnection.Instance.State == IRCConnectionState.Connected) { ModManagerManualInstructionScreen.HasShownOnce = true; } UpdateUiHue(); if (TwitchPlaySettings.data.DarkMode) { HeaderBackground.color = new Color32(0x0E, 0x0E, 0x10, 0xFF); HeaderText.color = new Color32(0xEF, 0xEF, 0xEC, 0xFF); MessagesBackground.color = new Color32(0x3A, 0x3A, 0x3D, 0xFF); } else { HeaderBackground.color = new Color32(0xEE, 0xEE, 0xEE, 0xFF); HeaderText.color = new Color32(0x4F, 0x4F, 0x4F, 0xFF); MessagesBackground.color = new Color32(0xD8, 0xD8, 0xD8, 0xFF); } SetupChatSimulator(); }
protected override void LoadContent() { Pixel = new Texture2D(graphicsDeviceManager.GraphicsDevice, 1, 1); Color[] pixelData = new Color[1]; pixelData[0] = new Color(1f, 1f, 1f); Pixel.SetData(pixelData); background = GetTexture("background"); mountain = GetTexture("mountain"); boundaries = GetTexture("boundries"); beyond = GetTexture("beyond"); backgroundScale = pixelWidth / background.Width * backgroundZoom; mapSize = (new Vector2(background.Width, background.Height)) * backgroundScale; mapSize.Y += spaceAtTopOfMap; sounds = new Dictionary <string, SoundEffect>(); foreach (Coin coin in coins) { coin.position = GetConvertedPosition(coin.position); string fullSoundPath = Path.Combine("items", coin.soundName); LoadSound(coin.soundName, fullSoundPath); } string coinPath = Path.Combine("texture", "coins"); foreach (var file in Directory.GetFiles(coinPath)) { string storageName = Path.GetFileName(file); storageName = storageName.Substring(0, storageName.Length - 4); textureInfos.Add(new TextureInfo(storageName, GetTexture(Path.Combine("coins", storageName)))); } player.Textures = new List <Texture2D>(); player.Textures.Add(GetTexture("player-frames\\playerframe001")); player.Textures.Add(GetTexture("player-frames\\playerframe002")); player.Textures.Add(GetTexture("player-frames\\playerframe003")); player.Textures.Add(GetTexture("player-frames\\playerframe004")); player.Textures.Add(GetTexture("player-frames\\playerframe005")); player.Textures.Add(GetTexture("player-frames\\playerframe006")); player.Textures.Add(GetTexture("player-frames\\playerframe007")); player.Textures.Add(GetTexture("player-frames\\playerframe008")); player.Textures.Add(GetTexture("player-frames\\playerframe009")); player.position = new Vector2( mapSize.X / 2f, mapSize.Y - 300 ); camera = player.position; List <SoundEffect> songs = new List <SoundEffect>(); songs.Add(GetSound("music\\01")); songs.Add(GetSound("music\\02")); songs.Add(GetSound("music\\03")); songs.Add(GetSound("music\\04")); songs.Add(GetSound("music\\05")); songs.Add(GetSound("music\\06")); songs.Add(GetSound("music\\07")); songs.Add(GetSound("music\\08")); songs.Add(GetSound("music\\09")); songs.Add(GetSound("music\\10")); songs.Add(GetSound("music\\11")); musicPlayer = new MusicPlayer(songs, this); font = Content.Load <SpriteFont>("HeavyMountain"); }
public override void OnEnter() { // Create background camera. { GameObject cameraGo = new GameObject("BackgroundCamera"); cameraGo.transform.position = new Vector3(0f, 0f, -10f); Camera camera = cameraGo.AddComponent <Camera>(); camera.clearFlags = CameraClearFlags.SolidColor; camera.backgroundColor = Color.black; camera.cullingMask = 0; camera.orthographic = true; camera.orthographicSize = 5f; camera.depth = -1f; camera.useOcclusionCulling = false; camera.allowHDR = false; GameObject.DontDestroyOnLoad(cameraGo); } // Initialize Input system. { InputSystem.InitializeMain(); InputSystem.AddPlayerMain("Player0"); InputSystem.AddPlayerMain("Player1"); InputSystem.AddPlayerMain("Player2"); InputSystem.AddPlayerMain("Player3"); InputSystem.AddPlayerMain("Player4"); InputSystem.AddPlayerMain("Player5"); InputSystem.AddPlayerMain("Player6"); InputSystem.AddPlayerMain("Player7"); InputSystem.RefreshMapsMain(); } // Initialize WiFi Input system. { WiFiInputSystem.InitializeMain(); } // Init systems. { Messenger.Cleanup(); GameModulesManager.InitializeMain(); ObjectPool.InitializeMain(); MusicPlayer.InitializeMain(); if (musicPlayerOutputChannel != null && !musicPlayerOutputChannel.IsNone && musicPlayerOutputChannel.Value != null) { MusicPlayer.SetChannelMain((AudioMixerGroup)musicPlayerOutputChannel.Value); } // TODO: Set MusicPlayer output channel. SfxPlayer.InitializeMain(); AudioMixerManager.InitializeMain(); if (audioMixerSnapshot != null && !audioMixerSnapshot.IsNone && audioMixerSnapshot.Value != null) { AudioMixerManager.SetSnapshotMain((AudioMixerSnapshot)audioMixerSnapshot.Value, 0f); } GameServices.InitializeMain(); GameSettings.InitializeMain(); UIEventSystem.InitializeMain(); } // Init UI. { GameObject uiCamera = new GameObject("UICamera"); Camera cam = uiCamera.AddComponent <Camera>(); cam.clearFlags = CameraClearFlags.Depth; cam.cullingMask = 0; cam.cullingMask |= (1 << LayerMask.NameToLayer("UI")); cam.cullingMask |= (1 << LayerMask.NameToLayer("GUI")); cam.orthographic = true; cam.orthographicSize = 5f; cam.depth = float.MaxValue; cam.useOcclusionCulling = false; cam.allowHDR = false; /* FixedAspectRatio fixedAspectRatio = */ uiCamera.AddComponent <FixedAspectRatio>(); // fixedAspectRatio.targetAspectRatio = 1920f / 1080f; // uiCamera.AddComponent<GUILayer>(); GameObject.DontDestroyOnLoad(uiCamera); GameObject uiCanvas = new GameObject("UICanvas"); uiCanvas.layer = LayerMask.NameToLayer("UI"); Canvas canvas = uiCanvas.AddComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.pixelPerfect = false; canvas.worldCamera = cam; uiCanvas.AddComponent <UICanvas>(); CanvasScaler canvasScaler = uiCanvas.AddComponent <CanvasScaler>(); canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; canvasScaler.referenceResolution = new Vector2(1920, 1080); canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand; canvasScaler.referencePixelsPerUnit = 100; GraphicRaycaster graphicRaycaster = uiCanvas.AddComponent <GraphicRaycaster>(); graphicRaycaster.ignoreReversedGraphics = true; uiCanvas.tag = "MainCanvas"; GameObject.DontDestroyOnLoad(uiCanvas); } // PlayMaker Proxy. { GameObject playmakerProxy = new GameObject("PlayMaker Proxy"); GameObject playmakerGUIPrefab = (GameObject)Resources.Load("Core/PlayMakerGUI"); if (playmakerGUIPrefab != null) { GameObject playmakerGUI = (GameObject)GameObject.Instantiate(playmakerGUIPrefab, Vector3.zero, Quaternion.identity); playmakerGUI.SetParent(playmakerProxy); } GameObject playmakerUGUIProxyPrefab = (GameObject)Resources.Load("Core/PlayMakerUGUI"); if (playmakerUGUIProxyPrefab != null) { GameObject playmakerUGUIProxy = (GameObject)GameObject.Instantiate(playmakerUGUIProxyPrefab, Vector3.zero, Quaternion.identity); playmakerUGUIProxy.SetParent(playmakerProxy); } GameObject.DontDestroyOnLoad(playmakerProxy); } Finish(); }
public PlayState(bool _debug) { _isready = false; this._debug = _debug; musicPlayer = new MusicPlayer(); }
public void Execute() { mario.DescendFlag(delta); MusicPlayer.EffectList("flagpole").Play(); }
private void Awake() { _musicPlayer = FindObjectOfType <MusicPlayer>(); }
public void init() { musicPlayer = new MusicPlayer(); musicPlayer.handle = MainWindow.getHandle(); }
public void OnShopPressed() { DestroyAD(); MusicPlayer.PlayShopMusic(); ShopMenu.Show(); }
// Use this for initialization void Awake() { commsNavigation = FindObjectOfType <CommsNavigation>(); commsDisplay = GetComponent <Text>(); responseText = this.transform.Find("ResponseText").GetComponent <Text>(); responseTextCopy = this.transform.Find("ResponseTextCopy").GetComponent <Text>(); commsImg = this.transform.parent.GetComponent <RawImage>(); panels = bgdPanels.GetComponent <PanelsBottom>(); dateScreen = FindObjectOfType <DatingScreen>(); camMaster = FindObjectOfType <CameraMaster>(); musicBox = FindObjectOfType <MusicPlayer>(); scanner = FindObjectOfType <InfoScan>(); actCoord = FindObjectOfType <ActionSceneCoordinator>(); rightEye = FindObjectOfType <TeddyRightEye>(); bCam = FindObjectOfType <BodyCam>(); commsDisplay.enabled = false; commsImg.enabled = false; responseText.enabled = false; responseTextCopy.enabled = false; // responseTextCopy is only used for determining the line count of individual responses; it is never displayed panels.HideInfoBgdPanel(); textActivated = false; textActive = false; commsDisplay.supportRichText = true; responseText.supportRichText = true; responseTextCopy.supportRichText = true; currentText = ""; currentResponseText = ""; listOfResponses = ""; responseTextCopy.text = ""; currentResponseNumber = 0; readyForSelection = false; portrait.enabled = false; portraitFrame.enabled = false; unravellingText = false; unravellingResponseText = false; showingLoadingText = false; isUnravelled = false; unravellingTextStartTimeSet = false; char[] tempChars = loadingString.ToCharArray(); for (int i = 0; i < tempChars.Length; i++) { loadingChars.Add(tempChars[i]); } skipUnravelling = false; canSkipUnravelling = false; unravellingTextCharIndex = 0; loadingStringCharIndex = 0; unravellingTextTimeRef = 0; unravellingResponseTextTimeRef = 0; loadingTextTimeRef = 0; closeEnoughToCommunicate = false; isUsingStardater = false; isInDatingChat = false; }
// == private methods == private void Start() { sc = SoundController.FindSoundController(); mp = MusicPlayer.FindMusicPlayer(); scene = SceneController.FindSceneController(); }
void Start() { musicPlayer = FindObjectOfType <MusicPlayer>(); volumeSlider.value = PlayerPrefsController.GetVolume(); difficultySlider.value = PlayerPrefsController.GetDifficulty(); }
public override void Initialize() { base.Initialize(); Session.Settings = new GameDefinitions.GameSettings(); scaleAnimationFinish = false; start = false; MusicPlayer.Play(MusicPlayer.MenuTheme); Manager.Graphics.EndShader(); // Cargamos la lista de cadenas de texto del juego: Session.Strings = Serializers.DeserializeFromTitleStorage <SerializableDictionary <string, string> >("GameData/Strings/" + Session.Culture + ".xml").ToDictionary(); Manager.Graphics.OffSet = Vector2.Zero; Manager.Graphics.LoadTexture("theGrid"); background = new Bitmap("theGrid"); background.Size = new Vector2(1280, 720); Manager.Graphics.LoadTexture("backgroundFog"); fog = new Bitmap("backgroundFog"); fog.Size = new Vector2(1280, 720); layer1 = new Sprite(Manager.Graphics.LoadTexture(@"GameUI\Gametitle\backgroundLayer1")); layer1.Scale = -0.4f; layer2 = new Sprite(Manager.Graphics.LoadTexture(@"GameUI\Gametitle\backgroundLayer1")); layer2.Location = new Vector2(1280, 0); layer2.Visible = false; Manager.Graphics.LoadTexture(@"GameUI\Gametitle\wall"); wall = new Bitmap(@"GameUI\Gametitle\wall"); fan = new Sprite(Manager.Graphics.LoadTexture(@"GameUI\Gametitle\fan")); fan.Location = new Vector2(-25, -100); fan.Animations.AddSecuence("default", new Rectangle(0, 0, 400, 400), 4, 64, true); fan.Animations.Play("default"); fan.Update(new GameTime()); lightLamp = new Sprite(Manager.Graphics.LoadTexture(@"GameUI\Gametitle\lightLamp")); lightLamp.Location = new Vector2(-24, 400); Manager.Graphics.LoadTexture(@"GameUI\Gametitle\joss"); joss = new Sprite(@"GameUI\Gametitle\joss"); joss.Scale = 4; Manager.Graphics.LoadTexture(@"GameUI\Gametitle\shine"); shine = new Bitmap(@"GameUI\Gametitle\shine"); logo = new Sprite(Manager.Graphics.LoadTexture(@"GameUI\Gametitle\logo")); logo.Location = new Vector2(800, 256); logo.Scale = 4; logo.Center = true; Manager.Graphics.LoadFont(@"Fonts\androidNation14"); footstep = new TextLabel(@"Fonts\androidNation14"); footstep.Location = new Vector2(Manager.Graphics.ScreenSafeArea.Center.X, Manager.Graphics.ScreenSafeArea.Bottom - 14); footstep.Text = Session.Strings["copyright"]; footstep.Visible = false; footstep.Center = true; footstepShadow = new TextLabel(@"Fonts\androidNation14"); footstepShadow.Location = new Vector2(Manager.Graphics.ScreenSafeArea.Center.X + 2, Manager.Graphics.ScreenSafeArea.Bottom - 14 + 2); footstepShadow.Text = Session.Strings["copyright"]; footstepShadow.Color = Color.Black; footstepShadow.Visible = false; footstepShadow.Center = true; Manager.Graphics.LoadFont(@"Fonts\androidNation20b"); pressStart = new TextLabel(@"Fonts\androidNation20b"); pressStart.Location = new Vector2(Manager.Graphics.ScreenSafeArea.Center.X, Manager.Graphics.ScreenSafeArea.Center.Y + 150); pressStart.Text = Session.Strings["pressStart"]; pressStart.Visible = false; pressStart.Center = true; pressStartShadow = new TextLabel(@"Fonts\androidNation20b"); pressStartShadow.Location = new Vector2(Manager.Graphics.ScreenSafeArea.Center.X + 2, Manager.Graphics.ScreenSafeArea.Center.Y + 150 + 2); pressStartShadow.Text = Session.Strings["pressStart"]; pressStartShadow.Color = Color.Black; pressStartShadow.Visible = false; pressStartShadow.Center = true; timer = new Timer(); timer2 = new Timer(); glitch = new GlitchColor(); Manager.Scene.AddEntity(glitch); }
public void ManualUpdate() { player.ManualUpdate(); leftTip.ManualUpdate(); rightTip.ManualUpdate(); if (!hasStarted) { return; } if (hasStarted && !isInPrelude && !MusicPlayer.IsPlaying) // Replay // source.pitch *= 1.1f; { MusicPlayer.Restart(); StartGame(); } Speed = bufferZ / bufferInterval; // Init new blocks double bufferTime = MusicPlayer.LiveTime + bufferInterval; while (index < notes.Length && notes[index].startTime <= bufferTime) { if (notes[index].isPara) { if (counter % level == 0) { InitBlock(notes[index], notes[index + 1]); } index += 2; } else { if (counter % level == 0) { InitBlock(notes[index]); } index += 1; } counter += 1; } // Update live blocks var node = liveBlockList.First; while (node != null) { var next = node.Next; var block = node.Value; if (shouldAutoPlay && (Math.Abs(MusicPlayer.LiveTime - block.startTime) < TimePerfect || MusicPlayer.LiveTime > block.startTime)) { block.hitSpeed = block.minDyingSpeed * 1.1f; block.hitVelocity = HeadingToVector(block.heading) * block.hitSpeed; block.shouldDie = true; } if (block.shouldDie) { if (!block.shouldDieSilently) { KillBlock(block); } deadBlockList.AddLast(block); liveBlockList.Remove(node); } else { UpdateBlock(block); } node = next; } // Wait dead blocks to be inactive node = deadBlockList.First; while (node != null) { var next = node.Next; var deadBlock = node.Value; if (deadBlock.startTime + recycleInterval + recycleGraceInterval < MusicPlayer.LiveTime) // Ready to be revived { deadBlock.gameObject.SetActive(false); inactiveBlockList.AddLast(deadBlock); deadBlockList.Remove(node); } node = next; } }
public void GameOver() { MusicPlayer.StopPlayer(); Sounds.SoundPlayer.GetInstance().PlaySoundEffect(SoundEffectNames.GameOver); }
public void Win() { MusicPlayer.StopPlayer(); Sounds.SoundPlayer.GetInstance().PlaySoundEffect(SoundEffectNames.Win); }
public void OnSingletonInit() { Log.I("AudioManager OnSingletonInit"); RegisterEvents( AudioEvent.SoundSwitch, AudioEvent.MusicSwitch, AudioEvent.VoiceSwitch, AudioEvent.SetSoundVolume, AudioEvent.SetMusicVolume, AudioEvent.SetVoiceVolume, AudioEvent.PlayMusic, AudioEvent.PlaySound, AudioEvent.PlayVoice, AudioEvent.PlayNode, AudioEvent.AddRetainAudio, AudioEvent.RemoveRetainAudioAudio ); SafeObjectPool <AudioPlayer> .Instance.Init(10, 1); MusicPlayer = AudioPlayer.Allocate(); MusicPlayer.usedCache = false; VoicePlayer = AudioPlayer.Allocate(); VoicePlayer.usedCache = false; CheckAudioListener(); gameObject.transform.position = Vector3.zero; AudioKit.Settings.MusicVolume.Bind(volume => { MusicPlayer.SetVolume(volume); }).AddTo(this); AudioKit.Settings.VoiceVolume.Bind(volume => { VoicePlayer.SetVolume(volume); }).AddTo(this); AudioKit.Settings.IsMusicOn.Bind(musicOn => { if (musicOn) { if (CurrentMusicName.IsNotNullAndEmpty()) { AudioKit.PlayMusic(CurrentMusicName); } } else { MusicPlayer.Stop(); } }).AddTo(this); AudioKit.Settings.IsVoiceOn.Bind(voiceOn => { if (voiceOn) { if (CurrentVoiceName.IsNotNullAndEmpty()) { AudioKit.PlayVoice(CurrentVoiceName); } } else { VoicePlayer.Stop(); } }).AddTo(this); AudioKit.Settings.IsSoundOn.Bind(soundOn => { if (soundOn) { } else { ForEachAllSound(player => player.Stop()); } }).AddTo(this); AudioKit.Settings.SoundVolume.Bind(soundVolume => { ForEachAllSound(player => player.SetVolume(soundVolume)); }).AddTo(this); }
private void FixedUpdate() { if (cutsceneawal == false) { MusicPlayer musicplayer = GameObject.FindGameObjectWithTag("MusicPlayer").GetComponent <MusicPlayer>(); musicplayer.BGMINGAME = true; if (!hasAuthority) { return; } cam = GameObject.FindGameObjectWithTag("PlayerCamera").gameObject; rb = GetComponent <Rigidbody>(); blendtohash = Animator.StringToHash("Blend"); anim.SetFloat(blendtohash, blend); if (Animation && blend <= 0.5f) { blend += animSpedd; } if (!Animation && blend >= 0f) { blend -= animSpedd; } if (canMove) { if (moveDir.x != 0 || moveDir.z != 0) { /*anim.SetBool("isRun", true);*/ Animation = true; Vector3 targetDir = moveDir; //Direction of the character targetDir.y = 0; if (targetDir == Vector3.zero) { targetDir = transform.forward; } Quaternion tr = Quaternion.LookRotation(targetDir); //Rotation of the character to where it moves Quaternion targetRotation = Quaternion.Slerp(transform.rotation, tr, Time.deltaTime * rotateSpeed); //Rotate the character little by little transform.rotation = targetRotation; } else { Animation = false; } if (IsGrounded()) { // Calculate how fast we should be moving Vector3 targetVelocity = moveDir; targetVelocity *= speed; // Apply a force that attempts to reach our target velocity Vector3 velocity = rb.velocity; if (targetVelocity.magnitude < velocity.magnitude) //If I'm slowing down the character { targetVelocity = velocity; rb.velocity /= 1.1f; } Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0; if (!slide) { if (Mathf.Abs(rb.velocity.magnitude) < speed * 1.0f) { rb.AddForce(velocityChange, ForceMode.VelocityChange); } } else if (Mathf.Abs(rb.velocity.magnitude) < speed * 1.0f) { rb.AddForce(moveDir * 0.15f, ForceMode.VelocityChange); //Debug.Log(rb.velocity.magnitude); } // Jump if (IsGrounded() && Input.GetButton("Jump")) { anim.SetBool("isJump", true); rb.velocity = new Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } else { anim.SetBool("isJump", false); } } else { if (!slide) { Vector3 targetVelocity = new Vector3(moveDir.x * airVelocity, rb.velocity.y, moveDir.z * airVelocity); Vector3 velocity = rb.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); rb.AddForce(velocityChange, ForceMode.VelocityChange); if (velocity.y < -maxFallSpeed) { rb.velocity = new Vector3(velocity.x, -maxFallSpeed, velocity.z); } } else if (Mathf.Abs(rb.velocity.magnitude) < speed * 1.0f) { rb.AddForce(moveDir * 0.15f, ForceMode.VelocityChange); } } } else { rb.velocity = pushDir * pushForce; } // We apply gravity manually for more tuning control rb.AddForce(new Vector3(0, -gravity * GetComponent <Rigidbody>().mass, 0)); } }
private void Dispose() { _MusicPlayer.Dispose(); _MusicPlayer = null; }
void CheckMouseDown() { if (Input.GetMouseButtonDown(0)) { cannon = null; float dis; float dis2 = 10; RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f); for (int i = 0; i < hitInfo.Length; i++) { if (paused == false) { if (hitInfo[i].collider.gameObject.name == "OptionsButton") { paused = true; UnityEngine.Object[] objects = FindObjectsOfType(typeof(GameObject)); foreach (GameObject go in objects) { go.SendMessage("OnPauseGame", SendMessageOptions.DontRequireReceiver); } options = true; GameObject instance = Instantiate(Resources.Load("OptionsMenu", typeof(GameObject))) as GameObject; OptionsMenu om = instance.GetComponent <OptionsMenu>(); om.mouseCheck = this.gameObject; return; } if (hitInfo[i].collider.gameObject.tag == "hitTest") { dis = Vector2.Distance(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), new Vector2(hitInfo[i].collider.gameObject.transform.parent.transform.position.x, hitInfo[i].collider.gameObject.transform.parent.transform.position.y)); if (dis < dis2) { dis2 = dis; cannon = hitInfo[i].collider.gameObject.GetComponentInParent <Cannon>(); } } else if (hitInfo[i].collider.gameObject.tag == "WeaponIcon") { WeaponIcon icon = hitInfo[i].collider.gameObject.GetComponent <WeaponIcon>(); if (icon.type != "Platform") { if (energy.energy >= icon.cost) { GameObject instance = Instantiate(Resources.Load(icon.type, typeof(GameObject))) as GameObject; cannon = instance.GetComponent <Cannon>(); cannon.type = icon.type; cannon.Drag(false); cannon.cost = icon.cost; return; } else { infoText.color = new Color(infoText.color.r, infoText.color.g, infoText.color.b, 1f); } } else { if (energy.energy >= icon.cost) { GameObject instance = Instantiate(Resources.Load(icon.type, typeof(GameObject))) as GameObject; platform = instance.GetComponent <Platform>(); } } } else if (hitInfo[i].collider.gameObject.name == "GoBack") { SceneManager.LoadScene(2); MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.ChangeSong = true; mp.nextSong = 0; } else if (hitInfo[i].collider.gameObject.name == "RestartLevel") { GameObject instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject; WeaponSelect ws = instance.gameObject.GetComponentInChildren <WeaponSelect>(); ws.map = false; paused = true; } } else { if (hitInfo[i].collider.gameObject.name == "Go") { if (hitInfo[i].collider.transform.parent.FindChild("WeaponSelect").FindChild("ActiveBox1").GetComponent <ActiveBox>().Type != "Empty") { SceneManager.LoadScene(1); } else { hitInfo[i].collider.gameObject.transform.parent.FindChild("WeaponSelect").FindChild("NoweaponsSelected").GetComponent <Text>().color = new Color(1f, 0f, 0f, 1f); } } else if (hitInfo[i].collider.gameObject.name == "ReturnToMap") { SceneManager.LoadScene(2); MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>(); mp.ChangeSong = true; mp.nextSong = 0; } else { for (int r = 1; r < 4; r++) { if (hitInfo[i].collider.gameObject.name == r.ToString()) { if (GameVar.WeaponsUnlocked[11 + r] == true) { Info info = GameObject.Find("Info").GetComponent <Info>(); info.ChangeInfo((byte)(12 + r)); } } } string PassiveSlotName; for (int r = 1; r < 13; r++) { PassiveSlotName = "PassiveBox" + r; if (hitInfo[i].collider.gameObject.name == PassiveSlotName) { PassiveBox passiveBox = hitInfo[i].collider.gameObject.GetComponent <PassiveBox>(); passiveBox.AddWeapon(); if (passiveBox.Locked == false) { Info info = GameObject.Find("Info").GetComponent <Info>(); info.ChangeInfo((byte)passiveBox.num); } } } for (int r = 1; r < 5; r++) { PassiveSlotName = "ActiveBox" + r; if (hitInfo[i].collider.gameObject.name == PassiveSlotName) { ActiveBox activeBox = hitInfo[i].collider.gameObject.GetComponent <ActiveBox>(); activeBox.ResetIcons(); } } } } } if (cannon != null) { cannon.Drag(); } } if (Input.GetMouseButtonUp(0)) { if (platform == null) { if (cannon != null) { RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f); for (int i = 0; i < hitInfo.Length; i++) { if (hitInfo[i].collider.gameObject.tag == "TrashCan") { if (cannon.emptyCannon != null) { energy.energy += Mathf.Round(cannon.cost * 0.66f); if (cannon.type == "Battery") { energy.maxEnergy *= 0.5f; } if (cannon.type == "Generator") { energy.energyAmount -= 1; } energy.UpdateUI(); } Destroy(cannon.emptyCannon, 0f); Destroy(cannon.gameObject, 0f);; return; } } StartCoroutine(MouseRelease(cannon)); } } else { platform.Drop(energy); platform = null; } } }
private void Awake() { Instance = this; AllowMusicInterruption = Settings.Get("AllowNoisemakersToInterruptMusic", true); }
private void Start() { musicPlayer = FindObjectOfType <MusicPlayer>(); audioManager = FindObjectOfType <AudioManager>(); }
void Awake() { musicPlayer = GameObject.FindObjectOfType <MusicPlayer>(); invalid = true; playing = false; ToneEditorCanvas = transform.parent.Find("ToneEditorCanvas").gameObject; { Button button = gameObject.transform.Find("Panel/ToneEditorButton").gameObject.GetComponent <Button>(); button.onClick.AddListener(() => { ToneEditorCanvas.SetActive(true); gameObject.SetActive(false); }); } { Button button = gameObject.transform.Find("Panel/PlayButton").gameObject.GetComponent <Button>(); cursolPosText = gameObject.transform.Find("Panel/CursolPosText").gameObject.GetComponent <Text>(); mmlField = gameObject.transform.Find("Panel/MMLField").gameObject.GetComponent <InputField>(); consoleText = gameObject.transform.Find("Panel/ConsolePanel").gameObject.GetComponentInChildren <Text>(); instructionText = gameObject.transform.Find("Panel/InstructionPanel").gameObject.GetComponentInChildren <Text>(); playButtonText = button.GetComponentInChildren <Text>(); mmlField.onValueChange.AddListener((str) => { invalid = true; if (musicPlayer.Playing) { playButtonText.text = "Stop"; } else { playButtonText.text = "Play"; } }); button.onClick.AddListener(() => { if (invalid) { if (musicPlayer.Playing) { musicPlayer.Stop(0.0f); playButtonText.text = "Play"; consoleText.text = ""; playing = false; } else { MySpace.Synthesizer.MMLSequencer.MyMMLSequence mml; string result = null; result = musicPlayer.ParseMMLText(mmlField.text, out mml); if (result == null) { List <object> toneSet; Dictionary <int, int> toneMap; result = musicPlayer.CreateDefaultToneMap(mml, out toneSet, out toneMap); if (result == null) { musicPlayer.Play(mml, toneSet, toneMap, 0.0f, appDataEventFunc, playingEventFunc); resetStb(); invalid = false; } } if (result == null) { consoleText.text = "Playing..."; playButtonText.text = "Pause"; playing = true; } else { consoleText.text = result; playButtonText.text = "Play"; playing = false; } } } else { if (musicPlayer.Playing) { musicPlayer.Pause(FadeTime); playButtonText.text = "Continue"; playing = false; } else { musicPlayer.Continue(FadeTime); playButtonText.text = "Pause"; playing = true; } } }); } { audioSource = gameObject.AddComponent <AudioSource>(); } { string clickMML = "$@(h_close5) = @pm8[4 7 op1[0 0 15 0 7 0 0 0 0 31 0 0 0 0] op2[0 0 0 0 7 0 0 1 0 21 18 5 15 13] op3[0 0 8 0 3 0 0 0 0 31 0 0 0 14] op4[0 0 15 0 3 0 1 1 5 31 17 15 13 9] lfo[0 127 0 0 31 0 0 0 0] ]\nt0=@(h_close5)a32c32"; clickSound = musicPlayer.CreateAudioClip("click", clickMML); } }
/// <summary> /// Start /// </summary> public void Start() { instance = this; }