/// <summary>"过牌"按钮事件 /// </summary> public void ClickBtnPassPokerEvent() { //当前玩家最大跳出 不可过牌 if (curPlayer == maxPlayerIndex) { player[curPlayer].ShowPoker(); return; } AudioSound.CreateSoundPlay("buyao" + Random.Range(1, 4)); //清空玩家上一次出牌 player[curPlayer].ClearPlayerLastPoker(); //创建出牌显示信息模板 GameObject go = Instantiate(ResourcesManage.dictionary["TemplatePokerShow"] as GameObject); //放置在玩家出牌显示中 go.transform.SetParent(player[curPlayer].transform.Find("LastPoker")); go.transform.localScale = Vector3.one; //图为当前扑克 go.GetComponent <Image>().sprite = ResourcesManage.CreateSprite("Pass"); //添加进出牌显示扑克组中 player[curPlayer].outShowPokers.Add(go); //过牌时重新显示 player[curPlayer].ShowPoker(); //下一个玩家 curPlayer = ++curPlayer % player.Length; time = 0; View_OutAndPassPoker.SetActive(false); }
/// <summary>不抢地主事件 /// </summary> public void ClickBtnNoGrabEvent() { AudioSound.CreateSoundPlay("bujiao"); //下一个玩家 curPlayer = ++curPlayer % player.Length; View_GrabLandLord.SetActive(false); }
/// <summary>出牌事件 /// </summary> public void ClickBtnOutPokerEvent() { //是否符合出牌规则并出牌 if (player[curPlayer].IFOutPoker()) { AudioSound.CreateSoundPlay("outcard1"); OutPokerEffects(); //出牌按钮隐藏 View_OutAndPassPoker.SetActive(false); //任意一方出完全部牌 if (player[curPlayer].pokerList.Count == 0) { //设为当前最大 maxPlayerIndex = curPlayer; //游戏结束 state = GameState.GameOver; return; } //显示扑克 player[curPlayer].ShowPoker(); //设为当前最大 maxPlayerIndex = curPlayer; //下一个玩家 curPlayer = ++curPlayer % player.Length; //重置等待时间 time = 0; } }
public void Change(string name) { AudioSound sound = Array.Find(sounds, s => s.name == _currentBackgroundSound); sound.source.Stop(); _currentBackgroundSound = name; Play(_currentBackgroundSound); SaveSystem.SaveSound(_currentBackgroundSound); }
public void Play(string name) { AudioSound s = Array.Find(sounds, sound => sound.name == name); if (s == null) { Debug.Log(name + " sound not found"); return; } s.source.Play(); }
public void Play(string name) { AudioSound s = Array.Find(sounds, AudioSound => AudioSound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + "not found!"); return; } s.source.Play(); }
public void Stop(string name) { AudioSound s = Array.Find(Sounds, sound => sound.name == name); if (s == null) { Debug.LogWarning("The Audioclip: " + name + " could not be found. Check for errors in the AudioManager component and it's code."); return; } s.Source.Stop(); }
void Start() { SceneManager.LoadSceneAsync("GameUI", LoadSceneMode.Additive); timeCanvas = GameObject.Find("TimeCanvas").transform; ShowTime = timeCanvas.Find("TimeImage/TimeText").GetComponent <Text>(); playerDataManage = PlayerDataManage.GetInstance(); //播放背景音乐 AudioSound.CreateSoundPlay("music", true, true); //初始化游戏 InitializeGame(); }
public void Play(string name) { AudioSound s = Array.Find(sounds, sound => sound.name == name); //name & find the name of the sound in array if (s == null) { print("Sound:" + name + " doesn't exist!"); return; //continue if sound is not found } s.source.Play(); //play sound according to the name (in inspector) }
void Awake() { if (Instance == null) { DontDestroyOnLoad(gameObject); Instance = this; } else if (Instance != this) { Destroy(gameObject); } }
/// <summary>抢地主事件 /// </summary> public void ClickBtnIsGrabEvent() { AudioSound.CreateSoundPlay("jiaodizhu"); //临时牌组,用于显示后的选择切换操作 Poker[] tempPoker = new Poker[PokerManage.listBack.Count]; //当前最大,出牌时优先 maxPlayerIndex = curPlayer; //遍历底牌,添加数据显示到手牌 for (int i = 0; i < PokerManage.listBack.Count; i++) { GameObject go = Instantiate(PokerManage.listBack[i].gameObject); Poker poker = go.GetComponent <Poker>(); tempPoker[i] = poker; go.AddComponent <BoxCollider2D>().size = new Vector2(1.05f, 1.5f); //添加进手牌 go.transform.SetParent(player[curPlayer].transform.Find("HandPoker")); player[curPlayer].pokerList.Add(go.GetComponent <Poker>()); //底牌可见 PokerManage.listBack[i].isVisible = true; } //地主设定 player[curPlayer].roleType = RoleType.landlord; //角色分配 for (int i = 0; i < player.Length; i++) { player[i].roleType = i != maxPlayerIndex ? RoleType.peasant : RoleType.landlord; player[i].transform.Find("UI/HeadImage/RoleType").GetComponent <Text>().text = player[i].roleType == RoleType.landlord ? "地主" : "农民"; if (player[i].operateType != OperateType.Protagonist) { player[i].transform.Find("UI/SurplusCount").GetComponent <Text>().text = "剩余: " + player[i].pokerList.Count + "张"; } } player[curPlayer].PokerSort(); player[curPlayer].ShowPoker(); //主视角选择及显示切换 if (player[curPlayer].operateType == OperateType.Protagonist) { for (int i = 0; i < tempPoker.Length; i++) { tempPoker[i].isVisible = true; tempPoker[i].ChangeSelect(); } } //进入轮牌 state = GameState.OutPoker; View_GrabLandLord.SetActive(false); }
IEnumerator LoadScenes() { ao = SceneManager.LoadSceneAsync("Main"); //加载全部资源 ResourcesManage.LoadAll(); //加载头像 ResourcesManage.LoadHeadImages(); //加载音效 AudioSound.LoadSound("sound/man"); ///加载全部扑克 PokerManage.LoadPoker(); yield return(ao); }
private void Update() { // update current sounds GameObject[] currentSoundsList = currentSounds.Values.ToArray(); foreach (GameObject g in currentSoundsList) { AudioSound a = g.GetComponent <AudioSound>(); AudioSource s = g.GetComponent <AudioSource>(); s.volume = a.volume * groups[a.groupName].volume; s.pitch = a.pitch * (a.pitchAffectedByTimeScale ? Time.timeScale : 1f); g.GetComponent <AudioLowPassFilter>().cutoffFrequency = overrideCutoff != -1f ? overrideCutoff : a.lowpass; } }
public void FadeOutVolume(string name) { AudioSound s = Array.Find(Sounds, sound => sound.name == name); if (s == null) { Debug.LogWarning("The Audioclip: " + name + " could not be found. Check for errors in the AudioManager component and it's code."); return; } s.Source.volume = 0.4f; s.Source.volume = 0.3f; s.Source.volume = 0.2f; s.Source.volume = 0.1f; }
private static AudioSource ChooseSource(AudioSound sound) { int tries = sound.Sources.Length; int i = 0; while (tries > 0) { i = UnityEngine.Random.Range(0, sound.Sources.Length); tries--; if (!sound.Sources[i].isPlaying) { return(sound.Sources[i]); } } return(null); }
void Awake() { if (_instance == null) { AudioSound snd = gameObject.GetComponentInChildren <AudioSound>(); _instance = this; _instance.sound = snd; InitLoadAudio(); DontDestroyOnLoad(this); } else { if (this != _instance) { Destroy(this.gameObject); } } }
public void CheckAns() { if (Ans != -1) //Answer and Click Shoot //If Wrong Answer { if (Ans != Answer && Ans != -2) { Ans = -1; ShowAns.text = ""; AudioSound.PlaySound("Wrong"); } else { //If Right Answer if (Ans == Answer) { BoomText.Play(); AudioSound.PlaySound("Shoot"); Qt [n].gameObject.SetActive(false); } countQt++; if (countQt <= 2) { n = Random.Range(0, Qt.Length); Debug.Log("สุ่ม ได้ " + n.ToString()); while (n == Arr [0] || n == Arr [1]) { n = Random.Range(0, Qt.Length); Debug.Log("สุ่มอีกที " + n.ToString()); } j += 1; Arr [j] = n; Qt [n].gameObject.SetActive(true); Ans = -1; ShowAns.text = ""; } } } else //Not Answer and Click Shoot { ShowAns.text = "กรุณากดตัวเลขก่อนกดปุ่มยิง"; } }
// Update is called once per frame void Update() { switch (_clipToPlay) { case AudioSound.Coin: _audioSource.PlayOneShot(coin); break; case AudioSound.Resize: _audioSource.PlayOneShot(resize); break; case AudioSound.Shrink: _audioSource.PlayOneShot(shrink); break; } _clipToPlay = AudioSound.Nothing; }
/// <summary>游戏结束操作 /// </summary> public void GameOver() { //关闭时钟显示 timeCanvas.GetComponent <Canvas>().enabled = false; Btn_ReStart.SetActive(true); View_GameOverView.SetActive(true); for (int i = 0; i < player.Length; i++) { player[i].ShowPoker(true); //显示名字 View_GameOverView.transform.Find("Player" + i).GetComponent <Text>().text = player[i].info.name; //显示角色 View_GameOverView.transform.Find("Player" + i + "_type").GetComponent <Text>().text = player[i].roleType == RoleType.landlord ? "地主" : "农民"; //得分 int score = 0; //分数符号 string scoreF = ""; //角色是否胜利判断是加分是减分 scoreF = player[maxPlayerIndex].roleType == player[i].roleType ? "+" : "-"; //是农民还是地主,农民只有倍分一半,地主全部倍分 score = player[i].roleType == RoleType.peasant ? (baseScore * MultipleCount) / 2 : baseScore * MultipleCount; //显示 Text scoreText = View_GameOverView.transform.Find("Player" + i + "_Score").GetComponent <Text>(); scoreText.text = scoreF + score; //数据中当前分加分和减分操作 int curScore = int.Parse(player[i].info.score); player[i].info.score = scoreF == "+" ? (curScore + score).ToString() : (curScore - score).ToString(); //显示信息 player[i].ShowPlayerInfo(); } //仅更新当前角色信息 playerDataManage.UpdatePlayerInfoToXml(player[0].info); //倍数初始化 MultipleCount = 2; AudioSound.CreateSoundPlay(player[maxPlayerIndex].operateType == OperateType.Protagonist ? "win" : "fail"); state = GameState.Empty; }
void Start() { _audio = GameObject.FindGameObjectWithTag("AudioListener").GetComponent <AudioSound>(); selectable[0] = colorblind; selectable[1] = mute; selectable[2] = back; selectable[selectIndex].GetComponent <Image>().color = Color.green; //selectable[selectIndex].GetComponentInChildren<Text>().color = Color.green; if (PlayerPrefs.GetInt("mute") == 1) { mute.GetComponent <Toggle>().isOn = true; _audio.MuteSound(); } if (PlayerPrefs.GetInt("colorblind") == 1) { colorblind.GetComponent <Toggle>().isOn = true; } }
public void OnMouseDown() { AudioSound.CreateSoundPlay("xuanpai"); ChangeSelect(); }
public void Play(string name) { AudioSound s = Array.Find(sounds, sound => sound.name == name); s.source.PlayOneShot(s.source.clip, s.volume); }
public void Play(string name) { AudioSound s = Array.Find(sounds, sound => sound.name == name); //name & find the name of the soundss s.source.Play(); //play sound according to the name (in inspector) }
public void Stop(string name) { AudioSound s = Array.Find(sounds, sound => sound.name == name); s.source.Stop(); }
//public GameObject tank; //Time.realtimeSinceStartup // Use this for initialization void Start() { // get a sound from the gameObject "Audio Source" from the game world sound = GameObject.Find("Audio Source"); audioSound = sound.GetComponent <AudioSound> (); }
// Use this for initialization void Start() { _audioSource = GetComponent <AudioSource>(); _clipToPlay = AudioSound.Nothing; }
public void Play(AudioSound type) { _clipToPlay = type; }
/// <summary> /// Will play the given sound. /// </summary> /// <param name="sound"></param> public void PlaySound(AudioSound sound) { }
public void ChangeSoundVol(float _value) { AudioSound.ChangeSoundVolume(_value); soundVol_Text.text = (int)(_value * 100) + "%"; }
// Use this for initialization void Start() { // set the audio sound and the sound sound = GameObject.Find("Audio Source"); audioSound = sound.GetComponent <AudioSound> (); }