Exemplo n.º 1
0
        /// <summary>
        /// Contructor
        /// </summary>
        public GameRun(string name)
        {
            _game1 = new Terrian1();
            log = SuperTripRecorder.Instance;
            _start = _game1.Start;
            player = new Player(name);

            GameStart();
        }
Exemplo n.º 2
0
 public DeadlyMonster(LocationObserverandObservable terrain, ITerrian terrain1)
 {
     _monsterHealth = 100;
     _current = terrain;
     _ter = terrain1;
     _locker = new object();
     _monster = new Thread(Search);
     _monster.Start();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public EatEvent(LocationObserverandObservable location, IItem item, IActor actor)
 {
     if(Eat(item))
     {
         _location = location;
         if (actor != null) _actor = actor;
     }
     else
     {
         throw new ArgumentException("Type Mismatch");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Start the game
        /// </summary>
        private void GameStart()
        {
            (player as Actor).Subscribe(_game1.Start as LocationObserverandObservable);
            (_game1.Start as LocationObserverandObservable).Subscribe(player as Actor);

            _start = _game1.Start;

            var tripRecorder = log as SuperTripRecorder;
            if (tripRecorder != null)
                tripRecorder.Subscribe(_start as LocationObserverandObservable );
                tripRecorder.Subscribe(player as Actor);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MoveEventEnter(LocationObserverandObservable location,IActor actor)
 {
     _actor = actor;
         _location = location;
 }
Exemplo n.º 6
0
        /// <summary>
        /// OnNext Method
        /// </summary>
        public override void OnNext(object request)
        {
            if (request is IDeathEvent)
            {
                if (_lives > 0)
                {
                    _lives--;
                }
                _health.Health = 0;
                if (IsDead == false)
                {
                    _health.Health = _config.StartingHealth;
                }
                else if (IsDead)
                {
                    Globals.GlobalVar = false;
                }

            }
            else if (request is ISurvivedTrap)
            {
                items.Remove(new Key());
            }
            else if(request is IMoveEventEnter)
            {
                _health.Health -= MovePenalty;
                _actorLocation = (request as IMoveEventEnter).Location;
            }
            else if (request is IDeadEndDeath)
            {
                _health.Health = 0;
                _lives = 0;
                Globals.GlobalVar = false;
            }
        }
Exemplo n.º 7
0
        private void Move()
        {
            var J = new Random().Next(1, 6);

            switch(J)
            {
                    case 1:
                    if(_current.GetNeighbors.ContainsKey(Directions.Up))
                    {
                        _current.ExitLocation(this);
                        var p = _current.GetNeighbors[Directions.Up];
                        _current = _ter.GetLocation(p.Name);

                    }
                    break;
                    case 2:
                    if (_current.GetNeighbors.ContainsKey(Directions.Down))
                    {
                        _current.ExitLocation(this);
                        var p = _current.GetNeighbors[Directions.Down];
                        _current = _ter.GetLocation(p.Name);

                    }
                    break;
                    case 3:
                    if (_current.GetNeighbors.ContainsKey(Directions.North))
                    {
                        _current.ExitLocation(this);
                        var p = _current.GetNeighbors[Directions.North];
                        _current = _ter.GetLocation(p.Name);

                    }
                    break;
                    case 4:
                    if (_current.GetNeighbors.ContainsKey(Directions.South))
                    {
                        _current.ExitLocation(this);
                        var p = _current.GetNeighbors[Directions.South];
                        _current = _ter.GetLocation(p.Name);

                    }
                    break;
                    case 5:
                    if (_current.GetNeighbors.ContainsKey(Directions.East))
                    {
                        _current.ExitLocation(this);
                        var p = _current.GetNeighbors[Directions.East];
                        _current = _ter.GetLocation(p.Name);

                    }
                    break;
                    case 6:
                    if (_current.GetNeighbors.ContainsKey(Directions.West))
                    {
                        _current.ExitLocation(this);
                        var p = _current.GetNeighbors[Directions.West];
                        _current = _ter.GetLocation(p.Name);

                    }
                    break;

            }
        }
Exemplo n.º 8
0
        public override void Look()
        {
            var j = _current.GetNeighbors.GetEnumerator();

            while (j.MoveNext())
            {
                if (j != null)
                {
                    var P = j.Current.Value;
                    var N = _ter.GetLocation(P.Name);
                    if (N.Players.Count > 0)
                    {
                        _current.ExitLocation(this);
                        _current = N;

                    }

                }
            }
        }
Exemplo n.º 9
0
 ///<summary>
 /// Constructor
 ///</summary>
 public SurvivedTrap(LocationObserverandObservable location, IActor actor)
 {
     _actor = actor;
         _location = location;
 }
Exemplo n.º 10
0
 public MonsterEncounterEvent(LocationObserverandObservable loc, IActor actor)
 {
     _location = loc;
     _actor = actor;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructor takes ILocation, IItem, and IActor
 /// </summary>
 public DropEvent(LocationObserverandObservable location, IItem item, IActor actor)
 {
     _actor = actor;
         _item = item;
         _location = location;
 }