sas
This commit is contained in:
parent
055fbf0f4d
commit
d2e9da4313
6
.idea/.idea.projectZ/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.projectZ/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -7,27 +8,32 @@ public class CellSpawner : NetworkBehaviour
|
||||
{
|
||||
public GameObject prefab;
|
||||
public float spawnTime;
|
||||
private int _capacity;
|
||||
|
||||
private CustomNetworkManager _networkManager;
|
||||
private GameObject _instance;
|
||||
private bool spawnStarted = false;
|
||||
private bool _spawnStarted = false;
|
||||
private float _timer;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (!isServer) return;
|
||||
_capacity = _networkManager.maxConnections;
|
||||
Console.WriteLine(_capacity);
|
||||
SpawnPref();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (!isServer) return;
|
||||
if (!isServer || _capacity <= 0) return;
|
||||
|
||||
if (_instance == null && spawnStarted == false)
|
||||
if (_instance == null && _spawnStarted == false)
|
||||
{
|
||||
spawnStarted = true;
|
||||
_spawnStarted = true;
|
||||
}
|
||||
|
||||
if (spawnStarted)
|
||||
if (_spawnStarted)
|
||||
{
|
||||
_timer += Time.fixedDeltaTime;
|
||||
}
|
||||
@ -52,6 +58,7 @@ public class CellSpawner : NetworkBehaviour
|
||||
{
|
||||
_instance = Instantiate(prefab, transform.position + transform.up * 1.2f, Quaternion.identity); //* 1.8f
|
||||
NetworkServer.Spawn(_instance);
|
||||
spawnStarted = false;
|
||||
_spawnStarted = false;
|
||||
_capacity--;
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 0}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState
|
||||
lastWriteTicks: -8584932388166862069
|
||||
lastWriteTicks: -8584910005848256330
|
||||
|
Loading…
x
Reference in New Issue
Block a user