Пример #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();
        }
Пример #2
0
        // PRAGMA MARK - Public Interface
        public UndoHistory(DynamicArenaData data, InputDevice inputDevice)
        {
            data_        = data;
            inputDevice_ = inputDevice;

            RecordState();

            MonoBehaviourWrapper.OnUpdate += HandleUpdate;
        }
Пример #3
0
        public void Init(DynamicArenaData dynamicArenaData, GameObject customPrefab)
        {
            customContainer_.RecycleAllChildren();
            if (customPrefab != null)
            {
                ObjectPoolManager.Create(customPrefab, parent: customContainer_);
            }

            dynamicArenaData_              = dynamicArenaData;
            dynamicArenaData_.OnDataDirty += HandleDataDirty;
            HandleDataDirty();
        }
Пример #4
0
        // PRAGMA MARK - Public Interface
        public static void Serialize(AttributeData attribute, int uniqueId, DynamicArenaData dynamicArenaData)
        {
            Type attributeType = attribute.GetType();

            if (!writerMap_.ContainsKey(attributeType))
            {
                Debug.LogWarning("Cannot serialize attribute of type: " + attributeType);
                return;
            }

            var writer = writerMap_[attributeType];

            writer.Invoke(attribute, uniqueId, dynamicArenaData);
        }
Пример #5
0
        private void LoadArenaToEdit(ArenaConfig arenaConfig)
        {
            editArena_ = arenaConfig;

            string dynamicArenaDataJson = editArena_.GetDynamicArenaDataJson();

            if (string.IsNullOrEmpty(dynamicArenaDataJson))
            {
                dynamicArenaData_ = new DynamicArenaData();
            }
            else
            {
                dynamicArenaData_ = JsonUtility.FromJson <DynamicArenaData>(dynamicArenaDataJson);
            }
            undoHistory_ = new UndoHistory(dynamicArenaData_, inputDevice_);

            dynamicArenaView_.Init(dynamicArenaData_, editArena_.Prefab);
            dynamicArenaView_.OnViewRefreshed += HandleArenaViewRefreshed;
        }