void StartWave() { if (_waveInProgress) { Debug.Log("Wave in progress quit"); return; } if (_currentWave >= Waves.Count) { Debug.Log("Waves ended count:" + Waves.Count + " current:" + _currentWave); enabled = false; return; } WaveClass wave = Waves[_currentWave]; if (wave.Active) { Debug.Log("Current wave is active"); return; } Debug.Log("Start wave"); _waveInProgress = true; StartCoroutine(wave.WaitMonsters(EndWave)); }
// Update is called once per frame void Update() { if (!attacking) { } if (spawnNumber < currentWave.enemies.Count && attacking) { cart.SetActive(true); startWave.SetActive(false); timer += Time.deltaTime; if (timer > currentWave.spawnDelay) { timer = 0; for (int i = 0; i < currentWave.number[spawnNumber]; i++) { GameObject x = Instantiate(currentWave.enemies[spawnNumber], enemySpawners.GetChild(Random.Range(0, enemySpawners.childCount)).position, Quaternion.identity); x.transform.SetParent(enemyTrans); } spawnNumber++; } } else { if (enemyTrans.childCount == 0 && attacking) { //cart.SetActive(false); startWave.SetActive(true); ShopSlot[] shopSlots = FindObjectsOfType <ShopSlot>(); foreach (ShopSlot shopSlot in shopSlots) { shopSlot.Restock(); } text.GetComponent <WaveText>().DisplayOver(); waveNumber++; spawnNumber = 0; timer = 0; attacking = false; if (waveNumber >= waves.Count) { waveNumber--; } currentWave = waves[waveNumber]; } } }
static WaveCore() { ObjectClass = new WaveClass("global::wave/lang/Object", null); ValueTypeClass = new WaveClass("global::wave/lang/ValueType", ObjectClass); VoidClass = new WaveClass("global::wave/lang/Void", ObjectClass); StringClass = new WaveClass("global::wave/lang/String", ObjectClass); Int16Class = new WaveClass("global::wave/lang/Int16", ValueTypeClass); Int32Class = new WaveClass("global::wave/lang/Int32", ValueTypeClass); Int64Class = new WaveClass("global::wave/lang/Int64", ValueTypeClass); ObjectClass.DefineMethod("getHashCode", Int32Class.AsType(WaveTypeCode.TYPE_I4), MethodFlags.Virtual | MethodFlags.Public); ObjectClass.DefineMethod("toString", StringClass.AsType(WaveTypeCode.TYPE_STRING), MethodFlags.Virtual | MethodFlags.Public); }
// Start is called before the first frame update void Start() { //text.GetComponent<WaveText>().Display(waveNumber); currentWave = waves[waveNumber]; }
public override void OnInspectorGUI() { _target.PauseTime = EditorGUILayout.Slider("Pause between waves", _target.PauseTime, 1, 60); EditorGUILayout.LabelField("Waves", EditorStyles.boldLabel); for (int i = 0; i < _target.Waves.Count; i++) { if (_showMonster.Count - 1 < i) { _showMonster.Add(true); _showWave.Add(true); } _showWave[i] = EditorGUILayout.Foldout(_showWave[i], "Wave " + i); if (!_showWave[i]) { continue; } EditorGUI.indentLevel++; WaveClass wave = _target.Waves[i]; wave.SpawnPoint = EditorGUILayout.ObjectField("SpawnPoint", wave.SpawnPoint, typeof(Transform), true) as Transform; wave.BornTime = EditorGUILayout.Slider("Born time(s)", wave.BornTime, 0, 5); _showMonster[i] = EditorGUILayout.Foldout(_showMonster[i], "Monsters"); if (_showMonster[i]) { EditorGUI.indentLevel++; for (int j = 0; j < wave.Monsters.Count; j++) { EditorGUILayout.LabelField("Monster " + j, EditorStyles.boldLabel); EditorGUI.indentLevel++; WaveAttack monster = wave.Monsters[j]; monster.SpawnCount = EditorGUILayout.IntSlider("Spawn count", monster.SpawnCount, 1, 50); monster.Hitpoints = EditorGUILayout.FloatField("Hitpoints", monster.Hitpoints); monster.Speed = EditorGUILayout.FloatField("Monsters speed", monster.Speed); monster.Params.AttackRange = EditorGUILayout.FloatField("Attack range", monster.Params.AttackRange); monster.Params.AttackDamage = EditorGUILayout.FloatField("Attack damage", monster.Params.AttackDamage); monster.Params.AttackSpeed = EditorGUILayout.FloatField("Attack speed", monster.Params.AttackSpeed); EditorGUI.indentLevel--; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove monster", GUILayout.Width(120))) { wave.Monsters.Remove(monster); } EditorGUILayout.EndHorizontal(); EditorGUILayout.TextArea("", GUI.skin.horizontalSlider); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add monster", GUILayout.Width(140))) { wave.Monsters.Add(new WaveAttack()); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; EditorGUILayout.TextArea("", GUI.skin.horizontalSlider); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove wave", GUILayout.Width(170))) { _target.Waves.Remove(wave); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); AddWave(); EditorGUILayout.EndHorizontal(); //Save data EditorUtility.SetDirty(_target); }
public static WaveRuntimeType AsType(this WaveClass @class) =>