Exemple #1
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     dadosjogador = player.GetComponent <DadosJogador> ();
     //enemyHealth = GetComponent<EnemyHealth>();
     anim = GetComponent <Animator> ();
 }
Exemple #2
0
    public void Carregar()
    {
        DadosJogador dados = SistemaDeSalvar.CarregarDados();

        if (dados != null)
        {
            PontosDeVida        = dados.VidaMaxima;
            VidaSlider.maxValue = dados.VidaMaxima;
            VidaAtual           = dados.VidaAtual;
            VidaSlider.value    = dados.VidaAtual;
            Poder   = dados.Poder;
            Cerebro = dados.Cerebro;

            Vector3 Posicao;
            Posicao.x          = dados.Posicao[0];
            Posicao.y          = dados.Posicao[1];
            Posicao.z          = dados.Posicao[2];
            transform.position = Posicao;

            TelaDeInicio.SetActive(false);
            Time.timeScale = 1;
        }
        else
        {
            TelaDeErro.SetActive(true);
        }
    }
    public static void SalvarJogador(JogadorStatus jogador)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          Path      = Application.persistentDataPath + "/SaveFile.lfc";
        FileStream      stream    = new FileStream(Path, FileMode.Create);

        DadosJogador dados = new DadosJogador(jogador);

        formatter.Serialize(stream, dados);
        stream.Close();
    }
    public static DadosJogador CarregarDados()
    {
        string Path = Application.persistentDataPath + "/SaveFile.lfc";

        if (File.Exists(Path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(Path, FileMode.Open);

            DadosJogador dados = formatter.Deserialize(stream) as DadosJogador;
            stream.Close();

            return(dados);
        }
        else
        {
            Debug.LogError("Arquivo nao encontrado em: " + Path);
            return(null);
        }
    }