Files
valheim/Assets/_Valheim/Scripts/Item/PropItem.cs
2025-07-04 14:16:14 +08:00

53 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
using Valheim;
public class PropItem : MonoBehaviour
{
public int id;
public GameObject sparkle;
public WeaponType weaponType;
public int amount;
public int atk;
public void Init(WeaponType type)
{
weaponType = type;
}
public void Reduce()
{
transform.localScale=Vector3.zero;
sparkle.SetActive(false);
}
public void Amplify()
{
transform.localScale=Vector3.one;
sparkle.SetActive(true);
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Weapon"))
{
var weapons=other.transform.parent.GetComponent<IceStaff>();
foreach (var item in MRNetworkManager.Ins.roomSlots)
{
var player = item.GetComponent<Player>();
if (weapons.playerId == player.index)
{
player.PickUpWeapon(weaponType,amount,atk);
StartCoroutine(GameManager.Ins.PlayAudio("道具拾取音效",transform,true));
NetworkServer.Destroy(gameObject);
}
}
}
}
}