密室逃脱——收集版

一、原版修改
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、新增物体

(1) 新增物体:UI-Image。Questions。设置它的Rect Transform。

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

2、新建CollectedItems.cs
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class CollectedItems : MonoBehaviour
{
    public QuestionCollision QuestionCollision;
    //public GameObject Questions;
    public TextMeshProUGUI ItemsText, TipText;
    static int nucleus=0, mitochondria = 0, GolgiApparatus = 0, endoplasmicReticulum = 0, ribosome = 0;
    void Start()
    {
        if (ItemsText == null || TipText == null)
        {
            Debug.LogError("Questions或ItemsText 或 TipText 未被正确分配!");
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            RandomEvent();
        }
    }
    public void RandomEvent()
    {
        int numericValue = Random.Range(0, 100);
        if (numericValue < 5 && nucleus==0)
        {
            nucleus = 1;
            TipText.text = "你发现了细胞核!";
        }
        else if(numericValue < 26)
        {
            mitochondria++;
            TipText.text = "你得到了线粒体!";
        }
        else if (numericValue < 41)
        {
            endoplasmicReticulum++;
            TipText.text = "你得到了内质网*1!";
        }
        else if (numericValue < 56)
        {
            GolgiApparatus++;
            TipText.text = "你得到了高尔基体*1!";
        }
        else if (numericValue < 76)
        {
            ribosome++;
            TipText.text = "你得到了核糖体*1!";
        }
        else if (numericValue < 86)
        {
            QuestionCollision.ShowQuestions(true);
            //Questions.SetActive(true);
        }
        else
        {
            TipText.text = "你什么都没有发现……";
        }
        ItemsUpdate();
    }
    void ItemsUpdate()
    {
        ItemsText.text = "当前持有:细胞核" + nucleus + ";线粒体" + mitochondria + ";高尔基体" + GolgiApparatus + ";内质网" + endoplasmicReticulum + ";核糖体" + ribosome;
    }
}
 
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI;

public class Observer : MonoBehaviour
{
    public Exercises exercises;
    public Transform player;
    public GameObject Questions;

    public TextMeshProUGUI ItemsText, TipText;
    static int nucleus=0, mitochondria = 0, GolgiApparatus = 0, endoplasmicReticulum = 0, ribosome = 0;

    bool canTriggerEffect = true;
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player")) // 玩家的标签为 "Player" 
        {
            exercises.ShowQuestion(0);
            RandomEvent(); 
        }
    }
    public void QuitBtn() 
    {
        GetComponent<UnityEngine.UI.Button>().gameObject.SetActive(false);
        Questions.SetActive(false);
    }
    void ItemsUpdate()
    {
        ItemsText.text =
            "当前持有:细胞核" + nucleus + ";线粒体" + mitochondria + ";高尔基体" + GolgiApparatus + ";内质网" + endoplasmicReticulum + ";核糖体" + ribosome;
    }
    void Start()
    {
        if (ItemsText == null || TipText == null)
        {
            Debug.LogError("ItemsText 或 TipText 未被正确分配!");
        }
    }
    void RandomEvent()
    {
        if (canTriggerEffect)
        {
            // 触发效果代码
            int numericValue = UnityEngine.Random.Range(0, 100);
            if (numericValue < 5 && nucleus == 0)//获取的随机数范围在0~4
            {
                nucleus = 1;
                TipText.text = "你发现了细胞核!";
                StartCoroutine(ClearTextRoutine(2f));
                print("随机数" + numericValue);
            }
            else if (numericValue < 21)
            {
                mitochondria++;
                TipText.text = "你得到了线粒体!";
                StartCoroutine(ClearTextRoutine(2f));
                print("随机数" + numericValue);
            }
            else if (numericValue < 41)
            {
                endoplasmicReticulum++;
                TipText.text = "你得到了内质网*1!";
                StartCoroutine(ClearTextRoutine(2f));
                print("随机数" + numericValue);
            }
            else if (numericValue < 61)
            {
                GolgiApparatus++;
                TipText.text = "你得到了高尔基体*1!";
                StartCoroutine(ClearTextRoutine(2f));
                print("随机数" + numericValue);
            }
            else if (numericValue < 81)
            {
                ribosome++;
                TipText.text = "你得到了核糖体*1!"; 
                StartCoroutine(ClearTextRoutine(2f));
                print("随机数" + numericValue);
            }
            else if (numericValue < 96)
            {
                Questions.SetActive(true);
            }
            else
            {
                TipText.text = "你什么都没有发现……";
                StartCoroutine(ClearTextRoutine(2f));
                print("随机数" + numericValue);
            }
            //gameEnding.CaughtPlayer ();
            ItemsUpdate();

            canTriggerEffect = false; // 触发效果,将canTriggerEffect设置为false
            StartCoroutine(CooldownRoutine()); // 启动冷却时间协程
        }
    }
    IEnumerator CooldownRoutine()
    {
        yield return new WaitForSeconds(60f); // 等待1分钟
        canTriggerEffect = true; // 冷却结束,可以再次触发效果
    }
    IEnumerator ClearTextRoutine(float delay)
    {
        yield return new WaitForSeconds(delay);
        TipText.text = "";
    }
}

