コード例 #1
0
        public RemoveFloorAreaCommand(Level level, Vector2Int start, Vector2Int end)
        {
            int xMin = Mathf.Min(start.x, end.x);
            int xMax = Mathf.Max(start.x, end.x);
            int yMin = Mathf.Min(start.y, end.y);
            int yMax = Mathf.Max(start.y, end.y);

            List <IWorldCommand> commands = new List <IWorldCommand>();

            for (int x = xMin; x <= xMax; x++)
            {
                for (int y = yMin; y <= yMax; y++)
                {
                    commands.Add(new RemoveFloorCommand(level, new Vector2Int(x, y)));
                }
            }

            command = new CompositeCommand(commands);
        }
コード例 #2
0
        public BuildFloorAreaCommand(Level level, Vector2Int start, Vector2Int end, int floorType = (int)FloorIndex.New)
        {
            int xMin = Mathf.Min(start.x, end.x);
            int xMax = Mathf.Max(start.x, end.x);
            int yMin = Mathf.Min(start.y, end.y);
            int yMax = Mathf.Max(start.y, end.y);

            List <IWorldCommand> commands = new List <IWorldCommand>();

            for (int x = xMin; x <= xMax; x++)
            {
                for (int y = yMin; y <= yMax; y++)
                {
                    commands.Add(new BuildFloorCommand(level, new Vector2Int(x, y), floorType));
                }
            }

            command = new CompositeCommand(commands);
        }
コード例 #3
0
        public RemoveWallLineCommand(Level level, Vector2Int vertexStart, Vector2Int vertexEnd)
        {
            if (vertexEnd.x != vertexEnd.x && vertexStart.y != vertexEnd.y)
            {
                Debug.Log("Diagonal lines are not allowed.");
            }

            int xMin = Mathf.Min(vertexStart.x, vertexEnd.x);
            int xMax = Mathf.Max(vertexStart.x, vertexEnd.x);
            int yMin = Mathf.Min(vertexStart.y, vertexEnd.y);
            int yMax = Mathf.Max(vertexStart.y, vertexEnd.y);

            List <IWorldCommand> commands = new List <IWorldCommand>();

            int diffX = xMax - xMin;
            int diffY = yMax - yMin;

            int z = 0;

            if (diffX > diffY)
            {
                xMax -= 1;
                z     = 1;
            }
            else
            {
                yMax -= 1;
            }

            for (int x = xMin; x <= xMax; x++)
            {
                for (int y = yMin; y <= yMax; y++)
                {
                    commands.Add(new RemoveWallCommand(level, new Vector3Int(x, y, z)));
                }
            }

            command = new CompositeCommand(commands);
        }