92 lines
2.6 KiB
C#
92 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using ToolsPack;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LadderTrigger : MonoBehaviour
|
|
{
|
|
//public ToolsPackGameObjectComponent ladder;
|
|
/// <summary>
|
|
/// 玩家相机
|
|
/// </summary>
|
|
public GameObject CameraPlayer;
|
|
|
|
/// <summary>
|
|
/// 上梯子后坐标
|
|
/// </summary>
|
|
public Transform UptheladderPos;
|
|
|
|
/// <summary>
|
|
/// 上梯子按钮
|
|
/// </summary>
|
|
public Button UpladderBtn;
|
|
|
|
/// <summary>
|
|
/// 下梯子按钮
|
|
/// </summary>
|
|
public Button DownladderBtn;
|
|
|
|
/// <summary>
|
|
/// 收回梯子按钮
|
|
/// </summary>
|
|
public Button TakeBackBtn;
|
|
|
|
/// <summary>
|
|
/// 梯子物体
|
|
/// </summary>
|
|
public GameObject LadderObj;
|
|
void Start()
|
|
{
|
|
//上梯子按钮
|
|
UpladderBtn.onClick.AddListener(() =>
|
|
{
|
|
CameraPlayer.GetComponent<Rigidbody>().useGravity = false;
|
|
CameraPlayer.gameObject.transform.position = UptheladderPos.transform.position;
|
|
DownladderBtn.gameObject.SetActive(true);
|
|
UpladderBtn.gameObject.SetActive(false);
|
|
TakeBackBtn.gameObject.SetActive(false);
|
|
RoleMove.instance.MouseScrollWheel();
|
|
RoleMove.instance.isup = true;
|
|
});
|
|
DownladderBtn.onClick.AddListener(() =>
|
|
{
|
|
RoleMove.instance.isup = false;
|
|
FirstPersonController.instance.playerCanMove = true;
|
|
CameraPlayer.transform.position = new Vector3(303.5654f, 1.559f, 163.5107f);
|
|
UpladderBtn.gameObject.SetActive(true);
|
|
DownladderBtn.gameObject.SetActive(false);
|
|
TakeBackBtn.gameObject.SetActive(true);
|
|
CameraPlayer.GetComponent<Rigidbody>().useGravity = true;
|
|
|
|
});
|
|
TakeBackBtn.onClick.AddListener(() =>
|
|
{
|
|
UpladderBtn.gameObject.SetActive(false);
|
|
Destroy(LadderObj);
|
|
});
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.gameObject.tag == "Player")
|
|
{
|
|
UpladderBtn.gameObject.SetActive(true);
|
|
TakeBackBtn.gameObject.SetActive(true);
|
|
//FirstPersonController.instance.playerCanMove = false;
|
|
Debug.Log(other.name);
|
|
//ladder.OnPersonClose();
|
|
}
|
|
}
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.gameObject.tag == "Player")
|
|
{
|
|
UpladderBtn.gameObject.SetActive(false);
|
|
TakeBackBtn.gameObject.SetActive(false);
|
|
Debug.Log(other.name);
|
|
//ladder.OnPersonAway();
|
|
}
|
|
}
|
|
}
|