Beispiel #1
0
    IEnumerator StartGame()
    {
        Services.Get <MenuMain>().StartGame();
        var logo = Services.Get <LogoMenu>();

        if (logo != null)
        {
            logo.Stop();
        }
        yield return(new WaitForSeconds(1.8f));

        //if(readyPlayers == null || readyPlayers.Length == 0)
        //    readyPlayers = Object.FindObjectsOfType<PlayerReady>();

        //Debug.Log(readyPlayers.Count(p => p.Active));
        //for (int i = 0; i < readyPlayers.Length; i++)
        //{
        //    if (readyPlayers[i].Active)
        //    {
        //        ActivePlayers.Add(readyPlayers[i].PlayerID);
        //    }
        //}

        InAudio.StopAll(gameObject);
        Application.LoadLevel(2);
    }
Beispiel #2
0
        public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            var normTime = animator.GetAnimatorTransitionInfo(layerIndex).normalizedTime;
            var go       = animator.gameObject;

            if (normTime > 0 && canSetVolume /*&& normTime < 1*/)
            {
                int count = Parameters.ParameterList.Count;
                if (!canSetVolume)
                {
                }
                canSetVolume = true;

                for (int i = 0; i < count; i++)
                {
                    var elem = Parameters.ParameterList[i];
                    //if (elem.StartVolume != elem.Target)
                    {
                        float lerp = Mathf.Lerp(elem.StartVolume, elem.Target, normTime);
                        //Debug.Log(name + " " + lerp + " " + elem.StartVolume + " " + elem.Target);
                        InAudio.SetVolumeForNode(go, elem.Node, lerp);
                    }
                }
            }
            //Debug.Log(animator.GetAnimatorTransitionInfo(layerIndex).normalizedTime);
        }
Beispiel #3
0
    void OnEnable()
    {
        if (instance == null || instance == this)
        {
            if (activeAudioListener == null)
            {
                activeAudioListener = FindActiveListener();
            }

            instance            = this;
            _inAudioEventWorker = GetComponentInChildren <InAudioEventWorker>();
            runtimeData         = GetComponentInChildren <InRuntimeAudioData>();
            BankLoader.LoadAutoLoadedBanks();
            runtimeData.UpdateEvents(InAudioInstanceFinder.DataManager.EventTree);
            //AudioBusVolumeHelper.UpdateCombinedVolume(InAudioInstanceFinder.DataManager.BusTree);
            DontDestroyOnLoad(transform.gameObject);

            if (InAudioInstanceFinder.DataManager != null && InAudioInstanceFinder.DataManager.BusTree != null)
            {
                var busRoot = InAudioInstanceFinder.DataManager.BusTree;
                TreeWalker.ForEach(busRoot, b => b.NodesInBus = new List <InPlayer>());
                busRoot.Dirty = true;
                AudioBusVolumeHelper.InitVolumes(busRoot);
                AudioBusVolumeHelper.UpdateVolumes(InAudioInstanceFinder.DataManager.BusTree);
            }
        }
        else
        {
            Object.Destroy(transform.gameObject);
        }
    }
Beispiel #4
0
    void ThirdClick()
    {
        Debug.Log(pgaBarLeft.sizeDelta.x);

        if (pgaBarLeft.sizeDelta.x < 50f)
        {
            if (pgaBarLeft.sizeDelta.x > 0f)
            {
                injectionQuality = (50f - pgaBarLeft.sizeDelta.x) / 50f;
            }
            else
            {
                injectionQuality = (50f - pgaBarRight.sizeDelta.x) / 50f;
            }

            InAudio.Play(this.gameObject, SoundController.Instance.bop3);
            //	Debug.Log ("Second Click");
            clicks = 3;
            AdministerDrugs();
            clicks = 0;

            if (medHeld == "Defib")
            {
                InAudio.Play(this.gameObject, SoundController.Instance.doof);
            }
        }
    }
