• Unity记录5.5-地图-随机生成连续洞穴块


    文章首发见博客:https://mwhls.top/4852.html
    无图/格式错误/后续更新请见首发页。
    更多更新请到mwhls.top查看
    欢迎留言提问或批评建议,私信不回。

    汇总:Unity 记录

    摘要:生成连续的洞穴地图块。

    随机生成连续洞穴-2023/9/5
    • 之前几天一直没想好洞穴这种四通八达的怎么实现,后来灵机一动,我把四通八达的一个块改成一通二达的四个块就好了。
    • 然后地下的块就直接取地面块的翻转,其它参数都不用改,效果还蛮好的。

    外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

    实现代码-2023/9/4-2023/9/5
    • 这部分的代码和前面的重复度比较高,有意义的只有新增的十个方向以及它们对应周围方向。
    • 其它部分就是一些查缺补漏,所以只放有意义的注释。
        /*  ---------- surface direction ----------
         *  ┌-----┬-----┬-----┐
         *  │__777│_____│999__│ I label these directions with numbers 
         *  │_7777│88888│9999_│     corresponding to the number pad positions for the block's solid area.
         *  │77777│88888│99999│ For example, 
         *  ├-----┼-----┼-----┤     1 in left-down, only left-down tiles are solid, i.e. from left to down
         *  │4____│55555│____6│     4 in left, the tiles in left are solid, i.e. from up-left to down-right
         *  │44___│55555│___66│     7,9 are opposite which denotes the empty area
         *  │444__│55555│__666│
         *  ├-----┼-----┼-----┤ Besides, _ means the reverse version
         *  │_____│_____│_____│
         *  │1____│22222│____3│
         *  │11___│22222│___33│
         *  └-----┴-----┴-----┘
         *  0. [empty, ]           : no tile in this block
         *  1. [left, down]        : from left to down
         *  2. [horizontal, ]      : from left to right
         *  3. [right, down]       : from right to down
         *  4. [vertical, left]    : from up-left to down-right
         *  5. [full, ]            : all tiles are soild
         *  6. [vertical, right]   : from up-right to down-left
         *  7. [left, up]          : from left to up
         *  8. [horizontal, ]      : 8. == 2.
         *  9. [right, up]         : from right to up
         * 
         *  ---------- reverse direction ----------
         *  10. [_empty, ]         : the reverse version of 0.
         *  11. [_left, down]      : the reverse version of 1.
         *  12. _2
         *  13. _3
         *  14. _4
         *  15. _5
         *  16. _6
         *  17. _7
         *  18. _8
         *  19. _9
         *  
         *  ---------- direction relation ----------
         * If direction of this block is 'x', which block can connect it?
         *  ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐
         *  │     │ 3 6 │     │       │     │     │     │       │     │ 1 4 │     │
         *  │     │_1 4 │     │       │     │     │     │       │     │_3 6 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │ 239 │  7  │ 459 │       │     │  2  │     │       │ 567 │  9  │ 127 │
         *  │     │     │_3 6 │       │     │     │     │       │_1 4 │     │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │  5  │     │       │     │     │     │       │     │  5  │     │
         *  │     │_123 │     │       │     │     │     │       │     │_123 │     │
         *  └-----┴-----┴-----┘       └-----┴-----┴-----┘       └-----┴-----┴-----┘
         * 
         *  ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐
         *  │     │ 1 4 │     │       │     │ 279 │     │       │     │ 3 6 │     │
         *  │     │_3 6 │     │       │     │     │     │       │     │_1 4 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │ 567 │  4  │ 036 │       │ 6 7 │  5* │ 4 9 │       │ 014 │  6  │ 459 │
         *  │_1 4 │     │_4 9 │       │_1 4 │     │_3 6 │       │_6 7 │     │_3 6 │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │ 4 9 │     │       │     │     │     │       │     │ 6 7 │     │
         *  │     │_6 7 │     │       │     │_123 │     │       │     │_4 9 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         * 
         *  ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐
         *  │     │  0  │     │       │     │  0  │     │       │     │  0  │     │
         *  │     │_279 │     │       │     │_279 │     │       │     │_279 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │ 239 │  1  │ 036 │       │ 239 │  2  │ 127 │       │ 014 │  3  │ 127 │
         *  │     │     │_4 9 │       │     │     │     │       │_6 7 │     │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │ 4 9 │     │       │     │  5  │     │       │     │ 6 7 │     │
         *  │     │_6 7 │     │       │     │_123 │     │       │     │_4 9 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         * 
         *  ┌-----┬-----┬-----┐
         *  │     │     │     │   x*: around with x
         *  │     │_279 │     │
         *  ├-----┼-----┼-----┤
         *  │ 1 4 │  0* │ 3 6 │
         *  │_6 7 │     │_4 9 │
         *  ├-----┼-----┼-----┤
         *  │     │ 123 │     │
         *  │     │     │     │
         *  ├-----┼-----┼-----┤
         * 
         *  ---------- reverse relation ----------
         *  
         *  ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐
         *  │     │ 1 4 │     │       │     │     │     │       │     │ 3 6 │     │
         *  │     │_3 6 │     │       │     │     │     │       │     │_1 4 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │ _7  │ 036 │       │     │ _2  │     │       │ 014 │ _9  │     │
         *  │_239 │     │_4 9 │       │     │     │     │       │_6 7 │     │_127 │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │0123 │     │       │     │     │     │       │     │0123 │     │
         *  │     │     │     │       │     │     │     │       │     │     │     │
         *  └-----┴-----┴-----┘       └-----┴-----┴-----┘       └-----┴-----┴-----┘
         * 
         *  ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐
         *  │     │ 3 6 │     │       │     │     │     │       │     │ 1 4 │     │
         *  │     │_1 4 │     │       │     │     │     │       │     │_3 6 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │ 014 │ _4  │ 459 │       │     │  0  │     │       │ 567 │ _6  │ 036 │
         *  │_6 7 │     │_3 6 │       │     │     │     │       │_1 4 │     │_4 9 │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │ 6 7 │     │       │     │     │     │       │     │ 4 9 │     │
         *  │     │_4 9 │     │       │     │     │     │       │     │_6 7 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         * 
         *  ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐       ┌-----┬-----┬-----┐
         *  │     │ 2579│     │       │     │ 2579│     │       │     │ 2579│     │
         *  │     │     │     │       │     │     │     │       │     │     │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │ _1  │ 459 │       │     │ _2  │     │       │ 567 │ _3  │     │
         *  │_239 │     │_3 6 │       │_239 │     │_127 │       │_1 4 │     │_127 │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         *  │     │ 6 7 │     │       │     │0123 │     │       │     │ 4 9 │     │
         *  │     │_4 9 │     │       │     │     │     │       │     │_6 7 │     │
         *  ├-----┼-----┼-----┤       ├-----┼-----┼-----┤       ├-----┼-----┼-----┤
         * 
         *  
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
  • 相关阅读:
    经典动画库 animate.css 的应用
    git 更换远程地址的方法
    深入了解PBKDF2:密码学中的关键推导函数
    C/C++轻量级并发TCP服务器框架Zinx-框架开发002: 定义通道抽象类
    Spring 6【数据绑定时类型转换、装饰器设计模式、DataBinder源码分析BeanWrapper、Errors、BindingResult】(十二)-全面详解(学习总结---从入门到深化)
    海外调查问卷赚钱是真的吗?
    基于STM32L431的Liteos低功耗Runstop模式的实现
    ASUS华硕ZenBook 13灵耀U 2代U3300F笔记本UX333FN/FA原装出厂Win10系统工厂安装模式
    数据库安全:InfluxDB 未授权访问-Jwt验证不当 漏洞.
    远程小组软件开发过程(3):人
  • 原文地址:https://blog.csdn.net/asd123pwj/article/details/133678246