本文整理汇总了C#中Tile.setTexture方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.setTexture方法的具体用法?C# Tile.setTexture怎么用?C# Tile.setTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.setTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: reloadMapContent
public bool reloadMapContent(string folder)
{
try
{
if (this.TextureSequences == null)
this.TextureSequences = new List<TileSequence>();
if (this.ObjectSequences == null)
this.ObjectSequences = new List<TileSequence>();
if (this.TileEvents == null)
this.TileEvents = new List<TileEvent>();
this.UpdateTileMapGraphicsContent();
//Creer le tableau a 2D des tiles
this.TabTiles = new Tile[this.NbLines, this.NbColumns];
JSONTileMap jsonMap = new JSONTileMap();
jsonMap.deserialize(folder, this);
jsonMap = null;
for (int i = 0; i < this.NbLines; i++)
{
for (int j = 0; j < this.NbColumns; j++)
{
Tile tile = new Tile(i, j, this.TilesWidth, this.TilesHeight, true, this) ;
int indexTileInTab = i * this.NbColumns + j;
if (this.textureContent != null)
{
int indexTexture = this.textureContent[indexTileInTab];
if (indexTexture > -1 && this.TileModelsTextureUsed.Count > indexTexture)
{
tile.setTexture(this.TileModelsTextureUsed[indexTexture]);
}
}
if (this.objectContent != null)
{
int indexObject = this.objectContent[indexTileInTab];
if (indexObject > -1 && this.TileModelsObjectsUsed.Count > indexObject)
tile.setObjectImage(this.TileModelsObjectsUsed[indexObject]);
}
if (this.textureSequenceContent != null)
{
int indexSequenceTexture = this.textureSequenceContent[indexTileInTab];
if (indexSequenceTexture > -1 && this.TextureSequences.Count > indexSequenceTexture)
tile.setTextureSequence(this.TextureSequences[indexSequenceTexture]);
}
if (this.objectSequenceContent != null)
{
int indexSequenceObject = this.objectSequenceContent[indexTileInTab];
if (indexSequenceObject > -1 && this.ObjectSequences.Count > indexSequenceObject)
tile.setObjectSequence(this.ObjectSequences[indexSequenceObject]);
}
if (this.collisionContent != null)
{
int collide = this.collisionContent[indexTileInTab];
if (collide == 0)
tile.IsCrossable = true;
else
tile.IsCrossable = false;
}
if (this.eventContent != null)
{
int indexEvent = this.eventContent[indexTileInTab];
if (indexEvent > -1 && this.TileEvents.Count > indexEvent)
tile.setEvent(this.TileEvents[indexEvent]);
}
this.TabTiles[i, j] = tile;
}
}
return true;
}
catch(Exception ex)
{
return false;
}
}
示例2: reloadFromFile
public bool reloadFromFile(string folder)
{
try
{
//Creer un tableau de textureFrame
int nbTotalTiles = this.NbColumns * this.NbLines;
//Creer le tableau a 2D des tiles
this.TabTiles = new Tile[this.NbLines, this.NbColumns];
string[] tabFrameTexture = new string[nbTotalTiles];
string[] tabFrameObj = new string[nbTotalTiles];
//Lire le fichier des textures devant exister
string finalpath = folder + "\\" + this.TilesMapName.ToLower() + "texturesinitfile.txt";
//Lire le fichier des objets devant exister
string finalpathObj = folder + "\\" + this.TilesMapName.ToLower() + "objectsinitfile.txt";
if (File.Exists(finalpath) && File.Exists(finalpathObj))
{
//Lire le fichier
string[] textContent = File.ReadAllLines(finalpath);
//Lire le fichier
string[] objContent = File.ReadAllLines(finalpathObj);
int indexDepText = 0;
int indexFinText = 0;
string indexFrameTexture = null;
int lastIndexOfText = 0;
int indexDepObj = 0;
int indexFinObj = 0;
string indexFrameObj = null;
int lastIndexOfObj = 0;
for (int i = 0; i < this.NbLines; i++)
{
indexDepText = 0;
indexFinText = 0;
indexFrameTexture = null;
lastIndexOfText = 0;
indexDepObj = 0;
indexFinObj = 0;
indexFrameObj = null;
lastIndexOfObj = 0;
for (int j = 0; j < this.NbColumns; j++)
{
//Creer une Tile
Tile tile = new Tile(i, j, this.TilesWidth, this.TilesHeight, true, this);
//Recuperer la texture
indexDepText = textContent[i].IndexOf("i", lastIndexOfText);
indexFinText = textContent[i].IndexOf("i", indexDepText + 1);
indexFrameTexture = textContent[i].Substring(indexDepText + 1, indexFinText - indexDepText - 1);
lastIndexOfText = indexFinText;
//Definir la texture du tile si elle existe
if (indexFrameTexture != null && !indexFrameTexture.Equals("N"))
{
int index = Convert.ToInt32(indexFrameTexture) - 1;
if (index < this.TileModelsTextureUsed.Count && index > -1)
tile.setTexture(this.TileModelsTextureUsed[index]);
}
//Recuperer l'objet
indexDepObj = objContent[i].IndexOf("i", lastIndexOfObj);
indexFinObj = objContent[i].IndexOf("i", indexDepObj + 1);
indexFrameObj = objContent[i].Substring(indexDepObj + 1, indexFinObj - indexDepObj - 1);
lastIndexOfObj = indexFinObj;
//Definir l'image objet du tile si elle existe
if (indexFrameObj != null && !indexFrameObj.Equals("N"))
{
int index = Convert.ToInt32(indexFrameObj) - 1;
if (index < this.TileModelsObjectsUsed.Count && index > -1)
tile.setObjectImage(this.TileModelsObjectsUsed[index]);
}
//L'inserer dans les tableau des tiles
this.TabTiles[i, j] = tile;
}
}
}
else
{
return false;
}
return true;
}
catch (Exception ex)
{
//.........这里部分代码省略.........