62 lines
1.4 KiB
C#
62 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using DragonLi.Core;
|
|
using JetBrains.Annotations;
|
|
using UnityEngine;
|
|
using UnityEngine.PlayerLoop;
|
|
|
|
public class WeaponProp : MonoBehaviour
|
|
{
|
|
public Collider box;
|
|
public GameObject[] weapons;
|
|
[NonSerialized]
|
|
public PlayerWeaponType weaponType;
|
|
|
|
[NonSerialized]
|
|
public int amount = 0;
|
|
|
|
|
|
public AudioSource audioSource;
|
|
|
|
private bool _isDes;
|
|
|
|
public void Init(PlayerWeaponType type)
|
|
{
|
|
weaponType = type;
|
|
_isDes = false;
|
|
amount=GameManager.Ins.PlayerBulletDataDic[(int)type].Number;
|
|
ShowWeapon(type);
|
|
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
|
{
|
|
if(!_isDes)
|
|
Destroy(gameObject);
|
|
},60);
|
|
}
|
|
|
|
public void ShowWeapon(PlayerWeaponType type)
|
|
{
|
|
for (int i = 0; i < weapons.Length; i++)
|
|
{
|
|
weapons[i].SetActive(false);
|
|
}
|
|
weapons[(int)type-1].SetActive(true);
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
transform.DORotate(new Vector3(0f, 360f, 0f), 5f, RotateMode.LocalAxisAdd).SetLoops(-1, LoopType.Restart);
|
|
}
|
|
|
|
|
|
public void Collider()
|
|
{
|
|
_isDes = true;
|
|
box.enabled = false;
|
|
audioSource.Play();
|
|
transform.gameObject.SetActive(false);
|
|
Destroy(transform.gameObject);
|
|
}
|
|
}
|