Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LocationPortal : MonoBehaviour, IPlayerTriggerable
- {
- // Teleports player without switching scenes
- [SerializeField] DesID destinationPortal;
- [SerializeField] Transform spawnPoint;
- PlayerController player;
- BuddyController buddy;
- [SerializeField] Fader fader;
- private void Start()
- {
- fader = FindObjectOfType<Fader>();
- player = FindObjectOfType<PlayerController>();
- buddy = FindObjectOfType<BuddyController>();
- }
- public void OnPlayerTriggered(PlayerController player)
- {
- player.Charecter.Animator.IsMoving = false;
- this.player = player;
- StartCoroutine(Teleport());
- }
- IEnumerator Teleport()
- {
- // GameController.Instance.PauseGame(true);
- yield return fader.FadeIn(0.5f);
- var portal = FindObjectsOfType<LocationPortal>().First(x => x != this && x.destinationPortal == this.destinationPortal);
- player.Charecter.SetPositionAndSnapToTile(portal.spawnPoint.position);
- //StopBuddy();
- yield return fader.FadeOut(0.5f);
- // GameController.Instance.PauseGame(false);
- }
- public void StopBuddy()
- {
- buddy.Charecter.Animator.IsMoving = false;
- StartCoroutine(Teleport());
- }
- public void OnCompanionTriggered(CompanionController companion)
- {
- companion.Charecter.Animator.IsMoving = false;
- StartCoroutine(Teleport());
- }
- public Transform SpawnPoint => spawnPoint;
- public bool triggerRepeatedly => false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement