Ejemplo n.º 1
0
 public Acteur(String loc, int x, int y, Parcelle p, int taille)
 {
     imageP           = new Bitmap(loc);
     placementP.X     = x;
     placementP.Y     = y;
     placementP.Width = placementP.Height = taille;
     parcelle         = p;
 }
Ejemplo n.º 2
0
 public Acteur(String loc, int x, int y, Parcelle p, int taille)
 {
     imageP = new Bitmap(loc);
     placementP.X = x;
     placementP.Y = y;
     placementP.Width = placementP.Height = taille;
     parcelle = p;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Создает новый земельный участок, но не присоединяет его к базе данных
        /// </summary>
        /// <returns>Земельный участок</returns>
        public Parcelle CreateNewParcel()
        {
            Parcelle newParcel = new Parcelle()
            {
                GUID = Guid.NewGuid()
            };

            return(newParcel);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Запуск процесса редактирования геометрии участка
        /// </summary>
        private void EditParcelGeometry_OnClick(object sender, RoutedEventArgs e)
        {
            if (Parcels.SelectedItem == null)
            {
                return;
            }
            Parcelle           parcel = (Parcelle)Parcels.SelectedItem;
            GeometryEditWindow win    = new GeometryEditWindow(parcel);

            win.ShowDialog();
        }
Ejemplo n.º 5
0
 public int AddParcelle(Parcelle parcelle)
 {
     return(DAL.ManageData <DAL.Parcelle> .Add(new DAL.Parcelle
     {
         CreationDate = DateTime.Now,
         Adresse = parcelle.Adresse,
         Lat = parcelle.Lat,
         Lng = parcelle.Lng,
         Nom = parcelle.Nom,
         Ville = parcelle.Ville
     }));
 }
Ejemplo n.º 6
0
        public int EditParcelle(Parcelle parcelle)
        {
            DAL.Parcelle par = DAL.ManageData <DAL.Parcelle> .Get(parcelle.IdParcelle);

            par.Adresse      = parcelle.Adresse;
            par.CreationDate = parcelle.CreationDate;
            par.Lat          = parcelle.Lat;
            par.Lng          = parcelle.Lng;
            par.Nom          = parcelle.Nom;
            par.Ville        = parcelle.Ville;

            return(DAL.ManageData <DAL.Parcelle> .Update(par));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Запуск процесса добавления нового земельного участка
        /// </summary>
        private void AddNewParcel(object sender, RoutedEventArgs e)
        {
            ParcelEditViewModel ViewModel = ((ViewModelLocator)FindResource("ViewModelLocator")).ParcelEditor;
            Parcelle            parcel    = ViewModel.CreateNewParcel();
            GeometryEditWindow  win       = new GeometryEditWindow(parcel);

            if (win.ShowDialog() ?? false)
            {
                ViewModel.AddNewParcelInDb(parcel);
            }

            //Выделяем новый зу и пролистываем таблицу до него
            Parcels.SelectedItem = parcel;
            Parcels.ScrollIntoView(parcel);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Помечает участок к удалению из базы данных и удаляет его из списка<see cref="Parcels"/>
        /// </summary>
        /// <param name="parcel">Удаляемые земельный участок</param>
        /// <remarks>Удаленный участок сохраняется в кэше <see cref="ParcelsDelete"/></remarks>
        public void DeleteParcelle(Parcelle parcel)
        {
            if (Parcels.Contains(parcel))
            {
                //Сохраняем сведения об удаленном участке для поддержки отмены операции
                if (ContextDb.Entry(parcel).State != EntityState.Added)
                {
                    ParcelsDelete.Add(parcel);
                }

                ContextDb.JuridiqueObjets.Remove(parcel);
                Parcels.Remove(parcel);

                //Уведомляем об изменении свойств
                RaisePropertyChanged(nameof(ParcelsViewSource));
                RaisePropertyChanged(nameof(Parcels));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Добавляет новый земельный участок к БД, присваивая ему новый кадастровый номер
        /// </summary>
        /// <param name="newParcel"></param>
        public void AddNewParcelInDb(Parcelle newParcel)
        {
            using (var context = ContextFactory.Create())
            {
                context.CadastraleSecteurs_v.Load();
                var cadSect = context.CadastraleSecteurs_v.Local;
                newParcel.CadSecteurNumero = cadSect.Where(s => s.Shape.Intersects(newParcel.Shape)).First().Numero;

                newParcel.ParcelleSurCadSecteurNumero = (Parcels.Where(p => p.CadSecteurNumero == newParcel.CadSecteurNumero)
                                                         .Max(p => p.ParcelleSurCadSecteurNumero) ?? 0) + 1;
                newParcel.NUP = string.Format("{0}-{1:D4}", newParcel.CadSecteurNumero, newParcel.ParcelleSurCadSecteurNumero);
                ContextDb.JuridiqueObjets.Attach(newParcel);
                ContextDb.Entry(newParcel).State = EntityState.Added;

                Parcels.Add(newParcel);


                //Уведомляем об изменении свойств
                RaisePropertyChanged(nameof(ParcelsViewSource));
                RaisePropertyChanged(nameof(Parcels));
            }
        }
Ejemplo n.º 10
0
    // accélérometre
    public void ArroserLegume()
    {
        Parcelle scriptParcelle = selectedParcelle.GetComponent <Parcelle>();

        zRot = (-Input.acceleration.x / accMax) * maxAngle;

        if (zRot > maxAngle)
        {
            zRot = maxAngle;
            scriptParcelle.AEteArrose();
            return;
        }
        else if (zRot < 5)
        {
            zRot = 0;
        }

        //Transform arrosoirEmpty = GameObject.FindGameObjectWithTag("ArrosoirEmpty").transform;
        //float xRot = arrosoirEmpty.eulerAngles.x;

        // on veut que l'arrosoir reste toujours droit ms face a la camera
        // la rotation est fixé dans Parcelle.cs->PositionnerArrosoir()
        arrosoir.eulerAngles = new Vector3(arrosoir.eulerAngles.x, arrosoir.eulerAngles.y, zRot);
    }
Ejemplo n.º 11
0
        public void InitializeDummyData()
        {
            const int nbExploitants = 3; //30
            const int nbParcelles = 5; //20
            const int nbTraitements = 2; //50
            const int nbPulverisations = 2;

            int cptExploitants = 0, cptParcelles = 0, cptTraitements = 0, cptPulverisations = 0;
            // Remplissage avec des valeurs quelconques
            for (int i = 1; i <= nbExploitants; i++)
            {
                cptExploitants++;
                Exploitant e = new Exploitant(cptExploitants, "Dupont_" + cptExploitants);
                e.Telephone = "046700000" + cptExploitants;
                e.Mail = "Dupont_" + cptExploitants + "@foo.bar";

                for (int j = 1; j <= nbParcelles; j++)
                {
                    cptParcelles++;
                    Parcelle p = new Parcelle(cptParcelles, j*10, e);
                    p.Description = "PAR Desc" + j + "_" + i;
                    p.Emplacement = "PAR Emp" + j + "_" + i;
                    for (int k = 1; k <= nbTraitements; k++)
                    {
                        cptTraitements++;
                        TraitementEnChamp t = new TraitementEnChamp(cptTraitements);
                        t.Description = "TRAIT Desc" + j + "_" + i + "_" + k;
                        t.Parcelle = p;

                        for (int l = 1; l <= nbPulverisations; l++)
                        {
                            cptPulverisations++;
                            Pulverisation pl = new Pulverisation(cptPulverisations);
                            pl.Dosage = i * 14;
                            pl.Description = "PUL Desc" + j + "_" + i + "_" + k;
                            pl.Traitement = t;

                            t.AjouterPulverisation(pl);
                        }
                        p.AjouterTraitement(t);
                    }
                    cptTraitements++;
                    TraitementSemence ts = new TraitementSemence(cptTraitements);
                    ts.Description = "TRAIT Desc" + j + "_" + i + "_" + (nbPulverisations+1);
                    ts.Dosage = 10;
                    ts.Parcelle = p;
                    p.AjouterTraitement(ts);

                    e.AjouterParcelle(p);
                }
                liste.Add(e);
            }
        }
 public GeometryEditWindow(Parcelle parcel)
 {
     InitializeComponent();
     ViewModel = ((ViewModelLocator)FindResource("ViewModelLocator")).ViewModelEditor;
     ViewModel.NewJob(parcel);
 }
Ejemplo n.º 13
0
    ////////////////////////////////////////////////////////////////////////////////////



    public override void OnTouchBeganAnywhere()
    {
        #region PLANTATION on touch began
        // si on touche une parcelle
        if ((GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP1) ||
            (GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP2))
        {
            ray = Camera.main.ScreenPointToRay(Input.touches[0].position);

            #region swipe begin
            if (Physics.Raycast(ray, out hit) && (hit.collider.gameObject.layer == parcelles))
            {
                GameObject parcelle       = hit.collider.gameObject;
                Parcelle   scriptParcelle = parcelle.GetComponent <Parcelle>();


                if (scriptParcelle.isSelected && scriptParcelle.GetCurState() == Parcelle.ParcelleState.creuser)
                {
                    // si on commence le swipe sur la parcelle selectionne
                    if (Input.touchCount == 1 && selectedParcelle && selectedParcelle.tag == parcelle.tag)
                    {
                        fp = Input.GetTouch(0).position;
                        lp = Input.GetTouch(0).position;
                    }
                }
            }
            #endregion

            #region drag begin
            if (selectedParcelle)
            {
                if (selectedParcelle.GetComponent <Parcelle>().GetCurState() == Parcelle.ParcelleState.graine)
                {
                    if (Input.touchCount == 1)
                    {
                        if ((carotte.HitTest(Input.GetTouch(0).position)))
                        {
                            BeginDrag(carotte, hit.point);
                        }
                        else if (tomate.HitTest(Input.GetTouch(0).position))
                        {
                            BeginDrag(tomate, hit.point);
                        }
                        else if (choux.HitTest(Input.GetTouch(0).position))
                        {
                            BeginDrag(choux, hit.point);
                        }
                        else if (aubergine.HitTest(Input.GetTouch(0).position))
                        {
                            BeginDrag(aubergine, hit.point);
                        }
                        else if (patate.HitTest(Input.GetTouch(0).position))
                        {
                            BeginDrag(patate, hit.point);
                        }
                        else if (oignon.HitTest(Input.GetTouch(0).position))
                        {
                            BeginDrag(oignon, hit.point);
                        }
                    }
                }
            }
            #endregion
        }
        #endregion
    }
Ejemplo n.º 14
0
    ////////////////////////////////////////////////////////////////////////////////////


    public override void OnTouchEndedAnywhere()
    {
        // on vérifie si on a appuyé sur le bouton de menu
        RetournerMenu();

        #region DIALOGUES
        // quete 1
        if (GameManagerJardin.curGameState == GameManagerJardin.GameState.queteJessicaP1)
        {
            ChangeState(GameManagerJardin.GameState.queteJessicaP1, GameManagerJardin.GameState.planterP1);
            AfficherBoutons();
        }

        // dialogue 1 de la tansition
        else if (GameManagerJardin.curGameState == GameManagerJardin.GameState.dialogueTransition1)
        {
            ChangeState(GameManagerJardin.GameState.dialogueTransition1, GameManagerJardin.GameState.transition);
        }

        // TEMPORARIRE
        // tansition
        else if (GameManagerJardin.curGameState == GameManagerJardin.GameState.transition)
        {
            ChangeState(GameManagerJardin.GameState.transition, GameManagerJardin.GameState.dialogueTransition2);
        }

        // dialogue 2 de la tansition 2
        else if (GameManagerJardin.curGameState == GameManagerJardin.GameState.dialogueTransition2)
        {
            ChangeState(GameManagerJardin.GameState.dialogueTransition2, GameManagerJardin.GameState.queteJessicaP2);
        }

        // quete 2
        else if (GameManagerJardin.curGameState == GameManagerJardin.GameState.queteJessicaP2)
        {
            ChangeState(GameManagerJardin.GameState.queteJessicaP2, GameManagerJardin.GameState.planterP2);
            AfficherBoutons();
        }

        // score
        else if (GameManagerJardin.curGameState == GameManagerJardin.GameState.score)
        {
            // on check si on a appuyer sur le bouton rejouer
            Rejouer();
        }
        #endregion


        #region PLANTATION on touch ended
        // si on touche une parcelle
        else if ((GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP1) ||
                 (GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP2))
        {
            // on vérifie si on a appuyé sur le bouton de validation
            ValiderLegumes();

            // on vérifie si on a appuyé sur le bouton d'info
            AfficherLegumesPlantes();

            ray = Camera.main.ScreenPointToRay(Input.touches[0].position);

            // si on a termine un touch en dehors d'une parcelle, sur le jardin
            if (Physics.Raycast(ray, out hit) && (hit.collider.gameObject.tag == "FloorJardin"))
            {
                // si on etait en train de dragger un legume
                if (dragging)
                {
                    AnnulerGraine();
                }

                /*
                 * // on deselectionne la parcelle couremment selectionne
                 * else if (selectedParcelle) {
                 *      selectedParcelle.GetComponent<Parcelle>().AEteDeSelectionne();
                 *      selectedParcelle = null;
                 *      NePasAfficherUILegumes();
                 * }
                 */
            }

            // si on a termine un touch sur une parcelle et qu'on est pas en train de tourner la camera
            else if (Physics.Raycast(ray, out hit) && (hit.collider.gameObject.layer == parcelles) && !rotatingCamera)
            {
                GameObject parcelle       = hit.collider.gameObject;
                Parcelle   scriptParcelle = parcelle.GetComponent <Parcelle>();

                // si on termine un touch sur une parcelle selectionne
                if (scriptParcelle.isSelected)
                {
                    // faire 3 petits swipe pour creuser
                    if (scriptParcelle.GetCurState() == Parcelle.ParcelleState.creuser)
                    {
                        // swipe action
                        #region swipe ended
                        if (((fp.x - lp.x) > dist) || ((fp.x - lp.x) < -dist) || ((fp.y - lp.y) < -dist) || ((fp.y - lp.y) > dist))
                        {
                            scriptParcelle.IncrementDigged();
                            scriptParcelle.AEteCreuse();
                        }
                        #endregion

                        if (scriptParcelle.IsFullyDigged())
                        {
                            AfficherUILegumes();
                        }
                    }

                    // on plante la graine, faire un drag and drop
                    // changement d'etat traité dans AjoutLegume(gTex), Appel dans TouchJardin
                    else if (scriptParcelle.GetCurState() == Parcelle.ParcelleState.graine)
                    {
                        #region drag ended
                        if (dragging && Input.touchCount == 1)
                        {
                            // si le legume a ete plante
                            if (AjoutLegume(legumeDragged))
                            {
                                ValiderGraine();
                            }
                            else
                            {
                                AnnulerGraine();
                            }
                        }
                        #endregion
                    }
                }

                // si on termine un touch sur une parcelle non selectionne
                else
                {
                    // si on etait en train de dragger, on annule le placement de la graine
                    if (dragging && Input.touchCount == 1)
                    {
                        AnnulerGraine();
                    }
                    // sinon on a termine le touch sur une parcelle non selectionne
                    else
                    {
                        if (selectedParcelle)
                        {
                            selectedParcelle.GetComponent <Parcelle>().AEteDeSelectionne();
                            NePasAfficherUILegumes();
                        }

                        // la nouvelle parcelle selectionné est celle qu'on a touché
                        selectedParcelle     = parcelle;
                        selectedParcelle.tag = parcelle.tag;
                        scriptParcelle.AEteSelectionne();


                        // si on reselectionne une parcelle qui attend une graine
                        if (scriptParcelle.GetCurState() == Parcelle.ParcelleState.graine)
                        {
                            AfficherUILegumes();
                        }
                    }
                }

                //print (hit.collider.tag + "   " + scriptParcelle.GetCurState() + "   " + scriptParcelle._legume);
            }
        }
        #endregion
    }
Ejemplo n.º 15
0
    ////////////////////////////////////////////////////////////////////////////////////


    public override void OnTouchMovedAnywhere()
    {
        #region PLANTATION on touch moved
        if ((GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP1) ||
            (GameManagerJardin.curGameState == GameManagerJardin.GameState.planterP2))
        {
            ray = Camera.main.ScreenPointToRay(Input.touches[0].position);

            #region Camera rotate
            // si on a termine un touch en dehors d'une parcelle, sur le jardin
            if (Physics.Raycast(ray, out hit) && (hit.collider.gameObject.tag == "FloorJardin"))
            {
                if (!dragging)
                {
                    RotateCamera();

                    // si on est train d'arroser on veut que l'arrosoir reste face a la camera
                    if (selectedParcelle && selectedParcelle.GetComponent <Parcelle>().GetCurState() == Parcelle.ParcelleState.arrosage)
                    {
                        arrosoir.eulerAngles = Camera.main.transform.eulerAngles;
                    }
                }
            }
            #endregion


            #region drag moved
            // si on est en train de dragger, on met a jour la position de la graine
            if (dragging)
            {
                graineClone.position = new Vector3(hit.point.x, 1, hit.point.z);
            }
            #endregion

            // si on bouge sur une parcelle
            if (Physics.Raycast(ray, out hit) && (hit.collider.gameObject.layer == parcelles))
            {
                GameObject parcelle       = hit.collider.gameObject;
                Parcelle   scriptParcelle = parcelle.GetComponent <Parcelle>();

                // si on a une parcelle selectionné et que la parcelle touché est la parcelle sélectionné
                if (selectedParcelle && selectedParcelle.tag == parcelle.tag)
                {
                    #region swipe moved
                    if (scriptParcelle.GetCurState() == Parcelle.ParcelleState.creuser)
                    {
                        if (Input.touchCount == 1)
                        {
                            lp = Input.GetTouch(0).position;
                        }
                    }
                    #endregion
                }
                #region Camera rotate
                else
                {
                    if (!dragging)
                    {
                        RotateCamera();
                    }
                }
                #endregion
            }
        }
        #endregion
    }