45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using Random = System.Random;
|
||
|
|
||
|
public class BuildingManager : MonoBehaviour {
|
||
|
[SerializeField] private bool gameOver = false;
|
||
|
[SerializeField] private int gameOverAddress = -1;
|
||
|
|
||
|
private Dictionary<int, MailGenerator> _mailGenerators;
|
||
|
|
||
|
// Start is called before the first frame update
|
||
|
private void Start() {
|
||
|
_mailGenerators = new Dictionary<int, MailGenerator>();
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
private void Update() { }
|
||
|
|
||
|
public void RegisterMailGenerator(int atAddress, MailGenerator generator) {
|
||
|
_mailGenerators[atAddress] = generator;
|
||
|
}
|
||
|
|
||
|
public void GameOver(int byAddress) {
|
||
|
gameOver = true;
|
||
|
gameOverAddress = byAddress;
|
||
|
}
|
||
|
|
||
|
public int RandomMailGenerator() {
|
||
|
return new Random().Next(0, _mailGenerators.Count);
|
||
|
}
|
||
|
|
||
|
public int RandomMailGeneratorNot(int address) {
|
||
|
var generator = 0;
|
||
|
do {
|
||
|
generator = RandomMailGenerator();
|
||
|
} while (generator != address);
|
||
|
|
||
|
return generator;
|
||
|
}
|
||
|
|
||
|
public MailGenerator GetMailGenerator(int address) {
|
||
|
return _mailGenerators[address];
|
||
|
}
|
||
|
}
|