/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here recHospital = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); recAmbulance = new Rectangle(125, 160, 45, 30); recHealth = new Rectangle(GraphicsDevice.Viewport.Width - 245, GraphicsDevice.Viewport.Height - 300, 5, 7); //health bar rectangle bottles[0] = new MedicineBottle(new Rectangle(123, 87, 22, 23), false, Content.Load <Texture2D>("Medicine Bottle")); bottles[1] = new MedicineBottle(new Rectangle(321, 174, 19, 18), false, Content.Load <Texture2D>("Medicine Bottle")); base.Initialize(); }
private void CheckConditions(List <Interactable> containedObjects) { foreach (Interactable value in containedObjects) { GeneralItem item = value as GeneralItem; ObjectType type = item.ObjectType; switch (type) { case ObjectType.Syringe: Syringe syringe = item as Syringe; if (syringe.Container.Capacity == 20000) { EnableCondition(Conditions.BigSyringe); } else if (syringe.Container.Capacity == 1000) { smallSyringes++; if (smallSyringes == 6) { EnableCondition(Conditions.SmallSyringes); } } break; case ObjectType.Needle: EnableCondition(Conditions.Needle); break; case ObjectType.Luerlock: EnableCondition(Conditions.Luerlock); break; case ObjectType.SyringeCapBag: EnableCondition(Conditions.SyringeCapBag); break; case ObjectType.Bottle: MedicineBottle bottle = item as MedicineBottle; if (bottle.Container.Capacity == 4000 || bottle.Container.Capacity == 16000) { EnableCondition(Conditions.RightBottle); } if (bottle.Container.Capacity == 4000) { correctMedicineBottle = true; } break; } } }
protected override void OnCollisionEnter(Collision other) { base.OnCollisionEnter(other); GameObject foundObject = GetInteractableObject(other.transform); GeneralItem item = foundObject?.GetComponent <GeneralItem>(); if (item == null) { return; } if (item.ObjectType == ObjectType.Bottle && this.IsClean) { MedicineBottle bottle = item as MedicineBottle; if (!bottle.IsClean) { bottle.Contamination = ContaminateState.Clean; UISystem.Instance.CreatePopup("Lääkepullon korkki puhdistettu.", MsgType.Done); Events.FireEvent(EventType.BottleDisinfect, CallbackData.Object(bottle)); } } }
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; } }