1
Fork 0
mirror of https://github.com/Steffo99/better-tee.git synced 2024-11-26 16:54:17 +00:00
better-tee/Assets/Packages/Mirror/Examples/Lobby/Scripts/Spawner.cs
2019-09-16 00:28:36 +02:00

39 lines
1 KiB
C#

using UnityEngine;
namespace Mirror.Examples.NetworkLobby
{
public class Spawner : NetworkBehaviour
{
public NetworkIdentity prizePrefab;
float x;
float z;
GameObject newPrize;
Reward reward;
void Start()
{
for (int i = 0; i < 10; i++)
{
SpawnPrize();
}
}
public void SpawnPrize()
{
x = Random.Range(-19, 20);
z = Random.Range(-19, 20);
newPrize = Instantiate(prizePrefab.gameObject, new Vector3(x, 1, z), Quaternion.identity);
newPrize.name = prizePrefab.name;
reward = newPrize.gameObject.GetComponent<Reward>();
reward.spawner = this;
reward.prizeColor = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
if (LogFilter.Debug) Debug.LogFormat("Spawning Prize R:{0} G:{1} B:{2}", reward.prizeColor.r, reward.prizeColor.g, reward.prizeColor.b);
NetworkServer.Spawn(newPrize);
}
}
}