本文整理汇总了C#中ICamera2D类的典型用法代码示例。如果您正苦于以下问题:C# ICamera2D类的具体用法?C# ICamera2D怎么用?C# ICamera2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICamera2D类属于命名空间,在下文中一共展示了ICamera2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:35,代码来源:World.cs
示例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);
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:36,代码来源:SkeletonDrawer.cs
示例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);
}
}
开发者ID:sergik,项目名称:Cardio,代码行数:7,代码来源:NanobotGroup.cs
示例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();
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:TransBoxManager.MoveManyTransBox.cs
示例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);
}
开发者ID:sergik,项目名称:Cardio,代码行数:31,代码来源:EnemyAttackScene.cs
示例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);
}
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:32,代码来源:EditorMapRenderer.cs
示例7: JointUpdateable
public JointUpdateable(I2DScene scene, FarseerWorld world,ICamera2D camera)
: base(scene)
{
this.camera = camera;
this.world = world;
this.Start();
}
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:7,代码来源:JointUpdateable.cs
示例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);
}
开发者ID:wtfcolt,项目名称:game,代码行数:37,代码来源:SkeletonDrawer.cs
示例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);
}
开发者ID:Vizzini,项目名称:netgore,代码行数:32,代码来源:MapEntityCursorTool.cs
示例10: Initialize
public void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
foreach (ScrollingBackground t in _layers)
{
t.Initialize(game, spriteBatch, camera);
}
_isInitialized = true;
}
开发者ID:sergik,项目名称:Cardio,代码行数:9,代码来源:BackgroundController.cs
示例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;
}
开发者ID:HeavyBomber,项目名称:HeavyBomber,代码行数:10,代码来源:LevelScreen.cs
示例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();
}
开发者ID:wtfcolt,项目名称:game,代码行数:17,代码来源:TransBoxManager.TransBox.cs
示例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);
}
开发者ID:sergik,项目名称:Cardio,代码行数:11,代码来源:ObstacleScene.cs
示例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);
}
开发者ID:sergik,项目名称:Cardio,代码行数:12,代码来源:ThinkCloud.cs
示例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);
}
开发者ID:wtfcolt,项目名称:game,代码行数:21,代码来源:MapSaveAsTool.cs
示例16: Initialize
public virtual void Initialize(Game game, SpriteBatch spriteBatch, ICamera2D camera)
{
if (Target == null)
{
throw new InvalidOperationException("You have to specify target before calling Initialize.");
}
SpriteBatch = spriteBatch;
Camera = camera;
if (!String.IsNullOrEmpty(AssetName))
{
Content = AnimatedObject.FromMetadata(game.Content.Load<AnimatedObjectMetadata>(AssetName), game.Content);
}
}
开发者ID:sergik,项目名称:Cardio,代码行数:15,代码来源:AttachableGameObject.cs
示例17: Draw
/// <summary>
/// Draws a TeleportEntity.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="camera">The <see cref="ICamera2D"/> that describes the current view.</param>
/// <param name="tele">TeleportEntity to draw.</param>
public static void Draw(ISpriteBatch sb, ICamera2D camera, TeleportEntityBase tele)
{
// Draw the source rectangle
Draw(sb, tele, _teleSourceColor);
// Draw the destination rectangle and the arrow pointing to it only if the map is the same
if (camera.Map != null && camera.Map.ID == tele.DestinationMap)
{
Draw(sb, tele.Destination, tele.Size, _teleDestColor);
// Arrow
var centerOffset = tele.Size / 2;
RenderArrow.Draw(sb, tele.Position + centerOffset, tele.Destination + centerOffset, _arrowColor);
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:21,代码来源:EntityDrawer.cs
示例18: HandleDrawBuffer
/// <summary>
/// When overridden in the derived class, handles drawing to the buffer.
/// </summary>
/// <param name="rt">The <see cref="RenderTarget"/> to draw to.</param>
/// <param name="sb">The <see cref="ISpriteBatch"/> to use to draw to the <paramref name="rt"/>. The derived class
/// is required to handle making Begin()/End() calls on it.</param>
/// <param name="camera">The <see cref="ICamera2D"/> to use when drawing.</param>
/// <returns>True if the drawing was successful; false if there were any errors while drawing.</returns>
protected override bool HandleDrawBuffer(RenderTarget rt, ISpriteBatch sb, ICamera2D camera)
{
// Draw the lights
sb.Begin(BlendMode.Add, camera);
foreach (var light in this)
{
if (camera.InView(light))
light.Draw(sb);
}
sb.End();
return true;
}
开发者ID:Vizzini,项目名称:netgore,代码行数:23,代码来源:LightManager.cs
示例19: Draw
/// <summary>
/// Draws the map borders.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="map">Map to draw the borders for.</param>
/// <param name="camera">Camera used to view the map.</param>
public virtual void Draw(ISpriteBatch sb, IMap map, ICamera2D camera)
{
if (sb == null || sb.IsDisposed)
return;
if (map == null)
return;
if (camera == null)
return;
// Left border and corners
if (camera.Min.X < 0)
{
var min = camera.Min;
var max = new Vector2(Math.Min(0, camera.Max.X), camera.Max.Y);
DrawBorder(sb, min, max);
}
// Right border and corners
if (camera.Max.X > map.Width)
{
var min = new Vector2(Math.Max(camera.Min.X, map.Width), camera.Min.Y);
var max = camera.Max;
DrawBorder(sb, min, max);
}
// Top border
if (camera.Min.Y < 0)
{
var min = new Vector2(Math.Max(camera.Min.X, 0), camera.Min.Y);
var max = new Vector2(Math.Min(camera.Max.X, map.Width), Math.Min(camera.Max.Y, 0));
DrawBorder(sb, min, max);
}
// Bottom border
if (camera.Max.Y > map.Height)
{
var min = new Vector2(Math.Max(camera.Min.X, 0), Math.Max(camera.Min.Y, map.Height));
var max = new Vector2(Math.Min(camera.Max.X, map.Width), camera.Max.Y);
DrawBorder(sb, min, max);
}
}
开发者ID:Vizzini,项目名称:netgore,代码行数:47,代码来源:MapBorderDrawer.cs
示例20: HandleDrawAfterMap
/// <summary>
/// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
/// </summary>
/// <param name="map">The map the drawing is taking place on.</param>
/// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
{
var msc = MapScreenControl.TryFindInstance(map);
if (msc == null)
return;
var dm = msc.DrawingManager;
if (dm == null)
return;
var lm = dm.LightManager;
if (lm == null)
return;
var lightSprite = SystemSprites.Lightblub;
var offset = lightSprite.Size / 2f;
foreach (var light in lm)
{
lightSprite.Draw(spriteBatch, light.Center - offset);
}
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:28,代码来源:MapLightSourceDrawerTool.cs
注:本文中的ICamera2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论