//copy ctor public UB_EncounterData(UB_EncounterData prius) { if (prius == null) { return; } SpawnWeight = prius.SpawnWeight; EncounterType = prius.EncounterType; Description = prius.Description; Icon = prius.Icon; Vitals = new EnemyVitals(prius.Vitals); Rewards = new EncounterRewards(prius.Rewards); EncounterActions = new Dictionary <string, string>(); foreach (var kvp in prius.EncounterActions) { EncounterActions.Add(kvp.Key, kvp.Value); } Spells = new Dictionary <string, EnemySpellDetail>(); foreach (var spell in prius.Spells) { Spells.Add(spell.Key, new EnemySpellDetail(spell.Value)); } Vitals.ActiveStati = new List <UB_SpellStatus>(); foreach (var status in prius.Vitals.ActiveStati) { Vitals.ActiveStati.Add(new UB_SpellStatus(status)); } }
public void EnemyAttackPlayer(bool isAmbush = false) { //randomly select a spell from the enemies spells and cast it on the player. int rng = 0; EnemyVitals vitals = turnController.currentEncounter.Data.Vitals; if (vitals.Spells.Count > 1) { List <int> tries = new List <int>(); do { if (tries.Count < vitals.Spells.Count) { rng = Random.Range(0, vitals.Spells.Count); if (tries.IndexOf(rng) == -1) { tries.Add(rng); } } else { break; } }while(vitals.Spells[rng].IsOnCooldown == false && tries.Count < vitals.Spells.Count); } Debug.Log(string.Format("{0} / {1}", rng, vitals.Spells.Count)); EnemySpellDetail spellRecord = vitals.Spells[rng]; // we will run this after the Callout animation UnityAction applyDamage = () => { fxController.PlayerTakesDamage(this.playerController, spellRecord.Detail.FX); this.playerController.TakeDamage(spellRecord.Detail.BaseDmg); // NEED TO make this decrement each turn // No penalty for the first attack on an ambush if (isAmbush != true && spellRecord.Detail.Cooldown > 0) { spellRecord.IsOnCooldown = true; spellRecord.CdTurns = spellRecord.Detail.Cooldown; } }; //Make our callout Sprite spellIcon = GameController.Instance.iconManager.GetIconById(spellRecord.Detail.Icon); this.enemyController.Callout(spellIcon, string.Format("{0} casts {1}", this.turnController.currentEncounter.DisplayName, spellRecord.SpellName), applyDamage); }
//Copy ctor public EnemyVitals(EnemyVitals prius) { if (prius == null) { return; } Health = prius.Health; Mana = prius.Mana; Speed = prius.Speed; Defense = prius.Defense; CharacterLevel = prius.CharacterLevel; MaxHealth = prius.MaxHealth; MaxMana = prius.MaxMana; MaxSpeed = prius.MaxSpeed; MaxDefense = prius.MaxDefense; if (prius.UsableItems != null && prius.UsableItems.Count > 0) { UsableItems = prius.UsableItems.ToList(); } else { UsableItems = new List <string>(); } Spells = new List <EnemySpellDetail>(); if (prius.Spells != null && prius.Spells.Count > 0) { foreach (var spell in prius.Spells) { Spells.Add(new EnemySpellDetail(spell)); } } ActiveStati = new List <UB_SpellStatus>(); if (prius.ActiveStati != null && prius.ActiveStati.Count > 0) { foreach (var status in ActiveStati) { ActiveStati.Add(new UB_SpellStatus(status)); } } }