public void AssignBlock(Block block) { foreach (var kvp in block.GetSpriteToSlotMap()) { BitSlotWidget slot = kvp.Value; slot.used = true; Transform spriteParent = new GameObject(gameObject.name + "SpriteRoot").transform; spriteParent.localScale = block.transform.localScale; spriteParent.SetParent(slot.transform); float slotAlpha = _bitSlots.IndexOf(slot) / (float)_bitSlots.Count; spriteParent.position = slot.transform.position + -Camera.main.transform.forward * _slotOffsetRange.Lerp(slotAlpha); SpriteRenderer sprite = kvp.Key; sprite.transform.SetParent(spriteParent); sprite.transform.localPosition = Vector3.zero; sprite.GetComponent <Collider>().enabled = false; } string soundName = "SFX_BlockPlacement" + (Mathf.Clamp(_addedBlockTypes.Count, 0, 3) + 1); GameSound placeSound = (GameSound)System.Enum.Parse(typeof(GameSound), soundName); GameSounds.PostEvent2D(placeSound); _addedBlockTypes.Add(block.GetBlockType()); if (_addedBlockTypes.Count > 1) { _combineButton.gameObject.SetActive(true); } }
void Start() { for (int i = 0; i < _startSounds.Length; i++) { GameSounds.PostMusicEvent(_startSounds[i]); } }
void OnDestroy() { for (int i = 0; i < _startSounds.Length; i++) { GameSounds.PostMusicEvent(_startSounds[i], Fabric.EventAction.StopSound); } }
public void playSound(GameSounds soundType) { if (PlayerPrefs.GetInt("SOUND").Equals(1)) { gameSoundsList[(int)soundType].Play(); } }
public void Combine() { _combineButton.gameObject.SetActive(false); GameSounds.PostEvent2D(GameSound.SFX_BlockCombine); // TODO: Calculate what item we need to give here ItemButtonWidget itemButton = Instantiate <ItemButtonWidget>(_itemButtonPrefabs.Random(), _breedRect); itemButton.transform.ResetLocals(); for (int i = 0; i < _itemSlots.Count; i++) { if (!_itemSlots[i].used) { _itemSlots[i].used = true; itemButton.FlyToSlot(_itemSlots[i]); break; } } _addedBlockTypes.Clear(); for (int i = 0; i < _bitSlots.Count; i++) { _bitSlots[i].used = false; foreach (Transform child in _bitSlots[i].transform) { Destroy(child.gameObject); } } }
public static void PlaySounds(GameSounds sound) { string soundString = ""; // chimes.wav // Windows Default.wav -- click to place // Windows User Account Control.wav -- click to place // tada.wav -- successful move switch (sound) { case GameSounds.SoundClickSuccessful: soundString = @"c:\Windows\Media\Windows User Account Control.wav"; break; case GameSounds.SoundFliptile: soundString = @"c:\Windows\Media\chimes.wav"; break; case GameSounds.SoundTurnComplete: soundString = @"c:\Windows\Media\tada.wav"; break; default: return; } using (var soundPlayer = new SoundPlayer(soundString)) { Thread.Sleep(500); soundPlayer.Play(); // can also use soundPlayer.PlaySync() } }
public static void PlaySound(GameSounds sound) { switch (sound) { case GameSounds.SlotHit: instance.GetComponent <AudioSource>().PlayOneShot(instance.slotHitSound); break; case GameSounds.Fanfare: instance.GetComponent <AudioSource>().PlayOneShot(instance.fanfareSound); break; case GameSounds.PrizeBounce: instance.GetComponent <AudioSource>().PlayOneShot(instance.prizeBounceSound); break; case GameSounds.HandleRelease: instance.GetComponent <AudioSource>().PlayOneShot(instance.handleReleaseSound); break; case GameSounds.SlotFailure: instance.GetComponent <AudioSource>().PlayOneShot(instance.slotFailureSound); break; case GameSounds.PrizeChoosed: instance.GetComponent <AudioSource>().PlayOneShot(instance.prizeChoosedSound); break; default: break; } }
public static void PlaySound(GameSounds gameSound, Vector3 position) { if (!isInitialized) { Initialize(); } AudioSource.PlayClipAtPoint(sounds[(int)gameSound], position); }
// Use this for initialization void Start() { ui = GameObject.FindObjectOfType <UIManager>(); gsounds = GetComponent <GameSounds>(); InitGame(); camShaker = GameObject.FindObjectOfType <CameraShaker>(); }
private static void PlaySound(GameSounds soundName) { var sound = ContentLoader.Load<Sound>(soundName.ToString()); if (sound == null) return; sound.Play(); sound.OnStop += instance => PlayXpCollectedSound(); }
void Start() { spear = 0; ladder = 0; pointsForItem = 5; pointsForEnemy = 10; pointsForChest = 50; gameSounds = GetComponent <GameSounds>(); }
void OnMouseUp() { if (_activeInputLens != null) { CameraOrbit.unlockedLens.RemoveRequestsWithContext(this); CameraOrbit.inputFreeLens.RemoveRequestsWithContext(this); _activeInputLens = null; List <BitSlotWidget> bitSlots = GetBreed().GetBitSlots(); for (int i = 0; i < bitSlots.Count; i++) { bitSlots[i].SetHighlight(false); } ResetFadeoutTimer(); bool allMatched = _spriteToSlotMap.Count == _bitSprites.Length; if (allMatched) { GetBreed().AssignBlock(this); Destroy(gameObject); } else { GameSounds.PostEvent2D(GameSound.SFX_BlockDeny); Vector2 screenMin = Vector2.zero; Vector2 screenMax = new Vector2(Screen.width, Screen.height); Vector2 screenBoundDiff = screenMax - screenMin; screenMin += screenBoundDiff * 0.001f; screenMax -= screenBoundDiff * 0.001f; Vector3 mousePos = ((Vector3)WadeUtils.Clamp((Vector2)Input.mousePosition, screenMin, screenMax)).SetZ(Input.mousePosition.z); bool uiOverlap = RectTransformUtility.RectangleContainsScreenPoint(GetBreed().GetBreedRect(), mousePos, Camera.main); if (!uiOverlap) { Vector3 worldPos = Camera.main.ScreenToWorldPoint(mousePos); if (Physics.Raycast(worldPos, Camera.main.transform.forward, out _hitInfo, Mathf.Infinity, _planetLayer, QueryTriggerInteraction.Ignore)) { _dropPos = _hitInfo.point + _hitInfo.normal * _dropGroundOffset; } } if (_changeScaleRoutine != null) { StopCoroutine(_changeScaleRoutine); } _changeScaleRoutine = StartCoroutine(ChangeScaleRoutine(false)); _dropRoutine = StartCoroutine(DropRoutine()); } BreedPanel breedPanel = UIManager.GetPanel <BreedPanel>(); breedPanel.GetLeftRotateRect().gameObject.SetActive(false); breedPanel.GetRightRotateRect().gameObject.SetActive(false); } }
protected void Start() { loaded = false; idle = true; rb2D = GetComponent <Rigidbody2D>(); gameSounds = GetComponent <GameSounds>(); rnd = new System.Random(); Time.timeScale = 1; }
private static void PlayAttackSound(GameSounds attackSoundName) { var attackSound = ContentLoader.Load <Sound>(attackSoundName.ToString()); if (attackSound != null) { attackSound.Play(); } }
private static void PlaySound(GameSounds soundName) { var sound = ContentLoader.Load <Sound>(soundName.ToString()); if (sound != null) { sound.Play(); } }
public override void SetUpReferences() { base.SetUpReferences(); spawner = GetComponent <GameSpawner>(); progression = GetComponent <GameProgression>(); pooler = GetComponent <GamePooler>(); sounds = GetComponent <GameSounds>(); }
// Check colider with mapLimitLayer or objectsLayer for stop player movement private bool GetNextPositionToMove(Axis direction, float moveY, float moveX) { Vector3 moveTo = new Vector3(); if (direction == Axis.X) { moveTo = moveToPoint.position + new Vector3(moveX, 0f, 0f); player.LastDirectionMovement = Axis.X; player.LastValueMovement = moveX; } else if (direction == Axis.Y) { moveTo = moveToPoint.position + new Vector3(0f, moveY, 0f); player.LastDirectionMovement = Axis.Y; player.LastValueMovement = moveY; } if (!Physics2D.OverlapCircle(moveTo, 0.2f, mapLimitLayer)) { // Check colider with checkPointLayer Collider2D checkPoint = Physics2D.OverlapCircle(moveTo, 0.2f, checkPointLayer); if (checkPoint != null && checkPoint.gameObject.CompareTag(gameObject.tag)) { moveToPoint.position = moveTo; return(false); } else if (checkPoint != null && !checkPoint.gameObject.CompareTag(gameObject.tag)) { GameSounds.PlayerSound(GameSounds.Sound.PlayerBlock); return(false); } // Check colider with squareLayer Collider2D square = Physics2D.OverlapCircle(moveTo, 0.2f, squareLayer); if (square != null && square.gameObject.CompareTag(gameObject.tag)) { GameSounds.PlayerSound(GameSounds.Sound.PlayerBlock); return(false); } else if (square != null && !square.gameObject.CompareTag(gameObject.tag)) { GameSounds.PlayerSound(GameSounds.Sound.PlayerChange); moveToPoint.position = moveTo; return(false); } moveToPoint.position = moveTo; return(true); } else { GameSounds.PlayerSound(GameSounds.Sound.PlayerMovement); } return(false); }
private static void PlaySound(GameSounds soundName) { var sound = ContentLoader.Load <Sound>(soundName.ToString()); if (sound == null) { return; } sound.Play(); sound.OnStop += instance => PlayXpCollectedSound(); }
public MainForm() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; _computerIntelligence = new MinMaxAI(); _music = new GameSounds(); _game = new Game(_computerIntelligence); SubscribeEvents(); _game.CreateNewGame(); }
private void Start() { // Locate other components gameSounds = FindObjectOfType <GameSounds>(); // Initialize states AttachedState = new AttachableAttachedState(this); FreeState = new AttachableFreeState(this); // Initialize data State = FreeState; }
public void CompleteLevel() { lvlComplete = true; pauseGame = true; GameSounds.PlayerSound(GameSounds.Sound.LvLWin); completeLevelUI.SetActive(true); SetScoreValue(); if (PlayerPrefs.GetInt("LevelSelect") >= PlayerPrefs.GetInt("LastLevelComplete")) { PlayerPrefs.SetInt("LastLevelComplete", PlayerPrefs.GetInt("LastLevelComplete", 1) + 1); } }
public static void RemoveSound(GameSounds obj) { try { if (Sounds.ContainsKey(obj)) { Sounds.Remove(obj); } } catch (Exception exception) { ErrorLog.Add(exception); } }
public void GetVolume() { if (PlayerPrefs.GetInt("Volume", 1) == 1) { audioOn.SetActive(true); audioOff.SetActive(false); GameSounds.SetVolume(1); } else { audioOn.SetActive(false); audioOff.SetActive(true); GameSounds.SetVolume(0); } }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); source = GetComponent <AudioSource>(); ChangeMusic(); //source.enabled = false; } else { Destroy(gameObject); } }
public MainForm() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; _computerIntelligence = new MinMaxAI(); _music = new GameSounds(); _game = new Game(_computerIntelligence); _game.InitDrawHandler += InitializeDraw; _game.UpdateScoreHandler += UpdateScoreAndPlayerMove; _game.ShomMessageHandler += ShowMessage; _game.PlayGoodSoundHandler += _music.PlayGoodSound; _game.PlayBadSoundHandler += _music.PlayBadSound; _game.CreateNewGame(); }
public static void AddSound(GameSounds obj) { try { if (Sounds == null) { Sounds = new Dictionary <GameSounds, SoundEffect>(); } if (!Sounds.ContainsKey(obj)) { Sounds.Add(obj, ContentMgr.Load <SoundEffect>("Sounds/" + Enum.GetName(typeof(GameSounds), obj))); } } catch (Exception exception) { ErrorLog.Add(exception); } }
public void PlaySound(GameSounds sound) { AudioClip clip = null; switch (sound) { case GameSounds.Button: clip = buttonClips[Random.Range(0, buttonClips.Length)]; break; case GameSounds.DoorOpen: clip = doorClips[0]; break; case GameSounds.DoorClose: clip = doorClips[1]; break; case GameSounds.Hurt: clip = hurtClips[Random.Range(0, hurtClips.Length)]; break; case GameSounds.Jump: clip = jumpClips[Random.Range(0, jumpClips.Length)]; break; case GameSounds.Pickup: clip = pickupClips[Random.Range(0, pickupClips.Length)]; break; } if (clip != null) { if (_audioSource.isPlaying) { _audioSource.Stop(); } _audioSource.clip = clip; _audioSource.Play(); } }
static void Main(string[] args) { ShowMenu(); _computerIntelligence = new MinMaxAI(); _music = new GameSounds(); _game = new Game(_computerIntelligence); Subscribe(); CreateGame(true); string key; char option; bool gameProcess = true; int x = 0, y = 0; do { key = Console.ReadLine(); if (key.Length < 2) { if (char.TryParse(key.ToUpper(), out option)) { MenuProcess(option, ref gameProcess); } } else { if (int.TryParse(key[0].ToString(), out x) && int.TryParse(key[1].ToString(), out y)) { x--; y--; } else { continue; } _game.MoveTo(x, y); } }while (gameProcess); Console.ReadLine(); }
private void Awake() { gameObject.tag = Tag.Destructable; // Locate other components gameSounds = FindObjectOfType <GameSounds>(); // Locate a parent object for when the Attachable is not attached DefaultParentGameObject = GameObject.FindGameObjectWithTag(Tag.Interactive); Assert.IsNotNull(DefaultParentGameObject, "Failed to locate a gameobject with tag interactive"); BoxCollider collider = gameObject.AddComponent <BoxCollider>(); collider.material = (UnityEngine.PhysicMaterial)Resources.Load(ResourceConstant.Ground); gameObject.AddComponent <Rigidbody>(); // Parent to the appropriate object gameObject.transform.parent = DefaultParentGameObject.transform; }
void LoadAudioSettings() { FileInfo fileInf = new FileInfo(audioSettingsFilePath); if (!fileInf.Exists) { GameSounds.SetDefaultVolume(); return; } XmlDocument xDoc = new XmlDocument(); AES.DecryptFile(audioSettingsFilePath, true); xDoc.Load(audioSettingsFilePath); AES.EncryptFile(audioSettingsFilePath, true); XmlElement xRoot = xDoc.DocumentElement; foreach (XmlNode xVolume in xRoot) { switch (xVolume.Name) { case "MenuMusic": GameSounds.MenuMusicVolume = float.Parse(xVolume.Attributes.GetNamedItem("Value").Value); break; case "MenuSounds": GameSounds.MenuSoundsVolume = float.Parse(xVolume.Attributes.GetNamedItem("Value").Value); break; case "GameMusic": GameSounds.GameMusicVolume = float.Parse(xVolume.Attributes.GetNamedItem("Value").Value); break; case "GameSounds": GameSounds.GameSoundsVolume = float.Parse(xVolume.Attributes.GetNamedItem("Value").Value); break; default: throw new ArgumentException("Wrong data in file"); } } }
private void Awake() { if (instance != null && instance != this) { Destroy(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); if (_Mixer == null) { _Mixer = Resources.Load("AudioMixer") as AudioMixer; _MusicGroup = _Mixer.FindMatchingGroups("Music")[0]; _ActionGroup = _Mixer.FindMatchingGroups("Action")[0]; _SigneGroup = _Mixer.FindMatchingGroups("Signe")[0]; _FeedbackGroup = _Mixer.FindMatchingGroups("Feedback")[0]; _FinGroup = _Mixer.FindMatchingGroups("Fin")[0]; } if (_Sounds == null) { _Sounds = Resources.Load <GameSounds>("GameSounds"); } }
private static void PlayAttackSound(GameSounds attackSoundName) { var attackSound = ContentLoader.Load<Sound>(attackSoundName.ToString()); if (attackSound != null) attackSound.Play(); }
public void PlaySound(GameSounds sound) { _sounds.PlaySound(sound.ToString()); }
public void PlaySound(GameSounds sound, float pitch, float volume) { _sounds.PlaySound(sound.ToString(), pitch, volume); }
public static void PlaySound(GameSounds gameSound) { GameObject player = GameObject.Find("player"); PlaySound(gameSound, player.transform.position); }
private static void PlaySound(GameSounds soundName) { var sound = ContentLoader.Load<Sound>(soundName.ToString()); if (sound != null) sound.Play(); }
public static void PlaySound(GameSounds gameSound, Vector3 position) { if (!isInitialized) Initialize(); AudioSource.PlayClipAtPoint(sounds[(int)gameSound], position); }