Esempio n. 1
0
    //生成道具
    private void CreateItem()
    {
        Vector3          createPos   = transform.position;
        BigLevelItemInfo curItemInfo = MapMaker.Instance.GetCurBigLevelItemInfo();

        Debug.Log(curItemInfo.itemIndex_2x2);
        if (gridState.itemID >= 0 && gridState.itemID <= curItemInfo.itemIndex_2x2)
        {
            createPos += new Vector3(MapMaker.Instance.gridWidth / 2, -MapMaker.Instance.gridHeight / 2);
        }
        else if (gridState.itemID > curItemInfo.itemIndex_2x2 && gridState.itemID <= curItemInfo.itemIndex_1x2)
        {
            createPos += new Vector3(MapMaker.Instance.gridWidth / 2, 0);
        }
        GameObject item = Instantiate(itemPrefabs[gridState.itemID], createPos, Quaternion.identity);

        item.transform.SetParent(this.transform);
        curItem = item;
    }
Esempio n. 2
0
    //创建道具
    private void CreateItem()
    {
        GameObject itemGo = GameController.Instance.GetGameObjectResource
                                (GameController.Instance.mapMaker.bigLevelID.ToString() + "/Item/" + gridState.itemID.ToString());

        itemGo.transform.SetParent(GameController.Instance.transform);

        Vector3          createPos   = transform.position - new Vector3(0, 0, 3);
        BigLevelItemInfo curItemInfo = GameController.Instance.mapMaker.GetCurBigLevelItemInfo();

        if (gridState.itemID >= 0 && gridState.itemID <= curItemInfo.itemIndex_2x2)
        {
            createPos += new Vector3(GameController.Instance.mapMaker.gridWidth / 2, -GameController.Instance.mapMaker.gridHeight / 2);
        }
        else if (gridState.itemID > curItemInfo.itemIndex_2x2 && gridState.itemID <= curItemInfo.itemIndex_1x2)
        {
            createPos += new Vector3(GameController.Instance.mapMaker.gridWidth / 2, 0);
        }
        itemGo.transform.position              = createPos;
        itemGo.GetComponent <Item>().itemID    = gridState.itemID;
        itemGo.GetComponent <Item>().gridPoint = this;
    }