本文整理汇总了C#中ICamera2D类的典型用法代码示例。如果您正苦于以下问题:C# ICamera2D类的具体用法?C# ICamera2D怎么用?C# ICamera2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICamera2D类属于命名空间,在下文中一共展示了ICamera2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: World
/// <summary>
/// Initializes a new instance of the <see cref="World"/> class.
/// </summary>
/// <param name="getTime">Interface to get the current time.</param>
/// <param name="camera">Primary world view camera.</param>
/// <param name="userInfo">The user info. Can be null.</param>
public World(IGetTime getTime, ICamera2D camera, UserInfo userInfo)
{
_userInfo = userInfo;
_getTime = getTime;
_camera = camera;
MapDrawingExtensions.Add(new EmoticonMapDrawingExtension<Emoticon, EmoticonInfo<Emoticon>>(_emoticonDisplayManager));
if (userInfo != null)
{
Func<QuestID, bool> questStartReqs = x => UserInfo.HasStartQuestRequirements.HasRequirements(x) ?? false;
Func<QuestID, bool> questFinishReqs =
x =>
UserInfo.QuestInfo.ActiveQuests.Contains(x) &&
(UserInfo.HasFinishQuestRequirements.HasRequirements(x) ?? false);
var e = new QuestMapDrawingExtension<Character>(userInfo.QuestInfo, questStartReqs, questFinishReqs,
m => m.Spatial.GetMany<Character>(m.Camera.GetViewArea(), c => !c.ProvidedQuests.IsEmpty()),
c => c.ProvidedQuests)
{
QuestAvailableCanStartIndicator = new Grh(GrhInfo.GetData("Quest", "can start")),
QuestStartedIndicator = new Grh(GrhInfo.GetData("Quest", "started")),
QuestAvailableCannotStartIndicator = new Grh(GrhInfo.GetData("Quest", "cannot start")),
QuestTurnInIndicator = new Grh(GrhInfo.GetData("Quest", "turnin"))
};
MapDrawingExtensions.Add(e);
}
}
示例2: RecursiveDraw
/// <summary>
/// Recursively draws the joints and bones of a skeleton.
/// </summary>
/// <param name="camera">Camera to use.</param>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="selectedNode">SpriteBatch to draw to.</param>
/// <param name="node">Current node being drawn.</param>
/// <param name="colorIndex">Index of the color to use from the ColorList.</param>
static void RecursiveDraw(ICamera2D camera, ISpriteBatch sb, SkeletonNode selectedNode, SkeletonNode node, int colorIndex)
{
// Find the color of the joint
var color = _colorList[colorIndex];
if (node == selectedNode)
color = _nodeColorSelected;
else if (node.Parent == null)
color = _nodeColorRoot;
// Draw the joint
var scale = 1f / camera.Scale;
var origin = SkeletonNode.HalfJointVector;
_joint.Draw(sb, node.Position, color, SpriteEffects.None, 0f, origin, scale);
// Iterate through the children
foreach (var child in node.Nodes)
{
colorIndex++;
if (colorIndex == _colorList.Length)
colorIndex = 0;
// Draw the bone to the child
RenderLine.Draw(sb, node.Position, child.Position, _colorList[colorIndex], (1f / camera.Scale) * 2f);
// Draw the child
RecursiveDraw(camera, sb, selectedNode, child, colorIndex);
}
}
示例3: Initialize
public void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
for (int i = 0; i < _nanobots.Count; i++)
{
_nanobots[i].Initialize(game, spriteBatch, camera);
}
}
示例4: MoveManyTransBox
/// <summary>
/// Initializes a new instance of the <see cref="MoveManyTransBox"/> class.
/// </summary>
/// <param name="owner">The <see cref="TransBoxManager"/>.</param>
/// <param name="spatials">The <see cref="ISpatial"/>s.</param>
/// <param name="position">The position.</param>
/// <param name="camera">The camera.</param>
public MoveManyTransBox(TransBoxManager owner, IEnumerable<ISpatial> spatials, Vector2 position, ICamera2D camera)
{
_owner = owner;
_camera = camera;
_position = position;
_spatials = spatials.ToImmutable();
}
示例5: Initialize
public override void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
var state = game.Services.GetService<GameState>();
for (int index = 0; index < Enemies.Count; index++)
{
var enemy = Enemies[index];
enemy.Initialize(game, spriteBatch, camera);
//var range = enemy as IRangeEnemy;
//if (range != null)
//{
// _enemyScripts.Add(enemy,
// new RangeEnemyAttackScript(game, Random.Next((int) range.AttackInterval)) {Combatant = range});
//}
//else if (enemy is CloseCombatEnemy)
//{
// _enemyScripts.Add(enemy, new CloseCombatEnemyAttackScript
// {
// Combatant = (CloseCombatEnemy) enemy,
// Target = state.Player.Nanobots[Random.Next(state.Player.Nanobots.Count())]
// });
//}
}
Reactions.Add(PlayerAction.Shoot, ShootReaction);
Length = 400;
base.Initialize(game, spriteBatch, camera);
}
示例6: DrawMapBorders
private void DrawMapBorders(GraphicsContext graphicsContext, ICamera2D camera)
{
// Room borders
const int RoomBorderThickness = 2;
for(int x = 0; x < _map.WidthInRooms; x++)
{
for(int y = 0; y < _map.HeightInRooms; y++)
{
Vector2i roomSize = new Vector2i(Room.Width * Tile.Size, Room.Height * Tile.Size);
// Draw room sub-borders
for (int x1 = 0; x1 < 4; x1++)
{
for (int y1 = 0; y1 < 4; y1++)
{
graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(
graphicsContext,
new RectangleF(x * roomSize.X + x1 * roomSize.X / 4f, y * roomSize.Y + y1 * roomSize.Y / 4f, roomSize.X / 4f, roomSize.Y / 4f),
Color.RoyalBlue.MultiplyRGB(0.5f) * 0.5f,
RoomBorderThickness / camera.Zoom);
}
}
// Draw room borders
graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, new Rectangle(x * roomSize.X, y * roomSize.Y, roomSize.X, roomSize.Y), Color.RoyalBlue, RoomBorderThickness / camera.Zoom);
}
}
// Full map borders
const int MapBorderThickness = 4;
graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, new Rectangle(0, 0, _map.Width * Tile.Size, _map.Height * Tile.Size), Color.White, MapBorderThickness / camera.Zoom);
}
示例7: JointUpdateable
public JointUpdateable(I2DScene scene, FarseerWorld world,ICamera2D camera)
: base(scene)
{
this.camera = camera;
this.world = world;
this.Start();
}
示例8: Draw
/// <summary>
/// Draws a <see cref="Skeleton"/>.
/// </summary>
/// <param name="skeleton">The <see cref="Skeleton"/> to draw.</param>
/// <param name="camera">Camera to use.</param>
/// <param name="sb">The <see cref="ISpriteBatch"/> to draw with.</param>
/// <param name="selectedNode">The <see cref="SkeletonNode"/> to draw as selected.</param>
public static void Draw(Skeleton skeleton, ICamera2D camera, ISpriteBatch sb, SkeletonNode selectedNode = null)
{
if (skeleton == null)
{
Debug.Fail("skeleton is null.");
return;
}
if (skeleton.RootNode == null)
{
Debug.Fail("skeleton contains no root node.");
return;
}
if (sb == null)
{
Debug.Fail("sb is null.");
return;
}
if (sb.IsDisposed)
{
Debug.Fail("sb is disposed.");
return;
}
if (camera == null)
{
Debug.Fail("camera is null.");
return;
}
RecursiveDraw(camera, sb, selectedNode, skeleton.RootNode, 0);
}
示例9: MapContainer_KeyUp
/// <summary>
/// Handles when a key is raised on a map.
/// </summary>
/// <param name="sender">The <see cref="IToolTargetMapContainer"/> the event came from. Cannot be null.</param>
/// <param name="map">The <see cref="EditorMap"/>. Cannot be null.</param>
/// <param name="camera">The <see cref="ICamera2D"/>. Cannot be null.</param>
/// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data. Cannot be null.</param>
protected override void MapContainer_KeyUp(IToolTargetMapContainer sender, EditorMap map, ICamera2D camera, KeyEventArgs e)
{
// Handle deletes
if (e.KeyCode == Keys.Delete)
{
// Only delete when it is an Entity that is on this map
var removed = new List<object>();
foreach (var x in SOM.SelectedObjects.OfType<Entity>().ToImmutable())
{
if (map.Spatial.CollectionContains(x))
{
map.RemoveEntity(x);
if (!x.IsDisposed)
x.Dispose();
removed.Add(x);
}
}
SOM.SetManySelected(SOM.SelectedObjects.Except(removed).ToImmutable());
}
base.MapContainer_KeyUp(sender, map, camera, e);
}
示例10: Initialize
public void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
foreach (ScrollingBackground t in _layers)
{
t.Initialize(game, spriteBatch, camera);
}
_isInitialized = true;
}
示例11: LevelScreen
public LevelScreen(IGameObjectsFactory gameObjectsFactory, IUserInterfaceFactory interfaceFactory,
IMathFunctionsFactory functionsFactory, ICamera2D camera2D, IContentLoader contentLoader)
{
this.contentLoader = contentLoader;
this.camera = camera2D;
player = new Player();
this.objectsFactory = gameObjectsFactory;
scene2d = new Scene2D(gameObjectsFactory, new GameplayFactory(gameObjectsFactory), interfaceFactory);
this.functionsFactory = functionsFactory;
}
示例12: TransBox
/// <summary>
/// Initializes a new instance of the <see cref="TransBox"/> class.
/// </summary>
/// <param name="owner">The <see cref="TransBoxManager"/>.</param>
/// <param name="type">The <see cref="TransBoxType"/>.</param>
/// <param name="spatial">The <see cref="ISpatial"/>.</param>
TransBox(TransBoxManager owner, TransBoxType type, ISpatial spatial, ICamera2D camera)
{
_owner = owner;
_camera = camera;
_type = type;
_spatial = spatial;
_size = GetTransBoxSize(type);
_position = GetPosition();
}
示例13: Initialize
public override void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
Thrombus.Initialize(game, spriteBatch, camera);
Thrombus.WorldPosition = new Vector2(StartPosition + Thrombus.CollisionRectangle.Width / 2f + 40f, -60);
_textRenderer.Initialize(spriteBatch);
Reactions.Add(PlayerAction.Shoot, Shoot);
base.Initialize(game, spriteBatch, camera);
}
示例14: Initialize
public void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
if (Target == null)
{
throw new InvalidOperationException("You have to specify think cloud target before calling Initialize.");
}
_spriteBatch = spriteBatch;
_camera = camera;
Animation = Animation.FromMetadata(game.Content.Load<AnimationMetadata>(AssetName), game.Content);
}
示例15: MapContainer_KeyDown
/// <summary>
/// Handles when a key is pressed on a map.
/// </summary>
/// <param name="sender">The <see cref="IToolTargetMapContainer"/> the event came from. Cannot be null.</param>
/// <param name="map">The <see cref="EditorMap"/>. Cannot be null.</param>
/// <param name="camera">The <see cref="ICamera2D"/>. Cannot be null.</param>
/// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data. Cannot be null.</param>
protected override void MapContainer_KeyDown(IToolTargetMapContainer sender, EditorMap map, ICamera2D camera, KeyEventArgs e)
{
if (map != null)
{
// Save (Ctrl + Shift + S)
if (e.KeyCode == Keys.S && e.Control && e.Shift)
{
MapHelper.SaveMapAs(map, false);
return;
}
}
base.MapContainer_KeyDown(sender, map, camera, e);
}