예제 #1
0
    /// <summary>
    /// 生成金豆荚篮子
    /// </summary>
    private void CreateBasket(int startVertical, int startHorizontal)
    {
        GameObject basket = Instantiate(Resources.Load("prefabs/gridbase"), GridContentSet.transform) as GameObject;

        Destroy(basket.GetComponent <SpriteRenderer>());
        basket.name = "basket" + startVertical.ToString() + startHorizontal.ToString();
        basket.AddComponent <Image>();
        basket.GetComponent <Image>().sprite = mSprites[14];
        basketPoint = mGridBaseListManager[startVertical][startHorizontal].gridBase.GetComponent <RectTransform>().position;
        basket.GetComponent <RectTransform>().sizeDelta = new Vector2(gridSize * 0.9f, gridSize * 0.4f);
        basket.GetComponent <RectTransform>().position  = basketPoint + new Vector3(0.0f, -gridSize / 2 - gridSize * 0.4f / 2, 0.0f);

        BasketBean basketBean = new BasketBean();

        basketBean.basketVertical   = startVertical;
        basketBean.basketHorizontal = startHorizontal;
        basketBean.basket           = basket;
        if (basketListOfEditor == null)
        {
            basketListOfEditor = new List <BasketBean>();
        }
        basketListOfEditor.Add(basketBean);
    }
예제 #2
0
    public void InitData()
    {
        //[0]读取配置,获取对象
        editorData = JsonUtil.GetEditorData(10);
        GridUIAttributeManager.GetInstance().editorData = editorData;

        //[1]获取格子内容信息
        if (!editorData.gridData.Equals(""))
        {
            string[] gridDatas = editorData.gridData.Split(',');
            gridDataList = new List <GridBean>();
            foreach (string grid in gridDatas)
            {
                if (!grid.Equals(""))
                {
                    string[] result   = grid.Split('|');
                    GridBean gridBean = new GridBean();
                    gridBean.vertical    = int.Parse(result[0]);
                    gridBean.horizontal  = int.Parse(result[1]);
                    gridBean.spriteIndex = int.Parse(result[2]);
                    gridDataList.Add(gridBean);
                }
            }
            GridUIAttributeManager.GetInstance().gridDataList = gridDataList;
        }

        //[2]获取传送门数据
        if (!editorData.doorData.Equals(""))
        {
            string[] doorDatas = editorData.doorData.Split(',');
            doorDataList = new List <DoorBean>();
            foreach (string door in doorDatas)
            {
                if (!door.Equals(""))
                {
                    string[] result   = door.Split('|');
                    DoorBean doorBean = new DoorBean();
                    doorBean.inVertical    = int.Parse(result[0]);
                    doorBean.inHorizontal  = int.Parse(result[1]);
                    doorBean.outVertical   = int.Parse(result[2]);
                    doorBean.outHorizontal = int.Parse(result[3]);
                    doorDataList.Add(doorBean);
                }
            }
            GridUIAttributeManager.GetInstance().doorDataList = doorDataList;
        }

        //[3]获取冰块数据
        if (!editorData.iceData.Equals(""))
        {
            string[] iceDatas = editorData.iceData.Split(',');
            iceDataList = new List <IceBean>();
            foreach (string ice in iceDatas)
            {
                if (!ice.Equals(""))
                {
                    string[] result  = ice.Split('|');
                    IceBean  iceBean = new IceBean();
                    iceBean.iceVertical   = int.Parse(result[0]);
                    iceBean.iceHorizontal = int.Parse(result[1]);
                    iceBean.iceLevel      = int.Parse(result[2]);
                    iceDataList.Add(iceBean);
                }
            }
            GridUIAttributeManager.GetInstance().iceDataList = iceDataList;
        }

        //获取金豆荚篮子数据
        if (!editorData.basketData.Equals(""))
        {
            string[] basketDatas = editorData.basketData.Split(',');
            basketDataList = new List <BasketBean>();
            foreach (string basket in basketDatas)
            {
                if (!basket.Equals(""))
                {
                    string[]   result     = basket.Split('|');
                    BasketBean basketBean = new BasketBean();
                    basketBean.basketVertical   = int.Parse(result[0]);
                    basketBean.basketHorizontal = int.Parse(result[1]);
                    basketDataList.Add(basketBean);
                }
            }
            GridUIAttributeManager.GetInstance().basketDataList = basketDataList;
        }

        //获取树藤数据
        if (!editorData.timboData.Equals(""))
        {
            string[] timboDatas = editorData.timboData.Split(',');
            timboDataList = new List <TimboBean>();
            foreach (string timbo in timboDatas)
            {
                if (!timbo.Equals(""))
                {
                    string[]  result    = timbo.Split('|');
                    TimboBean timboBean = new TimboBean();
                    timboBean.timboVertical   = int.Parse(result[0]);
                    timboBean.timboHorizontal = int.Parse(result[1]);
                    timboDataList.Add(timboBean);
                }
            }
            GridUIAttributeManager.GetInstance().timboDataList = timboDataList;
        }
    }