Exemplo n.º 1
0
        public void Move(string input)
        {
            Room _newRoom;
            Room _oldRoom = Position;

            switch (input)
            {
            case "n":
                _newRoom = Position.North;
                break;

            case "s":
                _newRoom = Position.South;
                break;

            case "w":
                _newRoom = Position.West;
                break;

            case "e":
                _newRoom = Position.East;
                break;

            default:
                Console.WriteLine("Falsche Eingabe");
                _newRoom = Position;
                break;
            }
            if (_newRoom == null)
            {
                if (this.GetType() == typeof(Player))
                {
                    Console.WriteLine(this.Name + ": Diesen Weg gibt es nicht. Ihr Kontostand hat sich um 5 Euro reduziert");
                    this.Total -= 5;
                }
            }
            else
            {
                if (_newRoom != Position)
                {
                    Position = _newRoom;
                    _oldRoom.Exit(this);
                    if (this.GetType() == typeof(Player))
                    {
                        Console.WriteLine(this.Name + ": ging von " + _oldRoom.Name + " nach " + _newRoom.Name);
                    }
                    _newRoom.Entry(this);
                }
            }
        }
Exemplo n.º 2
0
        public void Move(string input)
        {
            Room    _newRoom;
            Room    _oldRoom  = Position;
            Boolean _occupied = false;

            switch (input)
            {
            case "n":
                _newRoom = Position.North;
                break;

            case "s":
                _newRoom = Position.South;
                break;

            case "w":
                _newRoom = Position.West;
                break;

            case "e":
                _newRoom = Position.East;
                break;

            default:
                Console.WriteLine("Falsche Eingabe");
                _newRoom = Position;
                break;
            }

            if (_newRoom == null)
            {
                if (this.GetType() == typeof(Player)) //only player
                {
                    Console.WriteLine("");
                    Console.WriteLine("Diesen Weg gibt es nicht. Ihre lebenspunkte haben sich um 5 reduziert");
                    this.Total -= 5;
                }
            }
            else
            {
                try
                {
                    _occupied = _newRoom.EnemyInRoom();
                }
                catch
                {
                    _occupied = false;
                }

                if (this.GetType() == typeof(Player) && _newRoom != Position)
                {
                    Position = _newRoom;
                    _oldRoom.Exit(this);
                    _newRoom.Entry(this);
                    Console.WriteLine("");
                    Console.WriteLine("Sie gingen von " + _oldRoom.Name + " nach " + _newRoom.Name);
                }

                if (this.GetType() == typeof(Enemy) && _newRoom != Position && _occupied != true)
                {
                    Position = _newRoom;
                    _oldRoom.Exit(this);
                    _newRoom.Entry(this);
                }
            }
        }