private void Clear() { m_Info = null; m_Cam = null; m_Players = null; m_Scaling = null; m_AirConfig = null; m_BgDef = null; m_BgCfg = null; }
/* * 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); }
private bool LoadFromStr(string str) { Clear(); if (string.IsNullOrEmpty(str)) { return(false); } ConfigReader reader = new ConfigReader(); reader.LoadString(str); // 1 var section = reader.GetSection("Info"); if (section != null) { m_Info = new StageInfo(); if (!section.GetPropertysValues(m_Info)) { Clear(); return(false); } } else { Clear(); return(false); } // 2 section = reader.GetSection("Camera"); if (section == null) { Clear(); return(false); } m_Cam = new StageCamera(); if (!section.GetPropertysValues(m_Cam)) { Clear(); return(false); } // 3 section = reader.GetSection("PlayerInfo"); if (section == null) { Clear(); return(false); } m_Players = new StagePlayerInfo(); if (!section.GetPropertysValues(m_Players)) { Clear(); return(false); } // 4 section = reader.GetSection("Scaling"); if (section != null) { m_Scaling = new StageScaling(); if (!section.GetPropertysValues(m_Scaling)) { Clear(); return(false); } } else { m_Scaling = new StageScaling(); } // 5 m_AirConfig = new AirConfig(reader); if (!m_AirConfig.IsVaild) { Clear(); return(false); } // 6 section = reader.GetSection("BGdef"); if (section == null) { Clear(); return(false); } m_BgDef = new BgDef(); if (!section.GetPropertysValues(m_BgDef)) { Clear(); return(false); } // 7. m_BgCfg = new BgConfig(); if (!m_BgCfg.LoadFromReader(reader)) { Clear(); return(false); } return(IsVaild); }