예제 #1
0
    void TestFlyWeight()
    {
        FlyweightFactory factory = new FlyweightFactory();

        FlyWeight flyWeightX = factory.GetFlyweight("酷炫效果");

        flyWeightX.Operation();

        FlyWeight flyWeightY = factory.GetFlyweight("旋转效果");

        flyWeightY.Operation();

        FlyWeight flyWeightZ = factory.GetFlyweight("光影效果");

        flyWeightZ.Operation();

        FlyWeight flyWeightUnshared = new UnsharedConcreteFlyWeight("火焰效果");

        flyWeightUnshared.Operation();

        FlyWeight flyWeightM = factory.GetFlyweight("光影效果");

        flyWeightM.Operation();

        FlyWeight flyWeightN = factory.GetFlyweight("光影效果");

        flyWeightN.Operation();

        Debug.Log("Total number of fly weight : " + factory.GetFlyWeightCount());
    }