WXMC/proj/unity/Assets/SystemPageExit.cs
2024-12-04 16:18:46 +08:00

31 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class SystemPageExit : MonoBehaviour
{
private Collider2D exitCollider;
public SystemPage neighborPage;
public SystemPage hostPage;
private SystemPageCamera systemPageCamera;
private void Start()
{
hostPage.systemPageExits.Append(this);
exitCollider = GetComponent<Collider2D>();
}
private void OnTriggerEnter2D(Collider2D collision)
{
collision.gameObject.TryGetComponent(out systemPageCamera);
if (systemPageCamera != null && systemPageCamera.currPage == hostPage)
{
Debug.Log(string.Format("Camera moving from {0} to {2}, the exit is {3}, hostPage: {1}, neighborPage:{2}.", systemPageCamera.currPage, hostPage, neighborPage, name));
systemPageCamera.targetPos = neighborPage.cameraTarget.position + new Vector3(0, 0, -10);
systemPageCamera.currPage = neighborPage;
systemPageCamera.isChangingPage = true;
}
}
}