Example #1
0
 public override void OnPointerExit(PointerEventData eventData)
 {
     AudioManager.instance.PlaySound(SoundName.MenuItemDeselected);
     if (loop != null)
     {
         loop.Stop();
     }
 }
Example #2
0
 public void Stop()
 {
     if (controller != null)
     {
         controller.Stop();
     }
 }
Example #3
0
 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();
 }
Example #4
0
    IEnumerator ChangeChannel(int Index, bool Static)
    {
        RadioSwapping = true;

        if (Static)
        {
            ASC_Radio.SetVolume(0.5f);
            ASC_Radio.Sound = StaticSound;
            ASC_Radio.Play();
            yield return(new WaitForSeconds(1f));

            ASC_Radio.Stop();
        }

        PlaySong();

        yield return(new WaitForSeconds(0.25f));

        RadioSwapping = false;
    }
Example #5
0
    IEnumerator Alarm()
    {
        ASC.AS.loop = true;
        ASC.Sound   = AlarmSound;
        ASC.Play();

        WarningText.fontSize = 0.01f;
        WarningText.text     = "NIGHT OVER";

        yield return(new WaitForSeconds(3f));

        ASC.Stop();
    }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            TimeManager.instance.StartDay();
            controller = AudioManager.instance.PlaySoundLoop(SoundName.Dash);
        }

        if (Input.GetKeyDown(KeyCode.S) && controller != null)
        {
            controller.Stop();
        }
    }
 public void StopAllLoopingSounds()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         Transform child = transform.GetChild(i);
         if (child.gameObject.activeSelf)
         {
             AudioSourceController controller = child.GetComponent <AudioSourceController>();
             if (controller.Looping)
             {
                 controller.Stop();
             }
         }
     }
 }
Example #8
0
 public void SetFrozen(bool State)
 {
     Frozen = State;
     if (Frozen)
     {
         ASC_Engine.Stop();
         SetStation(0, false);
     }
     else
     {
         ASC_Engine.Play();
         BA.FixGlass();
         if (!RadioTurnedOff)
         {
             SetStation(DefaultStation, false);
         }
     }
 }
Example #9
0
    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;
    }
