public void loadOpenWorld() { //TODO get info from the displayed bird and transfer to open world bird GameObject bird = new GameObject("Player"); bird.transform.localScale = new Vector2(10, 10); bird.AddComponent <SpriteRenderer>(); bird.AddComponent <Animator>(); ArboretumBird refBird = (ArboretumBird)UnityEngine.Object.FindObjectOfType(typeof(ArboretumBird)); bird.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)Resources.Load("Animations/" + refBird.stats.type + "Anim"); bird.AddComponent <OpenWorldBird>(); //add attributes! OpenWorldBird b = bird.GetComponent <OpenWorldBird>(); b.stats.baseColor = refBird.stats.baseColor; b.stats.canFreeFly = refBird.stats.canFreeFly; b.stats.stamina = refBird.stats.stamina; b.stats.maxAltitude = refBird.stats.maxAltitude; b.stats.maxSpeed = refBird.stats.maxSpeed; OpenWorldCamera camera = (OpenWorldCamera)UnityEngine.Object.FindObjectOfType(typeof(OpenWorldCamera)); camera.player = bird.GetComponent <OpenWorldBird>(); Destroy(refBird.gameObject); }
public void loadArboretumBirds() { int i = 0; foreach (Transform child in transform.Find("Birds").transform) { Bird refBird = child.gameObject.GetComponent <Bird>(); GameObject bird = new GameObject(refBird.stats.birdName); bird.transform.localScale = new Vector2(10, 10); bird.AddComponent <SpriteRenderer>(); bird.AddComponent <Animator>(); bird.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)Resources.Load("Animations/" + refBird.stats.type + "Anim"); bird.AddComponent <ArboretumBird>(); ArboretumBird b = bird.GetComponent <ArboretumBird>(); b.stats.birdName = refBird.stats.birdName; b.stats.maxSpeed = refBird.stats.maxSpeed; b.stats.type = refBird.stats.type; b.stats.maxAltitude = refBird.stats.maxAltitude; b.stats.stamina = refBird.stats.stamina; b.name = refBird.stats.birdName; b.stats.baseColor = refBird.stats.baseColor; bird.name = refBird.stats.birdName; i++; } }
public void sellBird() { GameObject birds = GameObject.Find("Birds"); if (birds.transform.childCount > 1) { GameController control = (GameController)Object.FindObjectOfType(typeof(GameController)); control.credits++; ArboretumBird oldBird = (ArboretumBird)Object.FindObjectOfType(typeof(ArboretumBird)); control.removeBirdRef(oldBird); goToArboretum(); } else { print("Cannot sell your only bird!"); } }
void Start() { startTime = Time.time; currBird = (ArboretumBird)Object.FindObjectOfType(typeof(ArboretumBird)); showStats(); }