/* * public static PlayerState SceneGroupToSaveGroup(PlayerState group) * { * return SceneGroupToSaveGroup ((int)group); * } * * * public static PlayerState SceneGroupToSaveGroup(int group) * { * return (PlayerState)(-(group + 1)); * } */ public bool LoadScene(string fileName, BgConfig config) { if (string.IsNullOrEmpty(fileName) || config == null) { return(false); } SffFile sf = new SffFile(); if (!sf.LoadFromFileName(fileName)) { return(false); } /* 处理场景 */ for (int i = 0; i < config.BgCount; ++i) { var bg = config.GetBg(i); if (bg != null) { if (bg.bgType == BgType.normal) { var staticBg = bg as BgStaticInfo; // PlayerState saveGroup = SceneGroupToSaveGroup(staticBg.srpiteno_Group); PlayerState group = (PlayerState)(staticBg.srpiteno_Group); // if (!HasLoadImageFrame(saveGroup, staticBg.srpiteno_Group, staticBg.spriteno_Image)) // LoadCharState(sf, group, bg.name, staticBg.spriteno_Image, false, true, saveGroup); if (!HasLoadImageFrame(staticBg.srpiteno_Group, staticBg.spriteno_Image)) { LoadCharState(sf, group, bg.name, staticBg.spriteno_Image); } } } } return(true); }
/* * public static PlayerState SceneGroupToSaveGroup(PlayerState group) * { * return SceneGroupToSaveGroup ((int)group); * } * * * public static PlayerState SceneGroupToSaveGroup(int group) * { * return (PlayerState)(-(group + 1)); * } */ public bool LoadScene(string fileName, SceneConfig config) { if (string.IsNullOrEmpty(fileName) || config == null || config.BgCfg == null) { return(false); } SffFile sf = new SffFile(); if (!sf.LoadFromFileName(fileName)) { return(false); } /* 处理场景 */ var cfg = config.BgCfg; for (int i = 0; i < cfg.BgCount; ++i) { var bg = cfg.GetBg(i); if (bg != null) { if (bg.bgType == BgType.normal) { var staticBg = bg as BgStaticInfo; // PlayerState saveGroup = SceneGroupToSaveGroup(staticBg.srpiteno_Group); PlayerState group = (PlayerState)(staticBg.srpiteno_Group); // if (!HasLoadImageFrame(saveGroup, staticBg.srpiteno_Group, staticBg.spriteno_Image)) // LoadCharState(sf, group, bg.name, staticBg.spriteno_Image, false, true, saveGroup); if (!HasLoadImageFrame(staticBg.srpiteno_Group, staticBg.spriteno_Image)) { LoadCharState(sf, group, bg.name, staticBg.spriteno_Image); } } } } if (config.AirCfg != null) { if (!LoadAir("Scene", config.AirCfg)) { ClearAll(); return(false); } for (int i = 0; i < config.AirCfg.GetStateCount(); ++i) { var key = config.AirCfg.GetStateByIndex(i); var value = config.AirCfg.GetBeginAction(key); if (value != null) { for (int j = 0; j < value.ActionFrameListCount; ++j) { ActionFrame frame; if (value.GetFrame(j, out frame)) { if (!HasLoadImageFrame(frame.Group, frame.Index)) { string name = string.Format("Scene_{0:D}_{1:D}", frame.Group, frame.Index); LoadCharState(sf, (PlayerState)frame.Group, name, frame.Index); } } } } } } return(true); }