本文整理汇总了C#中Enemy.setEnemyType方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.setEnemyType方法的具体用法?C# Enemy.setEnemyType怎么用?C# Enemy.setEnemyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy.setEnemyType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadTiles
/*************************************************
* Load tiles from file and populate levelTiles
*************************************************/
public void LoadTiles(string fileStream)
{
// Load the level and ensure all of the lines are the same length.
int width = 0;
List<string> lines = new List<string>();
using (StreamReader reader = new StreamReader(fileStream))
{
string line = reader.ReadLine();
width = line.Length;
while (line != null)
{
lines.Add(line);
if (line.Length != width)
throw new Exception(String.Format("The length of line {0} is different from all preceeding lines.", lines.Count));
line = reader.ReadLine();
}
}
LEVEL_WIDTH = width;
LEVEL_HEIGHT = lines.Count();
levelTiles = new Tile[LEVEL_WIDTH, LEVEL_HEIGHT];
camera.setGameScale();
currentLevelName = allLevels.ElementAt(currentLevelNr - 1);
int y = 0;
foreach (string row in lines)
{
int x = 0;
foreach (char aChar in row)
{
//Block tile
if(aChar.ToString().Equals("#"))
levelTiles[x, y] = Tile.createBlocked();
//Empty tile
if (aChar.ToString().Equals("."))
levelTiles[x, y] = Tile.createEmpty();
//Trap I.E Disco tile
if (aChar.ToString().Equals("T"))
levelTiles[x, y] = Tile.createTrap();
//Player start position
if (aChar.ToString().Equals("1"))
{
levelTiles[x, y] = Tile.createEmpty();
player.setPlayerPosition(new Vector2(x, y));
}
//Exit tile
if (aChar.ToString().Equals("X"))
levelTiles[x, y] = Tile.createExit();
//Heart Tile/gem
if (aChar.ToString().Equals("L"))
{
levelTiles[x, y] = Tile.createEmpty();
Vector2 gemPos = new Vector2(x, y);
Gem aGem = new Gem(gemPos);
aGem.setGemType(Gem.GemType.Life);
gemList.Add(aGem);
}
// Enemy - Rasta
if (aChar.ToString().Equals("R"))
{
levelTiles[x, y] = Tile.createEmpty();
Vector2 enemyPos = new Vector2(x, y);
Enemy theEnemy = new Enemy(enemyPos, camera.getScaleX());
theEnemy.setEnemyType(Enemy.EnemyType.Rasta);
enemyList.Add(theEnemy);
}
// Enemy - HipHopper
if (aChar.ToString().Equals("H"))
{
levelTiles[x, y] = Tile.createEmpty();
Vector2 enemyPos = new Vector2(x, y);
Enemy theEnemy = new Enemy(enemyPos, camera.getScaleX());
theEnemy.setEnemyType(Enemy.EnemyType.HipHopper);
enemyList.Add(theEnemy);
}
// Enemy - Ghost
if (aChar.ToString().Equals("G"))
{
levelTiles[x, y] = Tile.createEmpty();
Vector2 enemyPos = new Vector2(x, y);
Enemy theEnemy = new Enemy(enemyPos, camera.getScaleX());
theEnemy.setEnemySpeed(new Vector2(2.0f * ((float)randMovement.NextDouble() / (float)1f) - 1.0f, (float)randMovement.NextDouble()));
theEnemy.setEnemyType(Enemy.EnemyType.Ghost);
enemyList.Add(theEnemy);
}
levelTiles[x, y].setTilePosition(new Vector2(x, y));
//.........这里部分代码省略.........