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 WaveDataObject GetNextWave() { if (_currentSequance != null && _currentSequance.Waves != null) { if (_currentSequance.Waves.Count > _currentWaveIndex) { WaveDataObject nextWave = _currentSequance.Waves[_currentWaveIndex]; _currentWaveIndex++; return nextWave; } } _waveTimeCount = 0; _currentSequance = null; return 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(); }
public void PlaySequanceForEditMode(SequanceDataObject sequance) { _sequanceDataObjectForEditor = sequance; }
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(); } }