本文整理汇总了C#中Engine.AddObject方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.AddObject方法的具体用法?C# Engine.AddObject怎么用?C# Engine.AddObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.AddObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
static void Initialize(Engine engine)
{
int startRow = 3;
int startCol = 2;
int endRow = WorldRows;
int endCol = WorldCols - 2;
for (int i = startCol; i < endCol; i++)
{
Block currBlock = new Block(new MatrixCoords(startRow, i));
//if (i == startCol + 7)
// currBlock = new ExplodingBlock(new MatrixCoords(startRow, i));
currBlock = new GiftBlock(new MatrixCoords(startRow, i));
//if (i > startCol + 3 && i < endCol - 25)
// currBlock = new UnpassableBlock(new MatrixCoords(startRow, i));
engine.AddObject(currBlock);
}
for (int i = startRow; i < endRow; i++)
{
IndestructibleBlock wallBlockLeft = new IndestructibleBlock(new MatrixCoords(i, startCol - 1));
engine.AddObject(wallBlockLeft);
IndestructibleBlock wallBlockRight = new IndestructibleBlock(new MatrixCoords(i, endCol));
engine.AddObject(wallBlockRight);
}
//for (int i = 6; i < 9; i++)
//{
// TrailObject trailObject = new TrailObject(new MatrixCoords(startRow + 1, i));
// engine.AddObject(trailObject);
//}
Ball theBall = new Ball(new MatrixCoords(WorldRows / 2, 0),
new MatrixCoords(1, 1));
engine.AddObject(theBall);
//MeteoriteBall theMeteoriteBall = new MeteoriteBall(new MatrixCoords(WorldRows / 2, 1), new MatrixCoords(1, 1));
//engine.AddObject(theMeteoriteBall);
//UnstoppableBall theUnstoppableBall = new UnstoppableBall(new MatrixCoords(WorldRows / 2, 1), new MatrixCoords(-1, 1));
//engine.AddObject(theUnstoppableBall);
Racket theRacket = new Racket(new MatrixCoords(WorldRows - 1, WorldCols / 2 - 3), RacketLength);
engine.AddObject(theRacket);
}
示例2: Initialize
const int battleTime = 120; // in seconds.
#endregion Fields
#region Methods
/// <summary>
/// Initializes the game engine.
/// </summary>
static void Initialize(Engine gameEngine)
{
KeyboardInterface keyboard1 = new KeyboardInterface(Environment.CurrentDirectory + "../../../player1settings.txt");
KeyboardInterface keyboard2 = new KeyboardInterface(Environment.CurrentDirectory + "../../../player2settings.txt");
HumanPlayer p1 = new HumanPlayer("player1", new GridPosition(2, 2), ObjectColor.Yellow, keyboard1);
HumanPlayer p2 = new HumanPlayer("player2", new GridPosition(battleFieldHeight - 3, battleFieldWidth - 4), ObjectColor.White, keyboard2);
gameEngine.AddObject(p1);
gameEngine.AddObject(p2);
int startRow = 1;
// Left wall
for (int i = startRow; i < battleFieldHeight - 1; i++)
{
Wall pillar = new Wall(new GridPosition(i, 0));
gameEngine.AddObject(pillar);
}
// Top wall
for (int i = 1; i < battleFieldWidth - 2; i++)
{
Wall pillar = new Wall(new GridPosition(startRow, i));
gameEngine.AddObject(pillar);
}
// Right wall
for (int i = startRow; i < battleFieldHeight - 1; i++)
{
Wall pillar = new Wall(new GridPosition(i, battleFieldWidth - 2));
gameEngine.AddObject(pillar);
}
// Bottom wall
for (int i = 1; i < battleFieldWidth - 2; i++)
{
Wall pillar = new Wall(new GridPosition(battleFieldHeight - 2, i));
gameEngine.AddObject(pillar);
}
Random rand = new Random();
for (int i = 0; i < 100; ++i)
{
gameEngine.AddObject(BlockFactory.CreateBlock(
rand.Next(20),
new GridPosition(rand.Next(3, battleFieldHeight - 3), rand.Next(3, battleFieldWidth - 4)),
ObjectColor.White)
);
}
for (int i = 0; i < 5; ++i)
{
gameEngine.AddObject(BlockFactory.CreateBlock(1,
new GridPosition(rand.Next(3, battleFieldHeight - 3), rand.Next(3, battleFieldWidth - 4)),
ObjectColor.Gray)
);
}
for (int i = 0; i < 5; ++i)
{
gameEngine.AddObject(BlockFactory.CreateBlock(2,
new GridPosition(rand.Next(3, battleFieldHeight - 3), rand.Next(3, battleFieldWidth - 4)),
ObjectColor.Gray)
);
}
}