Map.h
资源名称:PushBox.rar [点击查看]
上传用户:qhdwjd2004
上传日期:2020-12-29
资源大小:362k
文件大小:3k
源码类别:
iPhone
开发平台:
Objective-C
- #ifndef Map_h
- #define Map_h
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <unistd.h>
- #include <dirent.h>
- #include <sys/stat.h>
- #include <errno.h>
- /*
- byte Map[Map_LEN]={
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0
- };
- */
- ///////////////////////////////////////
- // 地图信息
- ///////////////////////////////////////
- // 地图大小
- #define Map_LEN 266
- // 总关数
- #define TOTAL_CHAPTER 255
- // 系统地图文件
- #define Sys_Map_Path "/Applications/PushBox.app/data.db"
- // 自定义地图文件路径
- #define Custom_Map_Path "~/Media/PushBox/"
- // 自定义地图文件后缀
- #define MAP_FILE_SUFFIX "map"
- // 残局文件名
- #define MESS_PATH "/Applications/PushBox.app/mess.r"
- // 关于文件
- #define About_Path "/Applications/PushBox.app/about.html"
- ///////////////////////////////////////
- // 地图表现
- ///////////////////////////////////////
- // 区块大小
- #define BoxSize 22
- // 边框
- #define BorderSize 6
- // 空
- #define EmptyBlock 0
- // 障碍
- #define WallBlock 1
- // 箱子
- #define BoxBlock 2
- // 箱子目的地
- #define TargetBlock 3
- // 玩家
- #define PlayerBlock 4
- // 箱子到达目的地
- #define BoxOnTargetBlock BoxBlock + TargetBlock
- // 玩家到达目的地
- #define PlayerOnTargetBlock PlayerBlock + TargetBlock
- ///////////////////////////////////////
- // 视图定义
- ///////////////////////////////////////
- #define COVERVIEW 0
- #define GAMEVIEW 1
- #define LISTVIEW 2
- #define SETTINGVIEW 3
- #define ABOUTVIEW 4
- ///////////////////////////////////////
- // 其他
- ///////////////////////////////////////
- typedef unsigned char byte;
- // 残局结构
- typedef struct{
- byte isCustom; // 是否为自定义关卡
- byte chapterIndex; // 当前关卡索引
- byte enableChapterCount; // 可选关卡数
- byte mapdata[Map_LEN]; // 关卡地图信息
- } Mess;
- #endif
- #import <Foundation/Foundation.h>
- #import <CoreFoundation/CoreFoundation.h>
- @interface Map : NSObject
- {
- }
- // 加载关卡地图
- +(void)LoadChapter:(byte)index Data:(byte[])mapdata;
- // 获取总关卡数
- +(int)ChapterCount;
- // 检查是否存在残局
- +(bool)CheckMessExist;
- // 保存残局
- +(void)SaveMess:(Mess)messdata;
- // 加载残局数据
- +(Mess)LoadMess;
- // 拷贝Mess
- +(Mess)MessCopy:(Mess)source;
- // 加载自定义地图
- +(void)LoadMap:(NSString*)path Data:(byte[])mapdata;
- // 删除自定义地图
- +(void)DeleteMap:(NSString*)path;
- // 检查文件是否存在
- +(bool)FileExist:(NSString*)path;
- // 检查目录是否存在
- +(bool)DirExist:(NSString*)path;
- // 创建目录
- +(bool)CreateDir:(NSString*)path;
- // 获取随机数
- +(int)GetRandNum;
- @end