Example #1
0
        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;
            }
        }
Example #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!");
                }
            }
        }
Example #3
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);
                }
            }
        }
Example #4
0
 public virtual void Execute(Mobile mobile, Map map, Tile nonPlayerCharacterTile)
 {
     if (mobile.CanAttack(map, nonPlayerCharacterTile))
     {
         mobile.Event = Transition.Attack;
     }
     else
     {
         mobile.Event = Transition.Chase;
     }
 }
Example #5
0
 public void UpdateState(Map map, Tile nonPlayerCharacterTile)
 {
     if (CurrentState != null)
         CurrentState.Execute(this, map, nonPlayerCharacterTile);
     else
         System.Diagnostics.Trace.WriteLine("zero state");
 }
Example #6
0
        public virtual bool CanMoveTo(Tile tile)
        {
            List<int> canMoveToTiles = new List<int>
            {
                Constants.TypeIds.Floor,
                Constants.TypeIds.OpenDoor
            };

            //See if this map object can make the requested move
            return canMoveToTiles.Contains(tile.TypeId) && tile.Mobile == null;
        }
Example #7
0
        public virtual bool CanMoveOnPath(Tile tile)
        {
            //TODO This list will need to vary depending on the mobile (Can Move To also)

            List<int> canMoveToTiles = new List<int>
            {
                Constants.TypeIds.Floor,
                Constants.TypeIds.OpenDoor
            };

            //See if this map object can make the requested move
            return canMoveToTiles.Contains(tile.TypeId) && ((tile.Mobile == null) || (tile.Mobile.MobileId == Constants.MobileId.Player));
        }
Example #8
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;
        }
Example #9
0
        public void ToggleDoor(Tile tileToUse, bool isOpen)
        {
            this.Tiles.Remove(tileToUse);

            if (isOpen)
            {
                this.Tiles.Add(new Tile { Location = tileToUse.Location, TypeId = Constants.TypeIds.Door });
            }
            else
            {
                this.Tiles.Add(new Tile { Location = tileToUse.Location, TypeId = Constants.TypeIds.OpenDoor });
            }
        }
Example #10
0
        public Tile MoveMobile(Tile mobileMapTile, Tile tileToMoveTo)
        {
            if (mobileMapTile.Mobile.CanMoveTo(tileToMoveTo))
            {
                tileToMoveTo.Mobile = mobileMapTile.Mobile;
                mobileMapTile.Mobile = null;
                this.Outdated = true;

                return tileToMoveTo;
            }

            return null;
        }
Example #11
0
        public Tile MoveMobile(LocalKeyInfo keyInfo, Tile mobileMapTile)
        {
            var mapLocation = new Location(mobileMapTile.Location.Left, mobileMapTile.Location.Top);

            var tileToMoveTo = this.GetTileInDirection(keyInfo, mapLocation);

            return this.MoveMobile(mobileMapTile, tileToMoveTo);
        }