Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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!");
                }
            }
        }
Esempio n. 3
0
        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!");
                }
            }
        }
Esempio n. 4
0
        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);
                }
            }
        }