private void objEditButton_Click(object sender, System.EventArgs e) { frmEditLayer EditLayer = new frmEditLayer(); cTileLayer Layer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; EditLayer.objNameText.Text = Layer.msName; EditLayer.objZText.Text = Layer.mfZ.ToString(); EditLayer.objLitBox.SelectedIndex = Layer.mbLit?1:0; EditLayer.objCollideBox.SelectedIndex = Layer.mbCollide?1:0; EditLayer.ShowDialog(); if (EditLayer.mbOkWasPressed) { Layer.msName = EditLayer.objNameText.Text; Layer.mfZ = (float)Convert.ToDouble(EditLayer.objZText.Text); Layer.mbLit = EditLayer.objLitBox.SelectedIndex == 1; Layer.mbCollide = EditLayer.objCollideBox.SelectedIndex == 1; UpdateLayers(); objLayerList.SelectedIndex = mlSelectedLayer; } EditLayer.Dispose(); }
private void objDeleteButton_Click(object sender, System.EventArgs e) { if (mlstTileLayers.Count == 1) { MessageBox.Show("There must be at least one layer!", "Error"); return; } DialogResult Result = MessageBox.Show("Are you sure you want to delete the layer '" + ((cTileLayer)mlstTileLayers[mlSelectedLayer]).msName + "'?", "Warning", MessageBoxButtons.YesNo); if (Result == DialogResult.Yes) { cTileLayer Layer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; mlstTileLayers.Remove(Layer); UpdateLayers(); if (mlSelectedLayer > 0) { mlSelectedLayer--; } objLayerList.SelectedIndex = mlSelectedLayer; } }
private void objNewButton_Click(object sender, System.EventArgs e) { cTileLayer LastLayer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; frmEditLayer EditLayer = new frmEditLayer(); EditLayer.objNameText.Text = "Untitled"; EditLayer.objZText.Text = (LastLayer.mfZ + 1).ToString(); EditLayer.objLitBox.SelectedIndex = 1; EditLayer.objCollideBox.SelectedIndex = 1; EditLayer.ShowDialog(); if (EditLayer.mbOkWasPressed) { AddLayer(EditLayer.objNameText.Text, (float)Convert.ToDouble(EditLayer.objZText.Text), EditLayer.objCollideBox.SelectedIndex == 1, EditLayer.objLitBox.SelectedIndex == 1, LastLayer.mlTileSize, mlSelectedLayer + 1); mlSelectedLayer = mlSelectedLayer + 1; objLayerList.SelectedIndex = mlSelectedLayer; } EditLayer.Dispose(); }
public void AddLayer(string asName, float afZ, bool abCollide, bool abLit, int alTileSize, int alPos) { cTileLayer TLayer = new cTileLayer(mMainForm.mTilesetsForm, asName, mMainForm.mlMapWidth, mMainForm.mlMapHeight, afZ, abCollide, abLit, alTileSize); AddLayer(TLayer, alPos); UpdateSettings(); }
private void UpdatePropLabel() { if (mlSelectedLayer < 0) { return; } cTileLayer Layer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; objPropLabel.Text = "Z: " + Layer.mfZ + "\n" + "Collide: " + Layer.mbCollide + " Lit: " + Layer.mbLit; }
public void AddLayer(cTileLayer aTLayer, int alPos) { if (alPos < 0) { mlstTileLayers.Add(aTLayer); objLayerList.Items.Add(objLayerList.Items.Count + " : " + aTLayer.msName); objLayerList.SetItemChecked(objLayerList.Items.Count - 1, true); objShadowLayerList.Items.Add(objShadowLayerList.Items.Count + " : " + aTLayer.msName); } else { mlstTileLayers.Insert(alPos, aTLayer); int LastShadowLayer = objShadowLayerList.SelectedIndex; objLayerList.Items.Clear(); objShadowLayerList.Items.Clear(); for (int i = 0; i < mlstTileLayers.Count; i++) { objLayerList.Items.Add(i + " : " + ((cTileLayer)mlstTileLayers[i]).msName); objShadowLayerList.Items.Add(i + " : " + ((cTileLayer)mlstTileLayers[i]).msName); } for (int i = 0; i < objLayerList.Items.Count; i++) { objLayerList.SetItemChecked(i, true); } if (LastShadowLayer >= alPos) { LastShadowLayer++; objShadowLayerList.SelectedIndex = LastShadowLayer; } } if (objLayerList.Items.Count == 1) { objLayerList.SelectedIndex = 0; objShadowLayerList.SelectedIndex = 0; mlSelectedLayer = 0; } if (objShadowLayerList.SelectedIndex < 0) { objShadowLayerList.SelectedIndex = 0; } }
private void objMoveDownButton_Click(object sender, System.EventArgs e) { if (mlSelectedLayer >= mlstTileLayers.Count - 1) { return; } cTileLayer TempLayer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; mlstTileLayers[mlSelectedLayer] = mlstTileLayers[mlSelectedLayer + 1]; mlstTileLayers[mlSelectedLayer + 1] = TempLayer; UpdateLayers(); mlSelectedLayer++; objLayerList.SelectedIndex = mlSelectedLayer; }
public cTile GetTile(int alX, int alY) { frmTileSets mTileSetsForm = mMainForm.mTilesetsForm; if (mTileSetsForm.mlSelectedTile < 0) { return(null); } if (mTileSetsForm.mlSelectedTileSet < 0) { return(null); } if (mlSelectedLayer < 0) { return(null); } cTileLayer TLayer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; return(TLayer.GetTile(alX, alY)); }
public void ToggleTileBreak(int alX, int alY) { frmTileSets mTileSetsForm = mMainForm.mTilesetsForm; if (mTileSetsForm.mlSelectedTile < 0) { return; } if (mTileSetsForm.mlSelectedTileSet < 0) { return; } if (mlSelectedLayer < 0) { return; } cTileLayer TLayer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; TLayer.ToggleTileBreak(alX, alY); }
public void DeleteTile(int alX, int alY) { frmTileSets mTileSetsForm = mMainForm.mTilesetsForm; if (mTileSetsForm.mlSelectedTile < 0) { return; } if (mTileSetsForm.mlSelectedTileSet < 0) { return; } if (mlSelectedLayer < 0) { return; } cTileLayer TLayer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; TLayer.SetTile(alX, alY, -1, -1, 0); }
public void SetTile(int alX, int alY) { frmTileSets mTileSetsForm = mMainForm.mTilesetsForm; if (mTileSetsForm.mlSelectedTile < 0) { return; } if (mTileSetsForm.mlSelectedTileSet < 0) { return; } if (mlSelectedLayer < 0) { return; } cTileLayer TLayer = (cTileLayer)mlstTileLayers[mlSelectedLayer]; TLayer.SetTile(alX, alY, mTileSetsForm.mlSelectedTileSet, mTileSetsForm.mlSelectedTile, mTileSetsForm.objRotationList.SelectedIndex); }
public void AddLayer(string asName,float afZ, bool abCollide, bool abLit,int alTileSize,int alPos) { cTileLayer TLayer = new cTileLayer(mMainForm.mTilesetsForm,asName, mMainForm.mlMapWidth, mMainForm.mlMapHeight, afZ, abCollide,abLit,alTileSize); AddLayer(TLayer, alPos); UpdateSettings(); }
public void AddLayer(cTileLayer aTLayer, int alPos) { if(alPos<0) { mlstTileLayers.Add(aTLayer); objLayerList.Items.Add(objLayerList.Items.Count+" : "+aTLayer.msName); objLayerList.SetItemChecked(objLayerList.Items.Count-1,true); objShadowLayerList.Items.Add(objShadowLayerList.Items.Count+" : "+aTLayer.msName); } else { mlstTileLayers.Insert(alPos,aTLayer); int LastShadowLayer = objShadowLayerList.SelectedIndex; objLayerList.Items.Clear(); objShadowLayerList.Items.Clear(); for(int i=0;i<mlstTileLayers.Count;i++) { objLayerList.Items.Add(i+" : "+((cTileLayer)mlstTileLayers[i]).msName); objShadowLayerList.Items.Add(i+" : "+((cTileLayer)mlstTileLayers[i]).msName); } for(int i=0;i<objLayerList.Items.Count;i++) { objLayerList.SetItemChecked(i,true); } if(LastShadowLayer>=alPos) { LastShadowLayer++; objShadowLayerList.SelectedIndex = LastShadowLayer; } } if(objLayerList.Items.Count==1) { objLayerList.SelectedIndex = 0; objShadowLayerList.SelectedIndex=0; mlSelectedLayer =0; } if(objShadowLayerList.SelectedIndex<0)objShadowLayerList.SelectedIndex=0; }
//////////////////////////////////////////////////////////////////////// // LOAD THE MAP // //////////////////////////////////////////////////////////////////////// public bool Load(string asFileName) { XmlDocument Doc = new XmlDocument(); try{ Doc.Load(asFileName); } catch { return(false); } XmlElement HplMapElem = (XmlElement)Doc.FirstChild; /////////////////////////// ////// HPL MAP /////////// /////////////////////////// int lR, lG, lB; mMainForm.msMapName = cHplXml.GetStr(HplMapElem, "Name", ""); mMainForm.mlMapWidth = cHplXml.GetInt(HplMapElem, "Width", 0); mMainForm.mlMapHeight = cHplXml.GetInt(HplMapElem, "Height", 0); mMainForm.mfLightZ = cHplXml.GetFloat(HplMapElem, "LightZ", 10); lR = cHplXml.GetInt(HplMapElem, "AmbColR", 0); lG = cHplXml.GetInt(HplMapElem, "AmbColG", 0); lB = cHplXml.GetInt(HplMapElem, "AmbColB", 0); mMainForm.mAmbientColor = Color.FromArgb(lR, lG, lB); foreach (XmlElement HplMapChild in HplMapElem.ChildNodes) { /////////////////////////// ////// LIGHT ////////////// /////////////////////////// if (HplMapChild.Name == "Lights") { XmlElement LightRootElem = HplMapChild; foreach (XmlElement LightElem in LightRootElem.ChildNodes) { string sName = LightElem.GetAttribute("Name"); bool bActive = cHplXml.GetBool(LightElem, "Active", true); float fRadius = cHplXml.GetFloat(LightElem, "Radius", 0); float fSpecular = cHplXml.GetFloat(LightElem, "Specular", 1); lR = cHplXml.GetInt(LightElem, "ColR", 0); lG = cHplXml.GetInt(LightElem, "ColG", 0); lB = cHplXml.GetInt(LightElem, "ColB", 0); Color Col = Color.FromArgb(lR, lG, lB); int lX = cHplXml.GetInt(LightElem, "X", 0); int lY = cHplXml.GetInt(LightElem, "Y", 0); float fZ = cHplXml.GetFloat(LightElem, "Z", 0); cLight LData = new cLight(lX, lY, fZ); LData.mColor = Col; LData.msName = sName; LData.mfRadius = fRadius; LData.mfSpecular = fSpecular; LData.mbActive = bActive; LData.mbCastShadows = cHplXml.GetBool(LightElem, "CastShadows", true); LData.mbAffectMaterial = cHplXml.GetBool(LightElem, "AffectMaterial", true); mMainForm.mLightForm.mlstLights.Add(LData); } } /////////////////////////// ////// SOUNDSOURCE///////// /////////////////////////// if (HplMapChild.Name == "SoundSources") { XmlElement SoundRootElem = HplMapChild; foreach (XmlElement SoundElem in SoundRootElem.ChildNodes) { string sName = SoundElem.GetAttribute("Name"); int lX = cHplXml.GetInt(SoundElem, "X", 0); int lY = cHplXml.GetInt(SoundElem, "Y", 0); float fZ = cHplXml.GetFloat(SoundElem, "Z", 0); cSoundSource SData = new cSoundSource(lX, lY, fZ); SData.msName = sName; SData.mbActive = cHplXml.GetBool(SoundElem, "Active", true); SData.msSoundName = cHplXml.GetStr(SoundElem, "SoundName", ""); SData.mfMinDist = cHplXml.GetFloat(SoundElem, "MinDist", 1); SData.mfMaxDist = cHplXml.GetFloat(SoundElem, "MaxDist", 100); SData.mlRandom = cHplXml.GetInt(SoundElem, "Random", 0); SData.mlInterval = cHplXml.GetInt(SoundElem, "Interval", 0); SData.mbLoop = cHplXml.GetBool(SoundElem, "Loop", true); SData.mbRelative = cHplXml.GetBool(SoundElem, "Relative", false); SData.mfRelX = cHplXml.GetFloat(SoundElem, "RelX", 0); SData.mfRelY = cHplXml.GetFloat(SoundElem, "RelY", 0); SData.mfRelZ = cHplXml.GetFloat(SoundElem, "RelZ", 0); SData.mfVolume = cHplXml.GetFloat(SoundElem, "Volume", 1); mMainForm.mSoundForm.mlstSounds.Add(SData); } } /////////////////////////// ////// PARTICLE SYSTEM //// /////////////////////////// if (HplMapChild.Name == "ParticleSystems") { XmlElement PartRootElem = HplMapChild; foreach (XmlElement PartElem in PartRootElem.ChildNodes) { string sName = PartElem.GetAttribute("Name"); int lX = cHplXml.GetInt(PartElem, "X", 0); int lY = cHplXml.GetInt(PartElem, "Y", 0); float fZ = cHplXml.GetFloat(PartElem, "Z", 0); cParticle PartData = new cParticle(mMainForm.mParticlesForm, lX, lY, fZ); PartData.msName = sName; PartData.mbActive = cHplXml.GetBool(PartElem, "Active", true); string sPartName = cHplXml.GetStr(PartElem, "PartName", ""); PartData.mlTypeNum = 0; int lCount = 0; foreach (cParticleType PType in mMainForm.mParticlesForm.mlstTypes) { if (sPartName == PType.msName) { PartData.mlTypeNum = lCount; break; } lCount++; } PartData.mfSizeX = cHplXml.GetFloat(PartElem, "SizeX", 0); PartData.mfSizeY = cHplXml.GetFloat(PartElem, "SizeY", 0); PartData.mfSizeZ = cHplXml.GetFloat(PartElem, "SizeZ", 0); mMainForm.mParticlesForm.mlstParticles.Add(PartData); } } /////////////////////////// ////// AREAS ////////////// /////////////////////////// if (HplMapChild.Name == "Areas") { XmlElement AreaRootElem = HplMapChild; foreach (XmlElement AreaElem in AreaRootElem.ChildNodes) { string sName = AreaElem.GetAttribute("Name"); int lX = cHplXml.GetInt(AreaElem, "X", 0); int lY = cHplXml.GetInt(AreaElem, "Y", 0); float fZ = cHplXml.GetFloat(AreaElem, "Z", 0); cArea AreaData = new cArea(mMainForm.mAreasForm, lX, lY, fZ); AreaData.msName = sName; AreaData.mbActive = cHplXml.GetBool(AreaElem, "Active", true); string sAreaName = cHplXml.GetStr(AreaElem, "AreaType", ""); AreaData.mlTypeNum = 0; int lCount = 0; foreach (cAreaType AType in mMainForm.mAreasForm.mlstTypes) { if (sAreaName == AType.msName) { AreaData.mlTypeNum = lCount; break; } lCount++; } AreaData.mfWidth = cHplXml.GetFloat(AreaElem, "Width", 0); AreaData.mfHeight = cHplXml.GetFloat(AreaElem, "Height", 0); AreaData.mfSizeX = cHplXml.GetFloat(AreaElem, "SizeX", 0); AreaData.mfSizeY = cHplXml.GetFloat(AreaElem, "SizeY", 0); AreaData.mfSizeZ = cHplXml.GetFloat(AreaElem, "SizeZ", 0); mMainForm.mAreasForm.mlstAreas.Add(AreaData); } } /////////////////////////// ////// PROP DATA/////////// /////////////////////////// else if (HplMapChild.Name == "PropData") { foreach (XmlElement PDataElem in HplMapChild.ChildNodes) { string sFile = Directory.GetCurrentDirectory() + cHplXml.GetStr(PDataElem, "File", ""); cPropData PropData = new cPropData(sFile); PropData.LoadData(); mMainForm.mPropsForm.AddProp(PropData); } } /////////////////////////// ////// ENTITIES /////////// /////////////////////////// else if (HplMapChild.Name == "Entities") { foreach (XmlElement EntityElem in HplMapChild.ChildNodes) { string sClass = EntityElem.GetAttribute("Class"); cImageEntity Entity = null; string sName = EntityElem.GetAttribute("Name"); string sDataName = EntityElem.GetAttribute("DataName"); bool bActive = cHplXml.GetBool(EntityElem, "Active", true); int lX = cHplXml.GetInt(EntityElem, "X", 0); int lY = cHplXml.GetInt(EntityElem, "Y", 0); float fZ = cHplXml.GetFloat(EntityElem, "Z", 0); float fWidth = cHplXml.GetFloat(EntityElem, "Width", 0); float fHeight = cHplXml.GetFloat(EntityElem, "Height", 0); float fAngle = cHplXml.GetFloat(EntityElem, "Angle", 0); bool bFlipH = cHplXml.GetBool(EntityElem, "FlipH", false); bool bFlipV = cHplXml.GetBool(EntityElem, "FlipV", false); int lAnimNum = cHplXml.GetInt(EntityElem, "AnimNum", 0); if (sClass == "Mapeditor.cProp") { cPropData PData = mMainForm.mPropsForm.GetData(sDataName); Entity = new cProp(PData, lX, lY, fZ); } Entity.msName = sName; Entity.mbActive = bActive; Entity.mfWidth = fWidth; Entity.mfHeight = fHeight; Entity.mfAngle = fAngle; Entity.mbFlipH = bFlipH; Entity.mbFlipV = bFlipV; Entity.mlAnimNum = lAnimNum; if (sClass == "Mapeditor.cProp") { mMainForm.mPropsForm.mlstProps.Add(Entity); } } } /////////////////////////// ////// TILE MAP /////////// /////////////////////////// else if (HplMapChild.Name == "TileMap") { XmlElement TileMapElem = HplMapChild; int lShadowLayerIndex = Convert.ToInt32(TileMapElem.GetAttribute("ShadowLayer")); mMainForm.mlDefaultTileSize = Convert.ToInt32(TileMapElem.GetAttribute("TileSize")); foreach (XmlElement TileMapChild in TileMapElem.ChildNodes) { //////////////////////////// ////// TILE SETS /////////// //////////////////////////// if (TileMapChild.Name == "TileSets") { XmlElement TileSetRootElem = TileMapChild; frmTileSets TileSetsForm = mMainForm.mTilesetsForm; foreach (XmlElement TSElem in TileSetRootElem.ChildNodes) { string sPath = Directory.GetCurrentDirectory() + TSElem.GetAttribute("FileName"); cTileSet TSData = new cTileSet(sPath); //MessageBox.Show(sPath); if (TSData.LoadData() == false) { MessageBox.Show("Couldn't load tileset '" + TSElem.GetAttribute("FileName") + "'!", "Error"); return(false); } TileSetsForm.AddTileSet(TSData); } } //////////////////////////// ////// TILE LAYERS ///////// //////////////////////////// else if (TileMapChild.Name == "Layers") { XmlElement LayerRootElem = TileMapChild; frmLayers LayerForm = mMainForm.mLayersForm; foreach (XmlElement TLayerElem in LayerRootElem.ChildNodes) { string sName = TLayerElem.GetAttribute("Name"); int lWidth = Convert.ToInt32(TLayerElem.GetAttribute("Width")); int lHeight = Convert.ToInt32(TLayerElem.GetAttribute("Height")); float fZ = (float)Convert.ToDouble(TLayerElem.GetAttribute("Z")); bool bCollide = Convert.ToBoolean(TLayerElem.GetAttribute("Collide")); bool bLit = Convert.ToBoolean(TLayerElem.GetAttribute("Lit")); int lTileSize = Convert.ToInt32(TLayerElem.GetAttribute("TileSize")); cTileLayer TLayer = new cTileLayer(mMainForm.mTilesetsForm, sName, lWidth, lHeight, fZ, bCollide, bLit, lTileSize); int lTileCount = 0; foreach (XmlElement TRowElem in TLayerElem.ChildNodes) { string sData = TRowElem.GetAttribute("Data"); int lDataCount = 0; //MessageBox.Show(sData); while (lDataCount < sData.Length) { cTile T = TLayer.mvTiles[lTileCount]; lDataCount = LoadTileData(T, sData, lDataCount); //MessageBox.Show("T:"+T.mlSet+" "+T.mlNum+" "+T.mlRotation+" "); lTileCount++; } } LayerForm.AddLayer(TLayer, -1); } } } //Set the shadow layer. mMainForm.mLayersForm.objShadowLayerList.SelectedIndex = lShadowLayerIndex; } } /////////////////////// ////// UPDATE /////////// /////////////////////// //MessageBox.Show("Loaded!"); return(true); }
//////////////////////////////////////////////////////////////////////// // LOAD THE MAP // //////////////////////////////////////////////////////////////////////// public bool Load(string asFileName) { XmlDocument Doc = new XmlDocument(); try{ Doc.Load(asFileName); } catch{ return false; } XmlElement HplMapElem = (XmlElement)Doc.FirstChild; /////////////////////////// ////// HPL MAP /////////// /////////////////////////// int lR,lG,lB; mMainForm.msMapName = cHplXml.GetStr(HplMapElem,"Name",""); mMainForm.mlMapWidth = cHplXml.GetInt(HplMapElem,"Width",0); mMainForm.mlMapHeight = cHplXml.GetInt(HplMapElem,"Height",0); mMainForm.mfLightZ = cHplXml.GetFloat(HplMapElem,"LightZ",10); lR = cHplXml.GetInt(HplMapElem,"AmbColR",0); lG = cHplXml.GetInt(HplMapElem,"AmbColG",0); lB = cHplXml.GetInt(HplMapElem,"AmbColB",0); mMainForm.mAmbientColor = Color.FromArgb(lR,lG,lB); foreach(XmlElement HplMapChild in HplMapElem.ChildNodes) { /////////////////////////// ////// LIGHT ////////////// /////////////////////////// if(HplMapChild.Name == "Lights") { XmlElement LightRootElem = HplMapChild; foreach(XmlElement LightElem in LightRootElem.ChildNodes) { string sName = LightElem.GetAttribute("Name"); bool bActive = cHplXml.GetBool(LightElem,"Active",true); float fRadius = cHplXml.GetFloat(LightElem,"Radius",0); float fSpecular = cHplXml.GetFloat(LightElem,"Specular",1); lR = cHplXml.GetInt(LightElem,"ColR",0); lG = cHplXml.GetInt(LightElem,"ColG",0); lB =cHplXml.GetInt(LightElem,"ColB",0); Color Col = Color.FromArgb(lR,lG,lB); int lX = cHplXml.GetInt(LightElem,"X",0); int lY = cHplXml.GetInt(LightElem,"Y",0); float fZ = cHplXml.GetFloat(LightElem,"Z",0); cLight LData = new cLight(lX,lY,fZ); LData.mColor = Col; LData.msName =sName; LData.mfRadius = fRadius; LData.mfSpecular = fSpecular; LData.mbActive = bActive; LData.mbCastShadows = cHplXml.GetBool(LightElem,"CastShadows",true); LData.mbAffectMaterial = cHplXml.GetBool(LightElem,"AffectMaterial",true); mMainForm.mLightForm.mlstLights.Add(LData); } } /////////////////////////// ////// SOUNDSOURCE///////// /////////////////////////// if(HplMapChild.Name == "SoundSources") { XmlElement SoundRootElem = HplMapChild; foreach(XmlElement SoundElem in SoundRootElem.ChildNodes) { string sName = SoundElem.GetAttribute("Name"); int lX = cHplXml.GetInt(SoundElem,"X",0); int lY = cHplXml.GetInt(SoundElem,"Y",0); float fZ = cHplXml.GetFloat(SoundElem,"Z",0); cSoundSource SData = new cSoundSource(lX,lY,fZ); SData.msName = sName; SData.mbActive = cHplXml.GetBool(SoundElem,"Active",true); SData.msSoundName = cHplXml.GetStr(SoundElem,"SoundName",""); SData.mfMinDist = cHplXml.GetFloat(SoundElem,"MinDist",1); SData.mfMaxDist = cHplXml.GetFloat(SoundElem,"MaxDist",100); SData.mlRandom = cHplXml.GetInt(SoundElem,"Random", 0); SData. mlInterval = cHplXml.GetInt(SoundElem,"Interval",0); SData.mbLoop = cHplXml.GetBool(SoundElem,"Loop", true); SData.mbRelative = cHplXml.GetBool(SoundElem,"Relative", false); SData.mfRelX = cHplXml.GetFloat(SoundElem,"RelX",0); SData.mfRelY = cHplXml.GetFloat(SoundElem,"RelY", 0); SData.mfRelZ = cHplXml.GetFloat(SoundElem,"RelZ", 0); SData.mfVolume = cHplXml.GetFloat(SoundElem,"Volume", 1); mMainForm.mSoundForm.mlstSounds.Add(SData); } } /////////////////////////// ////// PARTICLE SYSTEM //// /////////////////////////// if(HplMapChild.Name == "ParticleSystems") { XmlElement PartRootElem = HplMapChild; foreach(XmlElement PartElem in PartRootElem.ChildNodes) { string sName = PartElem.GetAttribute("Name"); int lX = cHplXml.GetInt(PartElem,"X",0); int lY = cHplXml.GetInt(PartElem,"Y",0); float fZ = cHplXml.GetFloat(PartElem,"Z",0); cParticle PartData = new cParticle(mMainForm.mParticlesForm,lX,lY,fZ); PartData.msName = sName; PartData.mbActive = cHplXml.GetBool(PartElem,"Active",true); string sPartName = cHplXml.GetStr(PartElem,"PartName",""); PartData.mlTypeNum = 0; int lCount=0; foreach(cParticleType PType in mMainForm.mParticlesForm.mlstTypes){ if(sPartName == PType.msName){ PartData.mlTypeNum = lCount; break; } lCount++; } PartData.mfSizeX = cHplXml.GetFloat(PartElem,"SizeX",0); PartData.mfSizeY = cHplXml.GetFloat(PartElem,"SizeY",0); PartData.mfSizeZ = cHplXml.GetFloat(PartElem,"SizeZ",0); mMainForm.mParticlesForm.mlstParticles.Add(PartData); } } /////////////////////////// ////// AREAS ////////////// /////////////////////////// if(HplMapChild.Name == "Areas") { XmlElement AreaRootElem = HplMapChild; foreach(XmlElement AreaElem in AreaRootElem.ChildNodes) { string sName = AreaElem.GetAttribute("Name"); int lX = cHplXml.GetInt(AreaElem,"X",0); int lY = cHplXml.GetInt(AreaElem,"Y",0); float fZ = cHplXml.GetFloat(AreaElem,"Z",0); cArea AreaData = new cArea(mMainForm.mAreasForm,lX,lY,fZ); AreaData.msName = sName; AreaData.mbActive = cHplXml.GetBool(AreaElem,"Active",true); string sAreaName = cHplXml.GetStr(AreaElem,"AreaType",""); AreaData.mlTypeNum = 0; int lCount=0; foreach(cAreaType AType in mMainForm.mAreasForm.mlstTypes) { if(sAreaName == AType.msName) { AreaData.mlTypeNum = lCount; break; } lCount++; } AreaData.mfWidth = cHplXml.GetFloat(AreaElem,"Width",0); AreaData.mfHeight = cHplXml.GetFloat(AreaElem,"Height",0); AreaData.mfSizeX = cHplXml.GetFloat(AreaElem,"SizeX",0); AreaData.mfSizeY = cHplXml.GetFloat(AreaElem,"SizeY",0); AreaData.mfSizeZ = cHplXml.GetFloat(AreaElem,"SizeZ",0); mMainForm.mAreasForm.mlstAreas.Add(AreaData); } } /////////////////////////// ////// PROP DATA/////////// /////////////////////////// else if(HplMapChild.Name == "PropData") { foreach(XmlElement PDataElem in HplMapChild.ChildNodes) { string sFile = Directory.GetCurrentDirectory() + cHplXml.GetStr(PDataElem,"File",""); cPropData PropData= new cPropData(sFile); PropData.LoadData(); mMainForm.mPropsForm.AddProp(PropData); } } /////////////////////////// ////// ENTITIES /////////// /////////////////////////// else if(HplMapChild.Name == "Entities") { foreach(XmlElement EntityElem in HplMapChild.ChildNodes) { string sClass = EntityElem.GetAttribute("Class"); cImageEntity Entity=null; string sName = EntityElem.GetAttribute("Name"); string sDataName = EntityElem.GetAttribute("DataName"); bool bActive = cHplXml.GetBool(EntityElem,"Active",true); int lX = cHplXml.GetInt(EntityElem,"X",0); int lY = cHplXml.GetInt(EntityElem,"Y",0); float fZ = cHplXml.GetFloat(EntityElem,"Z",0); float fWidth = cHplXml.GetFloat(EntityElem,"Width",0); float fHeight = cHplXml.GetFloat(EntityElem,"Height",0); float fAngle = cHplXml.GetFloat(EntityElem,"Angle",0); bool bFlipH = cHplXml.GetBool(EntityElem,"FlipH",false); bool bFlipV = cHplXml.GetBool(EntityElem,"FlipV",false); int lAnimNum = cHplXml.GetInt(EntityElem,"AnimNum",0); if(sClass=="Mapeditor.cProp") { cPropData PData = mMainForm.mPropsForm.GetData(sDataName); Entity = new cProp(PData,lX,lY,fZ); } Entity.msName = sName; Entity.mbActive = bActive; Entity.mfWidth = fWidth; Entity.mfHeight = fHeight; Entity.mfAngle = fAngle; Entity.mbFlipH = bFlipH; Entity.mbFlipV = bFlipV; Entity.mlAnimNum = lAnimNum; if(sClass=="Mapeditor.cProp") mMainForm.mPropsForm.mlstProps.Add(Entity); } } /////////////////////////// ////// TILE MAP /////////// /////////////////////////// else if(HplMapChild.Name == "TileMap") { XmlElement TileMapElem = HplMapChild; int lShadowLayerIndex = Convert.ToInt32(TileMapElem.GetAttribute("ShadowLayer")); mMainForm.mlDefaultTileSize = Convert.ToInt32(TileMapElem.GetAttribute("TileSize")); foreach(XmlElement TileMapChild in TileMapElem.ChildNodes) { //////////////////////////// ////// TILE SETS /////////// //////////////////////////// if(TileMapChild.Name == "TileSets") { XmlElement TileSetRootElem = TileMapChild; frmTileSets TileSetsForm = mMainForm.mTilesetsForm; foreach(XmlElement TSElem in TileSetRootElem.ChildNodes) { string sPath = Directory.GetCurrentDirectory() + TSElem.GetAttribute("FileName"); cTileSet TSData = new cTileSet(sPath); //MessageBox.Show(sPath); if(TSData.LoadData()==false) { MessageBox.Show("Couldn't load tileset '"+TSElem.GetAttribute("FileName")+"'!", "Error"); return false; } TileSetsForm.AddTileSet(TSData); } } //////////////////////////// ////// TILE LAYERS ///////// //////////////////////////// else if(TileMapChild.Name == "Layers") { XmlElement LayerRootElem = TileMapChild; frmLayers LayerForm = mMainForm.mLayersForm; foreach(XmlElement TLayerElem in LayerRootElem.ChildNodes) { string sName = TLayerElem.GetAttribute("Name"); int lWidth = Convert.ToInt32(TLayerElem.GetAttribute("Width")); int lHeight = Convert.ToInt32(TLayerElem.GetAttribute("Height")); float fZ = (float)Convert.ToDouble(TLayerElem.GetAttribute("Z")); bool bCollide = Convert.ToBoolean(TLayerElem.GetAttribute("Collide")); bool bLit = Convert.ToBoolean(TLayerElem.GetAttribute("Lit")); int lTileSize = Convert.ToInt32(TLayerElem.GetAttribute("TileSize")); cTileLayer TLayer = new cTileLayer(mMainForm.mTilesetsForm,sName,lWidth,lHeight, fZ,bCollide, bLit,lTileSize); int lTileCount=0; foreach(XmlElement TRowElem in TLayerElem.ChildNodes) { string sData = TRowElem.GetAttribute("Data"); int lDataCount =0; //MessageBox.Show(sData); while(lDataCount<sData.Length) { cTile T = TLayer.mvTiles[lTileCount]; lDataCount = LoadTileData(T, sData, lDataCount); //MessageBox.Show("T:"+T.mlSet+" "+T.mlNum+" "+T.mlRotation+" "); lTileCount++; } } LayerForm.AddLayer(TLayer,-1); } } } //Set the shadow layer. mMainForm.mLayersForm.objShadowLayerList.SelectedIndex = lShadowLayerIndex; } } /////////////////////// ////// UPDATE /////////// /////////////////////// //MessageBox.Show("Loaded!"); return true; }