/// <summary> /// Triggered when a character enters our path element /// </summary> /// <param name="collider">Collider.</param> public virtual void OnTriggerStay2D(Collider2D collider) { LevelMapCharacter mapCharacter = collider.GetComponent <LevelMapCharacter>(); if (mapCharacter == null) { return; } // we tell our character it's now colliding with a path element mapCharacter.CollidingWithAPathElement = true; mapCharacter.SetCurrentPathElement(this); // if our path element is on automatic, we'll direct our character to its next target if (AutomaticMovement) { if (mapCharacter.LastVisitedPathElement != Up && Up != null) { mapCharacter.SetDestination(Up); } if (mapCharacter.LastVisitedPathElement != Right && Right != null) { mapCharacter.SetDestination(Right); } if (mapCharacter.LastVisitedPathElement != Down && Down != null) { mapCharacter.SetDestination(Down); } if (mapCharacter.LastVisitedPathElement != Left && Left != null) { mapCharacter.SetDestination(Left); } } }
/// <summary> /// Triggered when a character exits our path element /// </summary> /// <param name="collider">Collider.</param> public virtual void OnTriggerExit2D(Collider2D collider) { LevelMapCharacter mapCharacter = collider.GetComponent <LevelMapCharacter>(); if (mapCharacter == null) { return; } GUIManager.Instance.GetComponent <LevelSelectorGUI>().TurnOffLevelName(); // we tell our character it's now not colliding with any path element mapCharacter.CollidingWithAPathElement = false; mapCharacter.SetCurrentPathElement(null); mapCharacter.LastVisitedPathElement = this; }
/// <summary> /// Triggered when a character enters our path element /// </summary> /// <param name="collider">Collider.</param> public virtual void OnTriggerEnter2D(Collider2D collider) { LevelMapCharacter mapCharacter = collider.GetComponent <LevelMapCharacter>(); if (mapCharacter == null) { return; } if (GetComponent <LevelSelector>() != null) { if (GUIManager.Instance.GetComponent <LevelSelectorGUI>() != null) { GUIManager.Instance.GetComponent <LevelSelectorGUI>().SetLevelName(GetComponent <LevelSelector>().LevelName.ToUpper()); } } }