Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Coordonnees c1 = new Coordonnees();
            Coordonnees c2 = new Coordonnees(1, 2);

            Console.WriteLine(c1);
            Console.WriteLine(c2);
            c1._latitude = 0;
            c1.Longitude = 10.12345;
            Console.WriteLine(c1);
            Console.WriteLine(c2);
            POI p1 = new POI("Coucou", new Coordonnees(10, 14.5892));
            POI p2 = new POI(p1);

            Console.WriteLine(p1);
            Console.WriteLine(p2);

            Polyline p = new Polyline();

            Console.WriteLine(p);

            Polygon poly1 = new Polygon();

            poly1.Draw();

            Thread.Sleep(10000);
        }
Ejemplo n.º 2
0
        private void POI_Import_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog();
            openFileDlg.DefaultExt = ".csv";
            openFileDlg.Filter     = "csv document (.csv)|*.csv";
            openFileDlg.ShowDialog();
            POI newPOI = new POI();

            string[] lines = File.ReadAllLines(openFileDlg.FileName);
            Console.WriteLine(lines.Length);
            if (lines.Length > 2)
            {
                //Erreur on essaye d'importer un Trajet
                MessageBox.Show("Erreur,impossible d'ajouter un traject comme POI!");
                return;
            }

            string s = lines[0];

            string[] lines2 = s.Split(';');
            newPOI.Latitude    = double.Parse(lines2[0]);
            newPOI.Longitude   = double.Parse(lines2[1]);
            newPOI.Description = lines2[2];

            myPersonalMapData.ObservableCollection.Add(newPOI);
            UpdateMainWindow();
        }
Ejemplo n.º 3
0
        public static Percurso ConvertDTOToModel(PercursoDTO dto)
        {
            Percurso p = new Percurso();

            p.PercursoID        = dto.ID;
            p.Name              = dto.Name;
            p.Description       = dto.Description;
            p.StartHour         = dto.StartHour;
            p.FinishHour        = dto.FinishHour;
            p.PercursoPOIsOrder = dto.PercursoPOIsOrder;

            if (dto.PercursoPOIs != null)
            {
                foreach (POIDTO poiDTO in dto.PercursoPOIs)
                {
                    POI poiCon = new POI();

                    poiCon.POIID       = poiDTO.ID;
                    poiCon.Name        = poiDTO.Name;
                    poiCon.Description = poiDTO.Description;
                    poiCon.GPS_Lat     = poiDTO.GPS_Lat;
                    poiCon.GPS_Long    = poiDTO.GPS_Long;
                    poiCon.Altitude    = poiDTO.Altitude;

                    p.PercursoPOIs.Add(poiCon);
                }
            }

            if (dto.Creator != null)
            {
                p.Creator = dto.Creator;
            }

            return(p);
        }
