public ActionResult Create([Bind(Include = "chave, tipo, descricao, inativo, geraconta")] Chaves chaves)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Chaves.Add(chaves);
             db.SaveChanges();
             TempData["success"] = "Chave criada com sucesso";
             return(RedirectToAction("Index"));
         }
         ViewBag.tipoChave = new SelectList(db.TipoChave.Where(c => c.Inativo == false), "tipo", "Tipo", chaves.Tipo);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                               eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                   ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     return(View(chaves));
 }
Esempio n. 2
0
 public particulasB(int tam, float vel, Chaves cha, ParticulasSA psa)
 {
     nivelTamanho = tam;
     velocidade   = vel;
     chaves       = cha;
     particulasSA = psa;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Chaves chaves = db.Chaves.Find(id);

            db.Chaves.Remove(chaves);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(string chaves, FormCollection collection)
        {
            Chaves Chave = db.Chaves.Find(chaves);

            db.Chaves.Remove(Chave);
            db.SaveChanges();
            TempData["success"] = "Chave excluída com sucesso";
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Preco,Numeros,Estrelas,TipoChaveFK")] Chaves chaves)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chaves).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TipoChaveFK = new SelectList(db.TipoChaves, "ID", "Tipo", chaves.TipoChaveFK);
     return(View(chaves));
 }
Esempio n. 6
0
 void Start()
 {
     jaPegou = false;
     Jogador = GameObject.FindWithTag("Player");
     if (Jogador != null)
     {
         _listaDeChaves = Jogador.GetComponent <Chaves>();
     }
     emissorDeSom             = GetComponent <AudioSource>();
     emissorDeSom.playOnAwake = false;
     emissorDeSom.loop        = false;
 }
        public ActionResult Edit([Bind(Include = "chave, tipo, descricao, inativo, geraconta")] Chaves Chaves1)
        {
            if (ModelState.IsValid)
            {
                db.Entry(Chaves1).State = EntityState.Modified;
                db.SaveChanges();
                TempData["success"] = "Chave editada com sucesso";
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public ActionResult Details(string chaves)
        {
            if (chaves == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chaves Chaves = db.Chaves.Find(chaves);

            if (Chaves == null)
            {
                return(HttpNotFound());
            }
            return(View(Chaves));
        }
        // GET: Chaves/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chaves chaves = db.Chaves.Find(id);

            if (chaves == null)
            {
                return(HttpNotFound());
            }
            return(View(chaves));
        }
        public ActionResult Edit(string chaves)
        {
            if (chaves == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chaves Chave = db.Chaves.Find(chaves);

            if (Chave == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Tipo = new SelectList(db.TipoChave, "tipo", "tipo", Chave.Tipo);
            return(View(Chave));
        }
Esempio n. 11
0
        // GET: Chaves/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chaves chaves = db.Chaves.Find(id);

            if (chaves == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TipoChaveFK = new SelectList(db.TipoChaves, "ID", "Tipo", chaves.TipoChaveFK);
            return(View(chaves));
        }
Esempio n. 12
0
    void Start()
    {
        rotacaoInicial = transform.eulerAngles;
        Jogador        = GameObject.FindWithTag("Player");
        if (Jogador != null)
        {
            listaDeChaves = Jogador.GetComponent <Chaves> ();
        }
        emissorSom             = GetComponent <AudioSource> ();
        emissorSom.playOnAwake = false;
        emissorSom.loop        = false;
        if (TextoTrancado != null)
        {
            TextoTrancado.enabled = false;
        }
        switch (EstadoInicial)
        {
        case EstadoInic.Fechada00:
            estaFechada  = true;
            estaTrancada = false;
            giroAlvo     = 0.0f;
            giroAtual    = 0.0f;
            break;

        case EstadoInic.Aberta90:
            estaFechada  = false;
            estaTrancada = false;
            if (inverterGiro == true)
            {
                giroAtual = grausDeGiro;
                giroAlvo  = grausDeGiro;
            }
            else
            {
                giroAtual = -grausDeGiro;
                giroAlvo  = -grausDeGiro;
            }
            break;

        case EstadoInic.Trancada:
            estaFechada  = true;
            estaTrancada = true;
            giroAlvo     = 0.0f;
            giroAtual    = 0.0f;
            break;
        }
    }
Esempio n. 13
0
        public ActionResult Create([Bind(Include = "ID,Preco,TipoChaveFK")] Chaves chaves, int[] numerosIds)
        {
            if (numerosIds == null || numerosIds.Length == 0)
            {
                ModelState.AddModelError("", "Seleccione números e estrelas.");
            }
            else
            {
                // Temos números...
                var todosNumeros = db.Numeros.Where(n => numerosIds.Contains(n.ID)).ToList();

                var numeros  = todosNumeros.Where(n => n.EEstrela == false).ToList();
                var estrelas = todosNumeros.Where(n => n.EEstrela == true).ToList();

                if (numeros.Count < 5 || numeros.Count > 11 || estrelas.Count < 2 || estrelas.Count > 12)
                {
                    ModelState.AddModelError("", "Seleccione o número correcto de números e estrelas");
                }
                else
                {
                    chaves.ListaNumeros = todosNumeros;
                }
            }

            if (ModelState.IsValid)
            {
                db.Chaves.Add(chaves);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var TodosNumeros = db.Numeros
                               .OrderBy(n => n.EEstrela)
                               .ThenBy(n => n.Valor)
                               .ToList();

            ViewBag.TodosNumeros = TodosNumeros;

            ViewBag.TipoChaveFK = new SelectList(db.TipoChaves, "ID", "Tipo", chaves.TipoChaveFK);
            return(View(chaves));
        }
Esempio n. 14
0
    void criaFilhos(Chaves chaves, ParticulasSA particulasSA)
    {
        //x' = x cos θ − y sin θ
        //y' = x sin θ + y cos θ

        Vector2 directionForce = new Vector2(1, 0);

        GameObject[] listaIrmao = new GameObject[3];
        int          numIrmaos  = 0;

        if (chaves.plasma == true)
        {
            GameObject newFilho = criaFilhoB("plasma", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }
        if (chaves.gasoso == true)
        {
            GameObject newFilho = criaFilhoB("gasoso", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }
        if (chaves.liquido == true)
        {
            GameObject newFilho = criaFilhoB("liquido", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }
        if (chaves.solido == true)
        {
            GameObject newFilho = criaFilhoB("solido", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }

        if (particulasSA.sonar == true)
        {
            GameObject newFilho = criaFilhoB("sonar", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }
        if (particulasSA.magnetico == true)
        {
            GameObject newFilho = criaFilhoB("magnetico", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }
        if (particulasSA.invisibildade == true)
        {
            GameObject newFilho = criaFilhoB("invisibildade", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }
        if (particulasSA.camaraLenta == true)
        {
            GameObject newFilho = criaFilhoB("camaraLenta", directionForce);
            listaIrmao[numIrmaos] = newFilho;
            directionForce        = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2));
            numIrmaos++;
        }

        for (int i = 0; i < numIrmaos; i++)
        {
            listaIrmao[i].GetComponent <particulasC>().numIrmaos = numIrmaos;
            listaIrmao[i].GetComponent <particulasC>().irmaos    = listaIrmao;
        }
    }
Esempio n. 15
0
        public ActionResult Partidas(FormCollection form)
        {
            List <string> nomeTimes = new List <string>();

            try
            {
                //-- Adicionando os times ao banco na tabela TimesDaCopa --//

                CopaDoMundoEntities ce = new CopaDoMundoEntities();

                List <Chaves> chaves = new List <Chaves>();

                var listaChaves = from c in ce.Chaves select c;

                foreach (var item in listaChaves)
                {
                    Chaves ch = new Chaves();
                    ch.Id_Chave   = item.Id_Chave;
                    ch.Nome_Chave = item.Nome_Chave;

                    chaves.Add(ch);
                }

                int contaTimes = 1;

                foreach (var i in chaves)
                {
                    for (int x = 1; x <= 4; x++)
                    {
                        TimesDaCopa ti = new TimesDaCopa();
                        ti.Nome_Time = form["Time" + x + i.Nome_Chave];
                        ti.Id_Chave  = i.Id_Chave;
                        ti.Id_Time   = contaTimes++;

                        ce.TimesDaCopa.Add(ti);
                    }
                }

                ce.SaveChanges();

                //-- Criando e adicionando os times de forma aleatória ao banco na tabela Jogos --//

                CopaDoMundoEntities ce2 = new CopaDoMundoEntities();

                List <TimesDaCopa> timesJogo = new List <TimesDaCopa>();

                foreach (var item in ce.TimesDaCopa)
                {
                    TimesDaCopa tc = new TimesDaCopa();
                    tc.Id_Chave  = item.Id_Chave;
                    tc.Id_Time   = item.Id_Time;
                    tc.Nome_Time = item.Nome_Time;

                    timesJogo.Add(tc);
                }

                int a     = 0;
                int IJogo = 1;
                for (int x = 1; x <= 4; x++)
                {
                    var list = new List <int> {
                        0, 1, 2, 3
                    };
                    var rnd = new Random();

                    var query =
                        from i in list
                        let r = rnd.Next()
                                orderby r
                                select i;

                    var shuffled = query.ToList();

                    var listaJ = from c in timesJogo where c.Id_Chave == x select c;

                    List <TimesDaCopa> timesJ = new List <TimesDaCopa>();

                    foreach (var item in listaJ)
                    {
                        TimesDaCopa tc = new TimesDaCopa();
                        tc.Id_Time   = item.Id_Time;
                        tc.Nome_Time = item.Nome_Time;
                        tc.Id_Chave  = item.Id_Chave;

                        timesJ.Add(tc);
                    }

                    for (int y = 1; y <= 2; y++)
                    {
                        Jogos ti = new Jogos();

                        ti.Id_Time1 = timesJ[shuffled[a]].Id_Time;
                        ti.Id_Time2 = timesJ[shuffled[a + 1]].Id_Time;
                        ti.FaseJogo = 1;
                        ti.Id_Chave = timesJ[shuffled[a]].Id_Chave;
                        ti.Id_Jogo  = IJogo++;

                        a = (a + 1) + y;

                        ce2.Jogos.Add(ti);
                    }
                    a = 0;
                }

                ce2.SaveChanges();

                //-- Apresentando os jogos registrados no banco na view --//

                CopaDoMundoEntities ce3 = new CopaDoMundoEntities();

                var listaJa = from c in ce3.Jogos
                              join d in ce3.TimesDaCopa on c.Id_Time1 equals d.Id_Time
                              join x in ce3.TimesDaCopa on c.Id_Time2 equals x.Id_Time
                              select new { time1 = d.Nome_Time, time2 = x.Nome_Time };

                foreach (var item in listaJa)
                {
                    nomeTimes.Add(item.time1 + " X " + item.time2);
                }

                ViewBag.ListaTimes = nomeTimes;
            }
            catch (Exception ex)
            {
            }
            return(View());
        }