public void AddLifeToGraph(LifeDot life) { Vector3Int coords = GetTilemapCoordsFromWorld(life.transform.position); LifeNode node = _mapGraph.GetNode(coords) as LifeNode; node.AddLife(life); }
public void ProcessStep() { foreach (Vector3Int pos in GridSystem.Instance.MainTilemap.cellBounds.allPositionsWithin) { LifeNode currentNode = GridSystem.Instance.GetNode(pos) as LifeNode; if (currentNode is null) { continue; } if (currentNode.Status == LifeNode.NodeStatus.Empty && currentNode.NewStatus == LifeNode.NodeStatus.Occupied) { LifeDot life = LifeHandlerRef.TakeLife(); life.transform.position = GridSystem.Instance.GetWorldCoordsFromTilemap(pos); currentNode.AddLife(life); life.gameObject.SetActive(true); } else if (currentNode.Status == LifeNode.NodeStatus.Occupied && currentNode.NewStatus == LifeNode.NodeStatus.Empty) { LifeDot life = currentNode.RemoveLife(); life.Die(); LifeHandlerRef.ReleaseLife(life); } else if (currentNode.Status == LifeNode.NodeStatus.Occupied && currentNode.NewStatus == LifeNode.NodeStatus.Occupied) { LifeDot life = currentNode.ObjectsOnTile[0].GetComponent <LifeDot>(); life.Grow(); } } GameUIRef.UpdateYearsText(Years); }
public void ReleaseLife(LifeDot life) { _activeLifes.Remove(life); life.gameObject.SetActive(false); life.Age = 0; _freeLifes.Add(life); }
public void AddLife(LifeDot life) { if (ObjectsOnTile.Count == 0) { ObjectsOnTile.Add(life.gameObject); Status = NodeStatus.Occupied; } }
public LifeDot RemoveLife() { if (ObjectsOnTile.Count != 0) { GameObject lifeObject = ObjectsOnTile[0]; LifeDot life = lifeObject.GetComponent <LifeDot>(); ObjectsOnTile.Clear(); Status = NodeStatus.Empty; return(life); } return(null); }
protected void RemoveLife(LifeNode node) { if (node.GetLife() == null) { return; } if (ChangePower(-1)) { LifeDot lifeDot = node.RemoveLife(); LifeHandlerRef.ReleaseLife(lifeDot); OnRemove.Invoke(); } }
public void Initialize(int tileCount = 100) { _activeLifes = new List <LifeDot>(); _freeLifes = new List <LifeDot>(); int startCount = tileCount / 2; for (int i = 0; i < startCount; ++i) { GameObject lifeGameObject = Instantiate(LifePrefab, transform); LifeDot life = lifeGameObject.GetComponent <LifeDot>(); lifeGameObject.SetActive(false); _freeLifes.Add(life); } }
protected void SpawnLife(LifeNode node) { if (node.GetLife() != null) { return; } if (ChangePower(-1)) { LifeDot life = LifeHandlerRef.TakeLife(); life.transform.position = GridSystem.Instance.GetWorldCoordsFromTilemap(node.Coords); node.AddLife(life); life.gameObject.SetActive(true); OnSpawn.Invoke(); } }
public void AddNewLife(LifeDot life) { _activeLifes.Add(life); }
public void RegisterLife(LifeDot life) { GridSystem.Instance.AddLifeToGraph(life); }