void Awake() { Instance = this; #if UNITY_ANDROID Screen.orientation = ScreenOrientation.Landscape; #endif Vector3 bottomRightScreenCorner = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0)); m_MainCharacter = this.transform.Find("Penguin").gameObject.AddComponent <CharacterController>(); if (m_MainCharacter != null) { InitialiseControls(); } else { Debug.LogError("MainCharacterNull"); } var environmentTransform = this.transform.Find("Environment"); m_EnvironmentManager = environmentTransform.gameObject.AddComponent <EnvironmentManager>(); if (m_EnvironmentManager == null) { Debug.LogError("EnvironmentManagerNull"); } m_EnvironmentManager.Initialise(bottomRightScreenCorner.x); Vector3 penguinPos = m_MainCharacter.gameObject.transform.position; float penguinWidth = m_MainCharacter.gameObject.GetComponent <BoxCollider2D>().size.x; m_HazardsManager = environmentTransform.gameObject.AddComponent <HazardsManager>(); m_HazardsManager.Initialise(penguinPos, penguinWidth, bottomRightScreenCorner.x); m_PathManager = environmentTransform.gameObject.AddComponent <PathManager>(); m_PathManager.Initialise(bottomRightScreenCorner.x); m_GuiManager = this.transform.Find("GUI").gameObject.AddComponent <GUIManager>(); m_GuiManager.Initialise(); gameDifficulty = GameDifficulty.Easy; playerState = PlayerState.Alive; StartCoroutine(Timer()); }
private void Awake() { Instance = this; #if UNITY_ANDROID Screen.orientation = ScreenOrientation.Landscape; #endif Vector2 topRightScreenCorner = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height)); m_Penguin = this.transform.Find("Penguin").gameObject; m_PenguinSpriteRenderer = m_Penguin.GetComponent <SpriteRenderer>(); m_PenguinSpriteRenderer.enabled = false; m_MainCharacter = m_Penguin.AddComponent <CharacterController>(); if (m_MainCharacter != null) { InitialiseControls(); } var environmentTransform = this.transform.Find("Environment"); m_EnvironmentManager = environmentTransform.gameObject.AddComponent <EnvironmentManager>(); if (m_EnvironmentManager == null) { Debug.LogError("EnvironmentManagerNull"); } m_EnvironmentManager.Initialise(topRightScreenCorner.x); Vector3 penguinPos = m_Penguin.transform.position;; float penguinWidth = m_Penguin.GetComponent <BoxCollider2D>().size.x; m_HazardsManager = environmentTransform.gameObject.AddComponent <HazardsManager>(); m_HazardsManager.Initialise(penguinPos, penguinWidth, topRightScreenCorner.x); m_GuiManager = this.transform.Find("GUI").gameObject.AddComponent <GUIManager>(); m_GuiManager.Initialise(); m_EffectManager = this.transform.Find("ParticleEffects&Lights").gameObject.AddComponent <EffectManager>(); m_EffectManager.Initialise(topRightScreenCorner, penguinPos); m_PathManager = environmentTransform.gameObject.AddComponent <PathManager>(); m_PathManager.Initialise(topRightScreenCorner.x); //m_GameState = GameState.Begin; }