// Delegated method from the player that resets each instance of the bottle // This may seem unorthodox but this was a "fix" to an issue where // bottles would not properly reset upon reloading a level private void LevelResetted(Maya maya) { maya.reset -= LevelResetted; isActive = true; mySprite.enabled = true; myCol.enabled = true; }
// Use this for initialization void Start() { anim = gameObject.GetComponent <Animator>(); nav = gameObject.GetComponent <NavMeshAgent>(); stats = gameObject.GetComponent <Stats>(); destination = transform.position; maya = GameObject.Find("Maya").GetComponent <Maya>(); move = false; attack = false; distToMaya = 100; }
void Start() { // Gets the components to later use them in the reset method myCol = GetComponent<BoxCollider2D>(); mySprite = GetComponent<SpriteRenderer>(); isActive = true; restoration = 100.0f; // Stores a reference to the player for the delegate method maya = (Maya)FindObjectOfType(typeof(Maya)); maya.reset += LevelResetted; }
void Awake() { if (maya == null) { maya = this; } }