Beispiel #5
0
    Medication DecideWhetherBloodLoss(Patient p)
    {
        float      bloodAmt = (float)UnityEngine.Random.Range(20, 50);
        Medication blood    = new Medication("Blood", bloodAmt, UnityEngine.Random.Range(6f, 18f), 5f, UnityEngine.Random.Range(1, 3));

        blood.currentLevel = UnityEngine.Random.Range(blood.dose * 0.4f, blood.dose);

        if (totalPatients > 2 && UnityEngine.Random.Range(0, 8) == 2)
        {
            GameObject bedGo = BedController.Instance.bedToGameObjectMap [p.bed];
            BedHud     hud   = bedGo.GetComponent <BedHud> ();

            hud.successText.gameObject.SetActive(true);
            hud.successText.text = "Administer " + bloodAmt.ToString() + " units!";

            hud.bloodText.transform.parent.transform.gameObject.SetActive(true);
            hud.bloodText.text = bloodAmt.ToString();


            InAudio.Play(this.gameObject, SoundController.Instance.alarm);
        }
        else
        {
            blood.dose            = 0f;
            blood.currentLevel    = 0f;
            blood.dosesUntilCured = 0;
        }


        return(blood);
    }
    Patient PatientIsDead(Patient p)
    {
        p.inTreatment = false;

        BedController.Instance.WheelBedOutOfBerth(p.bed);
        GameController.Instance.lives [GameController.Instance.patientsDied].SetActive(false);
        GameController.Instance.patientsDied++;

        GameObject bedGo = BedController.Instance.bedToGameObjectMap [p.bed];
        BedHud     hud   = bedGo.GetComponent <BedHud> ();

        hud.nameText.text = hud.nameText.text + " (RIP)";

        if (p.isMale)
        {
            hud.boy.transform.DOLocalMove(new Vector3(hud.boy.transform.position.x, 10f, hud.boy.transform.position.z), 1f);
        }
        else
        {
            hud.girl.transform.DOLocalMove(new Vector3(hud.girl.transform.position.x, 10f, hud.girl.transform.position.z), 1f);
        }


        InAudio.Play(this.gameObject, SoundController.Instance.dead);

        if (GameController.Instance.patientsDied == 3)
        {
            GameController.Instance.GameOver();
        }



        return(p);
    }
Beispiel #7
0
    void OnCollisionEnter(Collision col)
    {
        var other = col.gameObject.GetComponent <PlayerController>();

        if (other)
        {
//            Debug.Log("Impact " + playerPostFix);

            if (slippers && slippers.name.Contains("Shark"))
            {
                other.collider.enabled = false;
                var dead = Instantiate(brokenBody, other.transform.position, other.transform.rotation) as Transform;
                foreach (var parts in dead.GetComponentsInChildren <Rigidbody>())
                {
                    parts.AddForce(-col.contacts[0].normal * col.relativeVelocity.magnitude, ForceMode.VelocityChange);
                    parts.renderer.material.color = other.color;
                }

                InAudio.PlayAtPosition(GameManager.Instance.gameObject, deathSound, other.gameObject.transform.position);
                Destroy(other.gameObject);
                GameManager.Instance.Respawn(other);

                Services.Get <CameraShake>().ApplyShake(0.4f, 0.5f);
            }

            var impact = Vector3.Project(col.relativeVelocity, col.contacts[0].normal);
            impact *= other.Push / Push;
            rigidbody.AddForce(impact, ForceMode.VelocityChange);
            Services.Get <CameraShake>().ApplyShake(0.2f, 0.2f);
            //Debug.DrawRay(transform.position, impact, Color.red);
        }
    }
    Patient TriggerBloodLoss(Patient p)
    {
        Debug.Log("Blood loss!!");

        GameObject bedGo = BedController.Instance.bedToGameObjectMap[p.bed];
        BedHud     hud   = bedGo.GetComponent <BedHud> ();

        Medication m = p.currentPrescriptions ["Blood"];

        m.dose              = (float)UnityEngine.Random.Range(20, 50);
        m.currentLevel      = UnityEngine.Random.Range(m.dose * 0.4f, m.dose);
        m.dosesUntilCured   = Random.Range(1, 3);
        m.dosesAdministered = 0;
        m.effectLength      = UnityEngine.Random.Range(10f, 20f);

        hud.successText.gameObject.SetActive(true);
        hud.successText.text = "Administer " + m.dose.ToString() + " units!";
        InAudio.Play(this.gameObject, SoundController.Instance.alarm);

        hud.bloodText.transform.parent.transform.gameObject.SetActive(true);
        hud.bloodText.text = m.dose.ToString();


        return(p);
    }
Beispiel #9
0
        public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            var go    = animator.gameObject;
            int count = Parameters.ParameterList.Count;

            for (int i = 0; i < count; i++)
            {
                var elem = Parameters.ParameterList[i];
                elem.StartVolume = InAudio._getEventWorker().GetMinVolume(go, elem.Node);
                //Debug.Log("Enter " + name + " " + elem.StartVolume);
            }
            canSetVolume = true;
            Debug.Log("Enter " + Name);

            InAudio.PostEvent(go, OnEnterState.ToPost);

            int toPlayCount = OnEnterState.ToPlay.Count;
            var toPlay      = OnEnterState.ToPlay;

            for (int i = 0; i < toPlayCount; i++)
            {
                //Debug.Log("Play" + toPlay[i].Name);
                InAudio.Play(go, toPlay[i]);
            }

            int toStopCount = OnEnterState.ToStop.Count;
            var toStop      = OnEnterState.ToStop;

            for (int i = 0; i < toStopCount; i++)
            {
                InAudio.Stop(go, toStop[i]);
            }
        }
