密室逃脱——收集版修改测试

一、原版修改
1、导入资源

Unity Learn | 3D Beginner: Complete Project | URP

2、设置Scene

删除SampleScene,打开UnityTechnologies-3DBeginnerComplete下的MainScene

3、降低音量

(1) 打开Hierarchy面板上的Audio降低音量

(2) 打开Prefabs文件夹,找到Ghost,降低音量

4、给FaderCanvas添加组件

(1) Canvas Scaler

(2) Graphic Raycaster

二、编辑答题面板

(1) UI-Image,命名为Questions。

(2) 选中导入的图片,然后在Inspector面板中将Texture Type设置为Sprite (2D and UI)

(3) 更改Questions的Image,Transform

(4) 添加按钮,QuitBtn(以隐藏答题面板)

(5) 添OptionBtnA(ABCD)

(6) 新增文本:TipAnswerText、TitleText

三、建立和调用题库
1、创建Question.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Question
{public string titleIndex, questiont, correctOptionIndex; // 题号,问题文本, 正确答案的索引(1表示A,2表示B,依此类推)public string optionA, optionB, optionC, optionD;// 选项// 构造函数(可选),用于初始化问题public Questions(string titleInx, string q, string optsA, string optsB, string optsC, string optsD, string correctIndex){titleIndex = titleInx;questiont = q;optionA = optsA;optionB = optsB;optionC = optsC;optionD = optsD;correctOptionIndex = correctIndex;}// 检查答案是否正确public bool CheckAnswer(string playerChoice){return playerChoice == correctOptionIndex;}
}

或——建议这个

using System.Collections;
using System.Collections.Generic;
using UnityEngine;[System.Serializable]
public class Question
{public string questionTitle, questionTitleIndex; // 问题文本、题号public string[] options = new string[4]; // 选项数组,假设每个问题都有4个选项public int correctOptionIndex; // 正确答案的索引(1表示A,2表示B,依此类推)// 构造函数(可选),用于初始化问题public Question(string questionID, string questionText, string[] options, int correctOptionIndex){this.questionTitleIndex = questionID;this.questionTitle = questionText;this.options = options;this.correctOptionIndex = correctOptionIndex;}
}
2、加载题库并随机显示
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using TMPro;
using UnityEngine;public class LoadQuestions : MonoBehaviour
{//存放问题的容器public TextMeshProUGUI titleText, optionTextA, optionTextB, optionTextC, optionTextD;private void Start(){LoadQuestionsFromFile("YW");}public void LoadQuestionsFromFile(string filePath){//加载位于Resources文件夹中的YW文件TextAsset textFile = Resources.Load<TextAsset>("YW");//若文件加载成功if (textFile != null){Debug.Log("YW文件加载成功");//将textFile中储存的文本按行拆分成一个字符串数组,每个数组元素都表示一行文本("\n":换行符)//string[] lines = textFile.text.Split("new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None");//不同系统或编辑器可能使用的不同换行符格式string[] lines = textFile.text.Split("\n");// 获取一个随机的索引int randomIndex = UnityEngine.Random.Range(0, lines.Length);//从lines中获取一个随机元素,将之赋值给linestring line = lines[randomIndex];//解析line中的字段string[] fields = line.Split(":");// 创建问题对象Questions question = new(fields[0], fields[1], fields[2], fields[3], fields[4], fields[5], fields[6]);titleText.text = question.questiont;optionTextA.text = question.optionA;optionTextB.text = question.optionB;optionTextC.text = question.optionC;optionTextD.text = question.optionD;}else { Debug.Log("YW文件加载失败"); }}
}

