папочка навёл порядок в папках
This commit is contained in:
1 parent
9374a984e6
commit
b407380203
1123 files changed
+2764
-133233
No files matched your search
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using Boxes;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class Box : MonoBehaviour
|
||||
{
|
||||
public BoxData boxData;
|
||||
private Coroutine _lifetimeCoroutine;
|
||||
|
||||
public void Init(BoxData data)
|
||||
{
|
||||
boxData = data;
|
||||
if (_lifetimeCoroutine != null) StopCoroutine(_lifetimeCoroutine);
|
||||
_lifetimeCoroutine = StartCoroutine(LifetimeRoutine());
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Player"))
|
||||
{
|
||||
if (boxData != null)
|
||||
{
|
||||
GameEvents.OnBoxCollected?.Invoke(boxData);
|
||||
}
|
||||
CollectAndReturn();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator LifetimeRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(15f);
|
||||
CollectAndReturn();
|
||||
}
|
||||
|
||||
private void CollectAndReturn()
|
||||
{
|
||||
if (_lifetimeCoroutine != null) StopCoroutine(_lifetimeCoroutine);
|
||||
|
||||
if (boxData != null && boxData.boxPrefab != null)
|
||||
{
|
||||
SimpleObjectPool.Instance.ReturnToPool(boxData.boxPrefab, gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 004b1fc0980fdb241b3fad09064f5b2a
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Boxes
|
||||
{
|
||||
[CreateAssetMenu(fileName = "NewBoxData", menuName = "Boxes/Box Data")]
|
||||
public class BoxData : ScriptableObject
|
||||
{
|
||||
public enum BoxEffectType
|
||||
{
|
||||
AddScore,
|
||||
LoseScore,
|
||||
SpecialFurniture
|
||||
}
|
||||
|
||||
[Header("Игровые параметры")]
|
||||
public BoxEffectType effectType = BoxEffectType.AddScore;
|
||||
|
||||
[Tooltip("Значение эффекта (очки или секунды)")]
|
||||
public float effectValue = 1;
|
||||
|
||||
[Tooltip("Вес спавна")]
|
||||
public float spawnWeight = 10f;
|
||||
|
||||
[Header("Визуальное представление")]
|
||||
public GameObject boxPrefab;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6a293f7fca35fc43ac2f3ebcb0954ce
|
||||
Reference in new issue
Block a user