Game of Life Algorithm with constructors and abstract class architecture

Hi everyone,

i’m trying to learn the famous Game of Life algorithm. I have two classes. i have a Cell class which is a Unity abstract class and a CellController which extends Monobehaviour class.

so i need to extend Cell as a variable but i need to use transform or other things on it.
is it possible? if its not how can i use a constructor with single Cell Object or what should be my strategy?

so i need an orientation about architecture approach…

here is my example code :

public class GameOfLife : MonoBehaviour {

    private Cell cell;

    void InitGame(){
       cell = new Cell(x, y);
       // it appears i cant use transform variable or AddComponent function on 
       // cell variable.  
    }

    public class Cell {

		public float x, y;
		public bool state; 
		public bool nextState; 

           public Cell ( float xArg, float yArg ){
                // constructor functions etc...
           }
    }
}

One option would be to give your cell a reference to the CellController when you construct it. then the cell will be able to get the transform data and other components from the gameObject. (assuming thats what you meant. I might have misunderstood the point of your query).

Pass in the Transform as a parameter/argument, its only a reference anyways.

using UnityEngine;

public class GameOfLife : MonoBehaviour {

    private Cell cell;

    void InitGame(){
       cell = new Cell(x, y, this.transform); // could just use transform.
       // it appears i cant use transform variable or AddComponent function on 
       // cell variable.  
    }

    public class Cell {

       public float x, y;
       public bool state; 
       public bool nextState; 
       public Transform m_cellTransform;

       public Cell ( float xArg, float yArg ){
            // constructor functions etc...
       }

       public Cell (float x, float y, Transform transform){
			this.x = x;
			this.y = y;
			this.m_cellTransform = transform;
	   }
	   
	   public void MoveStuff(){
			this.m_cellTransform.position = new Vector3(this.x, thix.y, 0.0f);
	   }
    }
}

So each instance of cell will hold a reference to the transform of the game object it is attached to or something like that.