Ejemplo n.º 4
0
        public ActionResult AproveValidate(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SugerirPOI sugerirPOI = db.SugerirPOI.Find(id);

            try
            {
                if (ModelState.IsValid)
                {
                    POI pOI = new POI();
                    pOI.Nome          = sugerirPOI.Nome;
                    pOI.Descricao     = sugerirPOI.Descricao;
                    pOI.LocalID       = sugerirPOI.LocalID;
                    pOI.CategoriaID   = sugerirPOI.CategoriaID;
                    pOI.duracaoVisita = sugerirPOI.duracaoVisita;
                    db.POIs.Add(pOI);
                    db.Entry(sugerirPOI).State = EntityState.Deleted;
                    db.SaveChanges();
                    return(RedirectToAction("Validate"));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(sugerirPOI));
        }
Ejemplo n.º 5
0
        private void afficherTrajet(Polyline trajet)
        {
            MapPolyline mapPolyline = new MapPolyline();

            mapPolyline.Opacity         = 0.7;
            mapPolyline.StrokeThickness = trajet.Epaisseur;
            SolidColorBrush couleurTrajet = new SolidColorBrush(trajet.Couleur);

            mapPolyline.Stroke    = couleurTrajet;
            mapPolyline.Locations = new LocationCollection();
            foreach (CartoObj o in trajet.CollectionDeCoordonnes)
            {
                if (o is POI)
                {
                    POI     p       = o as POI;
                    Pushpin pushpin = new Pushpin();
                    pushpin.ToolTip    = p.Draw();
                    pushpin.Opacity    = 0.7;
                    pushpin.Location   = new Location(p.Latitude, p.Longitude);
                    pushpin.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
                    Carte.Children.Add(pushpin);
                    mapPolyline.Locations.Add(new Location(p.Latitude, p.Longitude));
                }
            }
            Carte.Children.Add(mapPolyline);
        }
Ejemplo n.º 6
0
    public void clicked()
    {
        if (!POI_ReferenceHub.Instance.POIEditWindow.gameObject.activeSelf)
        {
            POI_ReferenceHub.Instance.POIEditWindow.gameObject.SetActive(true);
        }

        // Here we get the POI from the POIInfo script that is attached to the activeButton.
        // We then use this info to populate the edit menu fields.
        POI clickedPOI = POI_ReferenceHub.Instance.POIMenu.GetComponent <POIActiveButtonManager>().activeButton.GetComponent <POIInfoRef>().poiInfo.Point;

        POI_ReferenceHub.Instance.poiInfoFields [0].text = clickedPOI.buttonName;
        POI_ReferenceHub.Instance.poiInfoFields [1].text = clickedPOI.position.x.ToString();
        POI_ReferenceHub.Instance.poiInfoFields [2].text = clickedPOI.position.y.ToString();
        POI_ReferenceHub.Instance.poiInfoFields [3].text = clickedPOI.position.z.ToString();
        POI_ReferenceHub.Instance.poiInfoFields [4].text = clickedPOI.rotation.y.ToString();

        //disable the Add bookmark button, enable save changes
        POI_ReferenceHub.Instance.POIEditWindow.FindChild("AddBookmark").gameObject.SetActive(false);
        POI_ReferenceHub.Instance.POIEditWindow.FindChild("SaveChanges").gameObject.SetActive(true);

        //grey out edit bookmark
        Transform editBut = POI_ReferenceHub.Instance.AddDeleteWindow.FindChild("EditBookmark") as Transform;

        editBut.GetComponent <Button>().enabled = false;        //disable edit button
        Transform editButText = editBut.FindChild("Text") as Transform;

        editButText.GetComponent <Text>().color = new Color(0.57f, 0.57f, 0.57f);
    }
Ejemplo n.º 7
0
    public void reveal(int x, int z)//--done
    {
        Debug.Log("reveal");
        int[] key = new int[] { x, z };
        POI   p   = getPOI(key[0], key[1], placedPOI);

        if (p != null)
        {
            p.setStatus(POIStatus.Revealed);
            gm.DestroyObject(getPOIPrefab(key[0], key[1], poiLookup));
            Remove(key[0], key[1], poiLookup);
            if (p.type == POIType.FalseAlarm)
            {
                Remove(key[0], key[1], placedPOI);
                p.setStatus(POIStatus.Removed);
            }
            else
            {
                GameObject go = gm.instantiateObject(p.Prefab, new Vector3((float)((double)x * 6 - 1.5), posY, (float)((double)z * 6 + 1.5)), Quaternion.identity);

                go.transform.Rotate(90, 0, 0);
                poiLookup.Add(key, go);
            }
        }
    }
Ejemplo n.º 8
0
        private void MenuItemPOIImport_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Multiselect = false;
            dlg.DefaultExt  = ".csv";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                Excel.Application oExcel = new Excel.Application();

                Excel.Workbook  WB = oExcel.Workbooks.Open(dlg.FileName);
                string          ExcelWorkbookName = WB.Name;
                int             worksheetcount    = WB.Worksheets.Count;
                Excel.Worksheet wks = (Excel.Worksheet)WB.Worksheets[1];

                string firstworksheetname = wks.Name;

                var firestcellValue = ((Excel.Range)wks.Cells[1, 1]).Value;
                Console.WriteLine("FIRST CELL VALUE = " + firestcellValue);
                Console.WriteLine("TEST = ", wks.Cells[2, 1]);
                Console.WriteLine("TEST = ", wks.Cells[2, 2]);
                Console.WriteLine("TEST = ", wks.Cells[2, 3]);
                Console.WriteLine("On a ouvert : " + dlg.FileName);
                POI p = new POI(new POI((string)((Excel.Range)wks.Cells[2, 3]).Value, (double)((Excel.Range)wks.Cells[2, 1]).Value, (double)((Excel.Range)wks.Cells[2, 2]).Value));
                mP.AddCartObj(p);
                AjouterPushPin(p);

                releaseObject(oExcel);
                releaseObject(WB);
                releaseObject(wks);
            }
        }
