Ejemplo n.º 1
0
    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"));
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     dude         = FindObjectOfType <Dude2D>();
     dudeRenderer = dude.GetComponent <SpriteRenderer>();
     cam          = GetComponent <Camera>();
     cam.aspect   = 16f / 9f;
 }
Ejemplo n.º 3
0
    // 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>();
    }
Ejemplo n.º 4
0
    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;
    }
Ejemplo n.º 5
0
 //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);
     }
 }
Ejemplo n.º 6
0
 // Use this for initialization
 private void Start()
 {
     player = FindObjectOfType <Dude2D>();
 }