Example #10
0
    private void Update()
    {
        if (!gameObject.transform.GetChild(1).gameObject.activeInHierarchy&& interaction_type != 17)
        {
            return;
        }
        if (is_inBounds && player != null)
        {
            if (player.GetComponent <PlayerActions>().GetInteraction())
            {
                switch (interaction_type)
                {
                case 0:
                    #region 纸条
                    WaitFor(2f);
                    GetSomething("纸条");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("BackpackUI/Canvas/Note").transform.GetComponent <NoteUI>().Show("纸条", 5f);
                        GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("纸条");
                    }, 2f));
                    #endregion
                    break;

                case 1:
                    #region 罐头
                    GetSomething("罐头");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("n格漫画UI").transform.GetComponent <CartoonUI>().Show(1);
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameController.LoadScene(4);
                        }, 13f));
                    }, 1f));
                    #endregion
                    break;

                case 2:
                    m_AudioSourceController.Play("四格漫画1-3", transform);
                    break;

                case 3:
                    #region 轮椅
                    GameObject.Find("零件堆").GetComponent <Animator>().SetTrigger("Disappear");
                    itemsData.items.Add(new Item("轮椅", "", get_object.GetComponent <SpriteRenderer>().sprite));
                    GetSomething("轮椅");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("n格漫画UI").transform.GetComponent <CartoonUI>().Show(2);
                    }, 1f));
                    CameraAndCharacterController cameraController = GameObject.Find("CameraAndCharacterController").GetComponent <CameraAndCharacterController>();
                    cameraController.character_man.GetComponent <ShowAndHide>().Hide(2f);
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        ShowChairMan();
                    }, 2f));
                    transform.parent.Find("SwitchTrigger").gameObject.SetActive(true);
                    #endregion
                    break;

                case 4:
                    #region 电线开关
                    m_AudioSourceController.Play("开关", transform);
                    WaitFor(8f);
                    GameObject.Find("TrackCameraController-ElectricWire").GetComponent <TrackCameraController>().StartMove();
                    m_AudioSourceController.Play("电流", transform);
                    transform.GetChild(1).gameObject.SetActive(false);
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("漏电的电线").GetComponent <Animator>().SetTrigger("IsCut");
                        GameObject.Find("ElectricLine").SetActive(false);
                        Destroy(remind);
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            m_AudioSourceController.Stop();
                        }, 1.5f));
                    }, 4f));
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("TrackCameraController-ElectricWire").GetComponent <TrackCameraController>().Finished();
                    }, 5.5f));
                    #endregion
                    break;

                case 5:
                    break;

                case 6:
                    #region 收据
                    WaitFor(1f);
                    GetSomething("收据1");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        //GameObject.Find("BackpackUI/Canvas/Note").transform.GetComponent<NoteUI>().Show("收据1", 5f);
                        GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("收据1");
                    }, 2f));
                    #endregion
                    break;

                case 7:
                    #region 日记
                    WaitFor(1f);
                    GetSomething("日记");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("日记");
                    }, 2f));
                    #endregion
                    break;

                case 8:
                    #region 花盆
                    if (GameObject.Find("BackpackUI").GetComponent <BackpackUI>().HasItem("瓶装水"))
                    {
                        GetComponent <Collider2D>().enabled = false;
                        WaitFor(15.5f);
                        LoseSomething("瓶装水");
                        m_AudioSourceController.Play("倒水", transform);
                        zimu.Show("希望它可以快快发芽。");
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameObject.Find("n格漫画UI").transform.GetComponent <CartoonUI>().Show(4);

                            StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                            {
                                zimu.Show("好像有一本日记。");
                                transform.parent.Find("日记Trigger").gameObject.SetActive(true);
                            }, 10.5f));
                        }, 3f));
                    }
                    else
                    {
                        WaitFor(9f);
                        LoseSomething("种子");
                        zimu.Show("种子已经种下了,或许需要给它浇浇水。");
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameObject.Find("TrackCameraController-Water").GetComponent <TrackCameraController>().StartMove();
                            StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                            {
                                GameObject.Find("TrackCameraController-Water").GetComponent <TrackCameraController>().Finished();
                            }, 5f));
                        }, 2f));
                    }
                    #endregion
                    break;

                case 9:
                    #region 瓶装水
                    WaitFor(1f);
                    GetSomething("瓶装水");
                    GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("瓶装水");
                    #endregion
                    break;

                case 10:
                    #region 种子
                    WaitFor(9f);
                    GetSomething("种子");
                    GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("种子");
                    zimu.Show("捡到了一颗种子,要找个地方把它种下。");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("TrackCameraController-FlowerPot").GetComponent <TrackCameraController>().StartMove();
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameObject.Find("TrackCameraController-FlowerPot").GetComponent <TrackCameraController>().Finished();
                            transform.parent.Find("花盆Trigger").GetComponent <Collider2D>().enabled = true;
                        }, 5f));
                    }, 2f));
                    #endregion
                    break;

                case 11:
                    #region 收音机
                    WaitFor(9f);
                    GetSomething("收音机");
                    GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("收音机");
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("TrackCameraController-Battery").GetComponent <TrackCameraController>().StartMove();
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameObject.Find("TrackCameraController-Battery").GetComponent <TrackCameraController>().Finished();
                            Invoke("CanMove", 2f);
                        }, 5f));
                        transform.parent.Find("电池Trigger").GetComponent <Collider2D>().enabled = true;
                    }, 2f));
                    #endregion
                    break;

                case 12:
                    #region 电池
                    WaitFor(1f);
                    GetSomething("电池");
                    GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("电池");
                    #endregion
                    break;

                case 13:
                    #region 零件
                    #endregion
                    break;

                case 14:
                    #region 炸弹
                    WaitFor(1f);
                    GetSomething("炸弹");
                    GameObject.Find("BackpackUI").GetComponent <BackpackUI>().AddItem("炸弹");
                    zimu.Show("一捆炸药!");
                    #endregion
                    break;

                case 15:
                    #region 电箱
                    //水坑没水
                    if (!transform.parent.Find("水坑Trigger/GetObject").GetChild(3).gameObject.activeInHierarchy)
                    {
                        WaitFor(7f);
                        GameObject.Find("TrackCameraController-Pool2").GetComponent <TrackCameraController>().StartMove();
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameObject.Find("TrackCameraController-Pool2").GetComponent <TrackCameraController>().Finished();
                            StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                            {
                                zimu.Show("电线断了...");
                            }, 1.5f));
                        }, 5f));
                        return;
                    }
                    //水坑有水并且已经摆了炸弹
                    if (transform.parent.Find("摆炸弹Trigger/GetObject").gameObject.activeInHierarchy)
                    {
                        GameObject.Find("n格漫画UI").transform.GetComponent <CartoonUI>().Show(5);
                    }
                    //水坑有水但是么有摆炸弹
                    else
                    {
                        WaitFor(7f);
                        GameObject.Find("TrackCameraController-Wall").GetComponent <TrackCameraController>().StartMove();
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            GameObject.Find("TrackCameraController-Wall").GetComponent <TrackCameraController>().Finished();
                            StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                            {
                                m_AudioSourceController.Play("电流", transform);
                                zimu.Show("电路连通了,或许可以点燃什么。");
                            }, 1.5f));
                        }, 5f));
                    }
                    #endregion
                    break;

                case 16:
                    #region 水坑
                    //包里有水
                    if (GameObject.Find("BackpackUI").GetComponent <BackpackUI>().HasItem("瓶装水"))
                    {
                        m_AudioSourceController.Play("倒水", transform);
                        LoseSomething("瓶装水");
                        GameObject.Find("TrackCameraController-Pool").GetComponent <TrackCameraController>().StartMove();
                        Transform pool = get_object.transform;
                        InputController.BanButton(true);
                        InputController.BanMouse(true);
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            if (!pool.GetChild(1).gameObject.activeInHierarchy)
                            {
                                Initial();
                                WaitFor(5f);
                                pool.GetChild(1).GetComponent <ShowAndHide>().Show(3f);
                                StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                                {
                                    GameObject.Find("TrackCameraController-Pool").GetComponent <TrackCameraController>().Finished();
                                    zimu.Show("还需要更多的水。");
                                }, 3f));
                            }
                            else if (!pool.GetChild(2).gameObject.activeInHierarchy)
                            {
                                Initial();
                                WaitFor(5f);
                                pool.GetChild(2).GetComponent <ShowAndHide>().Show(3f);
                                StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                                {
                                    GameObject.Find("TrackCameraController-Pool").GetComponent <TrackCameraController>().Finished();
                                    zimu.Show("还需要更多的水。");
                                }, 3f));
                            }
                            else if (!pool.GetChild(3).gameObject.activeInHierarchy)
                            {
                                WaitFor(11f);
                                pool.GetChild(3).GetComponent <ShowAndHide>().Show(3f);
                                StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                                {
                                    GameObject.Find("TrackCameraController-Pool").GetComponent <TrackCameraController>().Finished();
                                    //电路连通,可以开电箱
                                    transform.parent.Find("电箱Trigger").GetComponent <Collider2D>().enabled = true;
                                    GameObject.Find("TrackCameraController-ElectricityBox2").GetComponent <TrackCameraController>().StartMove();
                                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                                    {
                                        transform.parent.Find("电箱Trigger").GetChild(1).GetComponent <Animator>().SetBool("Open", true);
                                        m_AudioSourceController.Play("电流", transform);
                                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                                        {
                                            GameObject.Find("TrackCameraController-ElectricityBox2").GetComponent <TrackCameraController>().Finished();
                                            zimu.Show("只要再把电源打开。。。");
                                        }, 3f));
                                    }, 3f));
                                }, 3f));
                            }
                        }, 3f));
                    }
                    //包里没水
                    else
                    {
                        WaitFor(2f);
                        zimu.Show("或许可以想办法把这个水坑填满。");
                    }
                    #endregion
                    break;

                case 17:
                    #region 放炸弹
                    //包里没炸弹
                    if (!GameObject.Find("BackpackUI").GetComponent <BackpackUI>().HasItem("炸弹"))
                    {
                        WaitFor(2f);
                        zimu.Show("这面墙快塌了,要是有炸药什么的应该可以炸开吧。");
                        return;
                    }
                    //包里有炸弹
                    InputController.BanButton(true);
                    InputController.BanMouse(true);
                    Invoke("CanMove", 1f);
                    LoseSomething("炸弹");
                    //包里有炸弹且电路连通
                    if (transform.parent.Find("电箱Trigger").GetChild(1).GetComponent <Animator>().GetBool("Open"))
                    {
                        GameObject.Find("n格漫画UI").transform.GetComponent <CartoonUI>().Show(5);
                        return;
                    }
                    //包里有炸弹但电路不通
                    get_object.GetComponent <ShowAndHide>().Show(2f);
                    WaitFor(7f);
                    GameObject.Find("TrackCameraController-ElectricityBox").GetComponent <TrackCameraController>().StartMove();
                    StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                    {
                        GameObject.Find("TrackCameraController-ElectricityBox").GetComponent <TrackCameraController>().Finished();
                        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() =>
                        {
                            zimu.Show("电线断了...");
                        }, 1.5f));
                    }, 5f));
                    #endregion
                    break;

                default:
                    break;
                }
            }
        }
    }
