丢弃按钮,捡起按钮

This commit is contained in:
杨号敬 2024-12-24 22:01:21 +08:00
parent dfd654db8d
commit 1b6e787ec6
3 changed files with 427 additions and 375 deletions

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,17 @@ public class UseSkill : MonoBehaviour
{
Skill_Watering();
Skill_Pick();
if (currentItem != null)
{
if(currentItem.gameObject.name=="gun")
{
float dis= Vector3.Distance(GameObject.Find("player").transform.position, XFS.instance.transform.position);
if (dis >= 20f)
{
Drop();
}
}
}
}
//Á¬½ÓË®¹Ü

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.EventSystems;
@ -11,6 +12,7 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler
public Camera playerCamera; // 摄像机
public float rotationSpeed = 0.5f; // 摄像机旋转速度
public Transform target;
// 旋转角度限制
public float horizontalMinRotation = -75f; // 水平旋转最小值
public float horizontalMaxRotation = 75f; // 水平旋转最大值
@ -40,6 +42,7 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler
{
if (joystickInput.magnitude > 0)
{
// 根据摇杆的输入控制摄像机旋转
targetXRotation += joystickInput.x * rotationSpeed * Time.deltaTime;
targetYRotation -= joystickInput.y * rotationSpeed * Time.deltaTime;
@ -52,6 +55,7 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler
// 使用 Quaternion 来平滑过渡到目标旋转角度
playerCamera.transform.localRotation = Quaternion.Euler(targetYRotation, targetXRotation, 0f);
}
}