示例#1
0
        public void ShrinkZ(int lineZ, int length)
        {
            MapTips res = CreateInstance <MapTips>();

            res.Init(mapSizeX, mapSizeY, mapSizeZ);

            for (int x = 0; x < mapSizeX; ++x)
            {
                for (int y = 0; y < mapSizeY; ++y)
                {
                    for (int z = 0; z < mapSizeZ; ++z)
                    {
                        Vector3Int tagpos;
                        if (z < lineZ)
                        {
                            tagpos = new Vector3Int(x, y, z);
                        }
                        else
                        {
                            tagpos = new Vector3Int(x, y, z + length);
                        }

                        res.SetShape(GetShape(tagpos), x, y, z);
                    }
                }
            }

            this.shapes = res.shapes;
        }
示例#2
0
        public NativeMapTips(MapTips mapTips)
        {
            m_mapSizeX = mapTips.mapSizeX;
            m_mapSizeY = mapTips.mapSizeY;
            m_mapSizeZ = mapTips.mapSizeZ;

            shapes = new NativeArray <EnumShapeType>(mapTips.shapes, Allocator.Persistent);
            events = new NativeArray <int>(mapTips.events, Allocator.Persistent);
        }
示例#3
0
        public override void Initialize(Object[] targets)
        {
            base.Initialize(targets);

            LoadMapTipSprite();

            mapTips3_ = (MapTips)targets[0];
            SetDefaultCameraPos();
        }
示例#4
0
        //オブジェクト作成
        public void CreateObject(MapTips mapTips3, int mapId)
        {
            m_isXZ = new bool[mapTips3.mapSizeX * mapTips3.mapSizeZ];

            //XZ面で長方形サーチを掛けていく
            //未チェックの箇所があった場合、そこから長方形探索ループに入る
            //Xのラインで大きい長方形が出来るように内側のループをZでサーチを掛けていく
            List <MapNodePlate> nodeList  = SearchMapNode(mapTips3);
            List <TileFloor>    floorList = SearchFloor(mapTips3);
            List <TileWall>     wallList  = SearchWall(mapTips3);

            CreateMapPath.CreateMapPathObject(mapId, nodeList);
        }
示例#5
0
        TileFloor GetFloor(bool isSquare, int stX, int stZ, MapTips mapTips3)
        {
            //真上からブロックにぶつかるまで探す
            int           baseY     = -1;
            EnumShapeType baseShape = 0;
            int           basePal   = 0;
            bool          isFind    = false;

            for (int y = 0; y < mapTips3.mapSizeY; ++y)
            {
                int           revY  = (mapTips3.mapSizeY - y - 1);
                Vector3Int    pos   = new Vector3Int(stX, revY, stZ);
                EnumShapeType shape = mapTips3.GetShape(pos);
                int           pal   = mapTips3.GetEvent(pos);
                if (shape == 0)
                {
                    continue;             //空チップ
                }
                if (isSquare)
                {
                    if (IsTriFloor(shape))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!IsTriFloor(shape))
                    {
                        continue;
                    }
                }

                baseY     = revY + 1;
                baseShape = shape;
                basePal   = pal;
                isFind    = true;
                break;
            }

            if (isFind)
            {
                TileFloor res = new TileFloor(baseShape, basePal, baseY, stX, stZ);
                return(res);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
        TileWall GetWall(bool isSquare, int stX, int stY, MapTips mapTips3)
        {
            //手前からブロックにぶつかるまで探す
            int           baseZ     = -1;
            EnumShapeType baseShape = EnumShapeType.Empty;
            int           basePal   = 0;
            bool          isFind    = false;

            for (int z = 0; z < mapTips3.mapSizeZ; ++z)
            {
                Vector3Int    pos   = new Vector3Int(stX, stY, z);
                EnumShapeType shape = mapTips3.GetShape(pos);
                int           pal   = mapTips3.GetEvent(pos);
                if (shape == 0)
                {
                    continue;             //空チップ
                }
                if (isSquare)
                {
                    if (IsTriWall(shape))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!IsTriWall(shape))
                    {
                        continue;
                    }
                }

                baseZ     = z;
                baseShape = shape;
                basePal   = pal;
                isFind    = true;
                break;
            }

            if (isFind)
            {
                TileWall res = new TileWall(baseShape, basePal, baseZ, stX, stY);
                return(res);
            }
            else
            {
                return(null);
            }
        }
