Пример #1
0
        /// <summary>
        /// 初始化单项检测的位置
        /// </summary>
        private void InitPos()
        {
            List <List <Vector2> > mapPoses = new List <List <Vector2> >();

            for (int i = 0; i < m_xSize; i++)
            {
                List <Vector2> poses = new List <Vector2>();
                for (int j = 0; j < m_ySize; j++)
                {
                    poses.Add(new Vector2(m_InitPos.x + i * 0.2f, m_InitPos.y + j * 0.2f));
                    GameObject   go = GameObject.Instantiate(ResourceManager.LoadAsset <GameObject>(ResourceType.Prefab, "ShapDetection"), DetectionParent) as GameObject;
                    DetectionPos dp = go.GetComponent <DetectionPos>();
                    dp.pos_x = i;
                    dp.pos_y = j;
                    //Text tex = go.transform.GetComponentInChildren<Text>();
                    //tex.text = ToString(i) + ToString(j);
                    go.transform.localPosition = new Vector3(m_InitPos.x - j * 0.2f, m_InitPos.y - i * 0.2f, 0.1f);
                    if (MapHelper._mapInfo[i][j].isFill == 1)
                    {
                        Debug.LogError($" i :{i} j:{j}");

                        GameObject goo = GameObject.Instantiate(ResourceManager.LoadAsset <GameObject>(ResourceType.Prefab, "BlockCube")) as GameObject;
                        goo.transform.SetParent(shaps);
                        goo.transform.localPosition = new Vector3((m_InitPos.x - i * 0.2f), (m_InitPos.y - j * 0.2f), -0.9f);
                        goo.name = i.ToString() + j.ToString();
                        MapHelper.objcts[j, i] = goo;
                    }
                }
                mapPoses.Add(poses);
            }
            MapHelper.SetElePoses(mapPoses);
        }
Пример #2
0
        /// <summary>
        /// 初始话地图位置信息 并设置位置检测
        /// </summary>
        /// <returns></returns>
        private IEnumerator Generate()
        {
            WaitForSeconds         wait     = new WaitForSeconds(0f);
            List <List <Vector2> > mapPoses = new List <List <Vector2> >();

            for (int i = 0; i < m_xSize; i++)
            {
                List <Vector2> poses = new List <Vector2>();
                for (int j = 0; j < m_ySize; j++)
                {
                    GameObject go = GameObject.Instantiate(ResourceManager.LoadAsset <GameObject>(ResourceType.Prefab, "Cube")) as GameObject;
                    go.transform.localPosition = new Vector3(m_InitPos.x + j * m_Spece, m_InitPos.y - i * m_Spece, -0.05f);
                    poses.Add(new Vector2(m_InitPos.x + i * m_Spece, m_InitPos.y + j * m_Spece));
                    yield return(wait);
                }
                mapPoses.Add(poses);
            }
            MapHelper.SetElePoses(mapPoses);
        }