// Add one subject to the list public Subject AddSubject(Subject.Name name) { // pull one from reserved Subject ret = (Subject)this.PullFromReserved(); // set values ret.name = name; // add to the active this.Add(ret); return(ret); }
// set observer fields based on name public void set(Subject.Name name, MoveProxy mProxy) { if (name == Subject.Name.LeftKey) { this.direction = -2f; } else if (name == Subject.Name.RightKey) { this.direction = 2f; } this.privMoveProxy = mProxy; this.name = name; }
// method adding observer to a game object public void AddObserver(Subject.Name name, GameObject go) { Observer raw = (Observer)this.PullFromReserved(); // adding derived observer based on name if (name == Subject.Name.LeftKey || name == Subject.Name.RightKey) { // for left key and right key event // create a move observer to listen MoveObserver mo = (MoveObserver)raw; mo.set(name, (MoveProxy)go.pProxy); // downcasting dangerous // Add new observer to the list this.Add(mo); } }
// Find by name public Subject FindSubjectByName(Subject.Name name) { Subject ret = null; ret = (Subject)this.poActiveHead; while (ret != null) { if (ret.name == name) { break; } ret = (Subject)ret.pNext; } return(ret); }
public Subject() { this.name = Name.Uninitialized; }
public Observer() { this.name = Subject.Name.Uninitialized; }