Unity3D仿星露谷物語開發37之澆水動畫

1、目標

當點擊水壺時,實現澆水的動畫。同時有一個水從水壺中流出來的特效。

假如某個grid被澆過了,則不能再澆水了。。

如果某個grid沒有被dug過,也不能被澆水。

2、優化Settings.cs腳本

增加如下內容:

  public static float liftToolAnimationPause = 0.4f;public static float afterLiftToolAnimationPause = 0.4f;

3、優化Player.cs腳本

添加以下代碼:

private WaitForSeconds afterLiftToolAnimationPause;
private WaitForSeconds liftToolAnimationPause;// 在Start函數中添加如下代碼
liftToolAnimationPause = new WaitForSeconds(Settings.liftToolAnimationPause);
afterLiftToolAnimationPause = new WaitForSeconds(Settings.afterLiftToolAnimationPause);

在ProcessPlayerClickInput的switch中增加如下一行代碼:

在ProcessPlayerClickInputTool中增加如下代碼:

添加如下代碼:

 private void WaterGroundAtCursor(GridPropertyDetails gridPropertyDetails, Vector3Int playerDirection) { // Trigger animationStartCoroutine(WaterGroundAtCursorRoutine(playerDirection, gridPropertyDetails));}

添加如下代碼:

private IEnumerator WaterGroundAtCursorRoutine(Vector3Int playerDirection, GridPropertyDetails gridPropertyDetails) 
{PlayerInputIsDisabled = true;playerToolUseDisabled = true;// Set tool animation to watering can in override animationtoolCharacterAttribute.partVariantType = PartVariantType.wateringCan;characterAttributeCustomisationList.Clear();characterAttributeCustomisationList.Add(toolCharacterAttribute);animationOverrides.ApplyCharacterCustomisationParameters(characterAttributeCustomisationList);toolEffect = ToolEffect.watering;if(playerDirection == Vector3Int.right){isLiftingToolRight = true;}else if(playerDirection == Vector3Int.left){isLiftingToolLeft = true;}else if(playerDirection == Vector3Int.up){isLiftingToolUp = true;}else if(playerDirection == Vector3Int.down){isLiftingToolDown = true;}yield return liftToolAnimationPause;// Set Grid property details for watered groundif(gridPropertyDetails.daysSinceWatered == -1){gridPropertyDetails.daysSinceWatered = 0;}// Set grid property to wateredGridPropertiesManager.Instance.SetGridPropertyDetails(gridPropertyDetails.gridX, gridPropertyDetails.gridY, gridPropertyDetails);// After animation pauseyield return afterLiftToolAnimationPause;PlayerInputIsDisabled = false;playerToolUseDisabled = false;
}

其中:

ToolEffect.watering是枚舉值,值為1.

watering的觸發條件:

Player.cs完整代碼:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Player : SingletonMonobehaviour<Player>
{private WaitForSeconds afterUseToolAnimationPause;private WaitForSeconds useToolAnimationPause;private WaitForSeconds afterLiftToolAnimationPause;private WaitForSeconds liftToolAnimationPause;private bool playerToolUseDisabled = false;  // 如果玩家正在使用某個道具,其他道具將被禁用private AnimationOverrides animationOverrides;  // 動畫重寫控制器private GridCursor gridCursor;private List<CharacterAttribute> characterAttributeCustomisationList;  // 目標動作列表[Tooltip("Should be populated in the prefab with the equippped item sprite renderer")][SerializeField] private SpriteRenderer equippedItemSpriteRenderer = null; // 武器的圖片// Player attributes that can be swappedprivate CharacterAttribute armsCharacterAttribute;private CharacterAttribute toolCharacterAttribute;private float xInput;private float yInput;private bool isWalking;private bool isRunning;private bool isIdle;private bool isCarrying = false;private ToolEffect toolEffect = ToolEffect.none;private bool isUsingToolRight;private bool isUsingToolLeft;private bool isUsingToolUp;private bool isUsingToolDown;private bool isLiftingToolRight;private bool isLiftingToolLeft;private bool isLiftingToolUp;private bool isLiftingToolDown;private bool isPickingRight;private bool isPickingLeft;private bool isPickingUp;private bool isPickingDown;private bool isSwingToolRight;private bool isSwingToolLeft;private bool isSwingToolUp;private bool isSwingToolDown;private Camera mainCamera;private Rigidbody2D rigidbody2D;private Direction playerDirection;private float movementSpeed;private bool _playerInputIsDisabled = false;public bool PlayerInputIsDisabled { get => _playerInputIsDisabled; set => _playerInputIsDisabled = value; }protected override void Awake(){base.Awake();rigidbody2D = GetComponent<Rigidbody2D>();animationOverrides = GetComponentInChildren<AnimationOverrides>();// Initialise swappable character attributesarmsCharacterAttribute = new CharacterAttribute(CharacterPartAnimator.arms, PartVariantColour.none, PartVariantType.none);// Initialise character attribute listcharacterAttributeCustomisationList = new List<CharacterAttribute>();mainCamera = Camera.main;}private void Start(){gridCursor = FindObjectOfType<GridCursor>();useToolAnimationPause = new WaitForSeconds(Settings.useToolAnimationPause);afterUseToolAnimationPause = new WaitForSeconds(Settings.afterUseToolAnimationPause);liftToolAnimationPause = new WaitForSeconds(Settings.liftToolAnimationPause);afterLiftToolAnimationPause = new WaitForSeconds(Settings.afterLiftToolAnimationPause);}private void Update(){#region  Player Inputif (!PlayerInputIsDisabled){ResetAnimationTrigger();PlayerMovementInput();PlayerWalkInput();PlayerClickInput();PlayerTestInput();// Send event to any listeners for player movement inputEventHandler.CallMovementEvent(xInput, yInput, isWalking, isRunning, isIdle, isCarrying, toolEffect,isUsingToolRight, isUsingToolLeft, isUsingToolUp, isUsingToolDown,isLiftingToolRight, isLiftingToolLeft, isLiftingToolUp, isLiftingToolDown,isPickingRight, isPickingLeft, isPickingUp, isPickingDown,isSwingToolRight, isSwingToolLeft, isSwingToolUp, isSwingToolDown,false, false, false, false);}#endregion Player Input}private void FixedUpdate(){PlayerMovement();}/// <summary>/// 展示拿東西的動畫/// </summary>/// <param name="itemCode"></param>public void ShowCarriedItem(int itemCode){ItemDetails itemDetails = InventoryManager.Instance.GetItemDetails(itemCode);if(itemDetails != null){equippedItemSpriteRenderer.sprite = itemDetails.itemSprite;equippedItemSpriteRenderer.color = new Color(1f, 1f, 1f, 1f);// Apply 'carry' character arms customisationarmsCharacterAttribute.partVariantType = PartVariantType.carry;characterAttributeCustomisationList.Clear();characterAttributeCustomisationList.Add(armsCharacterAttribute);animationOverrides.ApplyCharacterCustomisationParameters(characterAttributeCustomisationList);isCarrying = true;}}public void ClearCarriedItem(){equippedItemSpriteRenderer.sprite = null;equippedItemSpriteRenderer.color = new Color(1f, 1f, 1f, 0f);// Apply base character arms customisationarmsCharacterAttribute.partVariantType = PartVariantType.none;characterAttributeCustomisationList.Clear();characterAttributeCustomisationList.Add(armsCharacterAttribute);animationOverrides.ApplyCharacterCustomisationParameters(characterAttributeCustomisationList);isCarrying = false;}private void PlayerMovement(){Vector2 move = new Vector2(xInput * movementSpeed * Time.deltaTime, yInput * movementSpeed * Time.deltaTime);rigidbody2D.MovePosition(rigidbody2D.position + move);}private void ResetAnimationTrigger(){toolEffect = ToolEffect.none;isUsingToolRight = false;isUsingToolLeft = false;isUsingToolUp = false;isUsingToolDown = false;isLiftingToolRight = false;isLiftingToolLeft = false;isLiftingToolUp = false;isLiftingToolDown = false;isPickingRight = false;isPickingLeft = false;isPickingUp = false;isPickingDown = false;isSwingToolRight = false;isSwingToolLeft = false;isSwingToolUp = false;isSwingToolDown = false;}private void PlayerMovementInput(){xInput = Input.GetAxisRaw("Horizontal");yInput = Input.GetAxisRaw("Vertical");// 斜著移動if (xInput != 0 && yInput != 0) {xInput = xInput * 0.71f;yInput = yInput * 0.71f;}// 在移動if (xInput != 0 || yInput != 0) {isRunning = true;isWalking = false;isIdle = false;movementSpeed = Settings.runningSpeed;// Capture player direction for save gameif (xInput < 0){playerDirection = Direction.left;}else if (xInput > 0){playerDirection = Direction.right;}else if (yInput < 0){playerDirection = Direction.down;}else{playerDirection = Direction.up;}}else if(xInput == 0 && yInput == 0){isRunning = false;isWalking = false;isIdle = true;}}// 按住Shift鍵移動為walkprivate void PlayerWalkInput(){if(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)){isRunning = false;isWalking = true;isIdle = false;movementSpeed = Settings.walkingSpeed;}else{isRunning = true;isWalking = false;isIdle = false;movementSpeed = Settings.runningSpeed;}}private void PlayerClickInput(){if (!playerToolUseDisabled){if (Input.GetMouseButton(0)){if (gridCursor.CursorIsEnabled){// Get Cursor Grid PositionVector3Int cursorGridPosition = gridCursor.GetGridPositionForCursor();// Get Player Grid PositionVector3Int playerGridPosition = gridCursor.GetGridPositionForPlayer();ProcessPlayerClickInput(cursorGridPosition, playerGridPosition);}}}}private void ProcessPlayerClickInput(Vector3Int cursorGridPosition, Vector3Int playerGridPosition){ResetMovement();Vector3Int playerDirection = GetPlayerClickDirection(cursorGridPosition, playerGridPosition);// Get Selected item detailsItemDetails itemDetails = InventoryManager.Instance.GetSelectedInventoryItemDetails(InventoryLocation.player);// Get Grid property details at cursor position (the GridCursor validation routine ensures that grid property details are not null)GridPropertyDetails gridPropertyDetails = GridPropertiesManager.Instance.GetGridPropertyDetails(cursorGridPosition.x, cursorGridPosition.y);if(itemDetails != null){switch (itemDetails.itemType){case ItemType.Seed:if (Input.GetMouseButtonDown(0)){ProcessPlayerClickInputSeed(itemDetails);}break;case ItemType.Commodity:if (Input.GetMouseButtonDown(0)){ProcessPlayerClickInputCommodity(itemDetails);}break;case ItemType.Watering_tool:case ItemType.Hoeing_tool:ProcessPlayerClickInputTool(gridPropertyDetails, itemDetails, playerDirection);break;case ItemType.none:break;case ItemType.count:break;default:break;}}}private Vector3Int GetPlayerClickDirection(Vector3Int cursorGridPosition, Vector3Int playerGridPosition) {if(cursorGridPosition.x > playerGridPosition.x){return Vector3Int.right;}else if(cursorGridPosition.x < playerGridPosition.x){return Vector3Int.left;}else if(cursorGridPosition.y > playerGridPosition.y){return Vector3Int.up;}else{return Vector3Int.down;}}private void ProcessPlayerClickInputSeed(ItemDetails itemDetails){if(itemDetails.canBeDropped && gridCursor.CursorPositionIsValid){EventHandler.CallDropSelectedItemEvent();}}private void ProcessPlayerClickInputCommodity(ItemDetails itemDetails){if(itemDetails.canBeDropped && gridCursor.CursorPositionIsValid){EventHandler.CallDropSelectedItemEvent();}}private void ProcessPlayerClickInputTool(GridPropertyDetails gridPropertyDetails, ItemDetails itemDetails, Vector3Int playerDirection){// Switch on toolswitch (itemDetails.itemType){case ItemType.Hoeing_tool:if (gridCursor.CursorPositionIsValid){HoeGroundAtCursor(gridPropertyDetails, playerDirection);}break;case ItemType.Watering_tool:if (gridCursor.CursorPositionIsValid){WaterGroundAtCursor(gridPropertyDetails, playerDirection);}break;default:break;}}private void WaterGroundAtCursor(GridPropertyDetails gridPropertyDetails, Vector3Int playerDirection) { // Trigger animationStartCoroutine(WaterGroundAtCursorRoutine(playerDirection, gridPropertyDetails));}private IEnumerator WaterGroundAtCursorRoutine(Vector3Int playerDirection, GridPropertyDetails gridPropertyDetails) {PlayerInputIsDisabled = true;playerToolUseDisabled = true;// Set tool animation to watering can in override animationtoolCharacterAttribute.partVariantType = PartVariantType.wateringCan;characterAttributeCustomisationList.Clear();characterAttributeCustomisationList.Add(toolCharacterAttribute);animationOverrides.ApplyCharacterCustomisationParameters(characterAttributeCustomisationList);toolEffect = ToolEffect.watering;if(playerDirection == Vector3Int.right){isLiftingToolRight = true;}else if(playerDirection == Vector3Int.left){isLiftingToolLeft = true;}else if(playerDirection == Vector3Int.up){isLiftingToolUp = true;}else if(playerDirection == Vector3Int.down){isLiftingToolDown = true;}yield return liftToolAnimationPause;// Set Grid property details for watered groundif(gridPropertyDetails.daysSinceWatered == -1){gridPropertyDetails.daysSinceWatered = 0;}// Set grid property to wateredGridPropertiesManager.Instance.SetGridPropertyDetails(gridPropertyDetails.gridX, gridPropertyDetails.gridY, gridPropertyDetails);// After animation pauseyield return afterLiftToolAnimationPause;PlayerInputIsDisabled = false;playerToolUseDisabled = false;}private void HoeGroundAtCursor(GridPropertyDetails gridPropertyDetails, Vector3Int playerDirection) {// Trigger animationStartCoroutine(HoeGroundAtCursorRoutine(playerDirection, gridPropertyDetails));}private IEnumerator HoeGroundAtCursorRoutine(Vector3Int playerDirection, GridPropertyDetails gridPropertyDetails){PlayerInputIsDisabled = true;playerToolUseDisabled = true;// Set tool animation to hoe in override animationtoolCharacterAttribute.partVariantType = PartVariantType.hoe;characterAttributeCustomisationList.Clear();characterAttributeCustomisationList.Add(toolCharacterAttribute);animationOverrides.ApplyCharacterCustomisationParameters(characterAttributeCustomisationList);if(playerDirection == Vector3Int.right){isUsingToolRight = true;}else if(playerDirection == Vector3Int.left){isUsingToolLeft = true;}else if(playerDirection == Vector3Int.up){isUsingToolUp = true;}else if(playerDirection == Vector3Int.down){isUsingToolDown = true;}yield return useToolAnimationPause;// Set Grid property details for dug groundif(gridPropertyDetails.daysSinceDug == -1){gridPropertyDetails.daysSinceDug = 0;}// Set grid property to dugGridPropertiesManager.Instance.SetGridPropertyDetails(gridPropertyDetails.gridX, gridPropertyDetails.gridY, gridPropertyDetails);// Display dug grid tilesGridPropertiesManager.Instance.DisplayDugGround(gridPropertyDetails);// After animation pauseyield return afterUseToolAnimationPause;PlayerInputIsDisabled = false;playerToolUseDisabled = false;}public Vector3 GetPlayerViewportPosition(){// Vector3 viewport position for player (0,0) viewport bottom left, (1,1) viewport top rightreturn mainCamera.WorldToViewportPoint(gameObject.transform.position);}public void DisablePlayerInputAndResetMovement(){DisablePlayerInpupt();ResetMovement();// Send event to any listeners for player movement inputEventHandler.CallMovementEvent(xInput, yInput, isWalking, isRunning, isIdle, isCarrying, toolEffect,isUsingToolRight, isUsingToolLeft, isUsingToolUp, isUsingToolDown,isLiftingToolRight, isLiftingToolLeft, isLiftingToolUp, isLiftingToolDown,isPickingRight, isPickingLeft, isPickingUp, isPickingDown,isSwingToolRight, isSwingToolLeft, isSwingToolUp, isSwingToolDown,false, false, false, false);}private void ResetMovement(){// Reset movementxInput = 0f;yInput = 0f;isRunning = false;isWalking = false;isIdle = true;}public void DisablePlayerInpupt(){PlayerInputIsDisabled = true;}public void EnablePlayerInput(){PlayerInputIsDisabled = false;}/// <summary>/// Temp routine for test input/// </summary>private void PlayerTestInput(){// Trigger Advance Timeif (Input.GetKeyDown(KeyCode.T)){TimeManager.Instance.TestAdvanceGameMinute();}// Trigger Advance Dayif (Input.GetKeyDown(KeyCode.G)){TimeManager.Instance.TestAdvanceGameDay();}// Test scene unload / loadif (Input.GetKeyDown(KeyCode.L)){SceneControllerManager.Instance.FadeAndLoadScene(SceneName.Scene1_Farm.ToString(), transform.position);}}
}

4、優化GridCursor.cs腳本

1)調整SetCursorValidity的邏輯。

