예제 #1
0
    // There are two cases that can occur when the player dies. They either earn another
    // chance to restore their lost XP, or they failed and the game restarts.
    override public void Die()
    {
        // If the player has not respawned yet, they have a chance to retrieve their
        // lost XP from the last enemy that killed them
        if (hasRespawned == false)
        {
            base.Die();
            currentHealth = getMaxHealth();
            healthBar.SetHealth(currentHealth);

            // Spawn player at spawn point
            GetComponent <Transform>().position = respawn.position;

            // Tag the enemy
            TagEnemy(lastEnemy);

            // Enemy steals the player's current XP
            CharacterExperience enemyXp = lastEnemy.GetComponent <CharacterExperience>();
            enemyXp.stealExp(playerXp);

            // Set the XP and count the respawn
            xpBar.SetXp(playerXp.xp);
            hasRespawned = true;
        }
        else if (hasRespawned == true)
        {
            base.Die();
            SceneManager.LoadScene("Main");
        }
    }
    // steal experience method that should be different for various characters
    public virtual void stealExp(CharacterExperience other)
    {
        this.xp  = this.xp + other.xp;
        other.xp = 0;

        StairScript.instance.spawnSteps();
    }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     mouseActive   = false;
     hasRespawned  = false;
     killCount     = 0;
     playerXp      = GetComponent <CharacterExperience>();
     statsUI       = StatsUI.instance;
     currentHealth = getMaxHealth();
     healthBar.SetMaxHealth(getMaxHealth());
     xpBar.SetXp(playerXp.xp);
 }
예제 #4
0
    // add a enemy kill when the player kills and enemy
    public void killedEnemy(CharacterExperience enemyXp)
    {
        killCount++;
        playerXp.stealExp(enemyXp);
        xpBar.SetXp(playerXp.xp);

        if (enemyXp.gameObject == lastEnemy.gameObject)
        {
            hasRespawned = false;
        }
    }
예제 #5
0
    // Start is called before the first frame update
    void Start()
    {
        // Instantiate the boolean values
        attack       = false;
        mouseActive  = false;
        hasRespawned = false;

        // Set up health bar and XP bar
        killCount     = 0;
        playerXp      = GetComponent <CharacterExperience>();
        statsUI       = StatsUI.instance;
        currentHealth = getMaxHealth();
        healthBar.SetMaxHealth(getMaxHealth());
        xpBar.SetXp(playerXp.xp);
    }
예제 #6
0
    override public void Die()
    {
        if (hasRespawned == false)
        {
            base.Die();
            currentHealth = getMaxHealth();
            healthBar.SetHealth(currentHealth);
            GetComponent <Transform>().position = respawn.position;

            CharacterExperience enemyXp = lastEnemy.GetComponent <CharacterExperience>();
            enemyXp.stealExp(playerXp);

            xpBar.SetXp(playerXp.xp);
            hasRespawned = true;
        }
        else if (hasRespawned == true)
        {
            base.Die();
            SceneManager.LoadScene("Main");
        }
    }
예제 #7
0
    // add an enemy kill when the player kills and enemy
    public void killedEnemy(CharacterExperience enemyXp)
    {
        // Steal the enemies XP and set the xp
        killCount++;
        playerXp.stealExp(enemyXp);
        xpBar.SetXp(playerXp.xp);

        // If the character was able to kill the enemy that stole their XP, reset the respawn
        if (lastEnemy != null && enemyXp.gameObject == lastEnemy.gameObject)
        {
            hasRespawned = false;
        }

        // Check if the boss was defeated
        if (enemyXp.CompareTag("Enemy0"))
        {
            mouseActive = true;

            // Display the win screen
            winScreen.SetActive(true);
            Time.timeScale = 0;
        }
    }