Exemplo n.º 1
0
    public void AddLifeToGraph(LifeDot life)
    {
        Vector3Int coords = GetTilemapCoordsFromWorld(life.transform.position);
        LifeNode   node   = _mapGraph.GetNode(coords) as LifeNode;

        node.AddLife(life);
    }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public void ReleaseLife(LifeDot life)
 {
     _activeLifes.Remove(life);
     life.gameObject.SetActive(false);
     life.Age = 0;
     _freeLifes.Add(life);
 }
Exemplo n.º 4
0
 public void AddLife(LifeDot life)
 {
     if (ObjectsOnTile.Count == 0)
     {
         ObjectsOnTile.Add(life.gameObject);
         Status = NodeStatus.Occupied;
     }
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 protected void RemoveLife(LifeNode node)
 {
     if (node.GetLife() == null)
     {
         return;
     }
     if (ChangePower(-1))
     {
         LifeDot lifeDot = node.RemoveLife();
         LifeHandlerRef.ReleaseLife(lifeDot);
         OnRemove.Invoke();
     }
 }
Exemplo n.º 7
0
    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);
        }
    }
Exemplo n.º 8
0
 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();
     }
 }
Exemplo n.º 9
0
 public void AddNewLife(LifeDot life)
 {
     _activeLifes.Add(life);
 }
Exemplo n.º 10
0
 public void RegisterLife(LifeDot life)
 {
     GridSystem.Instance.AddLifeToGraph(life);
 }