Example #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        FishDatabase database = (FishDatabase)target;

        if (GUILayout.Button("Save"))
        {
            database.Save();
        }
        if (GUILayout.Button("Load"))
        {
            database.Load();
        }
    }
Example #2
0
    void Start()
    {
        oldMask = Camera.main.cullingMask;
        menu    = FindObjectOfType <MainMenu>();
        fishPediaRect.localPosition = new Vector3(0, 0, 0);
        if (System.IO.File.Exists(Application.persistentDataPath + @"\fishpedia.json"))
        {
            string jsonSaveString = System.IO.File.ReadAllText(Application.persistentDataPath + @"\fishpedia.json");
            JsonUtility.FromJsonOverwrite(jsonSaveString, fishList);
        }
        else
        {
            System.IO.File.Create(Application.persistentDataPath + @"\fishpedia.json");
        }
        isOpened = false;
        SaveFishpedia();

        Vector2 newSize = fishPediaRect.sizeDelta;

        newSize.y = (30) + (FindObjectOfType <FishDatabase>().fish.Count * 30);
        newSize.y = Mathf.Clamp(newSize.y, 183, Mathf.Infinity);
        fishPediaRect.sizeDelta = newSize;

        FishDatabase database        = FindObjectOfType <FishDatabase>();
        List <Fish>  oldDatabaseFish = database.fish;
        List <Fish>  databaseFish    = new List <Fish>();

        foreach (var fish in oldDatabaseFish)
        {
            if (fish.basePrice != 0)
            {
                databaseFish.Add(fish);
            }
        }
        int y = 0;
        int z = 0;

        for (int i = 0; i < databaseFish.Count; i++)
        {
            GameObject cur = (GameObject)Instantiate(fishPediaListingPrefab, fishPediaRect.transform);
            cur.GetComponent <RectTransform>().anchoredPosition3D          = new Vector3(10 + (z * 110), -35 + (y * -110), 0);
            cur.GetComponent <RectTransform>().localEulerAngles            = Vector3.zero;
            cur.GetComponent <RectTransform>().localScale                  = Vector3.one;
            cur.GetComponent <FishPediaListing>().fish                     = new FishpediaFish(databaseFish[i].fishName, 0);
            cur.transform.FindChild("Border").GetComponent <Image>().color = databaseFish[i].rarityColour;
            GameObject child = cur.transform.FindChild("FishPosition").gameObject;
            GameObject fish  = (GameObject)Instantiate(databaseFish[i].fishPrefab, child.GetComponent <RectTransform>().position, cur.transform.rotation, child.transform);
            fish.GetComponentInChildren <MeshRenderer>().gameObject.layer = LayerMask.NameToLayer("UI");
            fish.transform.localScale    = new Vector3(fish.transform.localScale.x * 50f, fish.transform.localScale.y * 50f, fish.transform.localScale.z * 50f);
            fish.transform.localPosition = new Vector3(0, 0, -40);
            listings.Add(cur.GetComponent <FishPediaListing>());
            z++;
            int mod = i + 1;
            if (mod % 5 == 0)
            {
                y++;
                z = 0;
            }
        }
        List <FishpediaFish> bestFish = UniqueFishArray(fishList.fishList);

        foreach (var item in bestFish)
        {
            if (listings.Find(x => x.fish.fishName == item.fishName))
            {
                FishPediaListing listing = listings.Find(x => x.fish.fishName == item.fishName);
                listing.isCaught    = true;
                listing.fish.weight = item.weight;
            }
        }
    }