Exemple #1
0
        // PRAGMA MARK - IPlacer Implementation
        void IPlacer.Init(GameObject prefab, DynamicArenaData dynamicArenaData, UndoHistory undoHistory, InputDevice inputDevice, LevelEditor levelEditor, Action <GameObject> instanceInitialization, IList <AttributeData> attributeDatas)
        {
            if (prefab == null)
            {
                Debug.LogWarning("Cannot set preview object of null object!");
                return;
            }

            dynamicArenaData_ = dynamicArenaData;
            undoHistory_      = undoHistory;
            inputDevice_      = inputDevice;
            attributeDatas_   = attributeDatas;

            levelEditor_ = levelEditor;
            levelEditor_.Cursor.OnMoved += HandleCusorMoved;

            CleanupCurrentPlacable();

            placablePrefab_ = prefab;
            previewObject_  = ObjectPoolManager.Create(prefab, parent: this.gameObject);
            previewObject_.transform.localPosition = Vector3.zero;
            foreach (var collider in previewObject_.GetComponentsInChildren <Collider>())
            {
                collider.enabled = false;
            }

            if (instanceInitialization != null)
            {
                instanceInitialization.Invoke(previewObject_);
            }

            HandlePreviewObjectCreated();
            Initialize();
        }
Exemple #2
0
 protected override void OnStateExited()
 {
     if (levelEditor_ != null)
     {
         ObjectPoolManager.Recycle(levelEditor_);
         levelEditor_ = null;
     }
 }
Exemple #3
0
        protected override void OnStateEntered()
        {
            ArenaManager.Instance.CleanupLoadedArena();

            InputDevice inputDevice = InputManager.Devices.First();

            levelEditor_ = ObjectPoolManager.Create <LevelEditor>(GamePrefabs.Instance.LevelEditorPrefab);
            levelEditor_.Init(inputDevice, ExitToMainMenu);
        }
        // PRAGMA MARK - Public Interface
        public CursorContextMenu(InputDevice inputDevice, LevelEditor levelEditor)
        {
            inputDevice_ = inputDevice;
            levelEditor_ = levelEditor;

            populators_ = new IScrollableMenuPopulator[] {
                new SpawnPointContextPopulator(inputDevice, levelEditor_),
                new LevelObjectContextPopulator(levelEditor_),
            };

            MonoBehaviourWrapper.OnUpdate += HandleUpdate;
        }
Exemple #5
0
        // PRAGMA MARK - Public Interface
        public static void CheckAttributesAndSetObject(LevelEditor levelEditor, GameObject levelObjectPrefab)
        {
            if (levelObjectPrefab_ != null)
            {
                Debug.LogWarning("Cannot check attributes and set object when already setting attributes for some other prefab: " + levelObjectPrefab_);
                return;
            }

            levelEditor_       = levelEditor;
            levelObjectPrefab_ = levelObjectPrefab;

            var attributeMarkers = levelObjectPrefab_.GetComponentsInChildren <IAttributeMarker>();

            if (attributeMarkers == null || attributeMarkers.Length <= 0)
            {
                FinishSettingObject();
                return;
            }

            attributeDatas_ = attributeMarkers.Select(m => (AttributeData)Activator.CreateInstance(m.AttributeType)).ToArray();
            index_          = 0;

            FillAttributeMarkers();
        }
 // PRAGMA MARK - Public Interface
 public SpawnPointContextPopulator(InputDevice inputDevice, LevelEditor levelEditor)
 {
     inputDevice_ = inputDevice;
     levelEditor_ = levelEditor;
 }
 // PRAGMA MARK - Public Interface
 public LevelObjectContextPopulator(LevelEditor levelEditor)
 {
     levelEditor_ = levelEditor;
 }