117 lines
3.3 KiB
C#
117 lines
3.3 KiB
C#
using MotionFramework;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using ToolsPack;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LadderTrigger : MonoBehaviour
|
|
{
|
|
/// <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;
|
|
|
|
public static LadderTrigger instance;
|
|
/// <summary>
|
|
/// 梯子动画
|
|
/// </summary>
|
|
public SkinnedMeshRenderer ladderski;
|
|
|
|
/// <summary>
|
|
/// 判断是否在梯子上
|
|
/// </summary>
|
|
public bool isPlayerOnLadder = false;
|
|
public void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
void Start()
|
|
{
|
|
//GameObject CameraPlayer = GameObject.FindWithTag("MainCamera");
|
|
//上梯子按钮
|
|
UpladderBtn.onClick.AddListener(() =>
|
|
{
|
|
CameraPlayer.GetComponent<Rigidbody>().useGravity = false;
|
|
CameraPlayer.GetComponent<CapsuleCollider>().enabled = 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.GetComponent<CapsuleCollider>().enabled = true;
|
|
CameraPlayer.transform.position = new Vector3(304.2304f, 1.200014f, 164.2515f);
|
|
UpladderBtn.gameObject.SetActive(true);
|
|
DownladderBtn.gameObject.SetActive(false);
|
|
TakeBackBtn.gameObject.SetActive(true);
|
|
CameraPlayer.GetComponent<Rigidbody>().useGravity = true;
|
|
CameraPlayer.GetComponentInChildren<Camera>().fieldOfView = 60;
|
|
TooslManager.instance.ResetAllTools();
|
|
});
|
|
//收回梯子按钮
|
|
TakeBackBtn.onClick.AddListener(() =>
|
|
{
|
|
UpladderBtn.gameObject.SetActive(false);
|
|
LadderObj.gameObject.SetActive(false);
|
|
CameraPlayer.GetComponentInChildren<Camera>().fieldOfView = 60;
|
|
|
|
});
|
|
}
|
|
|
|
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);
|
|
// isPlayerOnLadder = true;
|
|
//ladder.OnPersonClose();
|
|
}
|
|
|
|
}
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.gameObject.tag == "Player")
|
|
{
|
|
UpladderBtn.gameObject.SetActive(false);
|
|
TakeBackBtn.gameObject.SetActive(false);
|
|
Debug.Log(other.name);
|
|
//isPlayerOnLadder = false;
|
|
}
|
|
}
|
|
}
|