示例#1
0
        private async Task InitializeExplorePage()
        {
            await DispatcherUtil.Dispatch(async() =>
            {
                var exploreItems = new ObservableCollection <ExploreItem>();

                try
                {
                    var tsnList = new List <string> {
                        "174371", "173420", "161061", "159785", "500028", "180130", "552304", "552303"
                    };

                    ExploreGrid.SetBinding(ListView.ItemsSourceProperty, new Binding {
                        Source = exploreItems
                    });

                    foreach (var tsn in tsnList)
                    {
                        var newItem = new ExploreItem();

                        newItem.Loading = true;

                        var record = await RequestManager.RequestFullRecord(tsn);

                        newItem.Name = record.GetCommonName();
                        newItem.TSN  = record.ScientificName.TSN;

                        // var imageModelLow = await RequestManager.RequestWikispeciesImage(record.ScientificName.CombinedName, 50);
                        // newItem.Image = new BitmapImage(new Uri(imageModelLow.GetThumbnail(), UriKind.Absolute));

                        var imageModel = await RequestManager.RequestWikispeciesImage(record.ScientificName.CombinedName, 400);
                        newItem.Image  = new BitmapImage(new Uri(imageModel.GetThumbnail(), UriKind.Absolute));

                        newItem.Loading = false;

                        exploreItems.Add(newItem);
                    }
                }
                catch (Exception e)
                {
                    ContentDialog errorDialog = new ContentDialog
                    {
                        Title           = "Error",
                        Content         = e.Message + " " + e.InnerException.ToString(),
                        CloseButtonText = "Ok",
                    };
                    ContentDialogResult result = await errorDialog.ShowAsync();

                    exploreItems.Clear();

                    Frame.Navigate(typeof(ErrorPage), null);
                }
            });
        }
示例#2
0
    // Use this for initialization


    public void initGrid()
    {
        nowIndex = PlayerData.getInstance().playerPos[1] + GRID_WIDTH * PlayerData.getInstance().playerPos[0];
        PlayerData.getInstance().grids[nowIndex / GRID_WIDTH] [nowIndex % GRID_WIDTH].isFinish = true;


        //grids[nowIndex].reveal();
        if (grids != null)
        {
            for (int i = 0; i < GRID_HEIGHT; i++)
            {
                for (int j = 0; j < GRID_WIDTH; j++)
                {
                    if (grids[i * GRID_WIDTH + j] != null)
                    {
                        GameObject.Destroy(grids[i * GRID_WIDTH + j].gameObject);
                    }
                }
            }
        }

        Vector2 picSize = gridPrefab.transform.GetChild(0).GetComponent <SpriteRenderer> ().sprite.bounds.size;

        for (int i = 0; i < GRID_HEIGHT; i++)
        {
            for (int j = 0; j < GRID_WIDTH; j++)
            {
                if (PlayerData.getInstance().grids[i][j] != null)
                {
                    GameObject  o           = GameObject.Instantiate(gridPrefab, tr);
                    ExploreGrid exploreGrid = o.GetComponent <ExploreGrid> ();
                    o.transform.localPosition = new Vector3(j * GRID_INTERVAL_WIDTH, -i * GRID_INTERVAL_HEIGHT, 0);
                    grids[i * GRID_WIDTH + j] = exploreGrid;
                    int finalI = i;
                    int finalJ = j;
                    if (PlayerData.getInstance().grids [i] [j].isFinish)
                    {
                        exploreGrid.reveal();
                    }

                    FieldEventlistener tListener = o.AddComponent <FieldEventlistener> ();
                    tListener.ClickEvent += delegate(GameObject gb, Vector3 clickpos) {
                        chooseEncounter(finalI * GRID_WIDTH + finalJ);
                    };
                }
            }
        }


        playerSymbol.transform.localPosition = new Vector3(PlayerData.getInstance().playerPos[1] * GRID_INTERVAL_WIDTH, -PlayerData.getInstance().playerPos[0] * GRID_INTERVAL_HEIGHT, 0);
        markGO.transform.localPosition       = playerSymbol.transform.localPosition;

        initCameraControl();
        SetMap();

        Vector3 startPos = playerSymbol.transform.position;

        //startPos.x = 0;
        startPos.z = mainCamera.transform.position.z;
        {
            if (startPos.y < (cameraBound [1] + cameraHalfHeight))
            {
                startPos.y = (cameraBound [1] + cameraHalfHeight);
            }
            if (startPos.y > (cameraBound [3] - cameraHalfHeight))
            {
                startPos.y = (cameraBound [3] - cameraHalfHeight);
            }
            if (startPos.x < (cameraBound [0] + cameraHalfWidth))
            {
                startPos.x = (cameraBound [0] + cameraHalfWidth);
            }
            if (startPos.x > (cameraBound [2] - cameraHalfWidth))
            {
                startPos.x = (cameraBound [2] - cameraHalfWidth);
            }
        }
        mainCamera.transform.position = startPos;
        isMovingMap         = false;
        isContinueMovingMap = false;
    }