增加如下一行代碼:

2)調整IsCursorValidForTool的邏輯。

添加如下代碼:

其完整代碼如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class GridCursor : MonoBehaviour
{private Canvas canvas; // 存儲白色畫布,UI光標位于其中private Grid grid;  // tilemap地圖private Camera mainCamera; // 對主相機的引用[SerializeField] private Image cursorImage = null;[SerializeField] private RectTransform cursorRectTransform = null;  // 光標對象的引用[SerializeField] private Sprite greenCursorSprite = null;[SerializeField] private Sprite redCursorSprite = null;private bool _cursorPositionIsValid = false;public bool CursorPositionIsValid { get => _cursorPositionIsValid; set => _cursorPositionIsValid = value; }private int _itemUseGridRadius = 0;public int ItemUseGridRadius { get => _itemUseGridRadius; set => _itemUseGridRadius = value; }private ItemType _selectedItemType;public ItemType SelectedItemType { get => _selectedItemType; set => _selectedItemType = value; }private bool _cursorIsEnabled = false;public bool CursorIsEnabled { get => _cursorIsEnabled; set => _cursorIsEnabled = value; }private void OnDisable(){EventHandler.AfterSceneLoadEvent -= SceneLoaded;}private void OnEnable(){EventHandler.AfterSceneLoadEvent += SceneLoaded;}// Start is called before the first frame updatevoid Start(){mainCamera = Camera.main;canvas = GetComponentInParent<Canvas>();}// Update is called once per framevoid Update(){if (CursorIsEnabled){DisplayCursor();}}private Vector3Int DisplayCursor(){if (grid != null){   // 之所以需要Grid是因為某些定位是基于grid的// Get grid position for cursorVector3Int gridPosition = GetGridPositionForCursor();// Get grid position for playerVector3Int playerGridPosition = GetGridPositionForPlayer();// Set cursor sprite,基于gridPosition和playerGridPosition設置光標的有效性SetCursorValidity(gridPosition, playerGridPosition);// Get rect transform position for cursorcursorRectTransform.position = GetRectTransformPositionForCursor(gridPosition);return gridPosition;}else{return Vector3Int.zero;}}public Vector3Int GetGridPositionForCursor(){// z is how far the objects are in front of the camera - camera is at -10 so objects are(-)-10 in front = 10Vector3 worldPosition = mainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -mainCamera.transform.position.z));return grid.WorldToCell(worldPosition);}public Vector3Int GetGridPositionForPlayer(){return grid.WorldToCell(Player.Instance.transform.position);}public Vector2 GetRectTransformPositionForCursor(Vector3Int gridPosition){Vector3 gridWorldPosition = grid.CellToWorld(gridPosition);Vector2 gridScreenPosition = mainCamera.WorldToScreenPoint(gridWorldPosition);return RectTransformUtility.PixelAdjustPoint(gridScreenPosition, cursorRectTransform, canvas);}private void SceneLoaded(){grid = GameObject.FindObjectOfType<Grid>();}private void SetCursorValidity(Vector3Int cursorGridPosition, Vector3Int playerGridPosition){SetCursorToValid();// Check item use radius is validif(Mathf.Abs(cursorGridPosition.x -  playerGridPosition.x) > ItemUseGridRadius|| Mathf.Abs(cursorGridPosition.y - playerGridPosition.y) > ItemUseGridRadius){SetCursorToInvalid();return;}// Get selected item details ItemDetails itemDetails = InventoryManager.Instance.GetSelectedInventoryItemDetails(InventoryLocation.player);if(itemDetails == null){SetCursorToInvalid();return;}// Get grid property details at cursor positionGridPropertyDetails gridPropertyDetails = GridPropertiesManager.Instance.GetGridPropertyDetails(cursorGridPosition.x, cursorGridPosition.y);if(gridPropertyDetails != null){// Determine cursor validity based on inventory item selected and grid property detailsswitch (itemDetails.itemType){case ItemType.Seed:if (!IsCursorValidForSeed(gridPropertyDetails)){SetCursorToInvalid();return;}break;case ItemType.Commodity:if (!IsCursorValidForCommodity(gridPropertyDetails)){SetCursorToInvalid();return;}break;case ItemType.Watering_tool:case ItemType.Hoeing_tool:if(!IsCursorValidForTool(gridPropertyDetails, itemDetails)){SetCursorToInvalid();return;}break;case ItemType.none:break;case ItemType.count:break;default:break;}}else{SetCursorToInvalid();return;}}private bool IsCursorValidForSeed(GridPropertyDetails gridPropertyDetails){return gridPropertyDetails.canDropItem;}private bool IsCursorValidForCommodity(GridPropertyDetails gridPropertyDetails){return gridPropertyDetails.canDropItem;}/// <summary>/// Sets the cursor as either valid or invalid for the tool for the target gridPropertyDetails. /// Returns true if valid or false if invalid/// </summary>/// <param name="gridPropertyDetails"></param>/// <param name="itemDetails"></param>/// <returns></returns>private bool IsCursorValidForTool(GridPropertyDetails gridPropertyDetails, ItemDetails itemDetails){// Switch on toolswitch (itemDetails.itemType){case ItemType.Hoeing_tool:if (gridPropertyDetails.isDiggable == true && gridPropertyDetails.daysSinceDug == -1){#region Need to get any items at location so we can check if they are reapable// Get world position for cursorVector3 cursorWorldPosition = new Vector3(GetWorldPositionForCursor().x + 0.5f, GetWorldPositionForCursor().y + 0.5f, 0f);// Get list of items at cursor locationList<Item> itemList = new List<Item>();HelperMethods.GetComponentsAtBoxLocation<Item>(out itemList, cursorWorldPosition, Settings.cursorSize, 0f);#endregion// Loop through items found to see if any are reapable type - we are not goint to let the player dig where there are reapable scenary itemsbool foundReapable = false;foreach(Item item in itemList){if(InventoryManager.Instance.GetItemDetails(item.ItemCode).itemType == ItemType.Reapable_scenary){foundReapable = true;break;}}if (foundReapable){return false;}else{return true;}}else{return false;}case ItemType.Watering_tool:if(gridPropertyDetails.daysSinceDug > -1 && gridPropertyDetails.daysSinceWatered == -1){return true;}else{return false;}default:return false;}}private void SetCursorToValid(){cursorImage.sprite = greenCursorSprite;CursorPositionIsValid = true;}private void SetCursorToInvalid(){cursorImage.sprite = redCursorSprite;CursorPositionIsValid = false;}/// <summary>/// DisableCursor is called in the UIInventorySlot.ClearCursors() method when an inventory slot item is no longer selected/// </summary>public void DisableCursor(){cursorImage.color = Color.clear;CursorIsEnabled = false;}/// <summary>/// EnableCursor is called in the UIInventorySlot.SetSelectedItem() method when an inventory slot item is selected and its itemUseGrid radius>0/// </summary>public void EnableCursor(){cursorImage.color = new Color(1f, 1f, 1f, 1f);CursorIsEnabled = true;}public Vector3 GetWorldPositionForCursor(){return grid.CellToWorld(GetGridPositionForCursor());}}

5、設置澆水半徑

默認情況下也是1,無需改動。

6、運行游戲

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/77677.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/77677.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/77677.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【2】Kubernetes 架構總覽

Kubernetes 架構總覽 主節點與工作節點 主節點 Kubernetes 的主節點&#xff08;Master&#xff09;是組成集群控制平面的關鍵部分&#xff0c;負責整個集群的調度、狀態管理和決策。控制平面由多個核心組件構成&#xff0c;包括&#xff1a; kube-apiserver&#xff1a;集…

如何對docker鏡像存在的gosu安全漏洞進行修復——筑夢之路

這里以mysql的官方鏡像為例進行說明&#xff0c;主要流程為&#xff1a; 1. 分析鏡像存在的安全漏洞具體是什么 2. 根據分析結果有針對性地進行修復處理 3. 基于當前鏡像進行修復安全漏洞并復核驗證 # 鏡像地址mysql:8.0.42 安全漏洞現狀分析 dockerhub網站上獲取該鏡像的…

【Tauri2】026——Tauri+Webassembly

前言 不多廢話 直言的說&#xff0c;筆者看到這篇文章大佬的文章 【04】Tauri 入門篇 - 集成 WebAssembly - 知乎https://zhuanlan.zhihu.com/p/533025312嘗試集成一下WebAssembly&#xff0c;直接開始 正文 準備工作 新建一個項目 安裝 vite的rsw插件和rsw pnpm instal…

OpenHarmony Camera開發指導(五):相機預覽功能(ArkTS)

預覽是在相機啟動后實時顯示場景畫面&#xff0c;通常在拍照和錄像前執行。 開發步驟 創建預覽Surface 如果想在屏幕上顯示預覽畫面&#xff0c;一般由XComponent組件為預覽流提供Surface&#xff08;通過XComponent的getXcomponentSurfaceId方法獲取surfaceid&#xff09;&…

puzzle(0531)腦力航跡

目錄 腦力航跡 規則 解法 簡單模式 中等模式 困難模式 專家模式 腦力航跡 規則 2條航跡會產生一個相對航跡&#xff1a; 根據相對航跡和其中一個航跡推導另外一個航跡。 解法 沒有任何需要推理的地方&#xff0c;就是純粹的2個矢量相加。 簡單模式 中等模式 困難模…

在win上安裝Ubuntu安裝Anaconda(linx環境)

一&#xff0c;安裝Ubuntu 1. 在 Microsoft 商城去下載Ubuntu(LTS:是長期維護的版本) 2.安裝完之后啟動程序&#xff0c;再重新打開一個黑窗口&#xff1a; wsl --list --verbose 3.關閉Ubuntu wsl --shutdown Ubuntu-22.04 WSL2 Ubuntu-20.04文件太占c盤空間&#xff0c;…

NEAT 算法解決 Lunar Lander 問題:從理論到實踐

NEAT 算法解決 Lunar Lander 問題:從理論到實踐 0. 前言1. 定義環境2. 配置 NEAT3. 解決 Lunar lander 問題小結系列鏈接0. 前言 在使用 NEAT 解決強化學習問題一節所用的方法只適用于較簡單的強化學習 (reinforcement learning, RL) 環境。在更復雜的環境中使用同樣的進化解…

【KWDB 創作者計劃】_上位機知識篇---ESP32-S3Arduino

文章目錄 前言1. ESP32-S3核心特性2. 開發環境搭建(1) 安裝Arduino IDE(2) 添加ESP32-S3支持(3) 選擇開發板(4) 關鍵配置3. 基礎代碼示例(1) 串口通信(USB/硬件串口)(2) Wi-Fi連接(3) 藍牙LE廣播4. 高級功能開發(1) USB OTG功能(2) AI加速(MicroTensorFlow)(3) 雙核任務處理…

JavaScript學習教程,從入門到精通,DOM節點操作語法知識點及案例詳解(21)

DOM節點操作語法知識點及案例詳解 一、語法知識點 1. 獲取節點 // 通過ID獲取 const element document.getElementById(idName);// 通過類名獲取&#xff08;返回HTMLCollection&#xff09; const elements document.getElementsByClassName(className);// 通過標簽名獲取…

PCA 降維實戰:從原理到電信客戶流失數據應用

一、簡介 在機器學習領域&#xff0c;數據的特征維度往往較高&#xff0c;這不僅會增加計算的復雜度&#xff0c;還可能導致過擬合等問題。主成分分析&#xff08;Principal Component Analysis&#xff0c;簡稱 PCA&#xff09;作為一種經典的降維技術&#xff0c;能夠在保留數…

信創時代編程開發語言選擇指南:國產替代背景下的技術路徑與實踐建議

&#x1f9d1; 博主簡介&#xff1a;CSDN博客專家、CSDN平臺優質創作者&#xff0c;高級開發工程師&#xff0c;數學專業&#xff0c;10年以上C/C, C#, Java等多種編程語言開發經驗&#xff0c;擁有高級工程師證書&#xff1b;擅長C/C、C#等開發語言&#xff0c;熟悉Java常用開…

Arcgis10.1的漢化包及破解文件分享

Arcgis10.1的漢化包分享 網上有好多10.2的漢化包&#xff0c;但是10.1的漢化包很少&#xff0c;特在此分析出來給大家 Arcgis10.1破解文件及漢化包: (訪問密碼: 9784) license manager破解安裝文件 另外也分享了license manager破解安裝文件&#xff0c;也在相同的分享鏈接里…

CrewAI Community Version(一)——初步了解以及QuickStart樣例

目錄 1. CrewAI簡介1.1 CrewAI Crews1.2 CrewAI Flows1.3 Crews和Flows的使用情景 2. CrewAI安裝2.1 安裝uv2.2 安裝CrewAI CLI 3. 官網QuickStart樣例3.1 創建CrewAI Crews項目3.2 項目結構3.3 .env3.4 智能體角色及其任務3.4.1 agents.yaml3.4.2 tasks.yaml 3.5 crew.py3.6 m…

word選中所有的表格——宏

Sub 選中所有表格()Dim aTable As TableApplication.ScreenUpdating FalseActiveDocument.DeleteAllEditableRanges wdEditorEveryoneFor Each aTable In ActiveDocument.TablesaTable.Range.Editors.Add wdEditorEveryoneNextActiveDocument.SelectAllEditableRanges wdEdito…

Tkinter與ttk模塊對比:構建現代 Python GUI 的進化之路

在 Python GUI 開發中&#xff0c;標準庫 tkinter 及其子模塊 ttk&#xff08;Themed Tkinter&#xff09;常被同時使用。本文通過功能對比和實際案例&#xff0c;簡單介紹這兩個模塊的核心差異。 1. 區別 Tkinter&#xff1a;Python 標準 GUI 工具包&#xff08;1994年集成&…

Linux系統之部署Dillinger個人文本編輯器

Linux系統之部署Dillinger個人文本編輯器 一、Dillinger介紹1.1 Dillinger簡介1.2 Dillinger特點1.3 使用場景二、本地環境介紹2.1 本地環境規劃2.2 本次實踐介紹三、檢查本地環境3.1 檢查本地操作系統版本3.2 檢查系統內核版本四、部署Node.js 環境4.1 下載Node.js安裝包4.2 解…

從malloc到free:動態內存管理全解析

1.為什么要有動態內存管理 我們已經掌握的內存開辟方法有&#xff1a; int main() {int val 20;//在棧空間上開辟四個字節char arr[20] { 0 };//在棧空間上開辟10個字節的連續空間return 0; }上述開辟的內存空間有兩個特點&#xff1a; 1.空間開辟的時候大小已經固定 2.數組…

健身房管理系統設計與實現(springboot+ssm+vue+mysql)含萬字詳細文檔

健身房管理系統設計與實現(springbootssmvuemysql)含萬字詳細文檔 健身房管理系統是一個全面的解決方案&#xff0c;旨在幫助健身房高效管理日常運營。系統主要功能模塊包括個人中心、會員管理、員工管理、會員卡管理、會員卡類型管理、教練信息管理、解聘管理、健身項目管理、…

seate TCC模式案例

場景描述 用戶下單時&#xff0c;需要創建訂單并從用戶賬戶中扣除相應的余額。如果訂單創建成功但余額劃扣失敗&#xff0c;則需要回滾訂單創建操作。使用 Seata 的 TCC 模式來保證分布式事務的一致性。 1. 項目結構 假設我們有兩個微服務&#xff1a; Order Service&#x…

【Linux】Rhcsa復習5

一、Linux文件系統權限 1、文件的一般權限 文件權限針對三類對象進行定義&#xff1a; owner 屬主&#xff0c;縮寫u group 屬組&#xff0c; 縮寫g other 其他&#xff0c;縮寫o 每個文件針對每類訪問者定義了三種主要權限&#xff1a; r&#xff1a;read 讀 w&…