Example #11
0
    // 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
    }
 public void stopSceneSong()
 {
     sceneSongController.Stop();
 }
Example #13
0
    private void FixedUpdate()
    {
        if (onIroningBoard && ironingBoard.garmentOnBoard != null)
        {
            if (TimeManager.instance.timeScale != 0.0f)
            {
                steamState = laundryIroningBoard.Press(transform.position.x);
            }
        }
        else
        {
            steamState = SteamState.Off;
        }

        if (steamState == SteamState.Steam && !steam.isEmitting)
        {
            steam.Play(true);
            smoke.Stop(true, ParticleSystemStopBehavior.StopEmitting);
        }
        if (steamState == SteamState.Burn && !smoke.isEmitting)
        {
            smoke.Play(true);
            steam.Stop(true, ParticleSystemStopBehavior.StopEmitting);
        }
        if (steamState == SteamState.Off && (steam.isEmitting || smoke.isEmitting))
        {
            steam.Stop(true, ParticleSystemStopBehavior.StopEmitting);
            smoke.Stop(true, ParticleSystemStopBehavior.StopEmitting);
        }

        if (steamState == SteamState.Steam)
        {
            if (burnLoop != null)
            {
                burnLoop.Stop();
                burnLoop = null;
            }
            if (steamLoop == null)
            {
                steamLoop = AudioManager.instance.PlaySoundLoop(SoundName.IronIsWorking);
            }
        }
        else if (steamState == SteamState.Burn)
        {
            if (steamLoop != null)
            {
                steamLoop.Stop();
                steamLoop = null;
            }
            if (burnLoop == null)
            {
                burnLoop = AudioManager.instance.PlaySoundLoop(SoundName.IronisBurning);
            }
        }
        else
        {
            if (steamLoop != null)
            {
                steamLoop.Stop();
                steamLoop = null;
            }

            if (burnLoop != null)
            {
                burnLoop.Stop();
                burnLoop = null;
            }
        }
    }
