コード例 #1
0
    void Start()
    {
        game = GameObject.Find(GameController.NAME).GetComponent <Game>();

        score            = game.GetScore();
        playerAttributes = game.GetPlayerAttributes();
        itemBag          = game.GetItemBag();
        badItemBag       = game.GetBadItemBag();

        // Set club trades
        clubTrades = game.GetBag().GetRandomClubs(COLS).ToArray();

        for (int i = 0; i < ROWS; i++)
        {
            for (int j = 0; j < COLS; j++)
            {
                SetItem(i, j, itemBag.GetItem());
                WritePositive(i, j, GetItem(i, j).GetName());
                WritePositiveExplanation(i, j, GetItem(i, j).GetDescription());

                if (i == 0)
                {
                    WriteNegative(i, j, SUB_CREDITS_AMOUNT.ToString());
                    WriteNegativeExplanation(i, j, String.Format("Costs {0} credits", SUB_CREDITS_AMOUNT));
                }
                if (i == 1)
                {
                    WriteNegative(i, j, clubTrades[j].GetName());
                    WriteNegativeExplanation(i, j, String.Format("Lose {0}", clubTrades[j].GetName()));
                }
                if (i == 2)
                {
                    SetBadItem(j, badItemBag.GetItem());
                    WriteNegative(i, j, GetBadItem(j).GetName());
                    WriteNegativeExplanation(i, j, GetBadItem(j).GetDescription());
                }
                int x = i; int y = j;
                positives[GetIndex(i, j)].onClick.AddListener(() => Clicked(x, y));
            }
        }
    }