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

49 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using DragonLi.Core;
using Mirror;
using UnityEngine;
using Valheim;
public class ItemBox : NetworkBehaviour
{
public Animator animator;
public GameObject boom;
private PropItem prop;
private bool isUp;
public void Init()
{
boom.SetActive(false);
int randomId=UnityEngine.Random.Range(1, GameManager.Ins.itemPres.Count+1);
prop=GameManager.Ins.CreateItem(randomId,transform.position,true);
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Weapon"))
{
animator.SetBool("isBoom",true);
boom.SetActive(true);
if(prop!=null)
prop.Amplify();
// transform.DOScale(Vector3.one * 0.2f, 0.5f).OnComplete(() =>
// {
// transform.DOScale(Vector3.one, 0.5f).OnComplete(() =>
// {
//
// });
// });
}
}
public void Del()
{
NetworkServer.Destroy(gameObject);
}
}