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); } } }
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!"); } } }