3、更改enemy设置

(1) 复制 PointOfView预制体,得到PointOfView(1),更名为CollectedItems

(2) 移除CollectedItems上的Observer.cs,添加CollectedItems.cs

(3) 删除Hierarchy面板上的除Ghost (3)以外的敌人的PointOfView。添加CollectedItems预制体并赋值

三、编辑答题面板预制体
1、设置面板

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

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

(3) 更改Questions的Image,Transform

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

2、添加test

(1) 添加文本。TitleText

(2) 添加按钮。OptionBtnA,按钮下文本的名字OptionTextA,更改文字字体,复制这个按钮得到四个选项按钮

(3) 将Questions制成预制体

(4) 制作题目

3、建立题库——简单题库

A. 创建ChoiceQuestion.cs(不用挂载的脚本)可以与其他脚本放在一起

定义问题类(包含一个问题(question字段)、四个选项(options数组)和正确答案的索引(correctOptionIndex字段))

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class Question
{
    public string question; // 问题文本
    public string[] options = new string[4]; // 选项数组,假设每个问题都有4个选项
    public int correctOptionIndex; // 正确答案的索引(0表示A,1表示B,依此类推)

    // 构造函数(可选),用于初始化问题
    public Question(string q, string[] opts, int correctIndex)
    {
        question = q;
        options = opts;
        correctOptionIndex = correctIndex;
    }
    // 检查答案是否正确
    public bool CheckAnswer(int playerChoice)
    {
        return playerChoice == correctOptionIndex;
    }
}

B. 在一个空物体上添加Exercises.cs,控制显示题目和选项、正误判断、答题后禁用按钮

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class Exercises : MonoBehaviour
{
    public Database_01 Database_01;//题库脚本
    public TextMeshProUGUI questionText;
    public Button[] optionButtons;

    private int currentQuestionIndex = 0; // 初始化当前问题索引为0


    public void ShowQuestion(int index)
    {
        if (index >= 0 && index < Database_01.questionsDatabase.Count)//如果index在questionsDatabase列表的有效范围内
        {
            // 显示题目(从列表中取出索引为index的问题,并将其文本内容显示在questionText的文本组件上)
            questionText.text = Database_01.questionsDatabase[index].question;

            // 显示选项(将Database_01中当前问题的选项文本显示在optionButtons数组或列表中的相应UI元素上)
            for (int i = 0; i < Database_01.questionsDatabase[index].options.Length; i++)
            {
                optionButtons[i].GetComponentInChildren<TextMeshProUGUI>().text = Database_01.questionsDatabase[index].options[i];
            }
        }
    }
    // 选项按钮的点击事件
    public void OnOptionButtonClicked(int buttonIndex)
    {

        foreach (var button in optionButtons)
        {
            button.interactable = false; // 设置为false以禁用按钮
        }
        // currentQuestionIndex:当前显示的问题的索引
        // 检查用户选择的答案是否正确
        bool isCorrect = Database_01.questionsDatabase[currentQuestionIndex].CheckAnswer(buttonIndex);

        // 根据检查结果执行相应的操作,比如更新UI、显示消息等
        if (isCorrect)
        {
            Debug.Log("回答正确!");
            currentQuestionIndex++; // 更新当前问题索引
        }
        else
        {
            Debug.Log("回答错误!");
        }
    }
}

