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


C# Map.Move方法代码示例

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


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

示例1: TakeTurn

        public override bool TakeTurn(Map _map)
        {
            if (Stats.HPCurrent <= 0)
            {
                Rock.Screen.Remove();
                return false;
            }

            if (Rock.Input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                if (!_map.Move(MyParty.X, MyParty.Y, MapMovement.Up))
                {
                    _map.TryCombat(this.MyParty, MapMovement.Up);
                }
                return true;
            }
            else if (Rock.Input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                if (!_map.Move(MyParty.X, MyParty.Y, MapMovement.Down))
                {
                    _map.TryCombat(this.MyParty, MapMovement.Down);
                }
                return true;
            }
            else if (Rock.Input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                if (!_map.Move(MyParty.X, MyParty.Y, MapMovement.Left))
                {
                    _map.TryCombat(this.MyParty, MapMovement.Left);
                }
                return true;
            }
            else if (Rock.Input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                if (!_map.Move(MyParty.X, MyParty.Y, MapMovement.Right))
                {
                    _map.TryCombat(this.MyParty, MapMovement.Right);
                }
                return true;
            }

            if (Rock.Input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.P))
            {
                if (Stats.Level < 100)
                {
                    Stats.Level += 1;
                    Stats.updateAttributes();
                }
            }

            return false;
        }
开发者ID:edg3,项目名称:TeamRoguelike,代码行数:52,代码来源:Player.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: 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

示例4: RunAI

        public void RunAI(Map map, WorldEntity me, Player player)
        {
            if (originalPosition.X == -1)
            {
                originalPosition.X = me.MyParty.X;
                originalPosition.Y = me.MyParty.Y;
            }

            Random rndm = new Random();
            if (rndm.Next(12) == 1)
            {
                //try roam
                var roamDir = (MapMovement)rndm.Next(4);
                int r_x = 0;
                int r_y = 0;
                switch (roamDir)
                {
                    case MapMovement.Up:
                        r_y = -1;
                        break;
                    case MapMovement.Down:
                        r_y = 1;
                        break;
                    case MapMovement.Left:
                        r_x = -1;
                        break;
                    case MapMovement.Right:
                        r_x = 1;
                        break;
                }

                if (Math.Sqrt(Math.Pow((me.MyParty.X + r_x) - originalPosition.X, 2) + Math.Pow((me.MyParty.Y + r_y) - originalPosition.Y, 2)) < 2)
                {
                    map.Move(me.MyParty.X, me.MyParty.Y, roamDir);
                }
            }
        }
开发者ID:edg3,项目名称:TeamRoguelike,代码行数:37,代码来源:DefaultOverworldAI.cs

示例5: 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

示例6: 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

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