或 ——建议下面这个(需要在Unity编辑器中设置选项按钮的On Click

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class LoadQuestions : MonoBehaviour
{public Text titleText;public Button[] optionButtons;private string[] lines; // 保存所有问题的数组private List<Question> questions = new List<Question>(); // 问题列表private Question currentQuestion;private void Start(){LoadQuestionsFromFile();UpdateQuestionUI();}//加载题库public void LoadQuestionsFromFile(){TextAsset textFile = Resources.Load<TextAsset>("test_01");if (textFile != null){lines = textFile.text.Split("\n");for (int i = 0; i < lines.Length; i++){string[] fields = lines[i].Split(":");if (fields.Length >= 7){string questionID = fields[0];string questionTitle = fields[1];string[] options = new string[] { fields[2], fields[3], fields[4], fields[5] };//int correctOptionIndex = int.Parse(fields[6]); // 将正确答案的索引作为整数类型存储int correctOptionIndex;if (int.TryParse(fields[6], out correctOptionIndex)) // 使用 TryParse 避免异常{questions.Add(new Question(questionID, questionTitle, options, correctOptionIndex));}else{Debug.LogError("文件格式错误:第 " + (i + 1) + " 行中的正确答案索引不是有效的整数");}}else{Debug.LogError("文件格式错误:第 " + (Array.IndexOf(lines, lines) + 1) + " 行没有足够的字段");}}}}//随机显示public void UpdateQuestionUI(){int randomIndex = UnityEngine.Random.Range(0, questions.Count - 1);currentQuestion = questions[randomIndex];string question = currentQuestion.questionTitle;string[] options = currentQuestion.options; // 获取选项数组int correctIndex = currentQuestion.correctOptionIndex; // 获取正确选项的索引titleText.text = question;for (int i = 0; i < optionButtons.Length; i++){optionButtons[i].onClick.RemoveAllListeners();int index = i; // 创建局部变量保存索引值optionButtons[i].GetComponentInChildren<Text>().text = options[i];}}
}
3、判断正误
    public void CheckAnswer(int optionIndex){if (optionIndex == currentQuestion.correctOptionIndex){Debug.Log("回答正确!" + optionIndex + currentQuestion.correctOptionIndex);}else{Debug.Log("回答错误!" + optionIndex + currentQuestion.correctOptionIndex);}}
4、禁用按钮
public void UpdateQuestionUI()
{int randomIndex = UnityEngine.Random.Range(0, questions.Count - 1);currentQuestion = questions[randomIndex];string question = currentQuestion.questionTitle;string[] options = currentQuestion.options; // 获取选项数组int correctIndex = currentQuestion.correctOptionIndex; // 获取正确选项的索引titleText.text = question;for (int i = 0; i < optionButtons.Length; i++){optionButtons[i].onClick.RemoveAllListeners();int index = i; // 创建局部变量保存索引值optionButtons[i].GetComponentInChildren<Text>().text = options[i];optionButtons[i].interactable = true; // 启用按钮}
}
public void CheckAnswer(int optionIndex)
{for (int i = 0; i < optionButtons.Length; i++){optionButtons[i].interactable = false; // 禁用按钮}if (optionIndex == currentQuestion.correctOptionIndex){Debug.Log("回答正确!" + optionIndex + currentQuestion.correctOptionIndex);}else{Debug.Log("回答错误!" + optionIndex + currentQuestion.correctOptionIndex);}
}
5、记录答过的题目,并从题库中清除
public void LoadQuestionsFromFile()
{TextAsset textFile = Resources.Load<TextAsset>("test_01");if (textFile != null){//确保跨平台兼容性拆分文本string[] lines = textFile.text.Split(new string[] { System.Environment.NewLine }, System.StringSplitOptions.RemoveEmptyEntries);for (int i = 0; i < lines.Length; i++){string[] fields = lines[i].Split(':');if (questions.Count > 0){usedQuestions.Clear();}if (fields.Length >= 7){string questionID = fields[0];string questionTitle = fields[1];string[] options = new string[] { fields[2], fields[3], fields[4], fields[5] };int correctOptionIndex;if (int.TryParse(fields[6], out correctOptionIndex)){questions.Add(new Question(questionID, questionTitle, options, correctOptionIndex));}else{Debug.LogErrorFormat("文件格式错误:第 {0} 行中的正确答案索引不是有效的整数", i + 1);}}else{Debug.LogErrorFormat("文件格式错误:第 {0} 行没有足够的字段", i + 1);}}}else{Debug.LogError("找不到文本文件 test_01");}
}

 完整脚本

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class LoadQuestions : MonoBehaviour
{public Text titleText;public Button[] optionButtons;private string[] lines; // 保存所有问题的数组private List<Question> questions = new List<Question>(); // 问题列表private Question currentQuestion;private void Start(){LoadQuestionsFromFile();UpdateQuestionUI();}public void LoadQuestionsFromFile(){TextAsset textFile = Resources.Load<TextAsset>("test_01");if (textFile != null){lines = textFile.text.Split("\n");for (int i = 0; i < lines.Length; i++){string[] fields = lines[i].Split(":");if (fields.Length >= 7){string questionID = fields[0];string questionTitle = fields[1];string[] options = new string[] { fields[2], fields[3], fields[4], fields[5] };//int correctOptionIndex = int.Parse(fields[6]); // 将正确答案的索引作为整数类型存储int correctOptionIndex;if (int.TryParse(fields[6], out correctOptionIndex)) // 使用 TryParse 避免异常{questions.Add(new Question(questionID, questionTitle, options, correctOptionIndex));}else{Debug.LogError("文件格式错误:第 " + (i + 1) + " 行中的正确答案索引不是有效的整数");}}else{Debug.LogError("文件格式错误:第 " + (Array.IndexOf(lines, lines) + 1) + " 行没有足够的字段");}}}}public void UpdateQuestionUI(){int randomIndex = UnityEngine.Random.Range(0, questions.Count - 1);currentQuestion = questions[randomIndex];string question = currentQuestion.questionTitle;string[] options = currentQuestion.options; // 获取选项数组int correctIndex = currentQuestion.correctOptionIndex; // 获取正确选项的索引titleText.text = question;for (int i = 0; i < optionButtons.Length; i++){optionButtons[i].onClick.RemoveAllListeners();int index = i; // 创建局部变量保存索引值optionButtons[i].GetComponentInChildren<Text>().text = options[i];optionButtons[i].interactable = true; // 启用按钮}}public void CheckAnswer(int optionIndex){for (int i = 0; i < optionButtons.Length; i++){optionButtons[i].interactable = false; // 禁用按钮}if (optionIndex == currentQuestion.correctOptionIndex){Debug.Log("回答正确!" + optionIndex + currentQuestion.correctOptionIndex);}else{Debug.Log("回答错误!" + optionIndex + currentQuestion.correctOptionIndex);}}
}
四、收集事件
1、新增文本

(1) 新增文本:ItemsText, TipText(可设置有透明度的黑色背景)

(2) 给JohnLemon添加标签Player

2、更改Enemies下的子物体

(1) 复制PointOfView预制体,重命名为ExitEventTriggers

(2) 删除Ghost (3)的PointOfView子物体,在该位置添加ExitEventTriggers子物体

(3) 编辑PointOfView预制体,删除Observer.cs组件,添加CollectedItems.cs组件

3、新建CollectedItems.cs

(1) 设置隐藏答题面板按钮,同时调用新题目

public GameObject questionsPanel;
public Button quitBtn;
public LoadQuestions LoadQuestions;void Start()
{questionsPanel.SetActive(false);
}public void HideQuestionPanel()
{if (questionsPanel != null){questionsPanel.SetActive(false); // 隐藏物体LoadQuestions.UpdateQuestionUI();}
}

(2) 增加显示背包物品

public Text itemsText;
static int nucleus = 0, mitochondria = 0, GolgiApparatus = 0, endoplasmicReticulum = 0, ribosome = 0;void Start()
{ItemsUpdate();
}void ItemsUpdate()
{itemsText.text = "当前持有:……" + nucleus + ";……" + mitochondria + ";……" + GolgiApparatus + ";……" + endoplasmicReticulum + ";……" + ribosome;
}

(3) 增加冷却事件

bool canTriggerEffect = true;void RandomEvent()
{if (canTriggerEffect){//执行接触事件……else{tipText.text = "你什么都没有发现……";StartCoroutine(ClearTextRoutine(2f));//2秒后文本消失} canTriggerEffect = false;StartCoroutine(CooldownRoutine());}
}IEnumerator CooldownRoutine()//接触事件有1分钟的冷却时间
{yield return new WaitForSeconds(60f); // 等待1分钟canTriggerEffect = true; // 冷却结束,可以再次触发效果
}
IEnumerator ClearTextRoutine(float delay)//提示文本显示后消失
{yield return new WaitForSeconds(delay);tipText.text = "";
}

(4) 增加收集事件

    void Start(){if (itemsText == null || tipText == null){Debug.LogError("ItemsText 或 TipText 未被正确分配!");}questionsPanel.SetActive(false);}private void OnTriggerEnter(Collider other){if (other.CompareTag("Player")){RandomEvent();}}void RandomEvent(){int numericValue = Random.Range(0, 100);if (numericValue < 5 && nucleus == 0){nucleus = 1;tipText.text = "你发现了nucleus!";}else if (numericValue < 26){mitochondria++;tipText.text = "你得到了mitochondria!";}else if (numericValue < 41){endoplasmicReticulum++;tipText.text = "你得到了endoplasmicReticulum*1!";}else if (numericValue < 56){GolgiApparatus++;tipText.text = "你得到了GolgiApparatus*1!";}else if (numericValue < 76){ribosome++;tipText.text = "你得到了ribosome*1!";}else if (numericValue < 86){questionsPanel.SetActive(true);}else{tipText.text = "你什么都没有发现……";}ItemsUpdate();}void ItemsUpdate(){itemsText.text = "当前持有:nucleus" + nucleus + ";……" + mitochondria + ";……" + GolgiApparatus + ";……" + endoplasmicReticulum + ";……" + ribosome;}
}

本节完整脚本

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;public class CollectedItems : MonoBehaviour
{public Text itemsText;public Text tipText;static int nucleus = 0, mitochondria = 0, GolgiApparatus = 0, endoplasmicReticulum = 0, ribosome = 0;public GameObject questionsPanel;public Button quitBtn;public LoadQuestions LoadQuestions;bool canTriggerEffect = true;void Start(){if (itemsText == null || tipText == null){Debug.LogError("ItemsText 或 TipText 未被正确分配!");}questionsPanel.SetActive(false);ItemsUpdate();}private void OnTriggerEnter(Collider other){if (other.CompareTag("Player")){RandomEvent();}}void RandomEvent(){if (canTriggerEffect){int numericValue = Random.Range(0, 100);if (numericValue < 5 && nucleus == 0){nucleus = 1;tipText.text = "你发现了nucleus!";StartCoroutine(ClearTextRoutine(2f));}else if (numericValue < 26){mitochondria++;tipText.text = "你得到了mitochondria!";StartCoroutine(ClearTextRoutine(2f));}else if (numericValue < 41){endoplasmicReticulum++;tipText.text = "你得到了endoplasmicReticulum*1!";StartCoroutine(ClearTextRoutine(2f));}else if (numericValue < 56){GolgiApparatus++;tipText.text = "你得到了GolgiApparatus*1!";StartCoroutine(ClearTextRoutine(2f));}else if (numericValue < 76){ribosome++;tipText.text = "你得到了ribosome*1!";StartCoroutine(ClearTextRoutine(2f));}else if (numericValue < 86){questionsPanel.SetActive(true);}else{tipText.text = "你什么都没有发现……";StartCoroutine(ClearTextRoutine(2f));}ItemsUpdate();canTriggerEffect = false;StartCoroutine(CooldownRoutine());}}void ItemsUpdate(){itemsText.text = "当前持有:nucleus" + nucleus + ";mitochondria" + mitochondria + ";GolgiApparatus" + GolgiApparatus + ";endoplasmicReticulum" + endoplasmicReticulum + ";ribosome" + ribosome;}IEnumerator CooldownRoutine(){yield return new WaitForSeconds(60f); // 等待1分钟canTriggerEffect = true; // 冷却结束,可以再次触发效果}IEnumerator ClearTextRoutine(float delay){yield return new WaitForSeconds(delay);tipText.text = "";}public void HideQuestionPanel(){if (questionsPanel != null){questionsPanel.SetActive(false); // 隐藏物体LoadQuestions.UpdateQuestionUI();//调用新题目}}
}
五、增加生命系统
1、新建PlayerHealth.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class PlayerHealth : MonoBehaviour
{public int maxHealth = 3;private int currentHealth;public Text life;public GameEnding gameEndings;private void Start(){currentHealth = maxHealth; // 先设置currentHealth的值UpdateHealthText();}public void AddHealth(){if (currentHealth < maxHealth){currentHealth++;UpdateHealthText();}}public void RemoveHealth(){if (currentHealth > 0){currentHealth--;UpdateHealthText();if (currentHealth == 0){gameEndings.CaughtPlayer(); // 玩家死亡}}}private void UpdateHealthText(){life.text = "当前生命" + currentHealth.ToString();}
}
2、增加文本显示生命值

(1) 增加显示当前生命值文本

(2) 增加减少生命值提醒图片

3、处理加减生命的方法
public class LoadQuestions : MonoBehaviourpublic PlayerHealth PlayerHealth;public void CheckAnswer(int optionIndex)
{
if (optionIndex == currentQuestion.correctOptionIndex)
{Debug.Log("回答正确!" + optionIndex + currentQuestion.correctOptionIndex);PlayerHealth.AddHealth();TipAnswerText.text = "回答正确!生命值+1!退出按Quit";
}
else
{Debug.Log("回答错误!" + optionIndex + currentQuestion.correctOptionIndex);PlayerHealth.RemoveHealth();TipAnswerText.text = "回答错误!生命值-1!\n+退出按Quit";
}
}
六、 更改死亡事件
using UnityEngine;
using UnityEngine.SceneManagement;public class GameEnding : MonoBehaviour
{public float fadeDuration = 1f;public float displayImageDuration = 1f;public GameObject player;public CanvasGroup exitBackgroundImageCanvasGroup;public AudioSource exitAudio;public CanvasGroup caughtBackgroundImageCanvasGroup;public AudioSource caughtAudio;bool m_IsPlayerAtExit;bool m_IsPlayerCaught;float m_Timer;bool m_HasAudioPlayed;void OnTriggerEnter (Collider other){if (other.gameObject == player){m_IsPlayerAtExit = true;}}public void CaughtPlayer (){m_IsPlayerCaught = true;}void Update (){if (m_IsPlayerAtExit){EndLevel (exitBackgroundImageCanvasGroup, false, exitAudio);}else if (m_IsPlayerCaught){EndLevel (caughtBackgroundImageCanvasGroup, true, caughtAudio);}}void EndLevel (CanvasGroup imageCanvasGroup, bool doRestart, AudioSource audioSource){if (!m_HasAudioPlayed){audioSource.Play();m_HasAudioPlayed = true;}m_Timer += Time.deltaTime;imageCanvasGroup.alpha = m_Timer / fadeDuration;if (m_Timer > fadeDuration + displayImageDuration){if (doRestart){//SceneManager.LoadScene ("MainScene1");Application.Quit();//退出游戏}else{Application.Quit ();}}}
}
七、增加敌人,增加随机死亡事件
八、添加手柄

(1) 下载并导入  资源包 

(2) 打开Prefabs 文件夹,将 Fixed Joystick 拖放到Hierarchy面板的Canvas下,调整大小和位置

(3) 调整脚本

public FixedJoystick fixedJoystick;
public float moveSpeed = 1f;void Start()
{……fixedJoystick = GameObject.FindObjectOfType<FixedJoystick>();
}private void FixedUpdate()
{// 手柄控制代码
if (fixedJoystick != null)
{float joystickHorizontal = fixedJoystick.Horizontal;float joystickVertical = fixedJoystick.Vertical;if (!Mathf.Approximately(joystickHorizontal, 0f) || !Mathf.Approximately(joystickVertical, 0f)){horizontal = joystickHorizontal;vertical = joystickVertical;m_Movement.Set(horizontal, 0f, vertical);m_Movement.Normalize();}
}
}

完整代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;public class PlayerMovement : MonoBehaviour
{public FixedJoystick fixedJoystick;public InputAction MoveAction;public float turnSpeed = 20f;public float moveSpeed = 1f;Animator m_Animator;Rigidbody m_Rigidbody;AudioSource m_AudioSource;Vector3 m_Movement;Quaternion m_Rotation = Quaternion.identity;void Start (){m_Animator = GetComponent<Animator> ();m_Rigidbody = GetComponent<Rigidbody> ();m_AudioSource = GetComponent<AudioSource> ();MoveAction.Enable();fixedJoystick = GameObject.FindObjectOfType<FixedJoystick>();}void FixedUpdate(){// 原有的键盘控制代码float horizontal = Input.GetAxis("Horizontal");float vertical = Input.GetAxis("Vertical");m_Movement.Set(horizontal, 0f, vertical);m_Movement.Normalize();// 手柄控制代码if (fixedJoystick != null){float joystickHorizontal = fixedJoystick.Horizontal;float joystickVertical = fixedJoystick.Vertical;if (!Mathf.Approximately(joystickHorizontal, 0f) || !Mathf.Approximately(joystickVertical, 0f)){horizontal = joystickHorizontal;vertical = joystickVertical;m_Movement.Set(horizontal, 0f, vertical);m_Movement.Normalize();}}bool hasHorizontalInput = !Mathf.Approximately(horizontal, 0f);bool hasVerticalInput = !Mathf.Approximately(vertical, 0f);bool isWalking = hasHorizontalInput || hasVerticalInput;m_Animator.SetBool("IsWalking", isWalking);if (isWalking){if (!m_AudioSource.isPlaying){m_AudioSource.Play();}}else{m_AudioSource.Stop();}Vector3 desiredForward = Vector3.RotateTowards(transform.forward, m_Movement, turnSpeed * Time.deltaTime, 0f);m_Rotation = Quaternion.LookRotation(desiredForward);// 移动角色m_Rigidbody.MovePosition(m_Rigidbody.position + m_Movement * moveSpeed * Time.fixedDeltaTime);}void OnAnimatorMove (){m_Rigidbody.MovePosition (m_Rigidbody.position + m_Movement * m_Animator.deltaPosition.magnitude);m_Rigidbody.MoveRotation (m_Rotation);}
}
九、发布

1、安装 WebGL Build Support

2、更改Color Space(other……)下

3、在File下进行打包

4、在publish中上传

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/41216.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

lnmp php7 安装ssh2扩展

安装ssh2扩展前必须安装libssh2包 下载地址: wget http://www.libssh2.org/download/libssh2-1.11.0.tar.gzwget http://pecl.php.net/get/ssh2-1.4.tgz &#xff08;这里要换成最新的版本&#xff09; 先安装 libssh2 再安装 SSH2: tar -zxvf libssh2-1.11.0.tar.gzcd libss…

【日志信息管理】管理日志信息的类

日志用于记录程序的执行记录包括程序的出错记录&#xff0c;程序致命退出原因&#xff0c;程序的正常执行记录。这样我们就可以很快的察觉程序的错误原因、执行状况等等&#xff0c;因此管理日志信息是非常重要的。 日志一般由以下部分组合&#xff1a; 日志时间、日志等级、…

Java 基础--File - IO流(2)

I/O流 定义 数据从硬盘流向内存为输入流&#xff0c;数据从内存流向硬盘为输出流。输入也叫读取数据&#xff0c;输出也叫写出数据。 IO分类 1.按照数据的流向分为&#xff1a;输入流和输出流 ①输入流&#xff1a;把数据从其他设备上读取到内存中的流 ②输出流&#xff1…

Qt 基础组件速学 事件过滤器

学习目标&#xff1a;理解事件过滤器 前置环境 运行环境:qt creator 4.12 学习内容和效果演示&#xff1a; Qt 提供了事件过滤器的机制,允许我们在事件到达目标对象之前对事件进行拦截和处理。这在以下情况下非常有用: 全局事件处理: 我们可以在应用程序级别安装一个事件过…

工控人最爱的PLC触摸屏一体机,有多香

PLC触摸屏一体机是什么 PLC触摸屏一体机&#xff0c;听起来可能有点技术化&#xff0c;但简单来说&#xff0c;它就是一个集成了可编程逻辑控制器&#xff08;PLC&#xff09;和触摸屏的智能设备。这种设备不仅能够执行自动化控制任务&#xff0c;还能实时显示和操作设备状态&a…

JVM原理(十九):JVM虚拟机内存模型

1. 硬件的效率与一致性 数据不安全的原因&#xff1a;缓存一致性的问题 共享内存多核系统&#xff1a;在多路处理器系统中&#xff0c;每个处理器都有自己的高速缓存&#xff0c;而他们又共享同一主内存。 线程先后执行结果不一致问题&#xff1a;除了增加高速缓存之外&#…

【Python】已解决:nltk.download(‘stopwords‘) 报错问题

文章目录 一、分析问题背景二、可能出错的原因三、错误代码示例四、正确代码示例五、注意事项 已解决&#xff1a;nltk.download(‘stopwords’) 报错问题 一、分析问题背景 在使用Python的自然语言处理库NLTK&#xff08;Natural Language Toolkit&#xff09;时&#xff0c…

CentOS 7安装Elasticsearch7.7.0和Kibana

一. 准备安装包 elasticsearch和kibana&#xff1a;官网历史版本找到并下载&#xff08;https://www.elastic.co/cn/downloads/past-releases#elasticsearch&#xff09;ik分词器&#xff1a;GitHub下载&#xff08;https://github.com/infinilabs/analysis-ik/releases/tag/v…

设计模式之状态机模式

一、状态机模式介绍 状态机模式&#xff08;State Machine Pattern&#xff09;是一种用于描述对象行为的软件设计模式&#xff0c;属于行为型设计模式。在状态机模式中&#xff0c;对象的行为取决于其内部状态&#xff0c;并且在不同的状态下&#xff0c;对象可能会有不同的行…

STM32F103C8T6核心板原理图和PCB分享

PCB图 原理图 资料下载地址&#xff1a; 原理图PCB库: https://545c.com/d/45573183-61875742-29897c?p7526 (访问密码: 7526)

[go-zero] 简单微服务调用

文章目录 1.注意事项2.服务划分及创建2.1 用户微服务2.2 订单微服务 3.启动服务3.1 etcd 服务启动3.2 微服务启动3.3 测试访问 1.注意事项 go-zero微服务的注册中心默认使用的是Etcd。 本小节将以一个订单服务调用用户服务来简单演示一下&#xff0c;其实订单服务是api服务&a…

Java 使用sql查询mongodb

在现代应用开发中&#xff0c;关系型数据库和NoSQL数据库各有千秋。MongoDB作为一种流行的NoSQL数据库&#xff0c;以其灵活的文档模型和强大的扩展能力&#xff0c;受到广泛欢迎。然而&#xff0c;有时开发者可能更熟悉SQL查询语法&#xff0c;或者需要在现有系统中复用SQL查询…

【ARMv8/v9 GIC 系列 5.6 -- GIC 超优先级中断详细介绍】

请阅读【ARM GICv3/v4 实战学习 】 文章目录 Interrupt superpriority超优先级中断的特性和应用Physical interface interrupt signalsPhysical Group 1 Non-NMI for Current Security StatePhysical Group 1 for Other Security State, or a Group 0 Non-NMIPhysical Group 1 …

进程控制-wait和waitpid进程回收

wait 阻塞函数 函数作用&#xff1a; 1. 阻塞并等待子进程退出 2. 回收子进程残留资源 3. 获取子进程结束状态&#xff08;退出原因&#xff09; pid_t wait(int *wstatus); 返回值&#xff1a; ‐1 : 回收失败&#xff0c;已经没有子进程了 >0 : 回收子进程对应的…

一种非凸全变差正则化的信号降噪方法(以模拟信号和轴承振动信号为例,MATLAB)

以旋转机械振动信号为例&#xff0c;由于旋转机械运行中背景噪声较强&#xff0c;振动信号需要进行降噪处理。常用的小波阈值降噪会在信号的不连续处产生虚假的波峰和伪吉布森震荡&#xff0c;而奇异值分解SVD去噪容易产生虚假分量&#xff0c;全变差去噪则不会出现这样的情况&…

深入理解JS逆向代理与环境监测

博客文章&#xff1a;深入理解JS逆向代理与环境监测 1. 引言 首先要明确JavaScript&#xff08;JS&#xff09;在真实网页浏览器环境和Node.js环境中有很多使用特性的区别。尤其是在环境监测和对象原型链的检测方面。本文将探讨如何使用JS的代理&#xff08;Proxy&#xff09…

STM32-USART

本内容基于江协科技STM32视频学习之后整理而得。 文章目录 1. 串口通信协议1.1 通信接口1.2 串口通信1.3 硬件电路1.4 电平标准1.5 串口参数及时序1.6 串口时序 2. USART串口通信2.1 USART简介2.2 USART框图2.3 USART基本结构2.4 数据帧2.5 数据帧-配置停止位2.6 起始位侦测2.…

【Python】一文向您详细介绍 argparse中 action=‘store_true’ 的作用

【Python】一文向您详细介绍 argparse中 action‘store_true’ 的作用 下滑即可查看博客内容 &#x1f308; 欢迎莅临我的个人主页 &#x1f448;这里是我静心耕耘深度学习领域、真诚分享知识与智慧的小天地&#xff01;&#x1f387; &#x1f393; 博主简介&#xff1a;98…

pdf怎么转换成图片格式文件,pdf文档怎么转换成图片格式

在数字化时代&#xff0c;pdf文件转换成图片格式是一种常见的操作&#xff0c;无论是在工作还是日常生活中&#xff0c;我们总会遇到需要将pdf文件转换为图片的需求。这可能是因为图片格式更易于分享、展示或编辑。那么&#xff0c;如何高效地将pdf转换成图片呢&#xff1f;本文…

图神经网络实战(16)——经典图生成算法

图神经网络实战&#xff08;16&#xff09;——经典图生成算法 0. 前言1. 图生成技术2. Erdős–Rnyi模型3. 小世界模型小结系列链接 0. 前言 图生成算法是指用于创建模拟图或网络结构的算法&#xff0c;这些算法可以根据特定的规则和概率分布生成具有特定属性的图&#xff0c…