private IEnumerator PlayerDeath() { activeState = GameController.States.death; mainCamera.GetComponent <CameraFollow>().m_Player = mainCamera.transform; Transform t = player.transform; Instantiate(puffPrefab, t.position, Quaternion.identity); Destroy(player.gameObject); if (stateData.Health > 0) { yield return(new WaitForSeconds(3)); player = Instantiate(playerPrefab); player.GetComponent <Transform>().position = playerSpawn.position; mainCamera.GetComponent <CameraFollow>().m_Player = player.transform; activeState = GameController.States.running; } else { gameOverPanel.gameObject.SetActive(true); Debug.Log("GameRestart after Player Death"); yield return(GameRestart(2, currentLevel, "PlayerDeath")); } }
// Use this for initialization void Start() { dude = FindObjectOfType <Dude2D>(); dudeRenderer = dude.GetComponent <SpriteRenderer>(); cam = GetComponent <Camera>(); cam.aspect = 16f / 9f; }
// Use this for initialization void Start() { main = FindObjectOfType <Camera>(); enemy_Rigidbody = GetComponent <Rigidbody2D>(); groundCheck = transform.Find("enemyGroundCheck"); maxHeight = transform.position.y + 6.5f; bossAnim = GetComponent <Animator>(); player = FindObjectOfType <Dude2D>(); startpos = transform.position; bossSpriteRenderer = GetComponent <SpriteRenderer>(); }
public void InitGame(string level) { // Find components heartsText = GameObject.Find("HeartsText").GetComponent <Text>(); coinsText = GameObject.Find("CoinsText").GetComponent <Text>(); endLevelPanel = GameObject.FindObjectOfType <Canvas>().GetComponent <CanvasContainer>().EndLevelPanel; gameOverPanel = GameObject.FindObjectOfType <Canvas>().GetComponent <CanvasContainer>().GameOverPanel; player = GameObject.FindGameObjectWithTag("Player").GetComponent <Dude2D>(); playerSpawn = GameObject.Find("Spawn").transform; mainCamera = GameObject.FindObjectOfType <Camera>(); stateData = GameObject.FindObjectOfType <GameState>(); soundController = GameObject.FindObjectOfType <SoundController>(); // Configure camera mainCamera.GetComponent <CameraFollow>().enabled = true; mainCamera.GetComponent <CameraFollow>().m_Player = player.gameObject.transform; endLevelPanel.gameObject.SetActive(false); gameOverPanel.gameObject.SetActive(false); // Set state Debug.Log("Initing with level " + level); this.currentLevel = level; activeState = States.running; }
//public int currentLevelX { get; set; } //public int currentLevelY { get; set; } // Use this for initialization void Start() { if (instance == null) { instance = this; player = FindObjectOfType <Dude2D>(); currentCheckpointPos = new Vector3(); allcheckpoints = FindObjectsOfType <CheckPointScript>(); foreach (CheckPointScript s in allcheckpoints) { print("Checkpoint with ID: " + s.getId()); if (s.getId() == PlayerPrefs.GetFloat("checkpoint")) { setCurrentCheckpoint(s); currentPoint.setActive(true); player.setSpawnPosition(currentPoint.transform.position); } } } else if (instance != this) { Destroy(gameObject); } }
// Use this for initialization private void Start() { player = FindObjectOfType <Dude2D>(); }