void Awake() { LavaWall = this; LevelReset.myLevelElements.Add(this); //I add this to the LevelReset to the monobehavior, this will call the reset //function when the player dies. if this code was more organized/better //we would instead be inheiting our level elements from a base class //and calling a virtual Reset function which could be overriden in each child //class. Transform myTargetParents = this.transform.FindChild("Targets"); //This is the object that holds my targets //this isn't the best practice, but was good enough for now for (int child = 0; child < myTargetParents.childCount; child++) //for each child of my child holder { myTargetPoints.Add(myTargetParents.GetChild(child).GetComponent <LavaChunk>()); //add their lava chunk to my list myTargetPoints [child].SetLavaWall(this); //set the lava wall reference in the chunk, so they can call the snap and whatnot myTargetPoints [myTargetPoints.Count - 1].DisableRenderer(); //go to each lava chunk and call disable renderer, so they're invisible } }
void Awake() { LavaWall = this; LevelReset.myLevelElements.Add (this); //I add this to the LevelReset to the monobehavior, this will call the reset //function when the player dies. if this code was more organized/better //we would instead be inheiting our level elements from a base class //and calling a virtual Reset function which could be overriden in each child //class. Transform myTargetParents = this.transform.FindChild ("Targets"); //This is the object that holds my targets //this isn't the best practice, but was good enough for now for (int child = 0; child < myTargetParents.childCount; child++) { //for each child of my child holder myTargetPoints.Add (myTargetParents.GetChild (child).GetComponent<LavaChunk>()); //add their lava chunk to my list myTargetPoints [child].SetLavaWall (this); //set the lava wall reference in the chunk, so they can call the snap and whatnot myTargetPoints [myTargetPoints.Count - 1].DisableRenderer (); //go to each lava chunk and call disable renderer, so they're invisible } }
public void SetLavaWall(TestingLava myLava) { myLavaWall = myLava; //when the lava chunk is grabbed by the lava wall controller, give chunks a reference to be used //in the snap to me }