Ejemplo n.º 1
0
    private void Start()
    {
        GameObject go;

        switch (Type)//依据传入的数据类型构造面板上的物品
        {
        case ItemType.food:
            go = GameObject.Instantiate(food[ID], transform.position, Quaternion.identity, this.transform);
            Food fd = go.GetComponent <Food>();
            fd.SetFood(ID, Quality, State);
            introducrion.text = fd.intro;
            break;

        case ItemType.drug:
            go = GameObject.Instantiate(drug[ID], transform.position, Quaternion.identity, this.transform);
            Drug dg = go.GetComponent <Drug>();
            dg = go.GetComponent <Drug>();
            dg.SetDrug(ID);
            introducrion.text = dg.intro;
            break;

        case ItemType.battery:
            go = GameObject.Instantiate(battery[ID], transform.position, Quaternion.identity, this.transform);
            Battery bty = go.GetComponent <Battery>();
            bty.SetBattery(ID, Quality);
            introducrion.text = bty.intro;
            break;

        case ItemType.upgrade:
            go = GameObject.Instantiate(upgrade[ID], transform.position, Quaternion.identity, this.transform);
            Upgrade ud = go.GetComponent <Upgrade>();
            ud.SetUpgrade(ID);
            introducrion.text = ud.intro;
            break;

        case ItemType.other:
            go = GameObject.Instantiate(other[ID], transform.position, Quaternion.identity, this.transform);
            Other ot = go.GetComponent <Other>();
            ot.SetOther(ID);
            introducrion.text = ot.intro;
            break;
        }
    }