コード例 #1
0
        private static void InjectSubBehaviours(Level level, LevelBehaviour levelBehaviour)
        {
            var subBehaviourString = level.properties.GetString(Symbols.SubBehaviours);

            if (subBehaviourString == null)
            {
                levelBehaviour.subBehaviours = NoSubBehaviours;
                return;
            }

            var subBehaviours = subBehaviourString.Split(CommaSeparator, StringSplitOptions.RemoveEmptyEntries);

            if (subBehaviours.Length == 0)
            {
                levelBehaviour.subBehaviours = NoSubBehaviours;
                return;
            }

            var subList = new List <ILevelSubBehaviour>();

            foreach (var subBehaviour in subBehaviours)
            {
                CreateLevelSubBehaviourDelegate createSubMethod;
                if (levelSubCache.TryGetValue(subBehaviour, out createSubMethod))
                {
                    ILevelSubBehaviour levelSubBehaviour = createSubMethod();
                    subList.Add(levelSubBehaviour);
                }
            }

            levelBehaviour.subBehaviours = new ReadOnlyList <ILevelSubBehaviour>(subList);
        }
コード例 #2
0
        public virtual void LevelWillChange(UpdateContext updateContext, LevelBehaviour nextLevelBehaviour, Level nextLevel)
        {
            /* Handler for when the current level is about to be changed out */

            foreach (var subBehaviour in subBehaviours)
            {
                subBehaviour.LevelWillChange(updateContext, nextLevelBehaviour, nextLevel);
            }
        }
コード例 #3
0
        private static void InjectSubBehaviours(Level level, LevelBehaviour levelBehaviour, UpdateContext context)
        {
            var hasGlobalSubBehaviours = globalSubCache != null && globalSubCache.Count > 0;

            var subBehaviourString = level.properties.GetString(Symbols.SubBehaviours);

            if (!hasGlobalSubBehaviours && subBehaviourString == null)
            {
                levelBehaviour.subBehaviours = NoSubBehaviours;
                return;
            }

            string[] subBehaviours = null;
            if (subBehaviourString != null)
            {
                subBehaviours = subBehaviourString.Split(CommaSeparator, StringSplitOptions.RemoveEmptyEntries);
                if (!hasGlobalSubBehaviours && subBehaviours.Length == 0)
                {
                    levelBehaviour.subBehaviours = NoSubBehaviours;
                    return;
                }
            }

            var subList = new List <ILevelSubBehaviour>();

            if (hasGlobalSubBehaviours)
            {
                foreach (var globalSubBehaviour in globalSubCache)
                {
                    subList.Add(globalSubBehaviour.Value(level, context));
                }
            }

            if (subBehaviours != null)
            {
                foreach (var subBehaviour in subBehaviours)
                {
                    CreateLevelSubBehaviourDelegate createSubMethod;
                    if (levelSubCache.TryGetValue(subBehaviour, out createSubMethod))
                    {
                        subList.Add(createSubMethod(level, context));
                    }
                }
            }

            levelBehaviour.subBehaviours = new ReadOnlyList <ILevelSubBehaviour>(subList);
        }
コード例 #4
0
        public static LevelBehaviour CreateLevelBehaviour(string behaviour, Level level, UpdateContext context)
        {
            if (behaviour == null)
            {
                return(new LevelBehaviour());
            }

            CreateLevelBehaviourDelegate createMethod;

            if (levelCache.TryGetValue(behaviour, out createMethod))
            {
                LevelBehaviour levelBehaviour = createMethod(level, context);

                InjectSubBehaviours(level, levelBehaviour);

                return(levelBehaviour);
            }

            Debug.WriteLine("Missing LevelBehaviour called \"" + behaviour + "\"");
            return(new LevelBehaviour());
        }
コード例 #5
0
ファイル: LevelSubBehaviour.cs プロジェクト: nehpe/Pixel3D
 public virtual void LevelWillChange(UpdateContext updateContext, LevelBehaviour nextLevelBehaviour, Level nextLevel)
 {
 }
コード例 #6
0
ファイル: LevelBehaviour.cs プロジェクト: pvmm/Pixel3D
 public virtual void LevelWillChange(UpdateContext updateContext, LevelBehaviour nextLevelBehaviour)
 {
     /* Handler for when the current level is about to be changed out */
 }