示例#7
0
 //貼り付け
 public void SetPaste(Vector3Int pos, MapTips tips)
 {
     for (int x = 0; x < tips.mapSizeX; ++x)
     {
         for (int y = 0; y < tips.mapSizeY; ++y)
         {
             for (int z = 0; z < tips.mapSizeZ; ++z)
             {
                 Vector3Int tagpos = new Vector3Int(pos.x + x, pos.y + y, pos.z + z);
                 if (this.IsSafePos(tagpos)) //はみでチェック
                 {
                     SetShape(tips.GetShape(x, y, z), tagpos);
                 }
             }
         }
     }
 }
示例#8
0
        //パス
        List <MapNodePlate> SearchMapNode(MapTips mapTips3)
        {
            List <MapNodePlate> pathList = new List <MapNodePlate>();

            for (int x = 0; x < mapTips3.mapSizeX; ++x)
            {
                for (int z = 0; z < mapTips3.mapSizeZ; ++z)
                {
                    var path = GetMapPath(x, z, mapTips3);
                    if (path.Count != 0)
                    {
                        pathList.AddRange(path);
                    }
                }
            }

            return(pathList);
        }
示例#9
0
        List <MapNodePlate> GetMapPath(int stX, int stZ, MapTips mapTips3)
        {
            List <MapNodePlate> res = new List <MapNodePlate>();
            //基準点ブロック
            //真上からブロックにぶつかるまで探す
            int  baseY      = -1;
            bool isTriFloor = false;

            for (int y = 0; y < mapTips3.mapSizeY; ++y)
            {
                int           revY  = (mapTips3.mapSizeY - y - 1);
                Vector3Int    pos   = new Vector3Int(stX, revY, stZ);
                EnumShapeType shape = mapTips3.GetShape(pos);
                if (shape == 0)
                {
                    continue;             //空チップ
                }
                baseY = revY;
                res.Add(new MapNodePlate(shape, baseY, stX, stZ, mapTips3.mapSizeX, mapTips3.mapSizeZ));
                isTriFloor = IsTriFloor(shape);
                break;
            }

            //三角床の場合は、下面もサーチ
            if (isTriFloor)
            {
                for (int y = baseY; y < mapTips3.mapSizeY; ++y)
                {
                    int           revY  = (mapTips3.mapSizeY - y - 1);
                    Vector3Int    pos   = new Vector3Int(stX, revY, stZ);
                    EnumShapeType shape = mapTips3.GetShape(pos);
                    if (shape != EnumShapeType.Box)
                    {
                        continue;
                    }

                    res.Add(new MapNodePlate(shape, revY, stX, stZ, mapTips3.mapSizeX, mapTips3.mapSizeZ));
                    break;
                }
            }

            return(res);
        }
示例#10
0
        void LoadMap()
        {
            var loadtips = AssetDatabase.LoadAssetAtPath <MapTips>(GetFilePath());

            if (loadtips != null)
            {
                m_mapTips      = loadtips.GetClone();
                m_mapSizeX     = m_mapTips.mapSizeX;
                m_mapSizeY     = m_mapTips.mapSizeY;
                m_mapSizeZ     = m_mapTips.mapSizeZ;
                m_isLoadMapTip = true;

                m_mapSprite = Resources.Load <Sprite>(MapEditorMain.MapImageName + m_mapId.ToString("d3"));
            }
            else
            {
                EditorUtility.DisplayDialog("LoadFile", "読み込めませんでした。\n" + GetFilePath(), "ok");
            }

            AssetDatabase.Refresh();
        }
