Пример #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>
        public static bool JudgeMove(GameObject detection, GameObject elem)
        {
            DetectionPos dp   = detection.GetComponent <DetectionPos>();
            int          posx = dp.pos_x;
            int          posy = dp.pos_y;
            bool         move = MapController.Fill(posx, posy, elem);

            if (move)
            {
                dp.InPosObj = elem;
            }
            return(move);
        }