public void OnEndInteraction() { Debug.Log("Dropping a hat, checking to see if there's a nearby HatHanger"); var overlappingItems = Physics.OverlapSphere(transform.position, 0.05f, -1, QueryTriggerInteraction.Collide); for (int i = 0; i < overlappingItems.Length; i++) { Transform item = overlappingItems[i].transform; if (item.gameObject.tag == "HatHanger") { // Do we need to reload the current level after attaching the hat? bool reloadLevelAfterAttach = LevelManager.Instance.currentlyLoadedSaveFile != this.saveFileId; if (LevelManager.Instance.WearHat(this)) { Debug.Log("Attaching hat to a hat hanger", item.gameObject); transform.SetParent(item); transform.GetComponent <Rigidbody>().isKinematic = true; if (reloadLevelAfterAttach) { ApplyUserSettings(SaveHatShelf.GetSaveFile(saveFileId)); LevelManager.Instance.ChangeScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, false, 0.5f); } return; } else { Debug.Log("Already wearing a hat"); } } Debug.Log("Dropping a hat"); transform.SetParent(null); transform.GetComponent <Rigidbody>().isKinematic = false; LevelManager.Instance.RemoveHat(this); } }
public void OnLevelWasLoaded() { // Since the flair buttons are stuck to a hat with a joint rather than children of its transform, // they get destroyed between level loads. They aren't children because this causes problems with // moving them around with your controllers. SaveHatShelf.BuildFlair(this); }
public void OnStickyDetached(Transform stickyParent) { HatFlair flair = stickyParent.GetComponent <HatFlair>(); if (!flair) { Debug.LogError("Sticky item was detached, but it's not a HatFlair instance", stickyParent); return; } SaveHatShelf.RemoveToothpickFlair(flair); }
public void OnStickyAttached(Transform stickyParent) { HatFlair flair = stickyParent.GetComponent <HatFlair>(); if (!flair) { Debug.LogError("Sticky item was attached, but it's not a HatFlair instance", stickyParent); return; } SaveHatShelf.AddFlair(this, flair); }
public void OnStickyAttached(Transform stickyParent) { HatFlair flair = stickyParent.GetComponent <HatFlair>(); if (!flair) { Debug.LogError("Sticky item was attached, but it's not a HatFlair instance", stickyParent); return; } Debug.Log("Attaching flair to jar", flair); SaveHatShelf.AddToothpickFlair(gameObject, flair); }
public void CountCoins() { Coin[] coins = FindObjectsOfType <Coin>(); Debug.Log("Found coin count: " + coinCount); coinCount = 0; foreach (Coin coin in coins) { coinCount += coin.coinValue; } if (currentlyLoadedSaveFile > 0) { SaveHatShelf.GetSaveFile(currentlyLoadedSaveFile).coins = coinCount; SaveHatShelf.Save(); } }
public SaveHatListEntry GetCurrentlyLoadedSaveFile() { return(SaveHatShelf.GetSaveFile(currentlyLoadedSaveFile)); }