// Start is called before the first frame update void Start() { if (audioSourceController == null) { audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } }
//显示字条。 itemName道具名,showTime淡入/淡出时间,间隔waitTime后再显示关闭按钮 public void Show(string itemName, float showTime = 0.5f, float waitTime = 2f, int count = 2) { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } if (itemName == "收音机") { m_AudioSourceController.Play("收音机杂音循环", transform); } else { m_AudioSourceController.Play("阅读字条", transform); } transform.Find("Canvas/Close Button").gameObject.SetActive(false); if (itemName != "收音机" && itemName != "收据1") { transform.Find("Canvas/Note Text").GetComponent <Text>().text = GameObject.Find("ItemsData").GetComponent <ItemsData>().GetItemByItemName(itemName).introduce; } if (itemName == "纸条" || itemName == "日记") { transform.Find("Canvas/Note Text").GetComponent <Text>().fontSize = 26; } GetComponent <ShowAndHideUI>().Show(showTime, delegate() { StartCoroutine(IE_ShowButton(1f, itemName, count)); }); //禁用输入 InputController.BanButton(true); InputController.BanMouse(true); GameObject.Find("EventSystem").GetComponent <EventSystem>().enabled = false; }
void Start() { TransitionUI.FadeOut(3f); AudioDataManager.Init(); AudioSourcesManager.Init(); GameObject.Find("AudioSourcesManager").GetComponent <AudioSource>().volume = AudioDataManager.GetAudioDataByName("bgm1").volumn *AudioDataManager.BGMVolumn; }
private void FinishCough() { InputController.BanButton(false); child.GetComponent <Animator>().SetBool("IsCough", false); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); last_time = 0f; is_Cough = false; InputController.GetKey(); }
private void Start() { last_time = 0f; is_Cough = false; child = transform.GetChild(0).gameObject; if (audioSourceController == null) { audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } }
//Button继续游戏 public void ContinueButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); Debug.Log("Continue"); }
public void GetSkill() { AudioSourceController audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); audioSourceController.Play("修理轮椅", transform); m_Disable = false; GetComponent <ShowAndHideUI>().Show(); GetComponent <Image>().sprite = normalSprite; GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f); transform.GetChild(0).GetComponent <Image>().color = new Color(1, 1, 1, 0); }
public void MusicButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); transform.Find("PauseCanvas/BackgroundPanel/BasicPanel").gameObject.SetActive(false); transform.Find("PauseCanvas/BackgroundPanel/MusicPanel").gameObject.SetActive(true); }
//Button退出 public void ExitButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); Application.Quit(); Debug.Log("Exit"); }
//Button开始新游戏 public void NewStartButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); SceneManager.LoadScene(1); //加载场景1 Debug.Log("NewStart"); }
//Button设置 public void SettingButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); transform.Find("MainCanvas/MainPanel").gameObject.SetActive(false); transform.Find("PauseUI/PauseCanvas").gameObject.SetActive(true); Debug.Log("Setting"); }
//显示获得道具的提示:道具名、渐入并淡出时长、上下偏移量、完全显示的停留时长、完全显示时的alpha值 public void GetShow(string itemName, float showTime = 2f, float offset = 0.4f, float holdTime = 0.2f, System.Action action = null, float alpha = 1f) { transform.Find("道具").GetComponent <Image>().sprite = itemsData.GetSpriteByItemName(itemName); transform.Find("符号").GetComponent <Image>().sprite = getIron; ShowFromTop(showTime, offset, holdTime, action, alpha); //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("获得道具", transform); }
public void ContinueButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); m_IsPause = false; transform.Find("PauseCanvas").gameObject.SetActive(false); Time.timeScale = 1f; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Dog")) { dog_inBounds = true; m_dog = collision.gameObject; if (getOrLose_prefab != null) { getOrLose = Instantiate(getOrLose_prefab); getOrLostItem = getOrLose.GetComponent <GetOrLostItem>(); } zimu = GameObject.Find("UI").transform.Find("字幕UI").GetComponent <ZimuUI>(); m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } }
public void UseSkill() { if (!m_IsCD && !m_Disable) { m_IsCD = true; m_Timer = 0f; GetComponent <Image>().sprite = normalSprite; GetComponent <Image>().color = new Color(0.5f, 0.5f, 0.5f, 1f); transform.GetChild(0).GetComponent <Image>().sprite = cdSprite; transform.GetChild(0).GetComponent <Image>().color = new Color(0f, 0f, 0f, 0.4f); AudioSourceController audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); audioSourceController.Play("冲刺", transform); StartCoroutine(IE_CD()); } }
private void Update() { if (SceneManager.GetActiveScene().buildIndex != 0) //场景不为主菜单时 { if (Input.GetKeyDown(KeyCode.Escape) && !m_IsPause) //开始暂停 { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); m_IsPause = true; /*GameObject[] UIs = GameObject.FindGameObjectsWithTag("UI"); * foreach (GameObject ui in UIs) * { * ui.SetActive(false); * }*/ transform.Find("PauseCanvas").gameObject.SetActive(true); transform.Find("PauseCanvas/BackgroundPanel/HelpPanel").gameObject.SetActive(false); transform.Find("PauseCanvas/BackgroundPanel/MusicPanel").gameObject.SetActive(false); transform.Find("PauseCanvas/BackgroundPanel/BasicPanel").gameObject.SetActive(true); ButtonOverride[] buttonOverrides = transform.GetComponentsInChildren <ButtonOverride>(); foreach (ButtonOverride buttonOverride in buttonOverrides) { buttonOverride.Init(); } Time.timeScale = 0f; } else if (Input.GetKeyDown(KeyCode.Escape) && m_IsPause) //取消暂停 { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); m_IsPause = false; transform.Find("PauseCanvas").gameObject.SetActive(false); Time.timeScale = 1f; } } }
public override void OnPointerEnter(PointerEventData eventData) { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮悬浮", transform); base.OnPointerEnter(eventData); Text text = transform.GetComponentInChildren <Text>(); if (text) { text.fontSize = GetComponent <ButtonParameter>().fonthighlightSize; text.color = GetComponent <ButtonParameter>().fontHighlightedColor; } }
public void BackpackToggle() { if (transform.GetComponent <Toggle>().isOn) { transform.GetComponent <Toggle>().targetGraphic.GetComponent <Image>().sprite = on; transform.GetComponent <Toggle>().targetGraphic.GetComponent <Image>().color = new Color(1, 1, 1, 1); } else { transform.GetComponent <Toggle>().targetGraphic.GetComponent <Image>().sprite = off; transform.GetComponent <Toggle>().targetGraphic.GetComponent <Image>().color = new Color(0.5f, 0.5f, 0.5f, 1); } if (audioSourceController == null) { audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } audioSourceController.Play("按钮", transform); }
public void MenuButton() { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("按钮", transform); if (SceneManager.GetActiveScene().buildIndex == 0) //场景为主菜单时,直接返回 { m_IsPause = false; transform.Find("PauseCanvas").gameObject.SetActive(false); transform.parent.Find("MainCanvas/MainPanel").gameObject.SetActive(true); } else //场景不为主菜单时,加载主菜单场景 { Time.timeScale = 1f; SceneManager.LoadScene(0); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Dog") { if (interaction_type == 0) { if (collision.contacts[0].normal.x == 1) { transform.parent.GetComponent <Animator>().SetTrigger("Open"); GameObject.Find("MouseCursor").GetComponent <MouseCursorController>().EnterPointPlane(); m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); m_AudioSourceController.Play("开关门", transform); GetComponent <Collider2D>().enabled = false; transform.parent.Find("Gate").gameObject.SetActive(false); InputController.BanMouse(true); InputController.BanButton(true); Invoke("CanMove", 2f); } } } }
void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { player = collision.gameObject; is_inBounds = true; if (interaction_type != 17 && gameObject.transform.GetChild(1).gameObject.activeInHierarchy) { remind = Instantiate(remind_prefab, remind_position); if (getOrLose_prefab != null) { getOrLose = Instantiate(getOrLose_prefab); getOrLostItem = getOrLose.GetComponent <GetOrLostItem>(); getOrLostItem.character = player.transform; } m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } else if (interaction_type == 17 && !gameObject.transform.GetChild(1).gameObject.activeInHierarchy) { remind = Instantiate(remind_prefab, remind_position); if (getOrLose_prefab != null) { getOrLose = Instantiate(getOrLose_prefab); getOrLostItem = getOrLose.GetComponent <GetOrLostItem>(); getOrLostItem.character = player.transform; } m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } if (interaction_type == 5) { remind = Instantiate(remind_prefab); remind.transform.parent = player.transform; remind.transform.localPosition = new Vector3(0f, 3f, 0f); remind.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); remind.GetComponent <ShowAndHide>().Show(1f); zimu.Show("太危险了!可是必须要过去。"); return; } } }
public void CloseButton(string itemName = null) { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } if (itemName != "收音机") { m_AudioSourceController.Play("阅读字条", transform); } else { m_AudioSourceController.Stop(); } //解除禁用输入 InputController.BanButton(false); InputController.BanMouse(false); StopCoroutine(IE_ShowButton()); GetComponent <ShowAndHideUI>().Hide(0.5f); GameObject.Find("EventSystem").GetComponent <EventSystem>().enabled = true; }
IEnumerator IE_ShowAndHide(float showTime, float holdTime, float alpha) { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } m_AudioSourceController.Play("气泡提示", transform); //淡入 float delta = Time.deltaTime / showTime; //showTime时间内渐入/淡出 while (GetComponent <CanvasGroup>().alpha != alpha) { GetComponent <RectTransform>().position = character.position + new Vector3(xOffset, yOffset, 0); GetComponent <CanvasGroup>().alpha += delta; if (GetComponent <CanvasGroup>().alpha > alpha) { GetComponent <CanvasGroup>().alpha = alpha; } yield return(0); } //保持完全显示 float timer = 0f; while (timer < holdTime) { GetComponent <RectTransform>().position = character.position + new Vector3(xOffset, yOffset, 0); timer += Time.deltaTime; yield return(0); } //淡出 Hide(showTime); }
private void Awake() { _instance = this; }
// Update is called once per frame void Update() { interaction = false; InputController.GetKey(); #region 切换视角 if (CameraController != null && GameController.GetCharacterNumber() == 2) { int mainCamera = CameraController.GetComponent <CameraAndCharacterController>().mainCamera; if (mainCamera == 0 && InputController.mouseDown) { CameraController.GetComponent <CameraAndCharacterController>().mainCamera = 1; CameraController.GetComponent <CameraAndCharacterController>().SendMessage("ChangeCamera"); } else if (mainCamera == 1 && InputController.buttonDown) { CameraController.GetComponent <CameraAndCharacterController>().mainCamera = 0; CameraController.GetComponent <CameraAndCharacterController>().SendMessage("ChangeCamera"); } } else if (GameController.GetCharacterNumber() != 2) { Debug.Log("这个场景的角色不是两个,所以不能切换视角!"); } #endregion #region 虚弱的人的移动 if (m_state == 0) { if (InputController.left) { gameObject.GetComponent <PoorManMoving>().SendMessage("MoveLeft"); audioSourceController.Play("人走路", transform); } else if (InputController.right) { gameObject.GetComponent <PoorManMoving>().SendMessage("MoveRight"); audioSourceController.Play("人走路", transform); } else if (InputController.interaction) { interaction = true; gameObject.GetComponent <PoorManMoving>().SendMessage("StopMoving"); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); return; } else { gameObject.GetComponent <PoorManMoving>().SendMessage("StopMoving"); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); return; } } #endregion #region 轮椅的移动 if (m_state == 1) { if (InputController.rush) { Skill rushSkill = GameObject.Find("技能UI/Canvas/Panel").transform.Find("技能1").GetComponent <Skill>(); if (rushSkill.IsAble()) { if (!rushSkill.isCD) { rushSkill.UseSkill(); //audioSourceController.Play("冲刺", transform); gameObject.GetComponent <ChairMoving>().SendMessage("Rush"); } } } if (InputController.left) { audioSourceController.Play("轮椅移动", transform); gameObject.GetComponent <ChairMoving>().SendMessage("MoveLeft"); } else if (InputController.right) { audioSourceController.Play("轮椅移动", transform); gameObject.GetComponent <ChairMoving>().SendMessage("MoveRight"); } else if (InputController.interaction) { interaction = true; gameObject.GetComponent <ChairMoving>().SendMessage("StopMoving"); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); return; } else { gameObject.GetComponent <ChairMoving>().SendMessage("StopMoving"); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); return; } } #endregion #region 健康人的移动 if (m_state == 2) { if (InputController.left) { gameObject.GetComponent <PlayerMoving>().SendMessage("IsMoving", true); gameObject.GetComponent <PlayerMoving>().SendMessage("MoveLeft"); audioSourceController.Play("人走路", transform); } else if (InputController.right) { gameObject.GetComponent <PlayerMoving>().SendMessage("IsMoving", true); gameObject.GetComponent <PlayerMoving>().SendMessage("MoveRight"); audioSourceController.Play("人走路", transform); } else if (InputController.interaction) { interaction = true; gameObject.GetComponent <PlayerMoving>().SendMessage("IsMoving", false); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); return; } else { gameObject.GetComponent <PlayerMoving>().SendMessage("IsMoving", false); audioSourceController.Stop(); audioSourceController = AudioSourcesManager.ApplyAudioSourceController(); return; } } #endregion #region 狗子的移动 if (m_state == 3) { GameObject plane = GameObject.FindGameObjectWithTag("Plane"); Vector3 target = new Vector3(InputController.hitPoint.x, InputController.hitPoint.y, plane.transform.position.z); if (InputController.right_mouseDown) { GetComponent <DogMoving>().SendMessage("JumpTo", target); } if (plane.GetComponent <Collider2D>().bounds.Contains(target)) { if (InputController.left_mouseDown) { GetComponent <DogMoving>().SendMessage("MoveTo", target); interaction = true; } } } #endregion }
IEnumerator IE_Show(int id, int n, float intervalTime, float showTime) { yield return(new WaitForSeconds(1f)); for (int i = 1; i <= n; i++) { //音效 if (m_AudioSourceController == null) { m_AudioSourceController = AudioSourcesManager.ApplyAudioSourceController(); } if (id == 2 && i == 1) { m_AudioSourceController.Play("四格漫画2-1", transform); } else if (id == 2 && i == 2) { m_AudioSourceController.Play("修理轮椅", transform); } else if (id == 2 && i == 3) { m_AudioSourceController.Play("四格漫画2-3", transform); } else if (id == 2 && i == 4) { m_AudioSourceController.Play("四格漫画2-4", transform); } else if (id == 1 && i == 1) { m_AudioSourceController.Play("开罐头", transform); } else if (id == 1 && i == 2) { m_AudioSourceController.Play("四格漫画1-2", transform); } else if (id == 1 && i == 3) { m_AudioSourceController.Play("四格漫画1-3", transform); } else if (id == 1 && i == 4) { m_AudioSourceController.Play("四格漫画1-4", transform); } else if (id == 3 && i == 2) { m_AudioSourceController.Play("收音机杂音", transform); } else if (id == 3 && i == 3) { m_AudioSourceController.Play("修理轮椅", transform); } else if (id == 3 && i == 4) { m_AudioSourceController.Play("四格漫画2-3", transform); } else if (id == 4 && i == 1) { m_AudioSourceController.Play("倒水", transform); } else if (id == 4 && i == 2) { m_AudioSourceController.Play("四格漫画2-3", transform); } else if (id == 4 && i == 3) { m_AudioSourceController.Play("花盆倒下", transform); } else if (id == 5 && i == 1) { m_AudioSourceController.Play("火花", transform); } else if (id == 5 && i == 2) { m_AudioSourceController.Play("爆炸", transform); } else if (id == 5 && i == 3) { m_AudioSourceController.Play("风", transform); } else if (id == 6 && i == 1) { m_AudioSourceController.Play("轮椅移动", transform); } else if (id == 6 && i == 2) { m_AudioSourceController.Play("人倒下", transform); } else if (id == 6 && i == 3) { m_AudioSourceController.Play("跑步", transform); } transform.Find("Canvas/Panel/" + m_CurCartoon + "/Image" + i).GetComponent <ShowAndHideUI>().Show(); yield return(new WaitForSeconds(intervalTime)); } transform.Find("Canvas/Panel/" + m_CurCartoon + "/Arrow").GetComponent <ShowAndHideUI>().Show(); GameObject.Find("EventSystem").GetComponent <EventSystem>().enabled = true; //以下是解除禁用输入后,玩家点击任意键,使得漫画UI淡出 while (true) { if (Input.anyKey) { //。。。。。。解除禁用玩家输入的函数放这里 InputController.BanButton(false); InputController.BanMouse(false); Hide(id); break; } yield return(0); } }