本文整理汇总了C#中World.AddWorldObject方法的典型用法代码示例。如果您正苦于以下问题:C# World.AddWorldObject方法的具体用法?C# World.AddWorldObject怎么用?C# World.AddWorldObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.AddWorldObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddWorldObjectTest
public void AddWorldObjectTest()
{
Planet planet1 = new Planet();
WorldObject[] worldObjects = {planet1};
World target = new World(worldObjects);
WorldObject spaceship1 = new Spaceship();
WorldObject spaceship2 = new Spaceship();
WorldObject projectile = new Projectile();
WorldObject explosion = new Explosion();
WorldObject planet2 = new Planet();
target.AddWorldObject(spaceship1);
target.AddWorldObject(spaceship2);
target.AddWorldObject(projectile);
target.AddWorldObject(explosion);
target.AddWorldObject(planet2);
Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(planet1));
Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(spaceship1));
Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(spaceship2));
Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(projectile));
Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(explosion));
Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(planet2));
}
示例2: SpaceBoss
/// <summary>
/// Constructor for Flint's Hat.
/// </summary>
/// <param name="parentScreen">The screen which this object is a part of.</param>
/// <param name="spriteBatch">The sprite batch which handles drawing this object.</param>
/// <param name="position">The initial position of this character.</param>
public SpaceBoss(Screen gameScreen, World world, SpriteBatch spriteBatch, Vector2 position, Character owner)
: base(world, spriteBatch, position)
{
mass = 1.0f;
//Set the Hat's owner
this.owner = owner;
this.gameScreen = gameScreen;
//Set up the Animation Map
animationMap = new Dictionary<string, Animation>();
//Set up the Hat's Animations
SetUpAnimation();
animationPlayer = new AnimationPlayer(spriteBatch, animationMap["Fall"]);
currentState = "None";
//Set the Hat's positon
if (owner.Facing == SpriteEffects.FlipHorizontally)
{
Position = owner.Position + new Vector2(20, -29);
}
else
{
Position = owner.Position + new Vector2(-20, -30);
}
//Set the hat's velocity
if (currentState.Contains("Fall"))
{
velocity = new Vector2(0, 0);
}
//Initializes the hat's hotspots.
List<CollisionHotspot> hotspots = new List<CollisionHotspot>();
hotspots.Add(new CollisionHotspot(this, new Vector2(-1, -10), HOTSPOT_TYPE.top));
hotspots.Add(new CollisionHotspot(this, new Vector2(-7, 1), HOTSPOT_TYPE.left));
hotspots.Add(new CollisionHotspot(this, new Vector2(5, 1), HOTSPOT_TYPE.right));
hotspots.Add(new CollisionHotspot(this, new Vector2(-1, 12), HOTSPOT_TYPE.bottom));
Hotspots = hotspots;
this.world = world;
world.AddWorldObject(this);
//this.ParentScreen.Components.Add(this);
}
示例3: FlintHat
/// <summary>
/// Constructor for Flint's Hat.
/// </summary>
/// <param name="parentScreen">The screen which this object is a part of.</param>
/// <param name="spriteBatch">The sprite batch which handles drawing this object.</param>
/// <param name="position">The initial position of this character.</param>
public FlintHat(Screen gameScreen, World world, SpriteBatch spriteBatch, Vector2 position, Character owner)
: base(world, spriteBatch, position)
{
mass = 1.0f;
//Set the Hat's owner
this.owner = owner;
this.gameScreen = gameScreen;
//Set up the Animation Map
animationMap = new Dictionary<string, Animation>();
//Set up the Hat's Animations
SetUpAnimation();
//Set the current Animation
currentAnimation = animationMap["Fall"];
animationPlayer = new AnimationPlayer(spriteBatch, animationMap["Fall"]);
currentState = "None";
//Set the Hat's positon
position = owner.Position + new Vector2(60, 0);
//Set the hat's velocity
velocity = new Vector2(0, 0);
//Initializes the hat's hotspots.
List<CollisionHotspot> hotspots = new List<CollisionHotspot>();
hotspots.Add(new CollisionHotspot(this, new Vector2(-1, -10), HOTSPOT_TYPE.top));
hotspots.Add(new CollisionHotspot(this, new Vector2(-7, 1), HOTSPOT_TYPE.left));
hotspots.Add(new CollisionHotspot(this, new Vector2(5, 1), HOTSPOT_TYPE.right));
hotspots.Add(new CollisionHotspot(this, new Vector2(-1, 12), HOTSPOT_TYPE.bottom));
Hotspots = hotspots;
this.world = world;
world.AddWorldObject(this);
//this.ParentScreen.Components.Add(this);
}