Exemplo n.º 1
0
    public void ShowChessmanInfoCanvas(Chessman selectedChessman)
    {
        // chess_info_canvas.enabled = true;

        string chess_id = null, attack_type = null;
        int    hp = -1, damage = -1, cost = -1, maxhp = -1;

        selectedChessman.GetInfo(ref chess_id, ref hp, ref maxhp, ref attack_type, ref damage, ref cost);
        string [] chess_id_list = { "King", "Queen", "Rook", "Bishop", "Knight", "Pawn" };

        Debug.Log(hp);

        GameObject num_txt_panel = chess_info_canvas.transform.Find("num_txt").gameObject;

        Debug.Log(num_txt_panel);
        num_txt_panel.SetActive(true);
        GameObject info_txt_panel = chess_info_canvas.transform.Find("info_txt").gameObject;

        info_txt_panel.SetActive(true);
        GameObject go;

        go = num_txt_panel.transform.Find("chess_id").gameObject;
        go.GetComponent <Text>().text = chess_id;
        go = num_txt_panel.transform.Find("hp").gameObject;
        go.GetComponent <Text>().text = hp.ToString() + " / " + maxhp.ToString();
        go = num_txt_panel.transform.Find("attack_type").gameObject;
        go.GetComponent <Text>().text = attack_type;
        go = num_txt_panel.transform.Find("damage").gameObject;
        go.GetComponent <Text>().text = damage.ToString();
        go = num_txt_panel.transform.Find("cost").gameObject;
        go.GetComponent <Text>().text = cost.ToString();
        go = num_txt_panel.transform.Find("Image").gameObject;
        go.GetComponent <Image>().sprite = null;
        for (int i = 0; i < 6; i++)
        {
            if (chess_id_list[i] == chess_id)
            {
                if (selectedChessman.isWhite)
                {
                    go.GetComponent <Image>().sprite = chessmanInfoSprite[i];
                }
                else
                {
                    go.GetComponent <Image>().sprite = chessmanInfoSprite[i + 6];
                }
                break;
            }
        }
    }