Example #1
0
        // 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);
        }
Example #2
0
        // 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;
        }
Example #3
0
        // 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);
            }
        }
Example #4
0
        // 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);
        }
Example #5
0
 public Subject()
 {
     this.name = Name.Uninitialized;
 }
Example #6
0
 public Observer()
 {
     this.name = Subject.Name.Uninitialized;
 }