Exemplo n.º 1
0
 static void Imprimir(Cofre cofre)
 {
     foreach (var item in cofre._Reservas)
     {
         Console.WriteLine($"K: {item.Key} - V: {item.Value}");
     }
 }
Exemplo n.º 2
0
 private void Start()
 {
     cofre   = GetComponentInParent <Cofre>();
     guion   = FindObjectOfType <Guion>();
     sonidos = GetComponent <AudioSource>();
     SetQuestion();
 }
Exemplo n.º 3
0
        public void Retirar()
        {
            var cofre = new Cofre(new Dictionary <ENota, uint>());

            cofre.Armazenar(ENota.CINQUENTA, 2);
            //Assert.Null(cofre.Retirar(80));
            Assert.Throws <ArgumentException>(() => cofre.Retirar(80));
        }
 void OnTriggerEnter2D(Collider2D other)
 {
     if(other.tag == "Enemigo")
     {
         Debug.Log("hit?");
         enemigoSaludScript = other.GetComponent<EnemigoSalud>();
         enemigoAnim = other.GetComponent<Animator>();
         enemigoSaludScript.recibirDaño(dañoArma);
         enemigoAnim.SetTrigger("golpeado");
         enemigoAnim.SetTrigger("repuesto");
     }
     if (other.tag == "Interactuable") {
         cofreScript = other.GetComponent<Cofre>();
         cofreScript.accion();
     }
 }
Exemplo n.º 5
0
    //7.COLISIONES CONSTANTES CON TRIGGERS
    void OnTriggerStay2D(Collider2D other)
    {
        //Cofre
        Cofre compCofre = other.GetComponent <Cofre>();
        MovimientoCocodrilo compCoco = other.GetComponent <MovimientoCocodrilo>();

        if (compCofre != null && tiempo > tiempoDeInmunidad && compCofre.enemigo && compCofre.abierto)
        {
            RecibeDaño(2, other.gameObject);
        }
        //Cocodrilos
        else if (compCoco != null && tiempo > tiempoDeInmunidad)
        {
            RecibeDaño(1, other.gameObject);
        }
        //Pinchos
        else
        {
            ColisionPichos(other.gameObject);
        }
    }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var cofre = new Cofre(new Dictionary <ENota, uint>());

            //cofre.Armazenar(ENota.VINTE, 2);
            cofre.Armazenar(ENota.CINQUENTA, 3);
            cofre.Armazenar(ENota.DEZ, 1);
            var retirada = 100;

            Console.WriteLine($"Antes da retirada.");
            Imprimir(cofre);
            try
            {
                cofre.Retirar((uint)retirada);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine($"Depois da retirada: ({retirada}).");
            Imprimir(cofre);

            //    ConsoleKey key;
            //    var tesouraria = new Tesouraria(new Cofre(), new List<RegistroDeTransacao>());

            //    var opcoesDoMenu = new Dictionary<ConsoleKey, String>();
            //    opcoesDoMenu.Add(ConsoleKey.F1, "Depositar 10");
            //    opcoesDoMenu.Add(ConsoleKey.F2, "Depositar 20");
            //    opcoesDoMenu.Add(ConsoleKey.F3, "Depositar 50");
            //    opcoesDoMenu.Add(ConsoleKey.F4, "Realizar Saque");
            //    opcoesDoMenu.Add(ConsoleKey.F5, "Verificar Saldo");
            //    opcoesDoMenu.Add(ConsoleKey.F10, "Sair");
            //    do
            //    {
            //        Console.Clear();
            //        Console.WriteLine("*** CAIXA ELETRONICO ***");
            //        Console.WriteLine("*** DIGITE A OPÇÃO DE ATENDIMENTO ***");
            //        foreach (var opcao in opcoesDoMenu)
            //        {
            //            Console.WriteLine(opcao.Key + " - " + opcao.Value);
            //        }
            //        key = Console.ReadKey(true).Key;
            //        Console.Clear();
            //        if (key != ConsoleKey.F10)
            //            switch (key)
            //            {
            //                case ConsoleKey.F1:
            //                    Console.WriteLine("Quantas notas deseja depositar?");
            //                    tesouraria.ProcessarTransacao(new Deposito(new Montante(ENota.DEZ,Convert.ToUInt32(Console.ReadLine()))));
            //                    break;
            //                case ConsoleKey.F2:
            //                    Console.WriteLine("Quantas notas deseja depositar?");
            //                    tesouraria.ProcessarTransacao(new Deposito(new Montante(ENota.VINTE, Convert.ToUInt32(Console.ReadLine()))));
            //                    break;
            //                case ConsoleKey.F3:
            //                    Console.WriteLine("Quantas notas deseja depositar?");
            //                    tesouraria.ProcessarTransacao(new Deposito(new Montante(ENota.CINQUENTA, Convert.ToUInt32(Console.ReadLine()))));
            //                    break;
            //                case ConsoleKey.F4:
            //                    Console.WriteLine("Digite o valor: ");
            //                    Console.ReadKey(true);
            //                    break;
            //                case ConsoleKey.F5:
            //                    Console.WriteLine("Relatório de notas: ");
            //                    Console.ReadKey(true);
            //                    break;
            //                default:
            //                    Console.WriteLine("Digite uma opção válida.\nPressione qualquer tecla para continuar...");
            //                    Console.ReadKey(true);
            //                    break;
            //            }
            //    } while (key != ConsoleKey.F10);
        }
Exemplo n.º 7
0
    //6.COLISIONES CON TRIGGERS
    void OnTriggerEnter2D(Collider2D other)
    {
        Disparo             compBala   = other.GetComponent <Disparo>();
        Moneda              compMoneda = other.GetComponent <Moneda> ();
        MovimientoCocodrilo compCoco   = other.GetComponent <MovimientoCocodrilo> ();
        Cofre compCofre = other.GetComponent <Cofre> ();

        //Colisión con bala enemiga
        if (compBala != null && compBala.TipoDeBala == Disparo.TipoBala.BalaEnemigo)
        {
            Destroy(other.gameObject);
            if (tiempo > tiempoDeInmunidad)
            {
                RecibeDaño(2, other.gameObject);
            }
        }


        //Colisión con pociones
        else if (other.gameObject.tag == "Poción")
        {
            GetComponent <AudioSource>().PlayOneShot(cogepocion);
            GameManager.instance.GanaPoción();
            Destroy(other.gameObject);
        }
        else if (other.gameObject.tag == "Finish")
        {
            GameManager.instance.FinNivel();
        }
        else if (other.gameObject.tag == "Checkpoint")
        {
            if (GameManager.instance.NivelActual() != 3)
            {
                GameManager.instance.Checkpoint();
            }
            else
            {
                GameManager.instance.FijaCamara();
                Destroy(other.gameObject);
            }
        }
        else if (other.gameObject.tag == "DeadZone")
        {
            GameManager.instance.RecibeDaño(10, true);
        }


        //Colisión con monedas
        else if (compMoneda != null)
        {
            GameManager.instance.GanaMonedas(compMoneda.Valor);
            Destroy(other.gameObject);
        }

        //Colisión con cocodrilos
        else if (compCoco != null && tiempo > tiempoDeInmunidad)
        {
            RecibeDaño(1, other.gameObject);
        }


        //Colisión con cofres (enemigos)
        else if (compCofre != null && tiempo > tiempoDeInmunidad &&
                 compCofre.enemigo && compCofre.abierto)
        {
            RecibeDaño(2, other.gameObject);
        }
        else
        {
            ColisionPichos(other.gameObject);
        }
    }