Exemplo n.º 1
0
        /// <summary>
        /// Insère ou met à jour la sélection d'un corp céleste saisie par l'utilisateur
        /// </summary>
        /// <param name="a_selectedPlanet">Objet PlanetSelection du corps céleste concerné</param>
        /// <returns>Nombre de lignes mises à jour, une valeur de -1 indique une erreur</returns>
        public int UpdateSelectedPlanet(PlanetSelection a_selectedPlanet)
        {
            int modifiedLineNumber = 0;

            try
            {
                using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
                {
                    connection.CreateTable <PlanetSelectionModel>();
                    PlanetSelectionModel foundItem = connection.Table <PlanetSelectionModel>().Where(i => i.ID == a_selectedPlanet.ID).FirstOrDefault();
                    if (foundItem == null)
                    {
                        modifiedLineNumber += connection.Insert(new PlanetSelectionModel(a_selectedPlanet.ID, a_selectedPlanet.Name, a_selectedPlanet.IsSelected)); // Insertion (1ère utilisation)...
                    }
                    else
                    {
                        if (foundItem.IsSelected != a_selectedPlanet.IsSelected)
                        {
                            modifiedLineNumber += connection.Update(new PlanetSelectionModel(a_selectedPlanet.ID, a_selectedPlanet.Name, a_selectedPlanet.IsSelected)); // ...ou mise à jour (utilisations ultérieures)
                        }
                    }
                }
            }
            catch (Exception)
            {
                // On renvoit un nombre < 0 pour indiquer qu'il y a une erreur, c'est le code amont qui gérera cette erreur
                modifiedLineNumber = -1;
            }
            return(modifiedLineNumber);
        }
        // Méthode permettant de renvoyer la bonne ressource image en fonction de la sélection
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PlanetSelection selectedPlanet = (PlanetSelection)value;

            if (selectedPlanet != null)
            {
                if (selectedPlanet.IsSelected)
                {
                    return(selectedPlanet.ImageSourceSelected);
                }
                else
                {
                    return(selectedPlanet.ImageSourceNotSelected);
                }
            }
            return(string.Empty);
        }
Exemplo n.º 3
0
    private void PlanetClicked(int planetId)
    {
        Debug.Log("Planet clicked " + planetId);

        FindObjectOfType <SoundManager>().PlayButtonClickSound();

        if ((PlanetSelection.Planets)planetId != FindObjectOfType <SaveManager>().GetPlanet())
        {
            if (planetId > 0)
            {
                //Check if player has all items
                if (!IsPlanetUnLocked(planetId - 1))
                {
                    return;
                }
            }

            CloseMap();

            PlanetSelection.LoadTravelGame((PlanetSelection.Planets)planetId);
        }
    }