Example #14
0
    IEnumerator RandomCalls()
    {
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(PhoneCallRandomness.x, PhoneCallRandomness.y)));

            int     RandomCaller = Random.Range(0, SpamCallers.Count);
            TextBox TB           = null;
            while (!TB)
            {
                yield return(new WaitForSeconds(0.5f));

                TB = GameObject.FindWithTag("TextBox").GetComponent <TextBox>();
            }

            if (!GetComponent <DashObject>().PickedUp&& !GetComponent <DashObject>().Locked&& !InCall && !TB.isActive)
            {
                if (GameObject.FindWithTag("Manager").GetComponent <Manager>().TimeIndex != 0 && GameObject.FindWithTag("Manager").GetComponent <Manager>().TimeIndex < 600)
                {
                    ASC.Sound = PhoneCallSound;
                    ASC.SetVolume(1f);
                    ASC.AS.loop = true;
                    ASC.Play();

                    PhoneNumber      = "";
                    PhoneScreen.text = "Incoming : " + SpamCallers[RandomCaller].CallerID;
                    DashObject DO = GetComponent <DashObject>();

                    int  Frames   = 0;
                    bool Answered = false;
                    while (Frames < (7 * 60))
                    {
                        yield return(null);

                        Frames++;

                        if (DO.PickedUp)
                        {
                            Answered = true;
                            Frames   = 1000;
                        }
                    }

                    if (Answered)
                    {
                        PhoneScreen.text = SpamCallers[RandomCaller].CallerID;
                        InCall           = true;

                        ASC.AS.loop = false;
                        ASC.Stop();


                        TB.CurrentVoice  = SpamCallers[RandomCaller].CallerVoice;
                        TB.CurrentSource = ASC;
                        ASC.SetVolume(1f);

                        int Index = 0;

                        bool HungUp = false;

                        while (Index < SpamCallers[RandomCaller].Lines.Count && HungUp == false)
                        {
                            TB.DisplayText(SpamCallers[RandomCaller].Lines[Index]);

                            while (TB.isPrinting && HungUp == false)
                            {
                                yield return(null);

                                if (!DO.PickedUp)
                                {
                                    HungUp = true;
                                }
                            }

                            /*
                             * Frames = 0;
                             * while(!HungUp && Frames < 30)
                             * {
                             *  yield return null;
                             *  Frames++;
                             *  if(!DO.PickedUp)
                             *  {
                             *      HungUp = true;
                             *  }
                             * }*/

                            Index++;
                        }

                        TB.Toggle();
                        ASC.SetPitch(1f);

                        if (!HungUp)
                        {
                            GetComponent <DashObject>().RemoveFromHands();
                        }

                        Clear();
                        InCall = false;
                    }

                    ASC.AS.loop = false;
                    ASC.Stop();

                    PhoneScreen.text = "";
                }
            }
        }
    }