Exemple #1
0
        private ElementoPreventivoModel convertiFaseInElementoPreventivo(FaseModel fase, decimal idElementoPreventivo, decimal idPadre)
        {
            ElementoPreventivoModel elemento = new ElementoPreventivoModel();

            elemento.IdElementoPreventivo = idElementoPreventivo;
            elemento.IdPadre           = idPadre;
            elemento.IdPreventivo      = _preventivoSelezionato.IdPreventivo;
            elemento.Codice            = fase.Codice;
            elemento.Reparto           = fase.Reparto;
            elemento.Ricarico          = fase.Ricarico;
            elemento.CostoOrario       = fase.Costo;
            elemento.IncludiPreventivo = fase.IncludiPreventivo;
            elemento.IdEsterna         = -1;
            elemento.TabellaEsterna    = string.Empty;
            elemento.PezziOrari        = 0;
            elemento.Peso        = 0;
            elemento.Superficie  = 0;
            elemento.Quantita    = 1;
            elemento.Descrizione = fase.Descrizione;
            elemento.Articolo    = string.Empty;
            elemento.Nota        = string.Empty;
            return(elemento);
        }
    public override void OnNotificacao(string evento_caminho, Object alvo, params object[] dados)
    {
        switch (evento_caminho)
        {
        case Notificacao.Fase.Inicio:
            model = GetComponent <FaseModel>();
            view  = GetComponentInChildren <FaseView>();

            view.SetFase(model.BatidasPorSegundo, model.TemposCriar, model.Proporcao);
            break;

        case Notificacao.Fase.CriarToupeiras:
            if (model.BuracosDisponiveis.Count > 0)
            {
                view.CriarToupeiras(model.MaxToupeiras,
                                    model.BuracosDisponiveis,
                                    model.Toupeiras,
                                    model.Bpm,
                                    model.SonsSurgindo[Random.Range(0, model.SonsSurgindo.Length)],
                                    model.SonsAcertou[Random.Range(0, model.SonsAcertou.Length)],
                                    model.SonsDano[Random.Range(0, model.SonsDano.Length)],
                                    //model.SonsFugiu[Random.Range(0, model.SonsFugiu.Length)],
                                    model.AcertouEfeito);
            }
            else
            {
                app.DebugFase("model.BuracosDisponiveis.Count == " + model.BuracosDisponiveis.Count);
            }
            break;

        case Notificacao.Fase.CriarArmadilhas:
            if (model.BuracosDisponiveis.Count > 0)
            {
                view.CriarArmadilhas(model.MaxArmadilhas,
                                     model.BuracosDisponiveis,
                                     model.Armadilhas,
                                     model.Bpm,
                                     model.SonsSurgindo[Random.Range(0, model.SonsSurgindo.Length)],
                                     model.SonsAcertou[Random.Range(0, model.SonsAcertou.Length)],
                                     model.SonsDano[Random.Range(0, model.SonsDano.Length)],
                                     model.AcertouEfeito);
            }
            else
            {
                app.DebugFase("model.BuracosDisponiveis.Count == " + model.BuracosDisponiveis.Count);
            }
            break;

        case Notificacao.Fase.AumentarDificuldade:
            model.Bpm *= 1.25f;
            if (model.Bpm > model.BpmMax)
            {
                model.Bpm = model.BpmMax;
            }
            break;

        case Notificacao.Jogador.MatarUmaToupeiraAleatoria:
            try
            {
                int r = Random.Range(0, TesteDados.Toupeiras.Length);
                while (TesteDados.Toupeiras[r].GetComponent <ToupeiraModel>().Descendo)
                {
                    r = Random.Range(0, TesteDados.Toupeiras.Length);
                }
                app.Notificar(Notificacao.Toupeira.MatarUma, TesteDados.Toupeiras[r].GetComponentInChildren <ToupeiraView>());
            } catch
            {
                app.Notificar(Notificacao.Toupeira.MatarUma, null);
            }

            break;

        case Notificacao.Jogador.MatarTodasToupeiras:
            for (int i = 0; i < TesteDados.Toupeiras.Length; i++)
            {
                app.Notificar(Notificacao.Toupeira.MatarTodas, TesteDados.Toupeiras[i].GetComponentInChildren <ToupeiraView>());
            }
            break;

/*            case Notificacao.Jogador.MatarTodasToupeiras:
 *              try
 *              {
 *                  app.DebugFase("MatarTodas");
 *                  for (int i = 0; i < TesteDados.Toupeiras.Length; i++)
 *                  {
 *                      app.Notificar(Notificacao.Toupeira.MatarTodas, TesteDados.Toupeiras[i].GetComponentInChildren<ToupeiraView>());
 *                  }
 *              } catch
 *              {
 *                  app.DebugFase("MatarTodas catch");
 *              }
 *
 *              break;
 */

        case Notificacao.Fase.Parar:
            app.DebugFase("Controller Parar");
            view.Parar();
            break;

        case Notificacao.Fase.Voltar:
            app.DebugFase("Controller Voltar");
            view.Voltar();
            break;

        case Notificacao.Fase.Fim:
            app.DebugFase("Fim");
            #region MELHORAR

            /*
             * app.musicaSource.Stop();
             * foreach(GameObject go in model.BuracosOcupados)
             * {
             *  try
             *  {
             *      Destroy(go.GetComponent<Buraco>().Toupeira);
             *  }
             *  catch
             *  {
             *      Destroy(go.GetComponent<Buraco>().Armadilha);
             *  }
             * }
             * foreach(GameObject go in model.Buracos)
             * {
             *  Destroy(go);
             * }
             */
            Destroy(GameObject.Find("Luzes"));

            /*
             * foreach(Text t in TesteContarTempo.TxtTimer)
             * {
             *  t.text = "00:00";
             * }
             */
            FindObjectOfType <TesteMenu>().GameOver();
            #endregion

            break;
        }
    }