Ejemplo n.º 9
0
        public async Task <List <POI> > getPOIList(int?id)
        {
            client = PVWebApiHttpClient.GetClient();

            IEnumerable <POIDTO> pois = null;
            var response = await client.GetAsync("api/POI/");

            if (response.IsSuccessStatusCode)
            {
                pois = await response.Content.ReadAsAsync <IEnumerable <POIDTO> >();
            }

            List <POI> poiList = new List <POI>();

            foreach (POIDTO poiDTO in pois)
            {
                POI poi = DTOConverters.ConvertDTOToModel(poiDTO);
                if (id != null && poi.POIID != id)
                {
                    poiList.Add(poi);
                }

                if (id == null)
                {
                    poiList.Add(poi);
                }
            }
            return(poiList);
        }
Ejemplo n.º 10
0
        private void MenuFilePOIImport_Click(object sender, RoutedEventArgs e)
        {
            bool           erreurImport = false;
            OpenFileDialog openFile     = new OpenFileDialog();

            openFile.Filter           = "Fichier CSV files(*.csv) | *.csv";
            openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFile.ShowDialog();

            POI poiLoad = null;

            try
            {
                poiLoad = POI.readCSVfile(openFile.FileName);
            }
            catch (CSVexception messageErreurLoadPoi)
            {
                MessageBox.Show(messageErreurLoadPoi.Message, "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error);
                erreurImport = true;
            }

            if (!erreurImport)
            {
                PersonneConnectee.ObservableCollection.Add(poiLoad);
                UpdateListBox();
                MessageBox.Show("OUVERTURE REUSSIE", "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 11
0
 public override void Start()
 {
     if (search.poi != null)
     {
         poi = search.poi;
     }
 }
Ejemplo n.º 12
0
        private void tbDetails_Click(object sender, RoutedEventArgs e)
        {
            ICartoObj o = (ICartoObj)ListBox.SelectedItem;
            string    titreFenetre = "", messageFenetre = "";

            if (o == null)
            {
                MessageBox.Show("Aucun élément de la ListBox est sélectionné", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                if (o is POI)
                {
                    POI p = o as POI;
                    titreFenetre   = "Caractéristiques détaillées du POI sélectionné";
                    messageFenetre = p.Draw();
                }
                if (o is Polyline)
                {
                    Polyline p = o as Polyline;
                    titreFenetre   = "Caractéristiques détaillées du trajet (Polyline) sélectionné";
                    messageFenetre = p.Draw();
                }
                if (o is Polygon)
                {
                    Polygon p = o as Polygon;
                    titreFenetre   = "Caractéristiques détaillées de la surface (Polygon) sélectionné";
                    messageFenetre = p.Draw();
                }
                MessageBox.Show(messageFenetre, titreFenetre, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 13
0
        public async Task <bool> UpdateHashtags(POI poi)
        {
            context.Database.ExecuteSqlCommand("delete from POIHashtag where POI_POIID = {0}", poi.POIID);
            await context.SaveChangesAsync();

            foreach (Hashtag tag in poi.Hashtags)
            {
                Hashtag existingTag = null;
                existingTag = await getHashtagRepository().FindHashtagAsync(tag.Text);

                if (existingTag == null)
                {
                    context.Hashtags.Add(tag);
                }
                else
                {
                    tag.HashtagID            = existingTag.HashtagID;
                    context.Entry(tag).State = EntityState.Unchanged;
                }
                await context.SaveChangesAsync();

                context.Database.ExecuteSqlCommand("Insert Into POIHashtag (POI_POIID,Hashtag_HashtagID)" +
                                                   "Values('" + poi.POIID + "','" + tag.HashtagID + "')");
            }
            await context.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 14
0
        public POIDTO ConvertModelToDTO(POI poi)
        {
            POIDTO dto = new POIDTO()
            {
                ID            = poi.POIID,
                Name          = poi.Name,
                Description   = poi.Description,
                OpenHour      = poi.OpenHour,
                CloseHour     = poi.CloseHour,
                VisitDuration = poi.VisitDuration,
                GPS_Lat       = poi.GPS_Lat,
                GPS_Long      = poi.GPS_Long,
                Altitude      = poi.Altitude,
                Creator       = poi.Creator,
                Approved      = poi.Approved,
                ConnectedPOI  = new List <POIConnectedDTO>(),
                Hashtags      = getHashtagRepository().ConvertModelListToDTO(poi.Hashtags)
            };

            foreach (POI connected in poi.ConnectedPOIs)
            {
                POIConnectedDTO poiCon = new POIConnectedDTO();

                poiCon.ID   = connected.POIID;
                poiCon.Name = connected.Name;

                dto.ConnectedPOI.Add(poiCon);
            }

            return(dto);
        }
Ejemplo n.º 15
0
        public async Task <bool> UpdatePOI(POI poi)
        {
            context.Database.ExecuteSqlCommand("delete from Caminho where POIID = {0}", poi.POIID);
            await context.SaveChangesAsync();

            context.Database.ExecuteSqlCommand("delete from Caminho where ConnectedPOIID = {0}", poi.POIID);
            await context.SaveChangesAsync();

            foreach (POI connected in poi.ConnectedPOIs)
            {
                context.Database.ExecuteSqlCommand("Insert Into Caminho (POIID,ConnectedPOIID)" +
                                                   "Values('" + poi.POIID + "','" + connected.POIID + "')");

                if (poi.Approved != null && poi.Approved != "no")
                {
                    context.Database.ExecuteSqlCommand("Insert Into Caminho (POIID,ConnectedPOIID)" +
                                                       "Values('" + connected.POIID + "','" + poi.POIID + "')");
                }
            }

            context.Entry(poi).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> Create([Bind(Include = "POIID,Name,Description,OpenHour,CloseHour,VisitDuration,GPS_Lat,GPS_Long,Altitude,ConnectedPOIs")] POI pOI)
        {
            ViewBag.PoiList = await getPOIList(null);

            var connectedForm = Request.Form["ConnectedPOIs"];

            parseConnectedPOIs(pOI, connectedForm);

            string openHour = Request.Form["OpenHour"];

            pOI.OpenHour = Convert.ToDateTime(openHour);

            string closeHour = Request.Form["CloseHour"];

            pOI.CloseHour = Convert.ToDateTime(closeHour);

            pOI.Creator  = PVWebApiHttpClient.getUsername();
            pOI.Approved = PVWebApiHttpClient.getUsername();

            client = PVWebApiHttpClient.GetClient();
            var responseHttp = await client.PostAsJsonAsync("api/POI", pOI);

            if (responseHttp.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public async Task <IHttpActionResult> PutHashtags(int id, POI pOI)
        {
            if (!ModelState.IsValid)
            {
                var    allErrors = ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage));
                string problems  = "";
                foreach (string error in allErrors)
                {
                    problems += " _____ " + error;
                }
                return(BadRequest("Invalid model object: " + problems));
            }

            if (id != pOI.POIID)
            {
                return(BadRequest("ID received is not equal to POI ID"));
            }

            try
            {
                await unitOfWork.POIRepository.UpdateHashtags(pOI);
            }
            catch (Exception ex)
            {
                return(BadRequest("Exception ocurred: " + ex.Message));
            }

            return(StatusCode(HttpStatusCode.OK));
        }
Ejemplo n.º 18
0
        private void tbAfficher_Click(object sender, RoutedEventArgs e)
        {
            ICartoObj o = (ICartoObj)ListBox.SelectedItem;

            if (o == null)
            {
                MessageBox.Show("Aucun élément de la ListBox est sélectionné", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                Carte.Children.Clear();
                if (o is POI)
                {
                    POI p = o as POI;
                    afficherPOI(p);
                }
                if (o is Polyline)
                {
                    Polyline p = o as Polyline;
                    afficherTrajet(p);
                }
                //if (o is Polygon)
                //{
                //    Polygon p = o as Polygon;

                //}
            }
        }
Ejemplo n.º 19
0
        /// POI *****************************************************************

        /// <summary>
        /// Gets a POI by name.
        /// </summary>
        /// <param name="poiName">Name of the POI.</param>
        /// <returns>A gym if the name is in the database, otherwise null.</returns>
        public POI GetPOI(ulong guild, string poiName)
        {
            POI    poi         = null;
            string queryString = $@"SELECT *
                                 FROM POI 
                                 WHERE GuildID={guild}
                                 AND Name='{poiName}';";

            using (SqlConnection conn = GetConnection())
            {
                conn.Open();
                using (SqlDataReader reader = new SqlCommand(queryString, conn).ExecuteReader())
                {
                    while (reader.Read())
                    {
                        poi = new POI
                        {
                            Name        = Convert.ToString(reader["Name"]),
                            Latitude    = Convert.ToString(reader["Latitude"]),
                            Longitude   = Convert.ToString(reader["Longitude"]),
                            IsGym       = Convert.ToInt32(reader["IsGym"]) == TRUE,
                            IsSponsored = Convert.ToInt32(reader["IsSponsored"]) == TRUE,
                            IsExGym     = Convert.ToInt32(reader["IsEx"]) == TRUE,
                        };
                    }
                }
                conn.Close();
            }
            return(poi);
        }
Ejemplo n.º 20
0
        private void copyToDto(POI poi, POIDTOReceive poiDto)
        {
            if (poiDto.Nome != null)
            {
                poi.Nome = poiDto.Nome;
            }
            if (poiDto.Descricao != null)
            {
                poi.Descricao = poiDto.Descricao;
            }
            Local local = db.Locals.Find(poiDto.LocalID);

            if (local != null)
            {
                poi.LocalID = poiDto.LocalID;
                poi.Local   = local;
            }
            Categoria categoria = db.Categorias.Find(poiDto.CategoriaID);

            if (categoria != null)
            {
                poi.CategoriaID = poiDto.CategoriaID;
                poi.Categoria   = categoria;
            }
            //poi.UserId = User.Identity.GetUserId();
            //poi.User = db.Users.Find(poi.UserId);
        }
Ejemplo n.º 21
0
        private void Modifier_Click(object sender, RoutedEventArgs e) //Lors de la modification , il suffit de cliquer sur un element et d'ensuite de cliquer sur modifier.
        {                                                             //Apres cela il suffit juste d'encoder une Description. La latitude et la longitude ne sont pas considerees...
                                                                      //MODIFIER NE FONCTIONNE QU'AVEC UN SEUL POINT !!!!! DONC NI DE POLYLINE NI DE POLYGONE  !!

            if (listBox.SelectedItem is Polygone || listBox.SelectedItem is MyCartographyObjects.Polyline)
            {
                return;
            }

            Coordonnees selectedPOI = (listBox.SelectedItem as Coordonnees);

            longitude = selectedPOI.Longitude;
            latitude  = selectedPOI.Latitude;
            _myMapData.ObservableCollection.Remove(selectedPOI);

            var mwDialog = new MainWindow();

            if (mwDialog.ShowDialog() == true)
            {
                //Retour de la dialog, recharge le fichier
                POI      point = new POI(mwDialog.TextBoxDescription.Text, latitude, longitude);
                Location loc   = new Location(latitude, longitude);
                Pushpin  pin   = new Pushpin();
                pin.Location = loc;
                pin.Tag      = point.Id;
                MyMap.Children.Add(pin);
                _myMapData.ObservableCollection.Add(point);
                listBox.Items.Refresh();
            }
        }
Ejemplo n.º 22
0
        public async Task <IHttpActionResult> PutPOI(int id, POI pOI)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pOI.Id)
            {
                return(BadRequest());
            }

            db.Entry(pOI).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!POIExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 23
0
        private void MenuFilePOIExport_Click(object sender, RoutedEventArgs e)//EXPORTE TOUT LES POIs PRESENTS DANS LES DONNEES
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();

            dlg.DefaultExt = ".csv";
            dlg.Filter     = "CSV Files (*.csv)|*.csv";

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string filename = dlg.FileName;

                StreamWriter sw = new StreamWriter(filename, false);
                // POI poi = _myMapData.ObservableCollection[0] as POI;
                foreach (ICartoObj car in _myMapData.ObservableCollection)
                {
                    if (car is POI)
                    {
                        POI poi = car as POI;
                        sw.WriteLine(poi.Latitude + ";" + poi.Longitude + ";" + poi.Description + ";");
                    }
                }

                sw.Close();
            }
        }
Ejemplo n.º 24
0
    public static void RotateToPOI(POI poi)
    {
        Vector3 point = poi.transform.position;

        Vector3 vectorToPlayer;

        vectorToPlayer = CAVECameraRig.playerViewpoint - earthTransform.position;



        vectorToPlayer = vectorToPlayer.normalized;


        Vector3 earthPoint = earthTransform.position + (vectorToPlayer * planetRadius);

        Debug.Log("FORWARD IS " + earthTransform.transform.forward);

        Quaternion rot = Quaternion.FromToRotation(point, earthPoint);

        float yRot = rot.eulerAngles.y;

        if (yRot > 180.0f)
        {
            Debug.Log("Y ROT WAS " + yRot);
            yRot = yRot - 360.0f;
            Debug.Log("Y ROT IS " + yRot);
        }

        //earthTransform.transform.Rotate(earthTransform.transform.up, yRot);
        RoutineRunner.instance.StartCoroutine(RotateEarth(yRot, 0.25f));
    }
Ejemplo n.º 25
0
        private void AjouterCoordonnee_Click(object sender, RoutedEventArgs e)
        {
            bool modificationOK = false;

            POI p = new POI();

            fenetrePOI fenetrePOI = new fenetrePOI(p);

            fenetrePOI.Owner = this;
            fenetrePOI.ShowDialog();
            if (fenetrePOI.NewPOI != null)
            {
                p.Id          = p.Id;
                p.Latitude    = fenetrePOI.NewPOI.Latitude;
                p.Longitude   = fenetrePOI.NewPOI.Longitude;
                p.Description = fenetrePOI.NewPOI.Description;
                Console.WriteLine("DEBUG newPoi to string : " + p.Draw());
                PolylineActuel.CollectionDeCoordonnes.Add(p);
                modificationOK = true;
                UpdateListBox();
            }

            if (!modificationOK)
            {
                MessageBox.Show("L'ajout à échouée", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 26
0
    public static Dictionary <string, List <PointOfInterestTemplate> > ComputeLuxuryAbundance(Game game)
    {
        GridMap <PointOfInterest>      gridMap = game.World.Atlas.GetMap(WorldAtlas.Maps.PointOfInterest) as GridMap <PointOfInterest>;
        List <PointOfInterestTemplate> source  = (from POI in gridMap.Data
                                                  where POI != null && POI.IsLuxuryDeposit()
                                                  select POI.PointOfInterestDefinition.PointOfInterestTemplate).ToList <PointOfInterestTemplate>();
        Dictionary <string, List <PointOfInterestTemplate> > dictionary = new Dictionary <string, List <PointOfInterestTemplate> >();

        dictionary.Add("Tier1", new List <PointOfInterestTemplate>());
        dictionary.Add("Tier2", new List <PointOfInterestTemplate>());
        dictionary.Add("Tier3", new List <PointOfInterestTemplate>());
        foreach (PointOfInterestTemplate pointOfInterestTemplate in source.Distinct <PointOfInterestTemplate>())
        {
            string empty = string.Empty;
            pointOfInterestTemplate.Properties.TryGetValue("LuxuryTier", out empty);
            if (dictionary.ContainsKey(empty))
            {
                dictionary[empty].Add(pointOfInterestTemplate);
            }
            else
            {
                Diagnostics.LogError("Luxury resource " + pointOfInterestTemplate.Name + " doesn't have tier data!");
            }
        }
        return(dictionary);
    }
Ejemplo n.º 27
0
        /// <summary>
        /// Export CurrentList to .xlsx
        /// </summary>
        /// <param name="path">path to target file</param>
        private void CurrentListAsExcel(string path)
        {
            using (var workbook = new XLWorkbook())
            {
                var worksheet = workbook.Worksheets.Add("POI");

                for (int i = 0; i < CurrentList.Count; i++)
                {
                    POI poi = CurrentList[i];

                    List <KeyValuePair <string, string> > properties = poi.GetPropertyList();

                    if (i == 0) // Create header
                    {
                        for (int column = 1; column <= properties.Count; column++)
                        {
                            string name = properties[column - 1].Key;
                            worksheet.Cell(1, column).SetValue <string>(name);
                            worksheet.Cell(1, column).Style.Fill.BackgroundColor = XLColor.LightSlateGray;
                            worksheet.Cell(1, column).Style.Font.FontColor       = XLColor.White;
                        }
                    }

                    for (int column = 1; column <= properties.Count; column++)
                    {
                        string value = properties[column - 1].Value;
                        worksheet.Cell(i + 2, column).SetValue <string>(value == null ? "null" : value);
                    }
                }

                workbook.SaveAs(path);
            }
        }
Ejemplo n.º 28
0
    public void dropPOI(int x, int z)
    {
        if (containsKey(x, z, movingPOI))
        {
            POI        p   = getPOI(x, z, movingPOI);
            GameObject obj = getPOIPrefab(x, z, movingPOILookup);
            Remove(x, z, movingPOI);
            Remove(x, z, movingPOILookup);

            int[] key = new int[] { x, z };
            placedPOI.Add(key, p);
            poiLookup.Add(key, obj);
            obj.transform.position = new Vector3((float)(x * 6 - 1.5), posY, (float)(z * 6 + 1.5));
        }
        else if (containsKey(x, z, movingTreated))
        {
            POI        p   = getPOI(x, z, movingTreated);
            GameObject obj = getPOIPrefab(x, z, movingTreatedLookup);
            Remove(x, z, movingTreated);
            Remove(x, z, movingTreatedLookup);

            int[] key = new int[] { x, z };
            treated.Add(key, p);
            treatedLookup.Add(key, obj);
            obj.transform.position = new Vector3((float)(x * 6 - 1.5), posY, (float)(z * 6 + 1.5));
        }
    }
Ejemplo n.º 29
0
 private void UpdateListBox()
 {
     ListBox.Items.Clear();
     foreach (ICartoObj o in PersonneConnectee.ObservableCollection)
     {
         if (o is POI)
         {
             POI p = o as POI;
             //ListBox.Items.Add("POI: " + p.Id + " / " + p.Description);
             ListBox.Items.Add(p);
         }
         if (o is Polyline)
         {
             Polyline p = o as Polyline;
             //ListBox.Items.Add("Trajet: " + p.Id);
             ListBox.Items.Add(p);
         }
         if (o is Polygon)
         {
             Polygon p = o as Polygon;
             //ListBox.Items.Add("Surface: " + p.Id);
             ListBox.Items.Add(p);
         }
     }
 }
Ejemplo n.º 30
0
        public Models.POI Get(int id)
        {
            POI poi = db.POIs.Find(id);


            return(poi);
        }
 // param: returns reference of duplicated point
 bool checkButtonNameExist(ref POI duplicatedPoint)
 {
     string butName = POI_ReferenceHub.Instance.poiInfoFields [0].text;
     foreach (POI point in POIButtonManager.originalHandler.projectPOIs){
         if(point.buttonName == butName){
             duplicatedPoint = point;
             return true; //button name existed
         }
     }
     return false; //button name does not exist
 }
 //create a new location and save to handler,
 //overwrite: true is overwrite existing, false will add a new point
 public void SaveChanges(bool overwrite)
 {
     //create new Point object
     string sFlag = Application.loadedLevelName;
     Vector3 pos = new Vector3 (float.Parse(POI_ReferenceHub.Instance.poiInfoFields [1].text), float.Parse(POI_ReferenceHub.Instance.poiInfoFields [2].text), float.Parse(POI_ReferenceHub.Instance.poiInfoFields [3].text));
     Vector3 rot = new Vector3 (0, float.Parse(POI_ReferenceHub.Instance.poiInfoFields [4].text), 0);
     POI newPoint = new POI (sFlag, POI_ReferenceHub.Instance.poiInfoFields [0].text, pos, rot, POI_GlobalVariables.defaultMarker);
     if(overwrite){
         point.UpdateByValue(newPoint);
         point.marker.transform.position = point.position;
     }else{
         //generate button and marker pair
         POIButtonManager.instance.GenerateButMarkerPair (newPoint);
         //add the point into the orginalHandler
         POIButtonManager.originalHandler.AddPoint(newPoint);
     }
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Create a new POI object.
 /// </summary>
 /// <param name="autoPoiID">Initial value of AutoPoiID.</param>
 /// <param name="poiId">Initial value of PoiId.</param>
 /// <param name="poiName">Initial value of PoiName.</param>
 public static POI CreatePOI(int autoPoiID, int poiId, string poiName)
 {
     POI pOI = new POI();
     pOI.AutoPoiID = autoPoiID;
     pOI.PoiId = poiId;
     pOI.PoiName = poiName;
     return pOI;
 }
Ejemplo n.º 34
0
        public void OnStateEnter()
        {
            if (!pathComputed)
                ComputePath();


            //GET POI FROM QUEUE
            if (pois.Count > 0)
            {
                poi = pois.Dequeue();
            }
            else
            {
                poi = null;
            }
        }
Ejemplo n.º 35
0
 static void DrawGizmoForMyScript(POI hNode, GizmoType gizmoType)
 {
     RaycastHit vHit;
     Ray vRay = new Ray(SceneView.lastActiveSceneView.camera.transform.position, SceneView.lastActiveSceneView.camera.transform.forward);
     if (Physics.Raycast(vRay, out vHit))
     {
         Gizmos.DrawSphere(vHit.point, 1.0f);
     }
 }
Ejemplo n.º 36
0
 /// <summary>
 /// There are no comments for POISet in the schema.
 /// </summary>
 public void AddToPOISet(POI pOI)
 {
     base.AddObject("POISet", pOI);
 }
Ejemplo n.º 37
0
 public PoiAnnotation(POI pointOfInterest, CLLocationCoordinate2D coordinate)
     : base(coordinate)
 {
     PointOfInterest = pointOfInterest;
 }
Ejemplo n.º 38
0
    // Update is called once per frame
    void LateUpdate ()
    {
        if (!isServer)
            return;

        if(tillExplosionEnd > 0.0f && rigidBody.isKinematic == false)
        {
            tillExplosionEnd -= Time.deltaTime;
            if(tillExplosionEnd <=0.0f)
            {
                rigidBody.isKinematic = true;
                agent.enabled = true;
            }
        }

        float resourceDistance = float.MaxValue;
#if UNITY_EDITOR
        if (stunRemaning > 0.0f )
#else
        if (stunRemaning > 0.0f || GGJNetworkManager.players.Count != 2)
#endif
        {
            stunRemaning -= Time.deltaTime;
            agent.ResetPath();
            return;
        }

        if (resource != null)
        {
            resourceDistance = Vector3.Distance(transform.position, resource.transform.position);
        }

        if (agent.enabled == true)
        {
            if (target != null)
            {
                float targetPos = Vector3.Distance(transform.position, target.transform.position);
                if (targetPos < resourceDistance || draggedResource != null || (resource != null && resource.getTarget() != this))
                {
                    agent.SetDestination(target.transform.position);
                }
                else if (draggedResource == null)
                {
                    agent.SetDestination(resource.transform.position);
                }
            }
            else if (resource != null && draggedResource == null)
            {
                agent.SetDestination(resource.transform.position);
            }
            else
            {
                agent.SetDestination(homeEmitter.position);
            }

            if (target != null)
            {
                float dist = Vector3.Distance(transform.position, target.transform.position);
                if (dist <= 1.5f)
                {
                    if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f)
                    {
                        Destroy(target.gameObject);
                        target = null;
                    }
                }
            }

            if (resource != null && resourceDistance < 1.5f)
            {
                if (resource.follow(this))
                    draggedResource = resource;
            }

            if (draggedResource != null)
            {
                float homeDistance = Vector3.Distance(homeEmitter.transform.position, transform.position);
                if (homeDistance < 1.5f)
                {
                    Destroy(draggedResource.gameObject);
                    draggedResource = null;

                    GameObject go = (GameObject)Instantiate(resourcePrefab, Vector2.zero, Quaternion.identity);
                    NetworkServer.Spawn(go);

                    if (GGJNetworkManager.players[playerNum] != null)
                    {
                        GGJNetworkManager.players[playerNum].resources += 1;
                    }
                }
                else
                {
                    speed *= withResourceSpeedMult;
                }
            }
        }

        resource = null;
        agent.speed =  speed;
        speed = maxSpeed;
    }
Ejemplo n.º 39
0
 private void DrawPoiOnMap(POI poi)
 {
     // Foreach POI point. Put it on Maps. 
     var poiIcon = new MapIcon
     {
         Location = new Geopoint(new BasicGeoposition { Latitude = poi.Latitude, Longitude = poi.Longitude }),
         NormalizedAnchorPoint = new Point(0.5, 0.5),
         Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/POI.png")),
         ZIndex = 2,
         CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible
     };
     MyMap.MapElements.Add(poiIcon);
 }
Ejemplo n.º 40
0
    private void DrawConnection(POI hFirst, POI hSecond, float headSize, Color color)
    {
        Vector3 vDirection = hFirst.Position - hSecond.Position;
        Vector3 dir = vDirection.normalized;
        Vector3 vConePosition = hSecond.Position - vDirection * -0.95f;


        Color c = Handles.color;
        Handles.color = color;
        Handles.DrawLine(hFirst.Position, hSecond.Position);
        Handles.ConeCap(0, vConePosition, Quaternion.LookRotation(dir != Vector3.zero ? dir : Vector3.right), headSize);
        Handles.color = c;
    }
Ejemplo n.º 41
0
    public void addPOI(POI poi)
    {
        if (!isServer)
            return;

        if (poi.playerNum != playerNum)
            return;

        float dist = Vector3.Distance(poi.transform.position, transform.position);
        if (target == null)
        {
            target = poi;
            distanceToPOI = dist;
        }
        else
        {
            if(dist < distanceToPOI)
            {
                target = poi;
                distanceToPOI = dist;
            }
        }
    }