public void BeginGame() { GameBegun = true; Vector3 origin = Vector3.forward; #if !UNITY_EDITOR origin = GameObject.FindWithTag("SkeletonOriginMarker").transform.position; #endif skeletonScatter.transform.position = origin; skeletonScatter.gameObject.SetActive(true); StartCoroutine(GenericCoroutines.DoAfterSeconds(() => { skeletonScatter.ScatterSkeleton(); skeletonManager.gameObject.SetActive(true); skeletonManager.transform.position = origin; }, 2)); Instantiate(welbyOriginPrefab).transform.position = origin; ARPlaneManager arpm = FindObjectOfType <ARPlaneManager>(); arpm.SetTrackablesActive(false); arpm.enabled = false; ARPointCloudManager arpcm = FindObjectOfType <ARPointCloudManager>(); arpcm.SetTrackablesActive(false); arpcm.enabled = false; PlaceOnPlane placeOnPlane = FindObjectOfType <PlaceOnPlane>(); placeOnPlane.enabled = false; placeOnPlane.placedPrefab.SetActive(false); }
private void ExplodeShip() { button.interactable = false; exploded = true; float heightPerDeck = blockPrefabRenderer.bounds.size.y * 2.5f * ship.transform.localScale.y; float distance = Mathf.Max(heightPerDeck * (ship.gridRoot.childCount / 2f + 2), ship.hullRoot.gameObject.MakeBoundingBoxForObjectRenderers().size.GreatestDimension() * .8f); foreach (Renderer piece in renderersAndStartPositions.Keys) { Vector3 helperOffset = Vector3.zero; if (piece.bounds.center == ship.hullRoot.position) { helperOffset = Vector3.down * Mathf.Epsilon; } StartCoroutine(GenericCoroutines.MoveAwayFrom(piece.transform, piece.bounds.center, ship.hullRoot.position + helperOffset, distance, 2)); } //Top and bottom decks should be 90% of the way to the nearest hull bits foreach (Deck deck in decksAndStartPositions.Keys) { if (Math.Abs(deck.transform.localPosition.y) > .0001f) { Vector3 awayFrom; if (deck.DecksFromCenter > 0) { awayFrom = deck.transform.position + Vector3.down * ship.transform.localScale.y; } else { awayFrom = deck.transform.position + Vector3.up * ship.transform.localScale.y; } StartCoroutine(GenericCoroutines.MoveAwayFrom(deck.transform, deck.transform.position, awayFrom, heightPerDeck * Mathf.Abs(deck.DecksFromCenter), 2)); } } //Change ui StartCoroutine(GenericCoroutines.DoAfterSeconds(() => { buttonText.text = "Unexplode Ship"; button.interactable = true; }, 2)); }
public void DisplayPart() { Debug.Log("Placing bone " + PlayerInventory.Instance.PartCurrentlyHeld); switch (PlayerInventory.Instance.PartCurrentlyHeld) { case PlayerInventory.PartHeldEnum.Part1: dinoParts[0].gameObject.SetActive(true); break; case PlayerInventory.PartHeldEnum.Part2: dinoParts[1].gameObject.SetActive(true); break; case PlayerInventory.PartHeldEnum.Part3: dinoParts[2].gameObject.SetActive(true); break; case PlayerInventory.PartHeldEnum.Part4: dinoParts[3].gameObject.SetActive(true); break; case PlayerInventory.PartHeldEnum.Empty: Debug.Log("No Bone To Place"); break; default: Debug.Log("Invalid"); break; } //if succeed ShellPuzzleController.Instance.OnSuccess = () => { ArtDisplay artDisplay = ShellPuzzleController.Instance.puzzle.artDisplay; artDisplay.gameObject.SetActive(false); ArtDisplay displayToShow = artDisplays[(int)PlayerInventory.Instance.PartCurrentlyHeld]; displayToShow.image.sprite = artDisplay.image.sprite; displayToShow.gameObject.SetActive(true); displayToShow.StopRotating(); gameObject.SetActive(true); PlayerInventory.Instance.PartCurrentlyHeld = PlayerInventory.PartHeldEnum.Empty; //todo Place new bone here }; StartCoroutine(GenericCoroutines.DoAfterSeconds(ShowPuzzle, 3)); }
private void UnExplodeShip() { button.interactable = false; exploded = false; foreach (KeyValuePair <Renderer, Vector3> piece in renderersAndStartPositions) { StartCoroutine(GenericCoroutines.MoveAndRotateOverSeconds(piece.Key.gameObject, piece.Value, piece.Key.transform.rotation, 2)); } foreach (KeyValuePair <Deck, Vector3> deck in decksAndStartPositions) { StartCoroutine(GenericCoroutines.MoveAndRotateOverSeconds(deck.Key.gameObject, deck.Value, deck.Key.transform.rotation, 2)); } //Change ui StartCoroutine(GenericCoroutines.DoAfterSeconds(() => { buttonText.text = "Explode Ship"; button.interactable = true; }, 2)); }
public void PopLayer(ShellLayer layer) { layer.target.gameObject.SetActive(false); layer.myEffect.gameObject.SetActive(false); float force = 1; layer.leftHalf.AddComponent <Rigidbody>().AddForce(force * Vector3.up, ForceMode.Impulse); layer.rightHalf.AddComponent <Rigidbody>().AddForce(force * Vector3.up, ForceMode.Impulse); StartCoroutine(GenericCoroutines.DoAfterSeconds(() => layer.gameObject.SetActive(false), 2)); if (shellLayersOrdered.IndexOf(layer) == 0) { Debug.Log("Show Prize!"); artDisplay.gameObject.SetActive(true); StartCoroutine(GrowImageAndStopRotating(2.5f)); } else { Debug.Log("Popping a layer"); shellLayersOrdered[shellLayersOrdered.IndexOf(layer) - 1].gameObject.SetActive(true); } }
public void Start() { rotating = true; StartCoroutine(GenericCoroutines.DoWhile(() => transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime), () => rotating)); }