Ejemplo n.º 1
0
 public void CheckIfThereIsDictionaryInData(Structs.DataCollection loadedData)
 {
     if (loadedData.MonthAverages == null || loadedData.MonthAverages.Count == 0)
     {
         loadedData.MonthAverages = new List <float>();
         for (int i = 1; i < 13; i++)
         {
             loadedData.MonthAverages.Add(0);
         }
         gameManager.SaveData();
     }
 }
Ejemplo n.º 2
0
    public void RemoveItemFromList()
    {
        //find tag if it exists and make amount 0
        Structs.Tag zeroTag = lvlOne.tagList.Find(i => i.name == curList[int.Parse(lvlOne.openListItem.name)].name);
        zeroTag.value = 0;
        lvlOne.tagList.Remove(lvlOne.tagList.Find(i => i.name == curList[int.Parse(lvlOne.openListItem.name)].name));
        lvlOne.tagList.Add(zeroTag);

        curList.RemoveAt(int.Parse(lvlOne.openListItem.name));
        lvlOne.SaveData();
        Destroy(lvlOne.openListItem);
        //nav.CloseEditPanel();
    }
Ejemplo n.º 3
0
    public void SaveItem()
    {
        if (nameField == "")
        {
            messageGO.GetComponent <Text>().text = "Name can't be empty";
            return;
        }
        else if (valueField == 0)
        {
            messageGO.GetComponent <Text>().text = "Value can't be zero";
            return;
        }
        //TODO check if valid value, name can be default
        if (String.IsNullOrEmpty(lvlOne.curListItem.name) && lvlOne.curListItem.value == 0)
        {
            //new item to be saved
            if (listMngr.CheckForDuplicateName(nameField) == -1)
            {
                listMngr.SaveItemInList(nameField, valueField, monthsField, yearsField, excludeFromAverage, false);
                nav.GoBack();
            }
            else
            {
                nav.OpenMergePanel();
            }
        }
        else
        {
            //existing item modified to be saved.
            if (listMngr.CheckForDuplicateName(nameField) == -1 || nameField == lvlOne.curListItem.name)
            {
                //REMARK: better to handle zero value in both fields
                if (monthsField == 0 && yearsField == 0)
                {
                    perm = true;
                }

                if (perm)
                {
                    lvlOne.UpdateSavedEntry(nameField, valueField, -1, -1, excludeFromAverage);
                }
                else
                {
                    lvlOne.UpdateSavedEntry(nameField, valueField, monthsField, yearsField, excludeFromAverage);
                }
                nav.GoBack();
            }
            else
            {
                nav.editing = true;
                nav.OpenMergePanel();
            }
        }
        lvlOne.SaveData();
    }
Ejemplo n.º 4
0
 public void DeleteIt()
 {
     lvlOne.tagList.RemoveAt(int.Parse(lvlOne.openListItem.name));
     lvlOne.SaveData();
     Destroy(lvlOne.openListItem);
 }