public void LoadFromFile(string path) { if (!File.Exists(path)) { return; } StreamReader sr = File.OpenText(path); string line = sr.ReadLine(); int totalWave = int.Parse(line); line = sr.ReadLine(); int PreloadWave = int.Parse(line); for (int i = 0; i < PreloadWave; i++) { line = sr.ReadLine(); } for (int id = 0; id < totalWave; id++) { EditorWave newWave = new EditorWave(this, sr); _waves.Add(newWave); CurrentEdit = -1; } sr.Close(); _editor.Repaint(); }
public void DrawLinks() { if (levelMgr.CurrentEdit > -1) { EditorWave _wave = levelMgr.GetWave(levelMgr.CurrentEdit); if (_wave == null) { return; } if (_wave.preWaves != null && _wave.preWaves.Length > 0) { string[] strPreWaves = _wave.preWaves.Split(','); for (int i = 0; i < strPreWaves.Length; i++) { int preWaveId; bool b = int.TryParse(strPreWaves[i], out preWaveId); if (b) { curveFromTo(preWaveId, _wave.ID, Color.green, Color.yellow); } } } foreach (EditorWave wv in levelMgr._waves) { if (wv.preWaves != null && wv.preWaves.Length > 0) { string[] strPreWaves = wv.preWaves.Split(','); if (strPreWaves.Contains(levelMgr.CurrentEdit.ToString())) { curveFromTo(levelMgr.CurrentEdit, wv.ID, Color.green, Color.yellow); } } } } }
public void RemoveWave(int id) { foreach (EditorWave _wave in _waves) { if (_wave.ID == id) { _toBeRemoved = _wave; } } }
public void AddScript() { int newid = GetEmptySlot(1000, 1100); if (newid >= 0) { EditorWave newWave = new EditorWave(newid); newWave.ID = newid; newWave.LevelMgr = this; _waves.Add(newWave); CurrentEdit = newWave.ID; } }
public void OnGUI() { _layout.OnGUI(); if (_toBeRemoved != null) { if (_toBeRemoved.ID == CurrentEdit) { CurrentEdit = -1; } _toBeRemoved.Remove(); _waves.Remove(_toBeRemoved); _toBeRemoved = null; } }
protected void curveFromTo(int parentID, int childID, Color color, Color color2) { EditorWave parent = levelMgr.GetWave(parentID); EditorWave child = levelMgr.GetWave(childID); if (parent != null && child != null) { Rect parentRect = parent.LayoutWindow._rect; Rect childRect = child.LayoutWindow._rect; parentRect.x += tabLength; childRect.x += tabLength; curveFromTo(parentRect, childRect, color, color2); } }
public void DrawDetailView() { EditorWave wv = levelMgr.GetWave(levelMgr.CurrentEdit); if (wv != null) { wv.SpawnType = (LevelSpawnType)EditorGUILayout.EnumPopup("Spawn Type", wv.SpawnType); GUILayout.BeginHorizontal(); wv.UID = EditorGUILayout.IntField(titles[(int)wv.spawnType], wv.UID); if (!string.IsNullOrEmpty(wv.name)) { EditorGUILayout.LabelField(wv.name); } GUILayout.EndHorizontal(); wv.Time = EditorGUILayout.FloatField("Spawn Time(s):", wv.Time); GUILayout.Space(20); wv.exString = EditorGUILayout.TextField("ExString(,):", wv.exString); wv.preWaves = EditorGUILayout.TextField("PreWaves(,):", wv.preWaves); wv.HasBuff = EditorGUILayout.Toggle("Add Buff:", wv.HasBuff); if (wv.HasBuff) { GUILayout.BeginHorizontal(); wv._buff_id = EditorGUILayout.TextField("Buff ID:", wv._buff_id); wv._buff_percent = EditorGUILayout.IntSlider("Buff Percent(%):", wv._buff_percent, 0, 100); GUILayout.EndHorizontal(); } GUILayout.Space(20); wv.isAroundPlayer = EditorGUILayout.Toggle("Around Player:", wv.isAroundPlayer); if (!wv.isAroundPlayer) { if (wv.go != null) { Vector3 pos = wv.go.transform.position; pos = EditorGUILayout.Vector3Field("Center:", pos); if (wv.go.transform.position != pos) { wv.go.transform.position = pos; } } } wv.Radius = EditorGUILayout.FloatField("Radius:", wv.Radius); wv.Count = EditorGUILayout.IntSlider("Count:", wv.Count, 0, 10); } }
public void AddWave() { int newid = GetEmptySlot(0, 100); if (newid >= 0) { EditorWave newWave = new EditorWave(newid); newWave.ID = newid; newWave.LevelMgr = this; _waves.Add(newWave); CurrentEdit = newWave.ID; } else { XDebug.Log("More than 100 waves?"); } }
public EntityWaveWindow(EditorWave wv) : base(wv) { }
public ScriptWaveWindow(EditorWave wv) : base(wv) { }
public WaveWindow(EditorWave wv) { _rect = new Rect(wv.rectX, wv.rectY, width, height); _wave = wv; }