63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using NaughtyAttributes;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class Portal : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[SerializeField] private List<GameInstanceType> types = new List<GameInstanceType>()
|
|||
|
|
{
|
|||
|
|
GameInstanceType.Base,
|
|||
|
|
GameInstanceType.Duo,
|
|||
|
|
GameInstanceType.Squad,
|
|||
|
|
GameInstanceType.Zombie
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
private bool _active = false;
|
|||
|
|
|
|||
|
|
[SerializeField] private GameObject to;
|
|||
|
|
[SerializeField] public GameObject instance;
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
UIManager.Instance.OnGameInstancePress += OnGameInstancePress;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnGameInstancePress()
|
|||
|
|
{
|
|||
|
|
if (types.Contains(UIManager.Instance.GameInstanceType))
|
|||
|
|
{
|
|||
|
|
instance.SetActive(true);
|
|||
|
|
_active = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
instance.SetActive(false);
|
|||
|
|
_active = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnTriggerEnter(Collider other)
|
|||
|
|
{
|
|||
|
|
if (!_active) return;
|
|||
|
|
if (other.gameObject.CompareTag("Player"))
|
|||
|
|
{
|
|||
|
|
var player = other.gameObject.GetComponent<Player>();
|
|||
|
|
var next = to.transform.position;
|
|||
|
|
player.transform.position = next;
|
|||
|
|
player.PlayerEntity.SetLastPositionAfterTeleportation(next);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Button("TP")]
|
|||
|
|
public void TP()
|
|||
|
|
{
|
|||
|
|
var player = Player.Instance;
|
|||
|
|
var next = to.transform.position;
|
|||
|
|
player.transform.position = next;
|
|||
|
|
player.PlayerEntity.SetLastPositionAfterTeleportation(next);
|
|||
|
|
}
|
|||
|
|
}
|