private void OnEnable() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } gamePlane = GameObject.Find("Gameplay Plane"); planeComp = gamePlane.GetComponentInChildren <PlaneMovement>(); movementComp = gamePlane.GetComponentInChildren <PlayerMovement>(); deathComp = gamePlane.GetComponentInChildren <PlayerDeath>(); obstacleComp = gamePlane.GetComponentInChildren <ObstaclePlacementState>(); followComp = gamePlane.GetComponentInChildren <PlayerFollowTarget>(); progressObstacle = Resources.Load <GameObject>("ProgressionObstacle"); endObstacle = Resources.Load <GameObject>("CompletionObstacle"); whiteFade = GameObject.Find("WhiteFade"); whiteFadeColor = whiteFade.GetComponentInChildren <Image>().color; whiteFadeColor.a = 0f; }
/// <summary> /// Helper method for instantiating singleton /// </summary> private void InstantiateSingleton() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } }
private void OnEnable() { planeComp = transform.parent.GetComponent <PlaneMovement>(); movementComp = transform.parent.GetComponentInChildren <PlayerMovement>(); deathComp = transform.parent.GetComponentInChildren <PlayerDeath>(); obstacleComp = transform.parent.GetComponentInChildren <ObstaclePlacementState>(); target = transform.parent.GetChild(2).transform; smoothSpeed = 0.125f; rotateSpeed = 2f; rollSpeed = 800f; }
/// <summary> /// Instantiate component references and variables /// </summary> private void OnEnable() { gameManager = GameManager.instance; planeComp = transform.parent.GetComponent <PlaneMovement>(); movementComp = transform.parent.GetComponentInChildren <PlayerMovement>(); deathComp = transform.parent.GetComponentInChildren <PlayerDeath>(); obstacleComp = transform.parent.GetComponentInChildren <ObstaclePlacementState>(); progressionObstacle = Resources.Load <GameObject>("ProgressionObstacle"); target = transform.parent.GetChild(2).transform; smoothSpeed = 0.125f; rotateSpeed = 2f; rollSpeed = 800f; formTimer = 0f; whaleVisual = transform.GetChild(0).GetChild(0).gameObject; planeVisual = transform.GetChild(0).GetChild(1).gameObject; flareVisual = transform.GetChild(0).GetChild(2).gameObject; playerState = movementComp.playerState; }