Beispiel #10
0
        public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            Debug.Log("Exit " + Name);
            canSetVolume = false;
            var go = animator.gameObject;

            InAudio.PostEvent(go, OnExitState.ToPost);

            int toPlayCount = OnExitState.ToPlay.Count;
            var toPlay      = OnExitState.ToPlay;

            for (int i = 0; i < toPlayCount; i++)
            {
                InAudio.Play(go, toPlay[i]);
            }

            int toStopCount = OnExitState.ToStop.Count;
            var toStop      = OnExitState.ToStop;

            for (int i = 0; i < toStopCount; i++)
            {
                InAudio.Stop(go, toStop[i]);
            }

            //Set Values to Max
        }
Beispiel #11
0
 void OnEnable()
 {
     if (onEnable != null)
     {
         InAudio.PostEvent(gameObject, onEnable);
     }
 }
 void OnDisable()
 {
     InAudio.PostEvent(gameObject, onDisable);
     if (onDisableMusic != null)
     {
         HandleMusic(onDisableMusic, "OnDisable");
     }
 }
 void OnDestroy()
 {
     InAudio.PostEvent(gameObject, onDestroy);
     if (onDestroyMusic != null)
     {
         HandleMusic(onDestroyMusic, "OnDestroy");
     }
 }
Beispiel #14
0
 public void Complain()
 {
     if (complainTimer > 2f)
     {
         InAudio.Play(Camera.main.gameObject, complaints);
         complainTimer = 0f;
     }
 }
 void Start()
 {
     InAudio.PostEvent(gameObject, onStart);
     if (onEnableMusic != null)
     {
         HandleMusic(onStartMusic, "OnStart");
     }
 }
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (CollisionList.CollisionReaction)
     {
         if (IsInLayerMask(collision.gameObject, CollisionList.Layers))
         {
             InAudio.PostEvent(gameObject, CollisionList.EventsEnter);
         }
     }
 }
Beispiel #17
0
    IEnumerator PlayWin()
    {
        gameOver = true;
        Services.Get <MusicPlayer>().GetComponent <AudioSource>().Stop();
        InAudio.PostEvent(gameObject, Winning);
        yield return(new WaitForSeconds(4));

        Application.LoadLevel(Application.loadedLevel == 2 ? 3 : 2);
        gameOver = false;
    }
 void OnTriggerExit(Collider collider)
 {
     if (CollisionList.TriggerReaction)
     {
         if (IsInLayerMask(collider.gameObject, CollisionList.Layers))
         {
             InAudio.PostEvent(gameObject, CollisionList.EventsExit);
         }
     }
 }
Beispiel #19
0
 public void OnPointerExit(PointerEventData eventData)
 {
     if (enabled)
     {
         if (stopNodeOnExit)
         {
             InAudio.Stop(gameObject, playNodeWhileMouseOver);
         }
     }
 }
 void OnCollisionExit(Collision collision)
 {
     if (CollisionList.CollisionReaction)
     {
         if (IsInLayerMask(collision.gameObject, CollisionList.Layers))
         {
             InAudio.PostEvent(gameObject, CollisionList.EventsExit);
         }
     }
 }
 private static void LoadOrUnload(BankHookAction action)
 {
     if (action.BankAction == BankHookActionType.Load)
     {
         InAudio.LoadBank(action.Bank);
     }
     else if (action.BankAction == BankHookActionType.Unload)
     {
         InAudio.UnloadBank(action.Bank);
     }
 }
Beispiel #22
0
    void OnTriggerEnter(Collider other)
    {
        var player = other.GetComponent <PlayerController>();

        if (player != null)
        {
            InAudio.PlayAtPosition(gameObject, deathSound, other.transform.position);
            Object.Destroy(other.gameObject);
            GameManager.Instance.Respawn(player);
        }
    }
Beispiel #23
0
 void Update()
 {
     if (GameInput.AllowInput)
     {
         if (isGrounded && Input.GetButtonDown("A_" + playerPostFix))
         {
             isGrounded = false;
             InAudio.Play(gameObject, jumpSound);
             rigidbody.AddForce(surfaceUp * Jump, ForceMode.Impulse);
         }
     }
 }
