예제 #1
0
        private void Start()
        {
            if (!setup)
            {
                this.light            = GetComponent <LG_Light>();
                this.animator         = GetComponent <LG_LightAnimator>() ?? this.light?.GetC_Light()?.gameObject?.GetComponent <LG_LightAnimator>();
                this.currentColor     = this.light.m_color;
                this.currentIntensity = this.light.GetIntensity();
                this.startIntensity   = this.currentIntensity;

                this.area  = this.light?.GetC_Light()?.m_sourceNode?.CourseNode?.m_area;
                this.zone  = this.area?.m_zone;
                this.layer = this.zone?.Layer;

                controllers.Add(this);
                this.setup = true;
            }
        }
        private static T SetupBase <T>(CPBlock block, LG_Area area, Vector3 position, Transform parent) where T : CPContext, new()
        {
            var context = new T()
            {
            };

            if (IsBuildDone)
            {
                CreatePuzzleInstance();
            }
            else
            {
                BuildQueue += CreatePuzzleInstance;
            }

            return(context);

            void CreatePuzzleInstance()
            {
                context.Instance = ChainedPuzzleManager.CreatePuzzleInstance(block, area, position, parent);
                context.Instance.add_OnPuzzleSolved(new Action(context.Solved_Internal));
                context.Setup(position);
            }
        }
 public static CPContext Setup(uint id, LG_Area area, Transform parent)
 => SetupBase <CPContext>(ToBlock(id), area, parent.position, parent);
 /// <summary>
 /// Create ChainedPuzzle Instance
 /// </summary>
 /// <typeparam name="T">ChainedPuzzleContext Type (derived or not)</typeparam>
 /// <param name="id">Block ID to use for puzzle</param>
 /// <param name="area">Area for chainedpuzzle</param>
 /// <param name="parent">Parent</param>
 /// <returns></returns>
 public static T Setup <T>(uint id, LG_Area area, Transform parent) where T : CPContext, new()
 => SetupBase <T>(ToBlock(id), area, parent.position, parent);
 public static CPContext Setup(CPBlock block, LG_Area area, Vector3 position, Transform parent)
 => SetupBase <CPContext>(block, area, position, parent);
 /// <summary>
 /// Create ChainedPuzzle Instance
 /// </summary>
 /// <typeparam name="T">ChainedPuzzleContext Type (derived or not)</typeparam>
 /// <param name="block">Block to use for puzzle</param>
 /// <param name="area">Area for chainedpuzzle</param>
 /// <param name="position">Initial Position for spawn</param>
 /// <param name="parent">Parent</param>
 /// <returns></returns>
 public static T Setup <T>(CPBlock block, LG_Area area, Vector3 position, Transform parent) where T : CPContext, new()
 => SetupBase <T>(block, area, position, parent);