using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.InputSystem; /// /// 板子组件 /// public class Board : Interactive { /// /// 留言板内容 /// public string text; /// /// 留言板主人的uid /// public int uid; /// /// 留言板位置 /// public Vector2 postion; private GameObject UI; private Text textUI; private Text UIDUI; private MyPlayer player; Board(Vector2 postion, int uid, string text){ this.postion = postion; this.uid = uid; this.text = text; } void Start(){ Init(); } void Update(){ if(CheckComfirm()){ UI.SetActive(false); player.GetComponent().SwitchCurrentActionMap("Normal"); } } private void Init(){ UI = GameObject.Find("留言板相关").transform.GetChild(1).gameObject; textUI = UI.GetComponent().GetChild(0).GetChild(0).GetComponent(); UIDUI = UI.GetComponent().GetChild(0).GetChild(1).GetComponent(); player = FindObjectOfType(); } /// /// 当玩家与留言板互动 /// public override void OnCall(){ UI.SetActive(true); textUI.text = text; UIDUI.text = "UID:"+uid; player.GetComponent().SwitchCurrentActionMap("NullMap"); } private bool CheckComfirm(){ //如果按下此帧按下此二键中的一个 return (Gamepad.current!= null && Gamepad.current.buttonEast.wasPressedThisFrame) || Input.GetKeyDown(KeyCode.K); } }