/// <summary> /// Contructor /// </summary> public GameRun(string name) { _game1 = new Terrian1(); log = SuperTripRecorder.Instance; _start = _game1.Start; player = new Player(name); GameStart(); }
public DeadlyMonster(LocationObserverandObservable terrain, ITerrian terrain1) { _monsterHealth = 100; _current = terrain; _ter = terrain1; _locker = new object(); _monster = new Thread(Search); _monster.Start(); }
/// <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"); } }
/// <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); }
/// <summary> /// Constructor /// </summary> public MoveEventEnter(LocationObserverandObservable location,IActor actor) { _actor = actor; _location = location; }
/// <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; } }
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; } }
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; } } } }
///<summary> /// Constructor ///</summary> public SurvivedTrap(LocationObserverandObservable location, IActor actor) { _actor = actor; _location = location; }
public MonsterEncounterEvent(LocationObserverandObservable loc, IActor actor) { _location = loc; _actor = actor; }
/// <summary> /// Constructor takes ILocation, IItem, and IActor /// </summary> public DropEvent(LocationObserverandObservable location, IItem item, IActor actor) { _actor = actor; _item = item; _location = location; }