예제 #1
0
    public static void AddPlayerArma(Dados.Personagens player, Dados.Armas arma)
    {
        PlayerArma p;

        p.player = player;
        p.arma   = arma;
        PlayersArmas.Add(p);
    }
예제 #2
0
 public static Dados.Armas QualArma(Dados.Personagens personagem)
 {
     for (int x = 0; x < PlayersArmas.Count; x++)
     {
         if (PlayersArmas[x].player == personagem)
         {
             return(PlayersArmas[x].arma);
         }
     }
     return(Dados.Armas.Nenhum);
 }
예제 #3
0
 public void FecharLoja()
 {
     Selecionados.VezLoja = Dados.PlayerIndice.Vazio;
     loja.SetActive(false);
     alvoLoja = null;
     Selecionados.LojaAberta = false;
     Personagem = Dados.Personagens.Nenhum;
     Player     = Dados.PlayerIndice.Vazio;
     Arma       = Dados.Armas.Nenhum;
     ArmaNivel  = Dados.ArmaNivel.Nivel1;
 }
예제 #4
0
 public void CarregarDadosSave()
 {
     Player     = alvoLoja.GetComponent <Move>().playerIndice;
     Personagem = alvoLoja.GetComponent <Atributos>().Personagem;
     Arma       = alvoLoja.GetComponent <ControleDeArmas>().arma;
     for (int x = 0; x < AutoSave.ArmasNiveis.Count; x++)
     {
         if (AutoSave.ArmasNiveis[x].arma == Arma)
         {
             ArmaNivel = AutoSave.ArmasNiveis[x].nivel;
             break;
         }
     }
 }
예제 #5
0
    public bool PodeSelecionar(Dados.Personagens person)
    {
        bool pode = true;

        for (int x = 0; x < selecao.Length; x++)
        {
            if (selecao[x].Person == person && selecao[x].Confirmado)
            {
                return(false);
            }
        }

        return(pode);
    }
    void Start()
    {
        if (Personagens.Length == 0)
        {
            txtBotaoPlayer.text = "Em breve...";
        }

        for (int x = 0; x < Personagens.Length; x++)
        {
            Personagens[x].GetComponent <Rigidbody>().isKinematic = true;
            Personagens[x].GetComponent <Move>().enabled          = false;
            Animator          anim   = Personagens[x].GetComponent <Animator>();
            Dados.Personagens person = Personagens[x].GetComponent <Atributos>().Personagem;
            Dados.Armas       arma   = AutoSave.QualArma(person);
            Dados.ArmaNivel   nivel  = AutoSave.QualNivel(arma);

            Personagens[x].SetActive(false);
        }
    }
    public void MudarPersonagem(int i)
    {
        selecao.SFX.PlayOneShot(selecao.SomClick);
        if (i > Personagens.Length - 1)
        {
            i = 0;
        }

        if (i < 0)
        {
            i = Personagens.Length - 1;
        }
        for (int x = 0; x < Personagens.Length; x++)
        {
            Personagens[x].SetActive(x == i ? true : false);
            Person = Personagens[x].GetComponent <Atributos>().Personagem;
            ControleDeArmas ctrArmas = Personagens[x].GetComponent <ControleDeArmas>();
            ctrArmas.AtivarArma(ctrArmas.arma, ctrArmas.nivel);
        }
        indice = i;
    }
    void Update()
    {
        timer += Time.deltaTime;
        if (Personagens.Length == 0)
        {
            return;
        }

        if (Input.GetButtonDown(playerIndice.ToString() + "B") && !Selecao)
        {
            SceneManager.LoadScene("Menu");
        }

        if (Selecao)
        {
            if (Input.GetAxisRaw(playerIndice.ToString() + "Right/Left") != 0 && timer > 1f)
            {
                timer = 0;
                switch ((int)Input.GetAxisRaw(playerIndice.ToString() + "Right/Left"))
                {
                case 1:
                    indice += 1;
                    MudarPersonagem(indice);
                    break;

                case -1:
                    indice -= 1;
                    MudarPersonagem(indice);
                    break;
                }
            }

            if (Input.GetButtonDown(playerIndice.ToString() + "A"))
            {
                print("A");
                if (FindObjectOfType <Selecao>().PodeSelecionar(Person))
                {
                    print("A");
                    selecao.SFX.PlayOneShot(selecao.SomClick);
                    Confirmado = true;
                    Personagens[indice].GetComponent <ControleDeAnimacao>().Selecionar();
                    GetComponent <Image>().color       = Color.yellow;
                    PersonagemSelecionado.personagem   = Person;
                    PersonagemSelecionado.playerIndice = playerIndice;
                }
            }

            if (Input.GetButtonDown(playerIndice.ToString() + "B"))
            {
                if (Confirmado)
                {
                    print("B");
                    selecao.SFX.PlayOneShot(selecao.SomClick);
                    Confirmado = false;
                    Personagens[indice].GetComponent <ControleDeAnimacao>().DesSelecionar();
                    GetComponent <Image>().color       = Color.white;
                    PersonagemSelecionado.personagem   = Dados.Personagens.Nenhum;
                    PersonagemSelecionado.playerIndice = Dados.PlayerIndice.Vazio;
                }
                else
                {
                    selecao.SFX.PlayOneShot(selecao.SomClick);
                    Selecao = false;
                    for (int x = 0; x < Personagens.Length; x++)
                    {
                        Personagens[x].SetActive(false);
                    }
                    Person = Dados.Personagens.Nenhum;
                    indice = 0;
                    txtBotaoPlayer.enabled = true;
                }
            }
        }


        if (Input.GetButtonDown(playerIndice.ToString() + "Start") && !Selecao)
        {
            Selecao = true;
            selecao.SFX.PlayOneShot(selecao.SomClick);
            Debug.Log(Personagens.Length, gameObject);
            Personagens[0].SetActive(true);
            Personagens[0].GetComponent <ControleDeAnimacao>().Idle(1);
            Person = Personagens[0].GetComponent <Atributos>().Personagem;
            ControleDeArmas ctrArmas = Personagens[0].GetComponent <ControleDeArmas>();
            ctrArmas.AtivarArma(ctrArmas.arma, ctrArmas.nivel);
            txtBotaoPlayer.enabled = false;
        }
    }
예제 #9
0
 public static void AtualizarArma(Dados.Personagens perso, Dados.Armas gun)
 {
     PlayerPrefs.SetInt(perso.ToString() + "Arma", (int)gun);
     CarregarArmaPlayer();
 }