예제 #1
0
        /// <summary>
        /// Returns an NPC with a randomly generated type.
        /// </summary>
        public INPC Create()
        {
            // 1) Generate a randomised EXtrinsic state object
            NPCExState exState = FlyweightFactory.CreateExState();

            // 2) Use the NPC type from the EXtrinsic state object
            //    to generate a (possibly shared) INtrinsic state object.
            NPCInState inState = FlyweightFactory.CreateFlyWeight(exState.TypeOfNPC).IntrinsicState;

            // 3) Finally create the revised NPC object, which implements INPC.
            return(new NPCRevised(inState, exState));
        }
예제 #2
0
 public NPCFlyweight(NPCInState inState)
 {
     IntrinsicState = inState;
 }
예제 #3
0
 public NPCRevised(NPCInState inState, NPCExState exState)
 {
     InState = inState;
     ExState = exState;
 }