61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DragonLi.Core;
|
|
using Mirror;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class AirdropItem : NetworkBehaviour
|
|
{
|
|
public GunType type ;
|
|
public BoxCollider boxCollider;
|
|
public Rigidbody rigidbody;
|
|
|
|
private bool isDie;
|
|
|
|
private void Start()
|
|
{
|
|
if(rigidbody == null)
|
|
rigidbody = GetComponent<Rigidbody>();
|
|
boxCollider.enabled = isServer;
|
|
rigidbody.isKinematic = !isServer;
|
|
isDie = false;
|
|
if (isServer)
|
|
{
|
|
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
|
{
|
|
if (!isDie)
|
|
{
|
|
NetworkServer.Destroy(gameObject);
|
|
isDie = true;
|
|
}
|
|
}, 20);
|
|
}
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision other)
|
|
{
|
|
if (other.gameObject.tag == "Player")
|
|
{
|
|
var player = other.gameObject.GetComponent<Player>();
|
|
if (player != null)
|
|
{
|
|
GunInfo info = GameManager.Ins.GunInfos[type][1];
|
|
if (type == GunType.WuDiZhao)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
player.GiveAirdrop(player.connectionToClient,type,info.BulletAmount);
|
|
}
|
|
|
|
boxCollider.enabled = false;
|
|
isDie = true;
|
|
NetworkServer.Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|