コード例 #1
0
    private void OnTrueEnter(Interactable enteringInteractable)
    {
        Needle needle = enteringInteractable as Needle;

        if (needle == null || !needle.Connector.HasAttachedObject)
        {
            return;
        }

        Syringe syringe = needle.Connector.AttachedInteractable as Syringe;

        if (syringe == null)
        {
            return;
        }

        if (generalItem.ObjectType == ObjectType.Bottle)
        {
            syringe.State.On(InteractState.InBottle);
            syringe.hasBeenInBottle = true;

            if (!generalItem.IsClean)
            {
                needle.Contamination = GeneralItem.ContaminateState.Contaminated;
            }

            if ((G.Instance.Scene as MedicinePreparationScene).NeedleUsed)
            {
                TaskBase.CreateGeneralMistake("Lääkettä yritettiin ottaa uudestaan");
            }

            Events.FireEvent(EventType.SyringeWithNeedleEntersBottle, CallbackData.Object(syringe));
        }

        syringe.BottleContainer = this;
    }
コード例 #2
0
 protected override void AttachEvents(GameObject intObject)
 {
     G.Instance.Audio.Play(AudioClipType.LockedItem);
     Events.FireEvent(EventType.AttachLuerlock, CallbackData.Object(intObject));
     Events.FireEvent(EventType.SyringeToLuerlock, CallbackData.Object(intObject));
 }
