using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class follow : ToolBase { [SerializeField] Transform game; [SerializeField] string name; [SerializeField] Dialogue dialogue; // Start is called before the first frame update void Start() { if (UIManager.Instance.ganTanHao.KeyGanTanHao.ContainsKey(GlobalFlag.userId)) { gameObject.SetActive(false); } } private void Update() { // 鼠标左键按下 if (Input.GetMouseButtonDown(0)) { // 从相机位置发射一条射线经过屏幕上的鼠标点击位置 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // 声明一个射线碰撞信息类 RaycastHit hit; // 进行碰撞检测 bool res = Physics.Raycast(ray, out hit,100,1<<9) && !EventSystem.current.IsPointerOverGameObject(); if (res) { // 如果产生了碰撞 if (hit.transform.name.Equals(name)) { //gameObject.SetActive(false); GameManager.Instance.JiaoHu = true; gameObject.SetActive(false); dialogue.gameObject.SetActive(true); dialogue.init("你好"); show(); } } } } // Update is called once per frame private void FixedUpdate() { transform.LookAt(game); } private async void show() { //if (!UIManager.Instance.ganTanHao.KeyGanTanHao.ContainsKey(GlobalFlag.userId)) //{ // UIManager.Instance.ganTanHao.KeyGanTanHao.Add(GlobalFlag.userId, GameManager.Instance.SceneName); // gameObject.SetActive(false); //} if (!UIManager.Instance.isChangJing && GameManager.Instance.GonZuoZheng) { await FractionManager.Instance.overAsync(3, 2, "工作证"); UIManager.Instance.isChangJing = true; } else if (!UIManager.Instance.isChangJing && !GameManager.Instance.GonZuoZheng) { await FractionManager.Instance.overAsync(3, 0, "工作证"); if (UIManager.Instance) { UIManager.Instance.isChangJing = true; } } } }