198 lines
4.9 KiB
C#
198 lines
4.9 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DefaultNamespace.ProcessMode;
|
|
using MotionFramework;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using HighlightPlus;
|
|
|
|
public class Fieldobservation : MonoBehaviour
|
|
{
|
|
public static Fieldobservation Instance;
|
|
|
|
[Header("警告按钮")]
|
|
/// <summary>
|
|
/// 警告按钮
|
|
/// </summary>
|
|
public Button ExclamationPointBtn;
|
|
|
|
[Header("玩家相机")]
|
|
/// <summary>
|
|
/// 玩家相机
|
|
/// </summary>
|
|
public Transform Cameraobj;
|
|
|
|
[Header("上梯子后坐标")]
|
|
/// <summary>
|
|
/// 上梯子后坐标
|
|
/// </summary>
|
|
public Transform UptheladderPos;
|
|
|
|
[Header("透明盖子")]
|
|
/// <summary>
|
|
/// 透明盖子
|
|
/// </summary>
|
|
public Transform Transparentover;
|
|
|
|
[Header("柜门卡栓碰撞")]
|
|
/// <summary>
|
|
/// 柜门卡栓碰撞
|
|
/// </summary>
|
|
public BoxCollider guimenkashuan;
|
|
|
|
[Header("电箱门")]
|
|
/// <summary>
|
|
/// 电箱门
|
|
/// </summary>
|
|
public GameObject guimen;
|
|
|
|
[Header("门锁01")]
|
|
/// <summary>
|
|
/// 门锁01
|
|
/// </summary>
|
|
public GameObject mensuo01;
|
|
|
|
[Header("柜门box碰撞")]
|
|
/// <summary>
|
|
/// 柜门box碰撞
|
|
/// </summary>
|
|
public BoxCollider guimenbox;
|
|
|
|
[Header("透明盖子上的封印cube碰撞")]
|
|
/// <summary>
|
|
/// 透明盖子上的封印cube碰撞
|
|
/// </summary>
|
|
public BoxCollider[] BOXseal;
|
|
|
|
[Header("透明盖子上的两颗螺丝")]
|
|
/// <summary>
|
|
/// 透明盖子上的两颗螺丝
|
|
/// </summary>
|
|
public GameObject[] screw;
|
|
|
|
[Header("判断")]
|
|
/// <summary>
|
|
/// 判断是否在梯子上
|
|
/// </summary>
|
|
public bool isPlayerOnLadder = false;
|
|
|
|
/// <summary>
|
|
/// 判断封印盒子是否在手上
|
|
/// </summary>
|
|
bool isbox = true;
|
|
|
|
bool isclick;
|
|
|
|
|
|
//public GameObject fengy;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
//public HighlightEffect _highlight;
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;
|
|
bool raycast = Physics.Raycast(ray, out hit);
|
|
if (raycast)
|
|
{
|
|
if (hit.collider.gameObject.name == "盖_透明外壳")
|
|
{
|
|
StartCoroutine(IEparentoverSeal());
|
|
BOXseal[0].enabled = true;
|
|
BOXseal[1].enabled = true;
|
|
//isbox = false;
|
|
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
|
|
}
|
|
if (hit.collider.gameObject.name == "变电箱_门")
|
|
{
|
|
StartCoroutine(IEguimenkashuan());
|
|
//if (isbox)
|
|
//{
|
|
guimenbox.GetComponent<BoxCollider>().enabled = true;
|
|
isbox = false;
|
|
// }
|
|
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 玩家与物体碰撞
|
|
/// </summary>
|
|
/// <param name="other"></param>
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.gameObject.name == "UptheladderPos")
|
|
{
|
|
isPlayerOnLadder = true;
|
|
Debug.Log(other.name);
|
|
//ladder.OnPersonClose();
|
|
}
|
|
if (other.gameObject.name == "检测是否到达场景后拿取工具碰撞")
|
|
{
|
|
isPlayerOnLadder = false;
|
|
Debug.Log(other.name);
|
|
//ladder.OnPersonClose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 玩家离开npc警告按钮消失
|
|
/// </summary>
|
|
/// <param name="other"></param>
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.name == "Man_stand")
|
|
{
|
|
ExclamationPointBtn.gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 透明外盖上的封印动画
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
IEnumerator IEparentoverSeal()
|
|
{
|
|
Transparentover.transform.localPosition = new Vector3(0, 0, 0);
|
|
yield return new WaitForSeconds(1f);
|
|
screw[0].gameObject.SetActive(true);
|
|
yield return new WaitForSeconds(0.5f);
|
|
screw[0].transform.localPosition = new Vector3(-0.07357633f, -0.01137948f, 0.003414989f);
|
|
screw[1].gameObject.SetActive(true);
|
|
yield return new WaitForSeconds(1.5f);
|
|
screw[1].transform.localPosition = new Vector3(0.07394123f, 0.013731f, 0.003414989f);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击柜门卡栓动画
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
IEnumerator IEguimenkashuan()
|
|
{
|
|
guimen.gameObject.transform.DOLocalRotate(new Vector3(-90, 0, 0), 1);
|
|
yield return new WaitForSeconds(1.1f);
|
|
mensuo01.gameObject.transform.DOLocalRotate(new Vector3(0, 0, 0), 1);
|
|
guimenkashuan.gameObject.GetComponent<BoxCollider>().enabled = true;
|
|
}
|
|
public bool IsPlayerOnLadder()
|
|
{
|
|
return isPlayerOnLadder;
|
|
}
|
|
}
|