本文整理汇总了C#中ISprite类的典型用法代码示例。如果您正苦于以下问题:C# ISprite类的具体用法?C# ISprite怎么用?C# ISprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISprite类属于命名空间,在下文中一共展示了ISprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(ISprite sprite, Offset offset)
{
if (sprite == null)
throw new ArgumentNullException("sprite");
if (offset == null)
throw new ArgumentNullException("offset");
var consoleColorBackup = Console.BackgroundColor;
Console.Clear(); // yeaks!
var width = sprite.Size.Width;
var height = sprite.Size.Height;
for (int i = widthBorderOffset; i < width + widthBorderOffset; i++)
{
Console.SetCursorPosition(i, 0);
Console.Write('-');
Console.SetCursorPosition(i, height + heightBorderOffset);
Console.Write('-');
}
for (int j = heightBorderOffset; j < height + heightBorderOffset; j++)
{
Console.SetCursorPosition(0, j);
Console.Write('|');
Console.SetCursorPosition(width + widthBorderOffset, j);
Console.Write('|');
}
Console.SetCursorPosition(0, 0);
Console.Write('/');
Console.SetCursorPosition(width + widthBorderOffset, 0);
Console.Write('\\');
Console.SetCursorPosition(0, height + heightBorderOffset);
Console.Write('\\');
Console.SetCursorPosition(width + widthBorderOffset, height + heightBorderOffset);
Console.Write('/');
var consoleBounds = new { Width = Console.WindowWidth, Height = Console.WindowHeight };
for (var i = 0; i < sprite.Size.Width; i++)
{
for (var j = 0; j < sprite.Size.Height; j++)
{
var x = offset.Left + i + widthBorderOffset;
var y = offset.Top + j + heightBorderOffset;
var brushBackground = sprite[i, j];
if (!((x >= 0) && (x < consoleBounds.Width) && (y >= 0)) || brushBackground == Color.Transparent)
{
continue;
}
Console.SetCursorPosition(x, y);
Console.BackgroundColor = brushBackground.ToConsoleColor();
Console.Write(_brushSymbol);
}
}
Console.BackgroundColor = consoleColorBackup;
}
示例2: AGSSingleFrameAnimation
public AGSSingleFrameAnimation (ISprite sprite) : base(new AGSAnimationConfiguration { Loops = 1 },
new AGSAnimationState(), 1)
{
AGSAnimationFrame frame = new AGSAnimationFrame (sprite) { Delay = -1 };
Frames.Add (frame);
Setup ();
}
示例3: HandleCollision
public override void HandleCollision(ISprite movSprite)
{
sounds.PlayCoin();
scene.mario.Coins += 1;
scene.mario.Points += 200;
// scene.Sprites.Remove(this);
}
示例4: CanDrawSprite
/// <summary>
/// Checks if a <see cref="ISprite"/> is valid to be drawn.
/// </summary>
/// <param name="sprite">The sprite to draw.</param>
/// <returns>True if the <paramref name="sprite"/> can be used to draw; otherwise false.</returns>
static bool CanDrawSprite(ISprite sprite)
{
if (sprite == null)
{
const string errmsg = "Attempted to draw using a null sprite.";
if (log.IsWarnEnabled)
log.Warn(errmsg);
return false;
}
if (sprite.Texture == null || sprite.Texture.IsDisposed)
{
const string errmsg = "Attempted to draw using sprite `{0}`, but the texture is not set or is disposed.";
if (log.IsWarnEnabled)
log.WarnFormat(errmsg, sprite);
return false;
}
if (sprite.Size.X < 1 || sprite.Size.Y < 1)
{
const string errmsg = "Attempted to draw using sprite `{0}`, but the size (width and/or height) is < 1.";
if (log.IsWarnEnabled)
log.WarnFormat(errmsg, sprite);
return false;
}
return true;
}
示例5: Z_NormalEatingRenderBehavior
public Z_NormalEatingRenderBehavior()
: base()
{
sprite = SCSServices.Instance.ResourceManager.GetResource<ISprite>("Zombies/Nameless/Attack");
SpriteBound = new Rectangle(0, 0, 89, 101);
sprite.Play();
}
开发者ID:doanhtdpl,项目名称:plants-vs-zombies-gameonmobile-uit-term7,代码行数:7,代码来源:Z_NormalEatingRenderBehavior.cs
示例6: CheckCollision
public override bool CheckCollision(ISprite sprite)
{
Player player = (Player)sprite;
Rectangle rectangle = new Rectangle((int)player._Position.X, (int)player._Position.Y, player.Texture.Width, player.Texture.Height);
return CoinRectangle.Intersects(rectangle);
}
示例7: CompositeSpriteHolder
public CompositeSpriteHolder(ISprite Tileset, int[,,] Tiles, int TileSize)
{
if (!(Tileset.FullSize.Width/(float) TileSize).IsInteger() ||
!(Tileset.FullSize.Height/(float) TileSize).IsInteger())
throw new Exception("The TileSize doesn't fit the image.");
this.Tileset = Tileset;
this.TileSize = TileSize;
var sizeX = Tiles.GetLength(0);
var sizeY = Tiles.GetLength(1);
var sizeZ = Tiles.GetLength(2);
var tilesX = Tileset.FullSize.Width/TileSize;
var tiles = new Tuple<int, int>[sizeX, sizeY, sizeZ];
for (int i = 0; i < sizeX; i++)
for (int j = 0; j < sizeY; j++)
for (int k = 0; k < sizeZ; k++)
tiles[i, j, k] = new Tuple<int, int>(Tiles[i, j, k]%tilesX, Tiles[i, j, k]/tilesX);
this.Tiles = tiles;
MinDepth = 0.5f;
MaxDepth = 0.5f;
}
示例8: Sprite
protected Sprite(ISprite other)
{
_size = other.Size;
_layout = new Color[_size.Width, _size.Height];
for (int i = 0; i < _size.Width; i++)
for (int j = 0; j < _size.Height; j++)
_layout[i, j] = other[i, j];
}
示例9: Render
public void Render(ISprite sprite)
{
ExecuteThreadSafe(copiedRenderers =>
{
foreach (var renderer in copiedRenderers)
renderer.Render(sprite);
});
}
示例10: ThrowFireLeftDecorator
public ThrowFireLeftDecorator(IMario mario, Game1 game)
{
this.mario = mario;
this.myGame = game;
WorldManager.SetPlayer(this);
sprite = MarioSpriteFactory.CreateFireThrowLeft();
}
示例11: NewStageMinorMode
/// <summary>
/// Constructs the minor mode and sets up the internal
/// sprites.
/// </summary>
public NewStageMinorMode()
: base()
{
// Create the block with a placeholder
block = AssetLoader.Instance.CreateSprite("Star");
Viewport.Add(block);
}
示例12: DoublePipe
public DoublePipe(Vector2 marioWarpCoordinates, Game1 game)
{
myGame = game;
pipeSprite = TileSpriteFactory.CreateDoublePipeSprite();
isWarpPipe = true;
warpLocation = marioWarpCoordinates;
}
示例13: FigureBase
protected FigureBase(Offset placement, PositionsCollection positions)
{
_positions = positions;
_placement = placement;
_positionNumber = 0;
_sprite = _positions.GetPositionByNumber(0);
}
示例14: Explode
public void Explode()
{
FireSprite = ProjectileSpriteFactory.CreateExplodingFireSprite();
physics.Acceleration = Vector2.Zero;
physics.Velocity = Vector2.Zero;
isExploded = true;
}
示例15: Mario
public Mario(Game1 game, int posX, int posY)
{
MarioFactory = new MarioFactory(game);
currentSprite = (MarioSprite)MarioFactory.MakeProduct(1);
powerupStateFactor = 0;
actionStateFactor = 1;
direction = 1;
idle = new MarioIdleState(this);
jump = new MarioJumpingState(this);
walk = new MarioWalkingState(this);
crouch = new MarioCrouchingState(this);
fall = new MarioFallingState(this);
standard = new MarioStandard(this);
super = new MarioSuper(this);
fire = new MarioFire(this);
dead = new MarioDead(this);
powerupState = standard;
currentState = idle;
previousState = currentState;
previousSprite = currentSprite;
marioVec.X = posX;
marioVec.Y = posY;
}