Map.h
上传用户:qhdwjd2004
上传日期:2020-12-29
资源大小:362k
文件大小:3k
源码类别:

iPhone

开发平台:

Objective-C

  1. #ifndef Map_h
  2. #define Map_h
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #include <unistd.h>
  7. #include <dirent.h>
  8. #include <sys/stat.h>
  9. #include <errno.h>
  10. /*
  11. byte Map[Map_LEN]={
  12.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  13.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  14.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  15.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  16.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  17.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  18.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  19.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  20.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  21.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  22.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  23.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  24.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  25.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  26.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  27.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  28.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  29.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  30.     0,0,0,0,0,0,0,0,0,0,0,0,0,0
  31. };
  32. */
  33. ///////////////////////////////////////
  34. // 地图信息
  35. ///////////////////////////////////////
  36. // 地图大小
  37. #define Map_LEN 266
  38. // 总关数
  39. #define TOTAL_CHAPTER 255
  40. // 系统地图文件
  41. #define Sys_Map_Path "/Applications/PushBox.app/data.db"
  42. // 自定义地图文件路径
  43. #define Custom_Map_Path "~/Media/PushBox/"
  44. // 自定义地图文件后缀
  45. #define MAP_FILE_SUFFIX "map"
  46. // 残局文件名
  47. #define MESS_PATH "/Applications/PushBox.app/mess.r"
  48. // 关于文件
  49. #define About_Path "/Applications/PushBox.app/about.html"
  50. ///////////////////////////////////////
  51. // 地图表现
  52. ///////////////////////////////////////
  53. // 区块大小
  54. #define BoxSize 22
  55. // 边框
  56. #define BorderSize 6
  57. // 空
  58. #define EmptyBlock  0
  59. // 障碍
  60. #define WallBlock 1
  61. // 箱子
  62. #define BoxBlock 2
  63. // 箱子目的地
  64. #define TargetBlock 3
  65. // 玩家
  66. #define PlayerBlock 4
  67. // 箱子到达目的地
  68. #define BoxOnTargetBlock BoxBlock + TargetBlock
  69. // 玩家到达目的地
  70. #define PlayerOnTargetBlock PlayerBlock + TargetBlock
  71. ///////////////////////////////////////
  72. // 视图定义
  73. ///////////////////////////////////////
  74. #define COVERVIEW 0
  75. #define GAMEVIEW 1
  76. #define LISTVIEW 2
  77. #define SETTINGVIEW 3
  78. #define ABOUTVIEW 4
  79. ///////////////////////////////////////
  80. // 其他
  81. ///////////////////////////////////////
  82. typedef unsigned char byte;
  83. // 残局结构
  84. typedef struct{
  85. byte isCustom; // 是否为自定义关卡
  86. byte chapterIndex; // 当前关卡索引
  87. byte enableChapterCount; // 可选关卡数
  88. byte mapdata[Map_LEN]; // 关卡地图信息
  89. } Mess;
  90. #endif
  91. #import <Foundation/Foundation.h>
  92. #import <CoreFoundation/CoreFoundation.h>
  93. @interface Map : NSObject
  94. {    
  95. }
  96. // 加载关卡地图
  97. +(void)LoadChapter:(byte)index Data:(byte[])mapdata;
  98. // 获取总关卡数
  99. +(int)ChapterCount;
  100. // 检查是否存在残局
  101. +(bool)CheckMessExist;
  102. // 保存残局
  103. +(void)SaveMess:(Mess)messdata;
  104. // 加载残局数据
  105. +(Mess)LoadMess;
  106. // 拷贝Mess
  107. +(Mess)MessCopy:(Mess)source;
  108. // 加载自定义地图
  109. +(void)LoadMap:(NSString*)path Data:(byte[])mapdata;
  110. // 删除自定义地图
  111. +(void)DeleteMap:(NSString*)path;
  112. // 检查文件是否存在
  113. +(bool)FileExist:(NSString*)path;
  114. // 检查目录是否存在
  115. +(bool)DirExist:(NSString*)path;
  116. // 创建目录
  117. +(bool)CreateDir:(NSString*)path;
  118. // 获取随机数
  119. +(int)GetRandNum;
  120. @end