public void AddFoxFromData(FoxData foxData) { GameObject foxToCreate = Instantiate(pfabFox, foxSpawnLocation.position, Quaternion.identity); Fox fox = foxToCreate.GetComponent <Fox>(); string foxType = foxData.foxType; FoxCollectionLog foxLog = FoxCollection.instance.GetFoxFromCollection(foxType); print(foxData); //assign values to the fox based on the data object created fox.foxName = foxData.foxName; fox.averageNapApart = foxData.napFrequency; fox.averageNapTime = foxData.napTime; fox.fullnessDecay = foxData.fullnessDecay; fox.fullness = foxData.fullness; fox.moveSpeed = foxData.moveSpeed; Transform foxModel = Instantiate(foxLog.foxMesh, foxToCreate.transform.position, foxToCreate.transform.rotation); foxToCreate.GetComponent <Fox>().foxModel = foxModel; //parent to the collision object in fox' foxModel.transform.SetParent(foxToCreate.GetComponent <Fox>().foxTransform); foxToCreate.name = foxData.foxName; print("Creating fox from sava data: " + fox.foxName); foxList.Add(foxToCreate); NameGenerator.instance.RemoveName(fox.foxName); //TODO remove fox name from the main list }
public GameData(List <GameObject> foxList, int pointsToAdd) { points = pointsToAdd; foreach (GameObject fox in foxList) { FoxData foxToAdd = new FoxData(fox); foxDataList.Add(foxToAdd); } //apparently I can't have things in here? I can only use the constructor? /* * foreach(GameObject fox in foxList) * { * //ERROR IN GETTING NAMES * String name = fox.GetComponent<Fox>().foxName; * foxNames.Add(name); * } * * points = pointsToAdd; */ }