示例#11
0
        //マップ作成
        void CreateNewMap()
        {
            //palette_ = CreateInstance<MapPalette>();
            m_mapTips = CreateInstance <MapTips>();
            m_mapTips.Init(m_mapSizeX, m_mapSizeY, m_mapSizeZ);

            for (int x = 0; x < m_mapSizeX; ++x)
            {
                for (int y = 0; y < m_mapSizeY; ++y)
                {
                    for (int z = 0; z < m_mapSizeZ; ++z)
                    {
                        //mapTips2[x, y, z] = 0;

                        if ((y == 0) || (z == m_mapSizeZ - 1))
                        {
                            SetMapShape(EnumShapeType.Box, x, y, z);
                        }
                    }
                }
            }
            m_isLoadMapTip = true;
        }
示例#12
0
        //マップサイズ変更
        void ResizeMap()
        {
            MapTips newMapTips3 = CreateInstance <MapTips>();

            newMapTips3.Init(m_mapSizeX, m_mapSizeY, m_mapSizeZ);

            for (int x = 0; x < m_mapTips.mapSizeX; ++x)
            {
                if (x >= m_mapSizeX)
                {
                    continue;
                }

                for (int y = 0; y < m_mapTips.mapSizeY; ++y)
                {
                    if (y >= m_mapSizeY)
                    {
                        continue;
                    }

                    for (int z = 0; z < m_mapTips.mapSizeZ; ++z)
                    {
                        if (z >= m_mapSizeZ)
                        {
                            continue;
                        }

                        newMapTips3.SetEvent(m_mapTips.GetEvent(x, y, z), x, y, z);
                        newMapTips3.SetShape(m_mapTips.GetShape(x, y, z), x, y, z);
                    }
                }
            }

            m_mapTips = newMapTips3;

            OpenMapEditor();
        }
示例#13
0
        //コピー
        public MapTips GetCopy(Vector3Int pos, Vector3Int size)
        {
            //MapTips res = new MapTips(size.x, size.y, size.z);
            MapTips res = CreateInstance <MapTips>();

            res.Init(size.x, size.y, size.z);

            for (int x = 0; x < size.x; ++x)
            {
                for (int y = 0; y < size.y; ++y)
                {
                    for (int z = 0; z < size.z; ++z)
                    {
                        Vector3Int tagpos = new Vector3Int(pos.x + x, pos.y + y, pos.z + z);
                        // Assert.IsTrue(this.IsSafePos(tagpos));
                        // Debug.Log(tagpos + " shape" + GetShape(tagpos));
                        res.SetShape(GetShape(tagpos), x, y, z);
                        // res.SetEvent(GetEvent(tagpos), tagpos);
                    }
                }
            }

            return(res);
        }
示例#14
0
        //床
        List <TileFloor> SearchFloor(MapTips mapTips3)
        {
            List <TileFloor> floorList = new List <TileFloor>();

            for (int x = 0; x < mapTips3.mapSizeX; ++x)
            {
                for (int z = 0; z < mapTips3.mapSizeZ; ++z)
                {
                    //int index = (x + (mapSizeX * z));
                    TileFloor sqFloor = GetFloor(true, x, z, mapTips3);
                    if (sqFloor != null)
                    {
                        floorList.Add(sqFloor);
                    }

                    TileFloor triFloor = GetFloor(false, x, z, mapTips3);
                    if (triFloor != null)
                    {
                        floorList.Add(triFloor);
                    }
                }
            }
            return(floorList);
        }
示例#15
0
        //壁
        List <TileWall> SearchWall(MapTips mapTips3)
        {
            List <TileWall> wallList = new List <TileWall>();

            for (int x = 0; x < mapTips3.mapSizeX; ++x)
            {
                for (int y = 0; y < mapTips3.mapSizeY; ++y)
                {
                    //int index = (x + (mapSizeX * y));
                    TileWall sqWall = GetWall(true, x, y, mapTips3);
                    if (sqWall != null)
                    {
                        wallList.Add(sqWall);
                    }

                    TileWall triWall = GetWall(false, x, y, mapTips3);
                    if (triWall != null)
                    {
                        wallList.Add(triWall);
                    }
                }
            }
            return(wallList);
        }
示例#16
0
 public void SetPasteMapTip(Vector3Int pos, MapTips tips)
 {
     m_mapTips.SetPaste(pos, tips);
 }