Ejemplo n.º 1
0
    /// <summary>
    /// ボタンなどのUIを作成する。
    /// </summary>
    /// <param name="arr"></param>
    public void CreateUI(ArrayList arr)
    {
        Debug.LogFormat("{0} : {1}", this.GetType().Name, new System.Diagnostics.StackFrame().GetMethod().Name);
        GameObject FishUIHead = new GameObject("FishUI");

        FishUIHead.transform.parent = _canvas.transform;


        Debug.LogFormat("Count {0}", arr.Count);

        for (int i = 0; i < _PAGE_ELEMENT && i < arr.Count; i++)
        {
            BioData data = ( BioData )arr[i];
            Debug.LogFormat("Count {0}, data name : {1}", arr.Count, data.GetNameEn());

            if (data.GetNameEn().Length < 1)
            {
                continue;
            }
            CreateUITip(FishUIHead, i, data);
        }


        FishUIHead.transform.localPosition = _UiHeadPos;
        FishUIHead.transform.localScale    = _UiHeadScale;
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 参照するUI画像をリソースから読み込んで表示
    /// </summary>
    /// <param name="fishUI">画像を設定するゲームオブジェクトの親オブジェクト</param>
    /// <param name="data">設定するデータ</param>
    private void PictureRef(GameObject fishUI, BioData data)
    {
        string type           = StringUtil.ToTitle(data.GetBioType().ToString());
        Image  image          = fishUI.transform.FindChild("View").GetComponent <Image>();
        string resourceString = "Image/" + type + "/" + data.GetNameEn();
        Sprite View           = Resources.Load(resourceString, typeof(Sprite)) as Sprite;

        image.sprite = View;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// OnClickイベントの作成
    /// </summary>
    /// <param name="fishUI">UI単位をまとめるオブジェクト。</param>
    /// <param name="data">作成する魚のデータ</param>
    private void ClickEvent(GameObject fishUI, BioData data)
    {
        BiologicalManager _manager     = GetComponent <BiologicalManager>();
        FishManager       fish         = _manager.GetFishManager();
        Button            createButton = GetButtonComponent(fishUI, "CreateButton");

        createButton.onClick.AddListener(() =>
        {
            fish.FishCreate(data.GetBioType(), data.GetNameEn());
        });

        Button deleteButton = GetButtonComponent(fishUI, "DeleteButton");

        if (BioType.FISH == data.GetBioType())
        {
            deleteButton.onClick.AddListener(() => fish.ObjectDelete(data.GetNameEn()));
            return;
        }
        // 魚以外はDeleteButtonは使わないので削除
        Destroy(deleteButton.gameObject);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// UIオブジェクトの生成
    /// </summary>
    /// <param name="FishUIHead">生成されたオブジェクトの親要素</param>
    /// <param name="i">生成位置を調整するインデックス</param>
    /// <param name="data">生成するオブジェクトのデータが入ったインスタンス</param>
    private void CreateUITip(GameObject FishUIHead, int i, BioData data)
    {
        Debug.LogFormat("uihead name :{0}, data en name :{1}", FishUIHead.name, data.GetNameEn());
        GameObject fishUI;
        int        posx     = 820 + ((i % 2) * 95);
        int        posy     = 370 - ((i / 2) * 95);
        Vector2    position = new Vector2(posx, posy);

        fishUI = Instantiate(_fishUI, position, Quaternion.identity);
        fishUI.transform.parent = FishUIHead.transform;
        fishUI.name             = data.GetNameJp();

        PictureRef(fishUI, data);
        ClickEvent(fishUI, data);
    }