public override void Remove(ScriptableObject toRemove) { WaveDefinition waveDefinition = toRemove as WaveDefinition; waveTimes.RemoveAt(waveDefinitions.IndexOf(waveDefinition)); waveDefinitions.Remove(waveDefinition); }
private void CurrentWaveOver() { currWave = null; //TODO //DEBUG restart // StartCurrentWave(); }
public void StartCurrentWave() { currWave = WaveLibrary.I.GetDefinition(gameCtrl.currWaveIdx); waveStartTime = Time.time; wavePartIncr = 0; currWaveEnemies = new Dictionary <int, Enemy>(); }
public void StartCurrentWave() { currWave = WaveLibrary.I.GetDefinition(gameCtrl.currWaveIdx); waveStartTime = Time.time; wavePartIncr = 0; currWaveEnemies = new Dictionary<int, Enemy>(); }
public void RemoveWaveFromTimeline(WaveDefinition waveDefinition) { int index = selectedMission.waveDefinitions.IndexOf(waveDefinition); Remove(_buttons[index]); _buttons[index].Destroy(); _buttons.RemoveAt(index); }
public HeldWave(Vector3 position, WaveDefinition waveDefinition) : base("Held" + waveDefinition.name, GameObject.CreatePrimitive(PrimitiveType.Quad)) { container.transform.localRotation = Quaternion.Euler(90, 0, 0); body.transform.localRotation = Quaternion.identity; body.transform.localScale = new Vector3(2, 1, 1); meshRenderer.material.color = Color.yellow; label.SetLocalRotation(Quaternion.identity); this.position = position; this.waveDefinition = waveDefinition; }
public static void resetWave(bool won = false) { if (won) { wave_number++; } setCoefficients(wave_number); wave = Difficulty.waves[(wave_number / 3) % Difficulty.waves.Length]; wave.enemy_palette = wave.enemy_palette + Mathf.FloorToInt(wave_number / (3.0f * Difficulty.waves.Length)); wave.reset(); }
public static void reset(int start_wave = 0) { wave_number = start_wave; wave = null; resetWave(); if (hardcore_mode) { hearts = 2; } else { hearts = DataStorage.Hearts; } setCoefficients(wave_number); }
IEnumerator SpawnWave(int waveNo) { WaveDefinition waveDefinition = waveDefinitions[waveNo]; List <int> selection = new List <int>(); //add hazardsPerWave times a 0 for (int i = 0; i < waveDefinition.HazardsPerWave; i++) { selection.Add(0); } //add friendsPerWave times a 1 for (int i = 0; i < waveDefinition.FriendsPerWave; i++) { selection.Add(1); } //Shuffle the list selection.Shuffle(); while (selection.Count > 0) { //spawn a gameObject GameObject gameObject; //check if friend or hazard int i = selection[0]; selection.RemoveAt(0); if (i == 0) { gameObject = waveDefinition.Hazards[Random.Range(0, waveDefinition.Hazards.Count)]; } else { gameObject = waveDefinition.Friends[Random.Range(0, waveDefinition.Friends.Count)]; } InstantiateGameObject(gameObject); yield return(new WaitForSeconds(spawnWait)); } }
public void ParseLevel(string filename) { // open level file if (System.IO.File.Exists(filename)) { Dictionary<string, object> json = (Dictionary<string, object>)MiniJSON.Json.Deserialize(File.ReadAllText(filename)); levelName = (string)json["name"]; musicFolder = (string)json["music"]; List<object> waves = (List<object>)json["waves"]; foreach (Dictionary<string, object> wave in waves) { WaveDefinition waveDefn = new WaveDefinition((long)wave["id"], (string)wave["track"]); foreach (Dictionary<string, object> enemy in (List<object>)wave["enemies"]) { Vector3 vec = new Vector3(); List<object> arr = (List<object>)enemy["spawnPos"]; for (int i = 0; i < arr.Count; i++) { vec[i] = (float)((double)arr[i]); } waveDefn.AddEnemy((long)enemy["id"], vec, (float)((double)enemy["delay"])); } waveDefns.Add(waveDefn); } List<object> level = (List<object>)json["level"]; foreach (List<object> wave in level) { levelDefn.AddPair((long)wave[0], (float)((double)wave[1])); } } else { Debug.LogError("Could not open level " + filename); } GameObject.Find("MixerObject").GetComponent<Mixer>().LoadTracks(musicFolder); }
public void SetSelectedWaveDefinition(WaveDefinition selectedWaveDefinition) => this.selectedWaveDefinition = selectedWaveDefinition;
private void AddWaveToTimeline(WaveDefinition selectedWaveDefinition, float timelinePosition) => _editor.timelineEditor.AddWaveToTimeline(selectedWaveDefinition, timelinePosition, true);
public void AddWaveDefinition(WaveDefinition waveDefinition) => waveDefinitions.Add(waveDefinition);
private void SetSelectedWaveDefinition(WaveDefinition waveDefinition) => _editor.waveEditor.SetSelectedWaveDefinition(waveDefinition);
public void AddWaveToTimeline(WaveDefinition waveDefinition, float timelinePosition, bool addToMission = false) { if (addToMission) { selectedMission.Add(waveDefinition, timelinePosition); } Button button = new Button("Wave", 1, 1, container, "Wave", fontSize: 20, Enter: (Button b) => { if (_editor.conveyor == null || !_editor.conveyor.showing) { b.SetColor(b.selected ? b.color : Color.green); } }, Stay: (Button b) => { if (_editor.conveyor == null || !_editor.conveyor.showing) { if (Input.GetMouseButtonDown(1)) { selectedMission.Remove(waveDefinition); _buttons.Remove(b); Remove(b); b.Destroy(); } else if (!b.selected && Input.GetMouseButtonDown(0)) { for (int i = 0; _buttons.Count > i; i++) { _buttons[i].Deselect(); _buttons[i].SetColor(Color.white); } _editor.waveEditor.SetSelectedWaveDefinition(waveDefinition); _editor.waveEditor.HideWaveEventButtons(); _editor.waveEditor.ShowWaveEventButtons(); b.SetColor(Color.yellow); b.Select(); } } }, Exit: (Button b) => { if (_editor.conveyor == null || !_editor.conveyor.showing) { if (_editor.waveEditor.heldWaveEvent == null && heldWave == null && Input.GetMouseButton(0)) { heldWaveIndex = selectedMission.waveTimes.IndexOf(timelinePosition); heldWave = new HeldWave(b.rect.position, waveDefinition); heldWave.SetPosition(mousePos + (Vector3.up * 2)); heldWave.SetText("Wave"); } b.SetColor(b.selected ? b.color : Color.white); } }); button.SetPosition(new Vector3(missionTimeline.rect.xMin + (timelinePosition * missionTimeline.rect.xMax), 0, missionTimeline.rect.yMin + 0.5f) + (Vector3.up * (missionTimeline.position.y + 1))); _buttons.Add(button); Add(button); }