Ejemplo n.º 1
0
    /// <summary>
    /// Writes all PokemonData(s) to a JSON.
    /// </summary>
    static public void WriteDataBase()
    {
        PokemonDataBase Database = new PokemonDataBase
        {
            PokemonData = PokemonData.GetDatabase()
        };

        //cache
        string Ref         = PokemonData.Database[0].GeneralInformation.Reference;
        string Path_Icon   = PokemonData.Database[0].GeneralInformation.Icon;
        string Path_Icon_1 = PokemonData.Database[0].GeneralInformation.IconShiny;

        for (int i = 0; i < PokemonData.Count; i++)
        {
            if (Database.PokemonData[i].GeneralInformation.Reference == Ref)
            {
                Database.PokemonData[i].GeneralInformation.Reference = Database.PokemonData[i].GeneralInformation.Name.ToLower(true);
            }

            /*if (Database.PokemonData[i].ID == -1)
             *  Database.PokemonData[i].ID = i;*/
            if (Database.PokemonData[i].GeneralInformation.Icon == Path_Icon)
            {
                Database.PokemonData[i].GeneralInformation.Icon = "Sheet1stGen/" + Database.PokemonData[i].GeneralInformation.Reference;
            }
            if (Database.PokemonData[i].GeneralInformation.IconShiny == Path_Icon_1)
            {
                Database.PokemonData[i].GeneralInformation.IconShiny = "Sheet1stGenShiny/" + Database.PokemonData[i].GeneralInformation.Reference;
            }
        }

        DataManagment.WriteToJSON(Database, "PokemonData/Monster");
    }
Ejemplo n.º 2
0
 void Awake()
 {
     if (datamanagment == null)
     {
         DontDestroyOnLoad(gameObject);
         datamanagment = this;
     }
     else if (datamanagment != this)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 3
0
        public ContactViewModel()
        {
            this.Contacts = DataManagment.LoadData <TrulyObservableCollection <Contact> >();
            if (this.Contacts == null)
            {
                this.Contacts = new TrulyObservableCollection <Contact>();
                //Replace with log
                Trace.WriteLine("Data not loaded");
            }
            this.Contacts.CollectionChanged += Contacts_CollectionChanged;
            this.SaveCommand = new RelayCommand(param =>
            {
                this.CanExecuteSave = this.CanExecuteCancel = false;
                Task.Run(() =>
                {
                    DataManagment.SaveData(this.Contacts.Where(c => string.IsNullOrEmpty(c.Error)).ToList());
                });
            }, () => CanExecuteSave);

            this.CancelCommand = new RelayCommand(param =>
            {
                this.CanExecuteSave = this.CanExecuteCancel = false;
                Task.Run(() =>
                {
                    this.Contacts = DataManagment.LoadData <TrulyObservableCollection <Contact> >();
                    this.Contacts.CollectionChanged += Contacts_CollectionChanged;
                });
            }, () => CanExecuteCancel);

            this.DeleteItemCommand = new RelayCommand(param =>
            {
                var contactToDelete = param as Contact;
                if (contactToDelete == null)
                {
                    return;
                }

                this.Contacts.Remove(contactToDelete);
                //if entry is not valid then add new empty row
                if (!string.IsNullOrEmpty(contactToDelete.Error))
                {
                    this.Contacts.Add(new Contact());
                }
                this.Contacts.Remove(contactToDelete);
            });

            CanExecuteCancel = CanExecuteSave = false;
        }
Ejemplo n.º 4
0
    /// <summary>
    /// Writes all PlayerData(s) to a JSON.
    /// </summary>
    static public void WriteDataBase()
    {
        PlayerDataBase Database = new PlayerDataBase
        {
            PlayerData = PlayerData.GetDatabase()
        };

        //cache
        //string Ref = PlayerData.Database[0].Reference;

        /*for (int i = 0; i < PlayerData.Count; i++)
         * {
         *  if (Database.PlayerData[i].ID == -1)
         *      Database.PlayerData[i].ID = i;
         * }*/

        DataManagment.WriteToJSON(Database, "PokemonData/Data");
    }
Ejemplo n.º 5
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            DataManagment dataManagment = new DataManagment();

            user.DarbSkait = rb_skaitytojas.Checked ? 0 : 1;
            user.Username  = textBox1.Text;
            user.Password  = textBox2.Text;
            var exists = dataManagment.LogMeIn(user);

            if (exists)
            {
                // successful login
                MessageBox.Show(exists.ToString() + " " + typeOfUser);
            }
            else
            {
                MessageBox.Show("Nekorektiski prisijungimo duomenys, bandykite dar karta");
            }
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Writes all MoveData(s) to a JSON.
    /// </summary>
    static public void WriteDataBase()
    {
        MoveDataBase Database = new MoveDataBase
        {
            MoveData = MoveData.GetDatabase()
        };

        //cache
        string Ref = MoveData.Database[0].Reference;

        for (int i = 0; i < MoveData.Count; i++)
        {
            if (Database.MoveData[i].Reference == Ref)
            {
                Database.MoveData[i].Reference = Database.MoveData[i].Name.ToLower(true);
            }
            if (Database.MoveData[i].ID == -1)
            {
                Database.MoveData[i].ID = i;
            }
        }

        DataManagment.WriteToJSON(Database, "PokemonData/Data");
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Return the whole DataBase (Class).
    /// Use with DataBase.MoveData[Index].
    /// </summary>
    /// <returns></returns>
    static public MoveDataBase LoadDataBase()
    {
        string JSON = DataManagment.ReadFromJSON("PokemonData/Data");

        return(JsonUtility.FromJson <MoveDataBase>(JSON));
    }