Beispiel #24
0
    public void WheelBedIn(Bed b)
    {
        InAudio.Play(this.gameObject, SoundController.Instance.wheelSound);

        GameObject go = bedToGameObjectMap [b];

        float time = 0.5f + (b.berth.column * 0.35f);

        go.transform.DOMove(new Vector3(b.berth.berthPosition.x - 2.5f, go.transform.position.y, 0f), time)
        .SetEase(Ease.Linear)
        .OnComplete(() => WheelToBerth(b, go));
    }
Beispiel #25
0
    void FirstClick()
    {
        Bed b = BedController.Instance.gameObjectToBedMap [bedNurseNextTo];

        if (b.treatmentDelay <= 0f)
        {
            InAudio.Play(this.gameObject, SoundController.Instance.bop1);
            isAdministeringTreatment = true;
            fillSpeed = UnityEngine.Random.Range(1.15f * NurseStressFactor, 1.85f * NurseStressFactor);
            clicks    = 1;
            //	Debug.Log ("Start Bar");
        }
    }
Beispiel #26
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (enabled)
     {
         if (ActivateOnMouseOver != null)
         {
             InAudio.PostEvent(gameObject, ActivateOnMouseOver);
         }
         if (playNodeWhileMouseOver != null)
         {
             InAudio.Play(gameObject, playNodeWhileMouseOver);
         }
     }
 }
 public void OnPointerClick(PointerEventData eventData)
 {
     if (enabled)
     {
         if (onClick != null)
         {
             InAudio.PostEvent(gameObject, onClick);
         }
         if (onClickSound != null)
         {
             InAudio.PlayPersistent(gameObject.transform.position, onClickSound);
         }
     }
 }
Beispiel #28
0
    void SecondClick()
    {
        InAudio.Play(this.gameObject, SoundController.Instance.bop2);
        percentageAdministered = pgaBarLeft.sizeDelta.x / 297f;
        Debug.Log("First Click" + percentageAdministered + pgaBarLeft.sizeDelta.x);
        clicks = 2;

        pgaClickMark.gameObject.SetActive(true);
        pgaClickMark.anchoredPosition = new Vector2(250.9f - pgaBarLeft.sizeDelta.x, -12f);

        if (medHeld == "Defib")
        {
            InAudio.Play(this.gameObject, SoundController.Instance.clear);
        }
    }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var inAudio = target as InAudio;

            if (inAudio.GetComponentInChildren <InAudioInstanceFinder>() == null ||
                inAudio.GetComponentInChildren <MusicPlayer>() == null ||
                inAudio.GetComponentInChildren <InCommonDataManager>() == null)
            {
                //Checks three of the needed objects if this is indeed a valid prefab
                //If you read this code, use the "InAudio Manager" prefab stored under InAudio/Prefabs/InAudio Manager
                EditorGUILayout.HelpBox("You are not using the InAudio Manager prefab.\nPlease use the InAudio prefab placed in \nInAudio/Prefabs/InAudio Manager\ninstead of placing the InAudio script on a random game object.", MessageType.Error);
            }

            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Support");
            EditorGUILayout.SelectableLabel("*****@*****.**");
            EditorGUILayout.EndHorizontal();


            GUI.enabled = Application.isPlaying;
            if (GUILayout.Button("Stop All Sound Effects"))
            {
                InAudio.StopAll();
            }
            if (GUILayout.Button("Stop All Music"))
            {
                InAudio.Music.StopAll();
            }
            GUI.enabled = true;
            EditorGUILayout.Separator();

            if (GUILayout.Button("Documentation"))
            {
                Application.OpenURL("http://innersystems.net/wiki");
            }
            if (GUILayout.Button("Forum"))
            {
                Application.OpenURL("http://forum.unity3d.com/threads/232490-InAudio-Advanced-Audio-for-Unity");
            }
            if (GUILayout.Button("Website"))
            {
                Application.OpenURL("http://innersystems.net/");
            }
        }
    Patient CheckWhetherCausedBloodLoss(Patient p, Medication m, float injectionQuality)
    {
        if (injectionQuality < 0.5f && m.name != "Blood" && m.name != "Defib")
        {
            InAudio.Play(this.gameObject, SoundController.Instance.ouch);

            float chanceOfLoss = Mathf.Pow(10f - (injectionQuality * 10f), 4f);
            float choose       = Random.Range(0f, 25000f);

            if (choose < chanceOfLoss)
            {
                p = TriggerBloodLoss(p);
            }
        }

        return(p);
    }
Beispiel #31
0
    void OnEnable()
    {
        if (instance == null || instance == this)
        {
            if (activeAudioListener == null)
                activeAudioListener = FindActiveListener();

            instance = this;

            InitializeInAudio();
        }
        else
        {
            Object.Destroy(transform.gameObject);
        }
    }