当前位置: 首页>>代码示例>>C#>>正文


C# World.AddWorldObject方法代码示例

本文整理汇总了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));
        }
开发者ID:julius,项目名称:pse_spacewar,代码行数:25,代码来源:WorldTest.cs

示例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);
        }
开发者ID:RochesterIndiesAnonymous,项目名称:Ironstag,代码行数:53,代码来源:SpaceBoss.cs

示例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);
        }
开发者ID:RochesterIndiesAnonymous,项目名称:Ironstag,代码行数:46,代码来源:FlintHat.cs


注:本文中的World.AddWorldObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。