mirror of
https://github.com/Xevion/Rebirth.git
synced 2025-12-11 10:08:21 -06:00
Switch to regrowth game
This commit is contained in:
43
Assets/Network.cs
Normal file
43
Assets/Network.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class Network : MonoBehaviour
|
||||
{
|
||||
private List<Planet> _planets;
|
||||
public Planet planetPrefab;
|
||||
|
||||
public void AddPlanet()
|
||||
{
|
||||
var planet = Instantiate(planetPrefab);
|
||||
planet.GenerateLine();
|
||||
planet.name = $"Planet {_planets.Count + 1}";
|
||||
planet.transform.parent = transform;
|
||||
_planets.Add(planet);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signal that a planet has been destroyed
|
||||
/// </summary>
|
||||
/// <param name="destroyed"></param>
|
||||
public void Destroyed(Planet destroyed)
|
||||
{
|
||||
_planets.Remove(destroyed);
|
||||
foreach (var planet in _planets)
|
||||
{
|
||||
if (planet != destroyed) continue;
|
||||
planet.neighbors.Remove(destroyed);
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_planets = new List<Planet>(FindObjectsOfType<Planet>());
|
||||
|
||||
AddPlanet();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user