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)); }
IEnumerator GrowImageAndStopRotating(float duration) { float timeElapsed = 0; float startScale = artDisplay.transform.localScale.x; while (timeElapsed < duration) { timeElapsed += Time.deltaTime; float scale = Mathf.Lerp(startScale, ShellPuzzleController.Instance.maxSize, timeElapsed / duration); artDisplay.transform.localScale = new Vector3(scale, scale, scale); yield return(new WaitForEndOfFrame()); } artDisplay.StopRotating(); ShellPuzzleController.Instance.OnSuccess(); }