Edited
Добавлен таймер, конфиг и публичный метод SpawnItems() CooldownRemaining - оставшееся время до спавна float CooldownSecondsRemaining - оставшееся время до спавна int
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 142c75ae48de4c7ba6fd0daad6905872, type: 3}
|
||||
m_Name: ItemPipeConfig
|
||||
m_EditorClassIdentifier:
|
||||
spawnInterval: 0.05
|
||||
spawnCooldown: 10
|
||||
localVelocityChange: {x: 0, y: -5, z: 0}
|
||||
guaranteedItems:
|
||||
- prefab: {fileID: 4504260422113134419, guid: 8790cd6f776403940ac664c5db12dab4, type: 3}
|
||||
amount: 1
|
||||
randomItemCount: 7
|
||||
randomItems:
|
||||
- prefab: {fileID: 2474374521670934351, guid: c91d2337125ccaf45a0c57af9a6703c8, type: 3}
|
||||
weight: 1
|
||||
- prefab: {fileID: 4728426142119307488, guid: 795e138cd804c7c42aa508895e6a61df, type: 3}
|
||||
weight: 1
|
||||
- prefab: {fileID: 4504260422113134419, guid: 8790cd6f776403940ac664c5db12dab4, type: 3}
|
||||
weight: 3
|
||||
randomSpawnX: 1
|
||||
randomSpawnZ: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3883e23238f84f748e616770b66fa885
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(
|
||||
fileName = "ItemPipeConfig",
|
||||
menuName = "Fort Bo/Pipe Junk/Item Pipe Config")]
|
||||
public sealed class ItemPipeConfig : ScriptableObject
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class GuaranteedItem
|
||||
{
|
||||
public GameObject prefab;
|
||||
|
||||
[Min(1)]
|
||||
public int amount = 1;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class RandomItem
|
||||
{
|
||||
public GameObject prefab;
|
||||
|
||||
[Min(0f)]
|
||||
public float weight = 1f;
|
||||
}
|
||||
|
||||
[Header("Timing")]
|
||||
[SerializeField, Min(0.05f)] private float spawnInterval = 0.5f;
|
||||
[SerializeField, Min(0f)] private float spawnCooldown = 10f;
|
||||
|
||||
[Header("Instant velocity change")]
|
||||
[SerializeField] private Vector3 localVelocityChange = Vector3.forward * 4.5f;
|
||||
|
||||
[Header("Guaranteed items")]
|
||||
[SerializeField] private List<GuaranteedItem> guaranteedItems = new();
|
||||
|
||||
[Header("Random items")]
|
||||
[SerializeField, Min(0)] private int randomItemCount = 5;
|
||||
[SerializeField] private List<RandomItem> randomItems = new();
|
||||
|
||||
[Header("Spawn position randomization")]
|
||||
[SerializeField, Min(0f)] private float randomSpawnX = 0.2f;
|
||||
[SerializeField, Min(0f)] private float randomSpawnZ = 0.2f;
|
||||
|
||||
public float SpawnInterval => spawnInterval;
|
||||
public float SpawnCooldown => spawnCooldown;
|
||||
public Vector3 LocalVelocityChange => localVelocityChange;
|
||||
public IReadOnlyList<GuaranteedItem> GuaranteedItems => guaranteedItems;
|
||||
public int RandomItemCount => randomItemCount;
|
||||
public IReadOnlyList<RandomItem> RandomItems => randomItems;
|
||||
public float RandomSpawnX => randomSpawnX;
|
||||
public float RandomSpawnZ => randomSpawnZ;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 142c75ae48de4c7ba6fd0daad6905872
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user