C.给空物体添加Database_01.cs,以建立题库

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Database_01 : MonoBehaviour
{
    public List<Question> questionsDatabase = new List<Question>(); // 选择题数据库

    void Start()
    {
        // 初始化选择题数据库
        InitializeQuestions();
    }

    void InitializeQuestions()
    {
        //添加一个问题到数据库
        questionsDatabase.Add(new Question(
            "…………是?",
            new string[] { "A. ……", "B. ……", "C. ……", "D. ……" },
            0 // 假设"选项A"是正确答案,所以索引是0
        ));

        //添加一个问题到数据库
        questionsDatabase.Add(new Question(
            "…………",
            new string[] { "A. 复杂性", "B. 多样性", "C. 统一性", "D. 稳定性" },
            2 // 假设"选项C"是正确答案,所以索引是2
        ));
    }
}
4、建立题库——导入txt文本的方式

(1) 加载文本

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using TMPro;
using UnityEngine;

public class QuizManager : MonoBehaviour
{
    private Question currentQuestion;//存储当前展示的题目
    private List<Question> questionList;

    public TextMeshProUGUI questionTextComponent; // 用于显示题干的Text组件
    public TextMeshProUGUI optionATextComponent; // 用于显示选项A的Text组件
    public TextMeshProUGUI optionBTextComponent; // 用于显示选项B的Text组件
    public TextMeshProUGUI optionCTextComponent; // 用于显示选项C的Text组件
    public TextMeshProUGUI optionDTextComponent; // 用于显示选项D的Text组件

    void Start()
    {
        questionList = new List<Question>();
        LoadQuestionsFromTxt("QuestionBank.txt");
        GetRandomQuestion();
    }
    //加载文本文件
    void LoadQuestionsFromTxt(string filename)
    {
        // 组合文件的完整路径。Application.streamingAssetsPath是Unity的一个属性,
        // 指向StreamingAssets文件夹的路径
        string filePath = Path.Combine(Application.streamingAssetsPath, filename);
        // 检查文件是否存在
        if (File.Exists(filePath))
        {
            // 使用File.OpenText来打开文件,并创建一个StreamReader来读取内容
            using (StreamReader reader = File.OpenText(filePath))
            {
                // 声明一个字符串变量line,用于存储从文件中读取的每一行内容
                string line;
                // 逐行读取文件内容,直到读取到文件末尾
                while ((line = reader.ReadLine()) != null)
                {
                    // 使用 | 分隔每一行的内容
                    string[] data = line.Split('|');
                    // 检查是否至少有6个由竖线分隔的值(问题、四个选项和答案)
                    if (data.Length < 6)
                    {
                        Debug.LogError("Invalid line format in question file: " + line);
                        continue; // 跳过这一行,继续读取下一行
                    }
                    // 从分割后的数组中提取问题、选项和答案
                    string question = data[0];
                    string optionA = "A. " + data[1];
                    string optionB = "B. " + data[2];
                    string optionC = "C. " + data[3];
                    string optionD = "D. " + data[4];
                    string answer = data[5].ToUpper();

                    // 检查答案是否在给定的选项中
                    if (!IsValidAnswer(answer, optionA, optionB, optionC, optionD))
                    {
                        Debug.LogError("Invalid answer in question file: " + line);
                        continue; // 跳过这一行,继续读取下一行
                    }

                    // 创建一个新的Question对象,并将其添加到questionList列表中
                    Question newQuestion = new Question(question, optionA, optionB, optionC, optionD, answer.ToUpper());
                    questionList.Add(newQuestion);
                }
            }
        }
        else
        {
            Debug.LogError("Cannot find question file: " + filename);
        }
    }
    // 检查答案是否在给定的选项列表中
    bool IsValidAnswer(string answer, string optionA, string optionB, string optionC, string optionD)
    {
        //StringComparison.OrdinalIgnoreCase:确保比较时不区分大小写
        return answer.Equals("A", StringComparison.OrdinalIgnoreCase) ||
               answer.Equals("B", StringComparison.OrdinalIgnoreCase) ||
               answer.Equals("C", StringComparison.OrdinalIgnoreCase) ||
               answer.Equals("D", StringComparison.OrdinalIgnoreCase);
    }
    //从题目列表中随机选择一个题目,并将其赋值给currentQuestion变量
    public void GetRandomQuestion()
    {
        if (questionList.Count == 0)
        {
            Debug.LogError("No questions to display.");
            return;
        }
        int randomIndex = UnityEngine.Random.Range(0, questionList.Count);
        currentQuestion = questionList[randomIndex];
        questionList.RemoveAt(randomIndex);// 从列表中移除问题,防止重复
    }
        void UpdateQuestionDisplay()
        {
            // 分别设置各个Text组件的text属性
            questionTextComponent.text = currentQuestion.QuestionText;
            optionATextComponent.text = currentQuestion.OptionAText;
            optionBTextComponent.text = currentQuestion.OptionBText;
            optionCTextComponent.text = currentQuestion.OptionCText;
            optionDTextComponent.text = currentQuestion.OptionDText;
        }
    
