private void ProcessTurn() { PreviousBattleActions = battleActions; foreach (KeyValuePair <int, BattleAction> entry in battleActions) { FighterController fc = FighterControllers[entry.Key]; fc.ActionRenderer.sprite = DataManager.Instance.BattleActionIcons[entry.Value.ActionType]; FighterController targetFC = FighterControllers[entry.Value.Target]; BattleActionResults bars = DataManager.Instance.BattleActionResults[entry.Value.ActionType]; float receivedDamage = 0; foreach (var bar in bars.BattleActionResultList) { if (bar.ActionType == battleActions[entry.Value.Target].ActionType) { receivedDamage = bar.ReceivingDamage; } } fc.Health -= receivedDamage; } DelayUtil.WaitForSeconds(TurnCooldownSeconds + 1, () => { foreach (KeyValuePair <int, BattleAction> entry in battleActions) { FighterControllers[entry.Key].ClearActionIcon(); } battleActions = new Dictionary <int, BattleAction>(); Dictionary <int, float> healthFighters = new Dictionary <int, float>(); foreach (KeyValuePair <int, FighterController> entry in FighterControllers) { healthFighters.Add(entry.Key, entry.Value.Health); } int loser = GetRoundLoser(healthFighters); if (loser >= 0) { RoundEnd(loser, FighterControllers); } else { turnInProgress = false; } }); }
/// <summary> /// Play music based on name and execute callback when done. /// </summary> /// <param name="name">Name of music clip</param> /// <param name="callback">Callback action</param> /// <returns>AudioSource playing the music</returns> public static AudioSource PlayMusic(string name, Action callback = null) { if (ShouldPlayerMusic) { try { AudioObject ao = musicDict[name]; ao.AudioSource.Play(); DelayUtil.WaitForSeconds(ao.AudioClip.length, callback); return(ao.AudioSource); } catch (KeyNotFoundException knfEx) { return(null); } } return(null); }