示例#1
0
 private void addGame(LibraryGame game)
 {
     gamesById[game.id] = game;
     gamesByAlias[game.alias] = game;
 }
示例#2
0
    private void addAvalableGame(Transform parent, UserInventoryItem item, Vector2 position)
    {
        RectTransform ui;
        Button uiButton;
        Text uiLabel;

        GameObject uiGameObject = (GameObject)GameObject.Instantiate(Resources.Load<GameObject>("UI/UserScreen/AvalableGame"));
        ui = (RectTransform)uiGameObject.transform;
        ui.SetParent(parent, false);
        ui.anchoredPosition = position;
        uiButton = ui.Find("Button").GetComponent<Button>();
        uiLabel = ui.Find("Text").GetComponent<Text>();

        wwwLoader.addLoader("AvalableGame" + item.itemId.ToString(), item.imageUri, delegate(WWW www, string tag)
        {
            if (www.texture != null)
            {
                Sprite iconSprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0.5f, 0.5f));
                uiButton.image.overrideSprite = iconSprite;
            }
        });

        uiLabel.text = item.name;
        uiButton.onClick.RemoveAllListeners();
        uiButton.onClick.AddListener(delegate()
        {
            long gameId = item.itemId;
            selectedGame = systemController.getLibrary().get(item.descriptionId);
            BaseGameController gameController = selectedGame.createController();
            if (gameController != null)
            {
                systemController.requestGame(gameId, gameController, loadGameDelegate);
            }
            else
            {
                messageBox.showMessage("Fail to crate game controller for item : " + item);
            }
        });
    }