Ejemplo n.º 1
0
        public override void MoveObject(int direction)
        {
            try
            {
                Tile tile = null;
                switch (direction)
                {
                case 1:
                    tile = StandsOnTile.UpTile;
                    break;

                case 2:
                    tile = StandsOnTile.DownTile;
                    break;

                case 3:
                    tile = StandsOnTile.LeftTile;
                    break;

                case 4:
                    tile = StandsOnTile.RightTile;
                    break;
                }
                if (tile != null && tile.CanEnter())
                {
                    if (tile is Destination)
                    {
                        GameObjectsCharacter = '0';
                    }
                    else
                    {
                        GameObjectsCharacter = 'o';
                    }

                    tile.ChangeObjectOnTile(this);
                    StandsOnTile.DeleteObjectOnTile();
                    StandsOnTile = tile;
                }
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public void moveEmployee(int direction)
        {
            try
            {
                Tile tile = null;
                switch (direction)
                {
                case 1:
                    tile = StandsOnTile.UpTile;
                    break;

                case 2:
                    tile = StandsOnTile.DownTile;
                    break;

                case 3:
                    tile = StandsOnTile.LeftTile;
                    break;

                case 4:
                    tile = StandsOnTile.RightTile;
                    break;
                }
                if (tile != null)
                {
                    if (tile.ObjectOnTile != null)
                    {
                        tile.ObjectOnTile.MoveObject(direction);
                    }

                    if (tile.CanEnter())
                    {
                        tile.ChangeObjectOnTile(this);
                        StandsOnTile.DeleteObjectOnTile();
                        StandsOnTile = tile;
                    }
                }
            }
            catch
            {
                throw;
            }
        }