Skip to content

Commit

Permalink
about Map
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuKaiwei committed Dec 13, 2011
1 parent 0158ffe commit 38b581b
Show file tree
Hide file tree
Showing 15 changed files with 966 additions and 401 deletions.
4 changes: 4 additions & 0 deletions cocos2d-xna/cocos2d-xna.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@
<Folder Include="support\data_support\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\cocos2d.Content.Pipeline.Importers\cocos2d.Content.Pipeline.Importers.csproj">
<Project>{FBE4633D-00D1-4391-8184-63B91DA28D4B}</Project>
<Name>cocos2d.Content.Pipeline.Importers</Name>
</ProjectReference>
<ProjectReference Include="..\cocos2d.Framework\cocos2d.Framework.csproj">
<Project>{CC156337-B4A7-479F-9262-9A708B5E1164}</Project>
<Name>cocos2d.Framework</Name>
Expand Down
2 changes: 1 addition & 1 deletion cocos2d-xna/platform/CCFileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static string fullPathFromRelativePath(string pszRelativePath)
/// </summary>
public static string fullPathFromRelativeFile(string pszFilename, string pszRelativeFile)
{
string m_sString = pszRelativeFile.Substring(0, pszRelativeFile.LastIndexOf("/\\") + 1);
string m_sString = pszRelativeFile.Substring(0, pszRelativeFile.LastIndexOf("/") + 1);
m_sString += pszFilename;
return m_sString;
}
Expand Down
88 changes: 84 additions & 4 deletions cocos2d-xna/platform/CCSAXParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ THE SOFTWARE.
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d.Framework;
using System.Xml.Linq;

namespace cocos2d
{
Expand All @@ -50,14 +52,92 @@ public bool init(string pszEncoding)

public bool parse(string pszFile)
{
CCFileData data = new CCFileData(pszFile, "rt");
ulong size = data.Size;
byte[] pBuffer = (byte[])data.Buffer;

if (pBuffer == null)
//CCFileData data = new CCFileData(pszFile, "rt");
//ulong size = data.Size;
//byte[] pBuffer = (byte[])data.Buffer;
CCContent data = CCApplication.sharedApplication().content.Load<CCContent>(pszFile);

if (data == null)
{
return false;
}
//Òª¸Éµôhttp
string str = data.Content;
XElement doc = XElement.Parse(str);
List<string> atts1 = new List<string>();

atts1 = (from item in doc.Attributes()
select item.Value.ToString()).ToList();

List<string> atts2 = new List<string>();
atts2 = (from item in doc.Attributes()
select item.Name.ToString()).ToList();

List<string> atts = new List<string>();
if (atts1.Count==atts2.Count)
{
for (int i = 0; i < atts1.Count; i++)
{
atts.Add(atts2[i]);
atts.Add(atts1[i]);
}
}
startElement(this, "map", atts.ToArray());

List<string> atts3 = new List<string>();
atts3 = (from item in doc.Descendants("tileset").LastOrDefault().Attributes()
select item.Name.ToString()).ToList();
List<string> atts4 = new List<string>();
atts4 = (from item in doc.Descendants("tileset").LastOrDefault().Attributes()
select item.Value.ToString()).ToList();

List<string> atts5 = new List<string>();
if (atts3.Count == atts4.Count)
{
for (int i = 0; i < atts3.Count; i++)
{
atts5.Add(atts3[i]);
atts5.Add(atts4[i]);
}
}
startElement(this, "tileset",atts5.ToArray());

List<string> atts6 = new List<string>();
atts6 = (from item in doc.Descendants("image").LastOrDefault().Attributes()
select item.Name.ToString()).ToList();
List<string> atts7 = new List<string>();
atts7 = (from item in doc.Descendants("image").LastOrDefault().Attributes()
select item.Value.ToString()).ToList();
List<string> atts8 = new List<string>();
if (atts6.Count == atts7.Count)
{
for (int i = 0; i < atts6.Count; i++)
{
atts8.Add(atts6[i]);
atts8.Add(atts7[i]);
}
}
startElement(this, "image", atts8.ToArray());

List<string> atts9 = new List<string>();
atts9 = (from item in doc.Descendants("data").FirstOrDefault().Attributes()
select item.Name.ToString()).ToList();
List<string> atts10 = new List<string>();
atts10 = (from item in doc.Descendants("data").FirstOrDefault().Attributes()
select item.Value.ToString()).ToList();
List<string> atts11 = new List<string>();
if (atts9.Count==atts10.Count)
{
for (int i = 0; i < atts10.Count; i++)
{
atts11.Add(atts9[i]);
atts11.Add(atts10[i]);
}
}
startElement(this, "data", atts11.ToArray());
endElement(data, "data");

#warning about xml
/// * this initialize the library and check potential ABI mismatches
/// * between the version it was compiled for and the actual shared
Expand Down
Loading

0 comments on commit 38b581b

Please sign in to comment.