示例#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
 /// <summary>
 /// Revised implementation of Animate, since Animate
 /// now needs to be passed the EXtrinsic state.
 /// </summary>
 public void Animate(NPCExState exState)
 {
     AnimationHandler.PerformAnimation(
         exState.X, exState.Y, exState.CurrentState,
         IntrinsicState.AnimationData);
 }
示例#3
0
 public NPCRevised(NPCInState inState, NPCExState exState)
 {
     InState = inState;
     ExState = exState;
 }