示例#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;
 }