示例#1
0
文件: Bob.cs 项目: mkniffen/Roguelike
        public void Execute(Mobile mobile, Map map, Tile nonPlayerCharacterTile)
        {
            if (mobile.CanAttack(map, nonPlayerCharacterTile))
            {
                map.GetPlayer().HitPoints -= 3;
                Status.WriteToStatusLine("Bob bores you to death... literally!");

                return;
            }
        }
示例#2
0
文件: Rat.cs 项目: mkniffen/Roguelike
        public void Execute(Mobile mobile, Map map, Tile nonPlayerCharacterTile)
        {
            if (Program.RandomNumber(4) < 3)
            {
                //Move
                var direction = map.GetDirectionRandom();

                if (direction != null)
                {
                    map.MoveMobile(direction, nonPlayerCharacterTile);
                }
            }
            else
            {
                //Attack
                if (nonPlayerCharacterTile.Mobile.CanAttack(map, nonPlayerCharacterTile))
                {
                    map.GetPlayer().HitPoints -= 3;
                    Status.WriteToStatusLine("The rat bites you!");
                }
            }
        }
示例#3
0
文件: Bob.cs 项目: mkniffen/Roguelike
        public void Execute(Mobile mobile, Map map, Tile nonPlayerCharacterTile)
        {
            if (mobile.CanAttack(map, nonPlayerCharacterTile))
            {
                mobile.Event = Transition.Attack;
                return;
            }

            var playerTile = map.GetPlayerTile();

            var tileToMoveTo = map.GetShortestDistanceDirectionToPlayer(mobile, playerTile.Location, nonPlayerCharacterTile.Location);
            //if null, don't move
            if (tileToMoveTo != null)
            {
                if (tileToMoveTo.TypeId == Constants.TypeIds.Door)
                {
                    map.ToggleDoor(tileToMoveTo, false);
                }
                else
                {
                    var tile = map.MoveMobile(nonPlayerCharacterTile, tileToMoveTo);
                }
            }
        }
示例#4
0
文件: Bob.cs 项目: mkniffen/Roguelike
 public virtual void Execute(Mobile mobile, Map map, Tile nonPlayerCharacterTile)
 {
     if (mobile.CanAttack(map, nonPlayerCharacterTile))
     {
         mobile.Event = Transition.Attack;
     }
     else
     {
         mobile.Event = Transition.Chase;
     }
 }
示例#5
0
 public InventoryCommand(Map map)
 {
     this.map = map;
 }
示例#6
0
 public PickUpCommand(Map map)
 {
     this.map = map;
 }
示例#7
0
 public OpenCloseCommand(Map map)
 {
     this.map = map;
 }
示例#8
0
 public LookCommand(Map map)
 {
     this.map = map;
 }
 public DisplayEquipmentCommand(Map map)
 {
     this.map = map;
 }
示例#10
0
 public QuitCommand(Map map)
 {
     this.map = map;
 }
示例#11
0
 public MoveMapPlayerCommand(Map map)
 {
     this.map = map;
 }
示例#12
0
 public void UpdateState(Map map, Tile nonPlayerCharacterTile)
 {
     if (CurrentState != null)
         CurrentState.Execute(this, map, nonPlayerCharacterTile);
     else
         System.Diagnostics.Trace.WriteLine("zero state");
 }
示例#13
0
        public bool CanAttack(Map map, Tile nonPlayerCharacterTile)
        {
            var topStart = nonPlayerCharacterTile.Location.Top - 1 < 1 ? 1 : nonPlayerCharacterTile.Location.Top - 1;
            var leftStart = nonPlayerCharacterTile.Location.Left - 1 < 1 ? 1 : nonPlayerCharacterTile.Location.Left - 1;

            var playerTile = map.GetPlayerTile();

            for (int top = topStart; top <= nonPlayerCharacterTile.Location.Top + 1; top++)
            {
                for (int left = leftStart; left <= nonPlayerCharacterTile.Location.Left + 1; left++)
                {
                    if (playerTile.Location.Top == top && playerTile.Location.Left == left)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
示例#14
0
 public WearCommand(Map map)
 {
     this.map = map;
 }
示例#15
0
 public AttackCommand(Map map)
 {
     this.map = map;
 }