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


C# Map.AddObject方法代码示例

本文整理汇总了C#中Map.AddObject方法的典型用法代码示例。如果您正苦于以下问题:C# Map.AddObject方法的具体用法?C# Map.AddObject怎么用?C# Map.AddObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.AddObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAddTwoMovableObjects

        public void TestAddTwoMovableObjects()
        {
            var map = new Map();
            var movableObject1 = new MapObject();
            map.AddObject(movableObject1);
            var movableObject2 = new MapObject();
            map.AddObject(movableObject2);

            Assert.AreEqual(2, map.GetNumDrawables());
            Assert.AreEqual(movableObject1, map.GetDrawable(0));
            Assert.AreEqual(movableObject2, map.GetDrawable(1));
        }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:12,代码来源:MapTest.cs

示例2: TestBlockingObjectCanShareCoordinateWithNonBlocking

        public void TestBlockingObjectCanShareCoordinateWithNonBlocking()
        {
            var map = new Map();
            var blockingObject = new MapObject {Position = new MapPosition(4, 4)};
            var nonBlockingObject = new MapObject {Position = new MapPosition(4, 3), Blocking = false};
            map.AddObject(blockingObject);
            map.AddObject(nonBlockingObject);

            map.Move(blockingObject, new PositionChange {Y = -1});

            Assert.AreEqual(new MapPosition(4, 3), blockingObject.Position);
        }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:12,代码来源:MapTest.cs

示例3: InitializeState

    void InitializeState()
    {
        CharacterPosition = new Vector2(-4f, -3.5f);

        Inventory = new Dictionary<Items, int>();
        Inventory[Items.Hatchet] = 1;
        Inventory[Items.Wood] = 5;

        Map = new Map();

        var vectors = new List<Vector2>();

        for (int i = 0; i < 20; i++)
        {
            Vector2 v;

            do
            {
                v = new Vector2(Random.Range(-5f, 5f), Random.Range(-5f, 5f));
            }
            while (vectors.Any(x => Vector2.Distance(v, x) < 0.5f));

            vectors.Add(v);
        }

        foreach (var p in vectors.OrderBy(x => x.y))
            Map.AddObject(MapObjectType.Tree, p.x, p.y);
    }
开发者ID:keenua,项目名称:civrust,代码行数:28,代码来源:GameController.cs

示例4: TestAddOneMovableObject

        public void TestAddOneMovableObject()
        {
            var map = new Map();
            var movableObject = new MapObject();
            map.AddObject(movableObject);

            Assert.AreEqual(1, map.GetNumDrawables());
            Assert.AreEqual(movableObject, map.GetDrawable(0));
        }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:9,代码来源:MapTest.cs

示例5: TestAdd7500ObjectsAndMove100Times

        public void TestAdd7500ObjectsAndMove100Times()
        {
            var map = new Map();
            for (int i = 0; i < 10; i++)
            {
                for (int x = 0; x < 30; x++)
                {
                    for (int y = 0; y < 25; y++)
                    {
                        var mapObject = new MapObject {Position = new MapPosition(x, y), Blocking = true};
                        map.AddObject(mapObject);
                    }
                }
            }

            var character = new MapObject {Position = new MapPosition(50, 50), Blocking = true};
            map.AddObject(character);
            for (int i = 0; i < 100; i++)
            {
                map.Move(character, new PositionChange {X = 1});
            }
        }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:22,代码来源:MapTest.cs

示例6: Update

 public override void Update(GameTime gameTime, Map.MapBase map, ObjectPool objectPool)
 {
     TimeSpan spawnCheck = DateTime.Now - timeSinceLastSpawn;
     if ((spawnCheck.TotalMilliseconds / 1000) > spawnTime && spawned < maxSpawned)
     {
         spawned++;
         switch (eType)
         {
             case "basic":
                     string guid = Guid.NewGuid().ToString();
                     map.AddObject("w" + guid, objectPool.AddObject(ObjectPool.ObjectTypes.Enemy, "w" + guid, "Enemies-Zombie"));
                     map.GetObject("w" + guid).Position = this.Position;
                 break;
         }
         timeSinceLastSpawn = DateTime.Now;
     }
     base.Update(gameTime);
 }