Exemple #3
0
        private void treeView1_DragDrop(object sender, DragEventArgs e)
        {
            Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));


            TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));

            if (draggedNode != null)
            {
                if (draggedNode == null)
                {
                    return;
                }

                TreeNode targetNode = treeView1.GetNodeAt(targetPoint);

                if (targetNode == null)
                {
                    draggedNode.Remove();
                    treeView1.Nodes.Add(draggedNode);
                    draggedNode.Expand();
                }
                else
                {
                    TreeNode parentNode = targetNode;

                    if (!draggedNode.Equals(targetNode) && targetNode != null)
                    {
                        bool canDrop = true;
                        while (canDrop && (parentNode != null))
                        {
                            canDrop    = !Object.ReferenceEquals(draggedNode, parentNode);
                            parentNode = parentNode.Parent;
                        }

                        if (canDrop)
                        {
                            draggedNode.Remove();
                            targetNode.Nodes.Add(draggedNode);

                            ElementoPreventivoModel elementoSpostato = (ElementoPreventivoModel)draggedNode.Tag;
                            decimal idPadre = estraiIdPadre(targetNode);
                            elementoSpostato.IdPadre = idPadre;
                            eliminaElementoDallaLista(elementoSpostato);
                            inserisciElementoNellaLista(elementoSpostato, draggedNode, idPadre);
                            RefreshGridView();
                            targetNode.Expand();
                        }
                    }
                }
            }
            else
            {
                TreeNode nodeToDropIn = this.treeView1.GetNodeAt(this.treeView1.PointToClient(new Point(e.X, e.Y)));
                if (nodeToDropIn == null)
                {
                    return;
                }

                // il nodo viene inserito sopra al node to drop in, in cascata, almeno che non siala radice

                if (nodeToDropIn.Parent == null || e.KeyState == 4)
                {
                    decimal idPadre = estraiIdPadre(nodeToDropIn);
                    decimal idElementoPreventivo = MPIntranet.Business.Articolo.EstraId();

                    FaseModel fase = (FaseModel)e.Data.GetData(typeof(FaseModel));
                    ElementoPreventivoModel elemento;
                    if (fase == null)
                    {
                        MateriaPrimaModel materiaPrima = (MateriaPrimaModel)e.Data.GetData(typeof(MateriaPrimaModel));
                        if (materiaPrima == null)
                        {
                            return;
                        }
                        elemento = convertiMateriaPrimaInElementoPreventivo(materiaPrima, idElementoPreventivo, idPadre);
                    }
                    else
                    {
                        elemento = convertiFaseInElementoPreventivo(fase, idElementoPreventivo, idPadre);
                    }
                    aggungiNodo(nodeToDropIn, elemento);

                    inserisciElementoNellaLista(elemento, nodeToDropIn, idPadre);
                    nodeToDropIn.ExpandAll();
                }
                else
                {
                    TreeNode padre = nodeToDropIn.Parent;
                    treeView1.Nodes.Remove(nodeToDropIn);

                    decimal idPadre = estraiIdPadre(padre);
                    decimal idElementoPreventivo = MPIntranet.Business.Articolo.EstraId();

                    FaseModel fase = (FaseModel)e.Data.GetData(typeof(FaseModel));
                    ElementoPreventivoModel elemento;
                    if (fase == null)
                    {
                        MateriaPrimaModel materiaPrima = (MateriaPrimaModel)e.Data.GetData(typeof(MateriaPrimaModel));
                        if (materiaPrima == null)
                        {
                            return;
                        }
                        elemento = convertiMateriaPrimaInElementoPreventivo(materiaPrima, idElementoPreventivo, idPadre);
                    }
                    else
                    {
                        elemento = convertiFaseInElementoPreventivo(fase, idElementoPreventivo, idPadre);
                    }
                    TreeNode nodoAggiunto = aggungiNodo(padre, elemento);
                    inserisciElementoNellaLista(elemento, padre, idPadre);
                    ElementoPreventivoModel elementoNodeToDropIn = (ElementoPreventivoModel)nodeToDropIn.Tag;
                    elementoNodeToDropIn.IdPadre = idElementoPreventivo;
                    nodoAggiunto.Nodes.Add(nodeToDropIn);
                    padre.ExpandAll();
                }

                RefreshGridView();
            }
        }