void Update() { if (!_isPaued) { if (_currentSequance == null) { _currentSequance = GetNextSequance(); } else { if (_currentWave == null) { _currentWave = GetNextWave(); } else { if (_waveTimeCount < _currentWave.Delay) { _waveTimeCount += Time.deltaTime; } else { foreach (SpawnedItemDataObject spawnedItem in _currentWave.SpawnedItems) { SpwanItem(spawnedItem); } _waveTimeCount = 0; _currentWave = null; } } } } }
private void DrawSequancesList(Rect rect) { Color panelColor = new Color(0.2f, 0.2f, 0.4f); ; EditorGUI.DrawRect(new Rect(0, 0, rect.width, rect.height), panelColor); EditorGUILayout.BeginVertical(); { if (GUILayout.Button("Load From File")) { LoadWavesFromFile(); } if (GUILayout.Button("Save")) { } _sequancesListScrollPosition = EditorGUILayout.BeginScrollView(_sequancesListScrollPosition); { if (_sequances == null) { _sequances = new List<SequanceDataObject>(); } panelColor.a = 0.5f; GUI.backgroundColor = panelColor; if (_sequancesList == null) { _sequancesList = new ReorderableList(_sequances, typeof(SequanceDataObject), true, false, true, true); _sequancesList.drawElementCallback = (Rect cellRect, int index, bool isActive, bool isFocused) => { if (_sequances != null && _sequances[index] != null && _sequances[index].Identifier != null) { GUI.Label(cellRect, _sequances[index].Identifier); } }; _sequancesList.onSelectCallback = (list) => { _currentSequance = _sequances[list.index]; _currentWave = null; _currentSpwanItem = null; }; _sequancesList.onAddCallback = (list) => { int newWaveId = _sequances.Count; SequanceDataObject newSequance = new SequanceDataObject(); newSequance.Identifier = "sequance." + newWaveId.ToString(); _sequances.Add(newSequance); }; } if (_sequancesList != null) { _sequancesList.DoLayoutList(); } GUI.backgroundColor = Color.white; } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }
private static void DrawSpwanedItemsList(WavesEditor wavesEditor) { if (wavesEditor._currentWave != null) { _spawnedItemsListScrollPosition = EditorGUILayout.BeginScrollView(_spawnedItemsListScrollPosition); { if (wavesEditor._currentWave != _selectedWave && wavesEditor._currentWave.SpawnedItems != null) { _spawnedItemsList = new ReorderableList(wavesEditor._currentWave.SpawnedItems, typeof(SpawnedItemDataObject), true, false, true, true); _spawnedItemsList.drawElementCallback = (Rect cellRect, int index, bool isActive, bool isFocused) => { if (wavesEditor._currentWave != null && wavesEditor._currentWave.SpawnedItems != null && wavesEditor._currentWave.SpawnedItems.Count > index) { if (wavesEditor._currentWave.SpawnedItems[index] != null) { GUI.DrawTexture(new Rect(cellRect.x, cellRect.y, 16, 16), TeaxtureForSpwanItem(wavesEditor._currentWave.SpawnedItems[index].SpwanedColor, wavesEditor)); } } }; _spawnedItemsList.onSelectCallback = (list) => { wavesEditor._currentSpwanItem = wavesEditor._currentWave.SpawnedItems[list.index]; _selectedTab = eWaveEditorTabTab.Item; }; _spawnedItemsList.onAddCallback = (list) => { SpawnedItemDataObject newItem = new SpawnedItemDataObject(); newItem.ForceVector = new Vector2(0, 144); wavesEditor._currentWave.SpawnedItems.Add(newItem); }; _selectedWave = wavesEditor._currentWave; } if (_spawnedItemsList != null) { _spawnedItemsList.DoLayoutList(); } } EditorGUILayout.EndScrollView(); } }
private static void DrawWaveList(WavesEditor wavesEditor) { if (wavesEditor._currentSequance != null) { _waveListScrollPosition = EditorGUILayout.BeginScrollView(_waveListScrollPosition); { if (wavesEditor._currentSequance != SelectedSequance) { _selectedWaveList = new ReorderableList(wavesEditor._currentSequance.Waves, typeof(SequanceDefenition), true, false, true, true); _selectedWaveList.drawElementCallback = (Rect cellRect, int index, bool isActive, bool isFocused) => { for (int i=0; i < wavesEditor._currentSequance.Waves[index].SpawnedItems.Count; i++) { GUI.DrawTexture(new Rect(cellRect.x + (i * 16), cellRect.y, 16, 16), TeaxtureForSpwanItem(wavesEditor._currentSequance.Waves[index].SpawnedItems[i].SpwanedColor, wavesEditor)); } if (wavesEditor._currentSequance.Waves[index].Delay > 0) { EditorGUI.LabelField(new Rect(cellRect.x + wavesEditor._currentSequance.Waves[index].SpawnedItems.Count * 16, cellRect.y, 100,16) ,"Delay " + wavesEditor._currentSequance.Waves[index].Delay); } }; _selectedWaveList.onSelectCallback = (list) => { wavesEditor._currentWave = wavesEditor._currentSequance.Waves[list.index]; _selectedTab = eWaveEditorTabTab.Wave; }; _selectedWaveList.onAddCallback = (list) => { if (wavesEditor._currentSequance != null) { WaveDataObject newWave = new WaveDataObject(); wavesEditor._currentSequance.Waves.Add(newWave); wavesEditor._currentWave = newWave; _selectedWave = newWave; list.index = list.count - 1; } }; SelectedSequance = wavesEditor._currentSequance; } _selectedWaveList.DoLayoutList(); } EditorGUILayout.EndScrollView(); } }
private static void AddItem(WavesEditor wavesEditor, float delay) { if (wavesEditor._currentSequance != null) { if (wavesEditor._currentSequance.Waves == null) { wavesEditor._currentSequance.Waves = new List<WaveDataObject>(); } WaveDataObject newWave = new WaveDataObject(); newWave.Delay = delay; wavesEditor._currentSequance.Waves.Add(newWave); } }