示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        //Application.OpenURL(@"C:\Windows\System32\osk.exe");
        b_pond.onClick.AddListener(ShowScroll);
        b_back.onClick.AddListener(HideScroll);
        b_list.onClick.AddListener(delegate { UpdateUIGroup(0); });
        b_archievement.onClick.AddListener(delegate { UpdateUIGroup(2); });

        buttonOrigin = b_list.GetComponent <Image>().sprite;
        boyOrigin    = boy.sprite;
        girlOrigin   = girl.sprite;
        img_sb0      = b_list.transform.Find("Image").GetComponent <Image>();
        img_sb1      = b_archievement.transform.Find("Image").GetComponent <Image>();

        //strangely it doesnt work
        //buttons = scrollView.GetComponentsInChildren<Button>();
        //for (int i = 0; i < buttons.Length; i++) {
        //    Debug.Log(i);
        //    Debug.Log(buttons[i].name);
        //    buttons[i].onClick.AddListener(delegate { ShowDetail(i); });
        //}

        AssetBundle ab;

#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        ab = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/data.ab");
#endif
#if UNITY_ANDROID
        ab = AssetBundle.LoadFromFile(Application.dataPath + "!assets/data.ab");
#endif
        TextAsset ta = ab.LoadAsset <TextAsset>("Fish");
        fishDataList = JsonUtility.FromJson <FishDataList>(ta.text);
        ab.Unload(true);

        fishCount.text = PlayerPrefs.GetInt("FishCount", 0).ToString();
        farthest.text  = (PlayerPrefs.GetFloat("Farthest", 0f) * 0.5f).ToString("0");
        PlayerPrefs.SetInt("TotalFishType", fishDataList.fish.Count);
        bool[] array = PlayerPrefsX.GetBoolArray("FishType", false, fishDataList.fish.Count);
        int    count = 0;
        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] == true)
            {
                count++;
            }
        }
        fishType.text = count.ToString();
        FillList();
        FillDetail();
        arhievement.gameObject.SetActive(false);
        detailView.gameObject.SetActive(false);
        scrollView.gameObject.SetActive(true);
        b_list.GetComponent <Image>().sprite         = buttonSelected;
        b_archievement.GetComponent <Image>().sprite = buttonOrigin;
        img_sb0.color = imgSelectedColor;
        img_sb1.color = imgDeSelectedColor;
    }
示例#2
0
    void Start()
    {
        spawnFishInterval     = 0.5f + TFMath.GaussRand() * 5f;
        spawnWharfInterval    = firstDockTime;
        spawnObstacleInterval = firstObstacleTime;
        AssetBundle ab;

#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        ab = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/data.ab");
#endif
#if UNITY_ANDROID
        ab = AssetBundle.LoadFromFile(Application.dataPath + "!assets/data.ab");
#endif
        TextAsset ta = ab.LoadAsset <TextAsset>("Fish");
        fishDataList = JsonUtility.FromJson <FishDataList>(ta.text);
        ab.Unload(true);
        int length = fishDataList.fish.Count;

        foreach (var item in fishDataList.fish)
        {
            toatlRarity += item.rarity[mapID];
        }
    }