    void OnUserAnswer()
    {
        // 处理用户答题后的操作

        // 获取下一个随机题目
        GetRandomQuestion();
        // 更新问题展示
        UpdateQuestionDisplay();
    }
}
// 定义一个名为Question的类,用于存储问题及其相关信息
[Serializable]
public class Question
{
    public string QuestionText;
    public string OptionAText;
    public string OptionBText;
    public string OptionCText;
    public string OptionDText;
    public string Answer; // 注意这里不需要ToUpper(),除非您有特定的需求

    public Question(string question, string optionA, string optionB, string optionC, string optionD, string answer)
    {
        QuestionText = question;
        OptionAText = optionA;
        OptionBText = optionB;
        OptionCText = optionC;
        OptionDText = optionD;
        Answer = answer;
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using TMPro;
using UnityEngine;

public class QuizManager : MonoBehaviour
{
    private Question currentQuestion;//存储当前展示的题目
    private List<Question> questionList;
    public TextMeshProUGUI questionText;

    void Start()
    {
        questionList = new List<Question>();
        LoadQuestionsFromTxt("QuestionBank.txt");
        GetRandomQuestion();
    }
    //加载文本文件
    void LoadQuestionsFromTxt(string filename)
    {
        // 组合文件的完整路径。Application.streamingAssetsPath是Unity的一个属性,
        // 指向StreamingAssets文件夹的路径
        string filePath = Path.Combine(Application.streamingAssetsPath, filename);
        // 检查文件是否存在
        if (File.Exists(filePath))
        {
            // 使用File.OpenText来打开文件,并创建一个StreamReader来读取内容
            using (StreamReader reader = File.OpenText(filePath))
            {
                // 声明一个字符串变量line,用于存储从文件中读取的每一行内容
                string line;
                // 逐行读取文件内容,直到读取到文件末尾
                while ((line = reader.ReadLine()) != null)
                {
                    // 使用 | 分隔每一行的内容
                    string[] data = line.Split('|');
                    // 检查是否至少有6个由竖线分隔的值(问题、四个选项和答案)
                    if (data.Length < 6)
                    {
                        Debug.LogError("Invalid line format in question file: " + line);
                        continue; // 跳过这一行,继续读取下一行
                    }
                    // 从分割后的数组中提取问题、选项和答案
                    string question = data[0];
                    string optionA = "A. " + data[1];
                    string optionB = "B. " + data[2];
                    string optionC = "C. " + data[3];
                    string optionD = "D. " + data[4];
                    string answer = data[5].ToUpper();

                    // 检查答案是否在给定的选项中
                    if (!IsValidAnswer(answer, optionA, optionB, optionC, optionD))
                    {
                        Debug.LogError("Invalid answer in question file: " + line);
                        continue; // 跳过这一行,继续读取下一行
                    }

                    // 创建一个新的Question对象,并将其添加到questionList列表中
                    Question newQuestion = new Question(question, optionA, optionB, optionC, optionD, answer.ToUpper());
                    questionList.Add(newQuestion);
                }
            }
        }
        else
        {
            Debug.LogError("Cannot find question file: " + filename);
        }
    }
    // 检查答案是否在给定的选项列表中
    bool IsValidAnswer(string answer, string optionA, string optionB, string optionC, string optionD)
    {
        //StringComparison.OrdinalIgnoreCase:确保比较时不区分大小写
        return answer.Equals("A", StringComparison.OrdinalIgnoreCase) ||
               answer.Equals("B", StringComparison.OrdinalIgnoreCase) ||
               answer.Equals("C", StringComparison.OrdinalIgnoreCase) ||
               answer.Equals("D", StringComparison.OrdinalIgnoreCase);
    }

    //从题目列表中随机选择一个题目,并将其赋值给currentQuestion变量
    public void GetRandomQuestion()
    {
        if (questionList.Count == 0)
        {
            Debug.LogError("No questions to display.");
            return;
        }
        int randomIndex = UnityEngine.Random.Range(0, questionList.Count);
        currentQuestion = questionList[randomIndex];
        questionList.RemoveAt(randomIndex);// 从列表中移除问题,防止重复
        string displayText = currentQuestion.QuestionText + "\n" + // 假设Question类有一个QuestionText属性
                             currentQuestion.OptionAText + "\n" + // 类似地,其他选项和答案也需要有相应的属性
                             currentQuestion.OptionBText + "\n" +
                             currentQuestion.OptionCText + "\n" +
                             currentQuestion.OptionDText;
        questionText.text = displayText;
    }
    void UpdateQuestionDisplay()
    {
        // 将currentQuestion的问题文本赋值
        // 将currentQuestion的问题文本赋值给questionText的text属性
        questionText.text = currentQuestion.QuestionText;
    }
    void OnUserAnswer()
    {
        // 处理用户答题后的操作

        // 获取下一个随机题目
        GetRandomQuestion();
        // 更新问题展示
        UpdateQuestionDisplay();
    }
}


// 定义一个名为Question的类,用于存储问题及其相关信息
[Serializable]
public class Question
{
    public string QuestionText;
    public string OptionAText;
    public string OptionBText;
    public string OptionCText;
    public string OptionDText;
    public string Answer; // 注意这里不需要ToUpper(),除非您有特定的需求

    public Question(string question, string optionA, string optionB, string optionC, string optionD, string answer)
    {
        QuestionText = question;
        OptionAText = optionA;
        OptionBText = optionB;
        OptionCText = optionC;
        OptionDText = optionD;
        Answer = answer;
    }
}

(1) 

(2) QuestionBank.txt文件位于Unity项目的StreamingAssets文件夹中,并且格式正确(即每行都有六个由 | 分隔的值)答案用ABCD表示

(3) 

(4)

4、设置调用test

(1) 给JohnLemon添加PlayerQuest.cs

5、判断正误

6、生命值脚本
using UnityEngine;

public class PlayerHealth : MonoBehaviour
{
    public int maxLives = 3;
    private int currentLives;

    private void Start()
    {
        currentLives = maxLives;
    }

    public void AddLife()
    {
        if (currentLives < maxLives)
        {
            currentLives++;
        }
    }

    public void LoseLife()
    {
        if (currentLives > 0)
        {
            currentLives--;
        }
        else
        {
            Debug.Log("角色死亡!退出游戏");
        }
    }
}

7、问题面板显示和隐藏脚本
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class QuestionCollision : MonoBehaviour
{
    public GameObject questionPanel;//问题面板
    public Button QuitBtn;
    public TextMeshProUGUI questionText;//问题文本
    public Button[] optionBtns;
    public PlayerHealth playerHealth;

    public void ShowQuestions(bool isQuestionActivated)
    {
        if (isQuestionActivated)
        {
            questionPanel.SetActive(true);
        }
        else
        {
            questionPanel.SetActive(false);
        }
        foreach (Button button in optionBtns)
        {
            button.onClick.AddListener(()=> CheckAnswer(button));
        }
    }
    public void OnClickQuitBtn()
    {
        questionPanel.SetActive(false);
    }
    void Start()
    {
        questionPanel.SetActive(false);
    }
    private void CheckAnswer(Button button)
    {
        if (button.CompareTag("CorrectAnswer"))
        {
            playerHealth.AddLife();
        }
        questionPanel.SetActive(false);
    }
}

    public List<Transform> bodyList = new List<Transform>();
    public GameObject bodyPrefab;
    public Sprite[] bodySprites = new Sprite[2];//数组中只含有2张图片
    private Transform canvas;
    private void Awake()
    {
        canvas = GameObject.Find("Canvas").transform;//找到Canvas的Transform
    }
    void BodyCreate()
    {
        //如果bodyList的元素数量是偶数,Index将被赋值为0。如果bodyList的元素数量是奇数,Index将被赋值为1
        int Index = (bodyList.Count % 2 == 0) ? 0 : 1;//bodyList.Count:列表中的元素数量(生成几种物体)
                                                      //bodyList.Count % 2:元素数量除以2,的余数
                                                      //bodyList.Count % 2 == 0:检查余数是否是0(是0,说明元素数量是偶数)
                                                      //? 0 : 1:如果元素数量是偶数(余数是0)则整个表达式的值是0。否则是1
        
        GameObject body = Instantiate(bodyPrefab,new Vector3(2000,2000,0),Quaternion.identity);//生成预制体在看不到的位置
        body.GetComponent<UnityImage>().sprite = bodySprites[Index];//从bodySprites数组中获取位于Index位置的图片
        body.transform.SetParent(canvas, false);//使Canvas成为body的父物体,而不使用它的世界坐标
        bodyList.Add(body.transform);
    }

ItemsBackground,ItemsText,TipText

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

使用 PyQt5 创建一个数字时钟

使用 PyQt5 创建一个数字时钟 效果代码解析定义时钟类初始化界面显示时间 完整代码 在这篇博客中&#xff0c;我们将使用 PyQt5 创建一个简单的数字时钟。 效果 代码解析 定义时钟类 class ClockWindow(QMainWindow):def __init__(self):super().__init__()self.setWindowTit…

Swift宏的实现

上篇介绍了Swift宏的定义与生声明&#xff0c;本篇主要看看是Swift宏的具体实现。结合Swift中Codable协议&#xff0c;封装一个工具让类或者结构体自动实现Codable协议&#xff0c;并且添加一些协议中没有的功能。 关于Codable协议 Codable很好&#xff0c;但是有一些缺陷&…

Redis基础教程(三):redis命令

&#x1f49d;&#x1f49d;&#x1f49d;首先&#xff0c;欢迎各位来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里不仅可以有所收获&#xff0c;同时也能感受到一份轻松欢乐的氛围&#xff0c;祝你生活愉快&#xff01; &#x1f49d;&#x1f49…

仓库管理系统11--物资设置

1、添加用户控件 <UserControl x:Class"West.StoreMgr.View.GoodsTypeView"xmlns"http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x"http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc"http://schemas.openxm…

sqlserver开启CDC

1、背景 由于需要学习flink cdc&#xff0c;并且数据选择sqlserver&#xff0c;所以这里记录sqlserver的cdc开启操作步骤。 2、基础前提 官方介绍地址&#xff1a;https://learn.microsoft.com/zh-cn/sql/relational-databases/track-changes/enable-and-disable-change-dat…

Ubuntu22.04 源码安装 PCL13+VTK-9.3+Qt6,踩坑记录

Ubuntu 22.04LTS;cmake-3.25.0;VTK-9.3;PCL-1.13;Qt6.6 PCL可以通过 apt 命令直接安装(sudo apt install libpcl-dev),apt 命令安装的 VTK 是简略版,没有对 Qt 支持的包,所以笔者使用源码安装 PCL 和 VTK。 1. 安装 VTK 1) 安装 ccmake 和 VTK 依赖项: sudo apt-g…

DataWhale-吃瓜教程学习笔记 (五)

学习视频&#xff1a;第4章-决策树_哔哩哔哩_bilibili 西瓜书对应章节&#xff1a; 第四章 4.1&#xff1b;4.2 文章目录 决策树算法原理- 逻辑角度- 几何角度 ID3 决策树- 自信息- 信息熵 &#xff08;自信息的期望&#xff09;- 条件熵 &#xff08; Y 的信息熵关于概率分布 …

从万里长城防御体系看软件安全体系建设@安全历史03

长城&#xff0c;是中华民族的一张重要名片&#xff0c;是中华民族坚韧不屈、自强不息的精神象征&#xff0c;被联合国教科文组织列入世界文化遗产名录。那么在古代&#xff0c;长城是如何以其复杂的防御体系&#xff0c;一次次抵御外族入侵&#xff0c;而这些防御体系又能给软…

HarmonyOS Next开发学习手册——创建轮播 (Swiper)

Swiper 组件提供滑动轮播显示的能力。Swiper本身是一个容器组件&#xff0c;当设置了多个子组件后&#xff0c;可以对这些子组件进行轮播显示。通常&#xff0c;在一些应用首页显示推荐的内容时&#xff0c;需要用到轮播显示的能力。 针对复杂页面场景&#xff0c;可以使用 Sw…

C++ sizeof的各种

C sizeof的各种 1. 含有虚函数的类对象的空间大小2. 虚拟继承的类对象的空间大小3. 普通变量所占空间大小4. 复合数据类型&#xff08;结构体和类&#xff09;5. 数组6. 类型别名7. 动态分配内存8. 指针9. 静态变量10. 联合体11. 结构体使用#program pack 1. 含有虚函数的类对象…

firewalld防火墙转发流量到其他端口forward port rules

假设云主机eth0: 47.93.27.106 tun0: inet 10.8.0.1 netmask 255.255.255.0 Show rules for a specific zone (public) sudo firewall-cmd --zonepublic --list-all Add the tun0 interface to the public zone: sudo firewall-cmd --zonepublic --add-interfacetun0 --…

关于图片大小问题造成的QPixmap或QImage读取图片失败的解决办法

今天碰到一个奇怪又离谱的问题 : 图片加载失败。明明路径是正确的&#xff0c;图片也实实在在存在。。。 经过比对&#xff0c;发现如下问题&#xff1a; 我就齐了怪了 这大小怎么差这么多&#xff1f;会不会是这里除了问题。秉持着怀疑的态度&#xff0c;我试着用GIMP重新导出…

机械设计简单介绍

机械设计简单介绍 1 介绍1.1 概述1.2 机械机构设计基本步骤1.3 关键1.3.1 静力学1.3.2 动力学1.3.3 运动学1.3.4 刚度学 1.4 示例【机械臂】 2 资料2.1 知识体系2.2 博客类汇总2.3 免费CAD模型获取2.4 3D打印2.5 SolidWorks 3 具备能力3.1 熟练翻阅 机械设计手册3.2 知道 N 家常…

【01-02】Mybatis的配置文件与基于XML的使用

1、引入日志 在这里我们引入SLF4J的日志门面&#xff0c;使用logback的具体日志实现&#xff1b;引入相关依赖&#xff1a; <!--日志的依赖--><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version&g…

Part 8.3.3 最近公共祖先

两个点的最近公共祖先&#xff0c;即两个点的所有公共祖先中&#xff0c;离根节点最远的一个节点。 【模板】最近公共祖先&#xff08;LCA&#xff09; 题目描述 如题&#xff0c;给定一棵有根多叉树&#xff0c;请求出指定两个点直接最近的公共祖先。 输入格式 第一行包含…

VMware虚拟机安装CentOS7.9 Oracle 11.2.0.4 RAC+单节点RAC ADG

目录 一、参考资料 二、RAC环境配置清单 1.主机环境 2.共享存储 3.IP地址 4.虚拟机 三、系统参数配置 1. 配置网卡 1.1 配置NAT网卡 1.2 配置HostOnly网卡 2. 修改主机名 3. 配置/etc/hosts 4. 关闭防火墙 5. 关闭Selinux 6. 配置内核参数 7. 配置grid、oracle…

vue3:星星评分组件

一、效果 二、代码 子组件stars.vue&#xff1a; <template><div class"stars"><div class"star" v-for"star in stars" :key"star" click"setScore(star)"><svgt"1719659437525"class&qu…

贪心算法题目总结

1. 整数替换 看到这道题目&#xff0c;我们首先能想到的方法就应该是递归解法&#xff0c;我们来画个图 此时我们出现了重复的子问题&#xff0c;就可以使用递归&#xff0c;只要我们遇到偶数&#xff0c;直接将n除以2递归下去&#xff0c;如果是奇数&#xff0c;选出加1和减1中…

面试框架一些小结

springcloud的⼯作原理 springcloud由以下⼏个核⼼组件构成&#xff1a; Eureka&#xff1a;各个服务启动时&#xff0c;Eureka Client都会将服务注册到Eureka Server&#xff0c;并且Eureka Client还可以反过来从Eureka Server拉取注册表&#xff0c; 从⽽知道其他服务在哪⾥ …

Java+JSP+Mysql+Tomcat实现Web图书管理系统

简介&#xff1a; 本项目是基于springspringmvcJdbcTemplate实现的图书馆管理系统&#xff0c;包含基本的增删改查功能&#xff0c;可作为JavaWeb初学者的入门学习案例。 环境要求&#xff1a; java8 mysql5.7及以下 eclipse最新版 项目目录 模块设计 页面设计 1. 登录页…