// Use this for initialization void Start() { GameObject waves = new GameObject("Waves"); waves.transform.parent = transform; waves.AddComponent<Waves>(); Waves wavesScript = waves.GetComponent<Waves>(); wavesScript.MaxLevel = 20; //units for wave 1 WaveUnit unit1 = new WaveUnit("SteamRebel", 1.5f, 0, 0, 20); WaveUnit unit2 = new WaveUnit("SteamRebel", 1.5f, 10, 1, 25); //units for wave 2 WaveUnit unit3 = new WaveUnit("SteamRebel", 1.5f, 0, 0, 30); WaveUnit unit4 = new WaveUnit("SteamRebel", 1.5f, 10, 1, 40); GameObject wave1 = new GameObject("wave1"); wave1.transform.parent = waves.transform; wave1.AddComponent<Wave>(); Wave wave1Script = wave1.GetComponent<Wave>(); wave1Script.minlvl = 1; wave1Script.maxlvl = 20; wave1Script.nextWaveDelay = 10; wave1Script.units = new WaveUnit[] { unit1, unit2}; GameObject wave2 = new GameObject("wave2"); wave2.transform.parent = waves.transform; wave2.AddComponent<Wave>(); Wave wave2Script = wave2.GetComponent<Wave>(); wave2Script.minlvl = 5; wave2Script.maxlvl = 20; wave2Script.nextWaveDelay = 10; wave2Script.units = new WaveUnit[] { unit3, unit4}; }
//Construct my unit. public Unit GetUnit(WaveUnit wu, Dungeon d) { //Create our unit to hold the result. Unit r = null; if (wu.data.unit != null) { r = Unit.NewUnit(wu.data.unit); } else { r = Unit.NewUnit(d.randomUnits[Random.Range(0, d.randomUnits.Count)]); } //Set equips. EquipUnit(ref r, wu, d); //Set rank and level. int ulevel = 1; if (wu.data.level > 0) { ulevel = wu.data.level - 1; } else if (level > 0) { ulevel = level - 1; } else { ulevel = d.unitLevel - 1; } if (wu.data.rank > 0) { r.rank = wu.data.rank; } else if (rank > 0) { r.rank = rank; } else if (d.unitRank > 0) { r.rank = d.unitRank; } else { r.rank = MathP.GetRank(ulevel); } r.LevelUp(ulevel); //Heal the unit. r.cHP = r.GetmHP(); //Return the result. return(r); }
IEnumerator M_Spawn(Wave wave) { int waveUnitIndex = 0; yield return(new WaitForSeconds(wave.m_beginTime)); while (true) { WaveUnit unit = wave.m_units[waveUnitIndex]; yield return(new WaitForSeconds(unit.m_spawnDelay)); var o = Instantiate(unit.m_enemy.m_obj.gameObject, M_GetSpawnPosition(unit.m_spawnPosType), Quaternion.identity); //o.transform.rotation = M_GetSpawnRotation(unit.m_spawnPosType); waveUnitIndex++; if (waveUnitIndex >= wave.m_units.Length) { waveUnitIndex = 0; } } }
//Equip the unit we're creating. private void EquipUnit(ref Unit r, WaveUnit wu, Dungeon d) { //Set our equipment. if (d.randEquip != null) { if (d.weaponEquipped) { r.weapon = Equipment.GetItem(d.randEquip, EquipType.Weapon); r.weapon.SetLevel(d.unitEquipLevel); } if (d.armorEquipped) { r.armor = Equipment.GetItem(d.randEquip, EquipType.Armor); r.armor.SetLevel(d.unitEquipLevel); } if (d.accessoryEquipped) { r.accessory = Equipment.GetItem(d.randEquip, EquipType.Accessory); r.accessory.SetLevel(d.unitEquipLevel); } } if (wu.data.weapon != null) { if (wu.data.weapon.WeaponMainStatsChoices.Find(n => n.stat == wu.data.weaponMainStat) != null) { r.weapon = GetEquipment(wu.data.weapon, EquipType.Weapon, wu.data.weaponMainStat); } else { Debug.Log("Something went wrong getting unit equips in this dungeon. Guess: You selected the wrong main stat, and no item with a main stat like that can exist."); } if (wu.data.equipLevel > 0) { r.weapon.SetLevel(wu.data.equipLevel); } else { r.weapon.SetLevel(equipLevel); } } if (wu.data.armor != null) { if (wu.data.armor.ArmorMainStatsChoices.Find(n => n.stat == wu.data.armorMainStat) != null) { r.armor = GetEquipment(wu.data.armor, EquipType.Armor, wu.data.armorMainStat); } else { Debug.Log("Something went wrong getting unit equips in this dungeon. Guess: You selected the wrong main stat, and no item with a main stat like that can exist."); } if (wu.data.equipLevel > 0) { r.armor.SetLevel(wu.data.equipLevel); } else { r.armor.SetLevel(equipLevel); } } if (wu.data.accessory != null) { if (wu.data.accessory.AccessoryMainStatsChoices.Find(n => n.stat == wu.data.accessoryMainStat) != null) { r.accessory = GetEquipment(wu.data.accessory, EquipType.Accessory, wu.data.accessoryMainStat); } else { Debug.Log("Something went wrong getting unit equips in this dungeon. Guess: You selected the wrong main stat, and no item with a main stat like that can exist."); } if (wu.data.equipLevel > 0) { r.accessory.SetLevel(wu.data.equipLevel); } else { r.accessory.SetLevel(equipLevel); } } }
int parseWaveUnit(string[] levelData, int index, List <WaveUnit> fileUnits) { WaveUnit fileUnit; fileUnit = new WaveUnit(); int i; bool isDone = false; for (i = index; i < levelData.Length; i++) { string key = ""; string val = ""; key = levelData[i].Split(seps)[0].Trim().ToLower(); if (levelData[i].Split(seps).Length > 1) { val = levelData[i].Split(seps)[1].TrimStart().TrimEnd(); } switch (key) { case "time": fileUnit.time = float.Parse(val); break; case "unit": foreach (GameObject ut in unitTypes) { if (val == ut.GetComponent <UiUnitType>().UnitName) { fileUnit.prefab = ut.GetComponent <UiUnitType>().getRandomUnit(); } } break; case "spawnloc": if (val.ToLower() == "randrow") { fileUnit.SpawnLocType = WaveUnit._spawnLocType.RandRow; } else if (val.ToLower() == "randtile") { fileUnit.SpawnLocType = WaveUnit._spawnLocType.RandTile; } else if (val.ToLower() == "specifiedtile") { fileUnit.SpawnLocType = WaveUnit._spawnLocType.SpecifiedTile; } else if (val.ToLower() == "specifiedrow") { fileUnit.SpawnLocType = WaveUnit._spawnLocType.SpecifiedRow; } else { fileUnit.SpawnLocType = WaveUnit._spawnLocType.RandRow; } break; case "tile": string val2 = ""; if (levelData[i].Split(seps).Length > 2) { val2 = levelData[i].Split(seps)[2]; } fileUnit.Tile.x = float.Parse(val); fileUnit.Tile.y = float.Parse(val2); break; default: isDone = true; break; } if (isDone) { break; } } fileUnits.Add(fileUnit); return(i); }
private static WaveUnit ParseWaveUnitForViterbi(string[] items) { // from Mulan dump string[] pos = items[2].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); uint waveOffset = uint.Parse(pos[0], CultureInfo.InvariantCulture); uint waveLength = uint.Parse(pos[1], CultureInfo.InvariantCulture); WaveUnit item = new WaveUnit(); item.SampleOffset = waveOffset; item.SampleLength = waveLength; if (WaveUnit.VoiceFont != null) { Dictionary<long, WaveUnit> wus = WaveUnit.VoiceFont.WaveUnits; if (wus.ContainsKey(item.SampleOffset)) { return wus[item.SampleOffset]; } else { wus.Add(item.SampleOffset, item); } } if (items.Length == 13) { item.Features = new TtsUnitFeature(); item.Features.Parse(items, 3); } return item; }
private static WaveUnit ParseWaveUnitForWaveUnitSel(string line) { // from Mulan dump // remove desired values line = Regex.Replace(line, @"/ *\d", string.Empty); string[] items = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); WaveUnit item = new WaveUnit(); if (items[2] == "-1") { item.Name = Phoneme.SilencePhone; item.SampleLength = long.Parse(items[3], CultureInfo.InvariantCulture); } else { item.SampleOffset = long.Parse(items[2], CultureInfo.InvariantCulture); item.SampleLength = long.Parse(items[3], CultureInfo.InvariantCulture); if (WaveUnit.VoiceFont != null) { Dictionary<long, WaveUnit> wus = WaveUnit.VoiceFont.WaveUnits; if (wus.ContainsKey(item.SampleOffset)) { return wus[item.SampleOffset]; } else { wus.Add(item.SampleOffset, item); } } item.Features = new TtsUnitFeature(); item.Features.Parse(items, 4); } return item; }