コード例 #3
0
    private IEnumerator PlayCoroutine(AutoPlayStrength autoPlay)
    {
        yield return(null);

        yield return(null);

        yield return(null);

        // Create objects

        GameObject g_syringeCapBag = Instantiate(p_syringeCapBag, SpawnPos, Quaternion.Euler(Vector3.zero));
        GameObject g_luerlock      = Instantiate(p_luerlock, SpawnPos, Quaternion.Euler(Vector3.zero));
        GameObject g_needle        = Instantiate(p_needle, SpawnPos, Quaternion.Euler(Vector3.zero));
        GameObject g_bigSyringe    = Instantiate(p_bigSyringe, SpawnPos, Quaternion.Euler(Vector3.zero));
        GameObject g_bottle        = Instantiate(p_bottle, SpawnPos, Quaternion.Euler(Vector3.zero));

        GameObject[] g_smallSyringes = new GameObject[6];

        Transform[] all = new Transform[11];
        all[0] = g_syringeCapBag.transform;
        all[1] = g_luerlock.transform;
        all[2] = g_needle.transform;
        all[3] = g_bigSyringe.transform;
        all[4] = g_bottle.transform;


        for (int i = 0; i < 6; i++)
        {
            g_smallSyringes[i] = Instantiate(p_smallSyringe, SpawnPos, Quaternion.Euler(Vector3.zero));
            all[5 + i]         = g_smallSyringes[i].transform;
        }

        IgnoreCollisions(all, true);

        yield return(null);

        yield return(null);

        yield return(null);

        Interactable    capBag     = ToIntr(g_syringeCapBag);
        LuerlockAdapter luerlock   = ToIntr(g_luerlock) as LuerlockAdapter;
        Needle          needle     = ToIntr(g_needle) as Needle;
        Syringe         bigSyringe = ToIntr(g_bigSyringe) as Syringe;
        MedicineBottle  bottle     = ToIntr(g_bottle) as MedicineBottle;

        Syringe[] smallSyringes = new Syringe[6];


        for (int i = 0; i < 6; i++)
        {
            smallSyringes[i] = ToIntr(g_smallSyringes[i]) as Syringe;
            NullCheck.Check(smallSyringes[i]);
        }

        NullCheck.Check(capBag, luerlock, needle, bigSyringe, bottle);
        // Select tools task

        Hand hand = VRInput.Hands[0].Hand;

        yield return(null);

        hand.InteractWith(capBag);
        yield return(null);

        hand.Uninteract();
        yield return(null);

        hand.InteractWith(luerlock);
        yield return(null);

        hand.Uninteract();
        yield return(null);

        hand.InteractWith(needle);
        yield return(null);

        hand.Uninteract();
        yield return(null);

        hand.InteractWith(bigSyringe);
        yield return(null);

        hand.Uninteract();
        yield return(null);

        hand.InteractWith(smallSyringes[0]);
        yield return(null);

        hand.Uninteract();
        yield return(null);

        // Select bottle task
        hand.InteractWith(bottle);
        yield return(null);

        hand.Uninteract();
        yield return(null);

        // Correct items in throughput task

        yield return(null);

        capBag.transform.position = correctPositions.GetChild(0).position;
        capBag.transform.up       = correctPositions.right;
        capBag.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        luerlock.transform.position = correctPositions.GetChild(1).position;
        luerlock.transform.up       = correctPositions.right;
        luerlock.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        needle.transform.position = correctPositions.GetChild(2).position;
        needle.transform.up       = correctPositions.right;
        needle.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        bigSyringe.transform.position = correctPositions.GetChild(3).position;
        bigSyringe.transform.up       = correctPositions.right;
        bigSyringe.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        bottle.transform.position = correctPositions.GetChild(4).position;
        bottle.transform.up       = correctPositions.right;
        bottle.Rigidbody.velocity = Vector3.zero;

        for (int i = 0; i < 6; i++)
        {
            smallSyringes[i].transform.position = correctPositions.GetChild(5 + i).position;
            smallSyringes[i].transform.up       = correctPositions.right;
            smallSyringes[i].Rigidbody.velocity = Vector3.zero;
            yield return(null);
        }

        if (autoPlay == AutoPlayStrength.ItemsToPassThrough)
        {
            IgnoreCollisions(all, false);
            yield break;
        }

        yield return(Wait);

        hand.InteractWith(teleportDoorKnob);


        yield return(null);

        IgnoreCollisions(all, false);
        yield return(null);

        IsAutoPlaying = false;

        if (autoPlay == AutoPlayStrength.WorkspaceRoom)
        {
            yield break;
        }

        yield return(new WaitForSeconds(1));

        capBag.transform.position = correctPositionLaminarCabinet.GetChild(0).position;
        capBag.transform.up       = correctPositions.right;
        capBag.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        luerlock.transform.position = correctPositionLaminarCabinet.GetChild(1).position;
        luerlock.transform.up       = correctPositions.right;
        luerlock.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        needle.transform.position = correctPositionLaminarCabinet.GetChild(2).position;
        needle.transform.up       = correctPositions.right;
        needle.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        bigSyringe.transform.position = correctPositionLaminarCabinet.GetChild(3).position;
        bigSyringe.transform.up       = correctPositions.right;
        bigSyringe.Rigidbody.velocity = Vector3.zero;
        yield return(null);

        bottle.transform.position = correctPositionLaminarCabinet.GetChild(4).position;
        bottle.transform.up       = correctPositions.right;
        bottle.Rigidbody.velocity = Vector3.zero;

        for (int i = 0; i < 6; i++)
        {
            smallSyringes[i].transform.position = correctPositionLaminarCabinet.GetChild(5 + i).position;
            smallSyringes[i].transform.up       = correctPositions.right;
            smallSyringes[i].Rigidbody.velocity = Vector3.zero;
            yield return(null);
        }

        if (autoPlay == AutoPlayStrength.ItemsToLaminarCabinet)
        {
            yield break;
        }

        yield return(Wait);

        hand.InteractWith(laminarCabinetCheckButton);

        if (autoPlay == AutoPlayStrength.CheckCabinetItems)
        {
            yield break;
        }

        yield return(Wait);

        GameObject g_sterileCloth = Instantiate(p_sterileCloth);

        g_sterileCloth.transform.position = new Vector3(100, 100, 100);
        g_sterileCloth.name = "STERILE CLOTH AUTOPLAY";
        yield return(null);

        Interactable sterileCloth = Interactable.GetInteractable(g_sterileCloth.transform);

        sterileCloth.transform.position = bottle.transform.position;

        yield return(Wait);

        sterileCloth.transform.position = regularTrash.transform.position;
        yield return(null);

        yield return(null);


        if (autoPlay == AutoPlayStrength.DisinfectBottle)
        {
            yield break;
        }

        needle.Connector.ConnectItem(bigSyringe);
        yield return(null);

        yield return(null);

        needle.transform.position = bottle.transform.position;
        bottle.Container.TransferTo(bigSyringe.Container, 900);
        yield return(null);

        yield return(null);

        needle.transform.position = bottle.transform.position + new Vector3(0, 0.25f, 0);

        yield return(null);

        yield return(null);

        needle.Connector.Connection.Remove();
        bigSyringe.transform.position = needle.transform.position + new Vector3(0.05f, 0, 0);

        yield return(null);

        yield return(null);

        if (autoPlay == AutoPlayStrength.TakeMedicine)
        {
            yield break;
        }

        luerlock.LeftConnector.ConnectItem(bigSyringe);
        Events.FireEvent(EventType.AttachLuerlock, CallbackData.Object(bigSyringe.gameObject));
        Events.FireEvent(EventType.SyringeToLuerlock, CallbackData.Object(bigSyringe.gameObject));

        yield return(null);

        yield return(null);

        if (autoPlay == AutoPlayStrength.BigSyringeToLuerlock)
        {
            yield break;
        }

        foreach (Syringe smallSyringe in smallSyringes)
        {
            luerlock.RightConnector.ConnectItem(smallSyringe);
            Events.FireEvent(EventType.AttachLuerlock, CallbackData.Object(smallSyringe.gameObject));
            Events.FireEvent(EventType.SyringeToLuerlock, CallbackData.Object(smallSyringe.gameObject));
            yield return(null);

            yield return(null);

            bigSyringe.Container.TransferTo(smallSyringe.Container, 150);

            yield return(null);

            yield return(null);

            luerlock.RightConnector.Connection.Remove();
            smallSyringe.transform.position = luerlock.transform.position + new Vector3(0.05f, 0, 0);
            yield return(null);

            yield return(null);
        }

        luerlock.LeftConnector.Connection.Remove();
        bigSyringe.transform.position = luerlock.transform.position + new Vector3(-0.05f, 0, 0);
        yield return(null);

        yield return(null);

        if (autoPlay == AutoPlayStrength.MedicineToSmallSyringes)
        {
            yield break;
        }

        foreach (Syringe smallSyringe in smallSyringes)
        {
            SyringeCap.AddSyringeCap(smallSyringe);
        }

        yield return(null);

        yield return(null);

        if (autoPlay == AutoPlayStrength.AddSyringeCaps)
        {
            yield break;
        }

        foreach (Syringe smallSyringe in smallSyringes)
        {
            smallSyringe.transform.position = sterileBag.transform.position;
            yield return(null);

            yield return(null);
        }

        if (autoPlay == AutoPlayStrength.SyringesToSterileBag)
        {
            yield break;
        }

        sterileBag.CloseSterileBagFinal();

        yield return(null);

        yield return(null);

        if (autoPlay == AutoPlayStrength.CloseSterileBag)
        {
            yield break;
        }

        needle.transform.position = sharpTrash.transform.position;
        yield return(null);

        yield return(null);

        luerlock.transform.position = regularTrash.transform.position;
        yield return(null);

        yield return(null);

        bigSyringe.transform.position = regularTrash.transform.position;
        yield return(null);

        yield return(null);

        if (autoPlay == AutoPlayStrength.Cleanup)
        {
            yield break;
        }
    }