Exemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        //If we collided with an enemy with the main character
        if (controlableCharacter == true && other.tag == "Enemy")
        {
            //Retain all players health in data retainer
            foreach (PlayerStatusExploring status in playerStatus)
            {
                dataRetainer.SetPlayerHealth(status.playerIndex, status.currentHealth);
                dataRetainer.SetPlayerMP(status.playerIndex, status.currentMP);
                dataRetainer.SetPlayerPosition(status.playerIndex, status.gameObject.transform.position);
            }
            //Check if we encountered the same enemy before and it hasn't respawned yet
            if (dataRetainer.defeatedEnemiesIndex.Contains(other.gameObject.GetComponent <MapEnemyMovement>().enemyIndex) == false)
            {
                //If it has respawned, remember it's index so that we can spawn it with a delay next time we load this scene
                dataRetainer.AddEncounter(other.gameObject.GetComponent <MapEnemyMovement>().enemyIndex);
            }

            dataRetainer.SaveEncounter(other.GetComponent <EnemyEncounterHolder>());

            //Load scene to delay so we can finish the animation
            StartCoroutine(LoadSceneWithDelay(2f));
        }
    }
Exemplo n.º 2
0
    public IEnumerator ChangeSceneWithDelay(string displayText, float waitTime)
    {
        foreach (Status status in characters)
        {
            if (status.gameObject.tag == "Player")
            {
                dataRetainer.SetPlayerHealth(status.playerIndex, status.health);
                dataRetainer.SetPlayerMP(status.playerIndex, status.currentMp);
            }
        }

        canvasAnimator.SetTrigger("EndBattle");
        endBattleText.text = displayText;
        yield return(new WaitForSeconds(waitTime));

        SceneManager.LoadScene("ExploringSceneSample");
    }