开发者ID:elefantstudio-se,项目名称:todesesser,代码行数:18,代码来源:ObjectEnemySpawner.cs

示例7: TestInteractWithObject

 public void TestInteractWithObject()
 {
     var mapItem = new MapObject {Position = new MapPosition(5, 5), Blocking = true};
     var character = new MapObject {Position = new MapPosition(4, 5), Blocking = true};
     var map = new Map();
     map.AddObject(mapItem);
     map.AddObject(character);
     map.Move(character, new PositionChange {X = 1});
 }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:9,代码来源:MapTest.cs

示例8: TestAddNullObjectThrowsException

 public void TestAddNullObjectThrowsException()
 {
     var map = new Map();
     map.AddObject(null);
 }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:5,代码来源:MapTest.cs

示例9: TestMoveDirectionWithTwoObjects

        private void TestMoveDirectionWithTwoObjects(
            MapPosition movablePosition,
            MapPosition staticPosition,
            PositionChange direction,
            MapPosition positionAfterMove)
        {
            var map = new Map();
            var staticObject = new MapObject { Position = staticPosition };
            var moveableObject = new MapObject { Position = movablePosition };
            map.AddObject(staticObject);
            map.AddObject(moveableObject);

            map.Move(moveableObject, direction);
            Assert.AreEqual(positionAfterMove, moveableObject.Position);
        }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:15,代码来源:MapTest.cs

示例10: Main

        public static void Main()
        {
            var gameWindow = new GameWindow { Width = 512, Height = 512 };
            var map = new Map();

            for(var x=0; x<16; x++)
                for (var y = 0; y < 16; y++)
                {
                    map.AddObject(new MapObject
                    {
                        Blocking = false,
                        Position = new MapPosition(x, y),
                        Quad = new Quad { FragmentPositionX = 1.0, FragmentPositionY = 3.0 }
                    });
                }

            map.AddObject(new MapObject
            {
                Blocking = true,
                Position = new MapPosition(3, 2),
                Quad = new Quad { FragmentPositionX = 2.0, FragmentPositionY = 3.0}
            });

            map.AddObject(new MapObject
            {
                Blocking = true,
                Position = new MapPosition(4, 7),
                Quad = new Quad { FragmentPositionX = 2.0, FragmentPositionY = 3.0 }
            });

            map.AddObject(new MapObject
            {
                Blocking = true,
                Position = new MapPosition(2, 5),
                Quad = new Quad { FragmentPositionX = 2.0, FragmentPositionY = 3.0 }
            });

            var character = new MapObject {Blocking = true, Position = new MapPosition(0, 0)};
            map.AddObject(character);

            var graphicObject = new Graphic
            {
                Gl = new GLWrapper(),
                Window = gameWindow,
                TextureFileName = @"..\..\Images\textures.png",
                DetermineScreenSizeInTiles = size => new Vector2d(16, 16),
                QuadList = map
            };

            gameWindow.Keyboard.KeyDown += (sender, args) =>
            {
                switch (args.Key)
                {
                    case Key.Escape:
                        graphicObject.Window.Close();
                        break;

                    case Key.Right:
                        map.Move(character, PositionChange.CreateRight());
                        break;

                    case Key.Left:
                        map.Move(character, PositionChange.CreateLeft());
                        break;

                    case Key.Up:
                        map.Move(character, PositionChange.CreateUp());
                        break;

                    case Key.Down:
                        map.Move(character, PositionChange.CreateDown());
                        break;
                }
            };

            graphicObject.Run();
        }
开发者ID:Ziretech,项目名称:Ubiq,代码行数:77,代码来源:App.cs


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