public void ChooseNextAbility() { nextAbilityImage.gameObject.SetActive(true); int totalChance = 0; foreach (var a in abilities) { totalChance += a.chance; } int randomIndex = Random.Range(0, totalChance); int anotherChance = -1; foreach (var a in abilities) { anotherChance += a.chance; if (anotherChance >= randomIndex) { nextAbility = a.ability; break; } } EnemyAbilityScriptableObject nextAbilityTargetable = nextAbility; if (nextAbilityTargetable.type == EnemyAbilityScriptableObject.Type.Offensive) { nextAbilityImage.sprite = damagingAbilitySprite; AbilityStep_Base att = nextAbilityTargetable.abilityStepsWithTargetingData[0].abilityStep; nextAbilityDamage.text = ((AbilityStep_Targetable)att).amount.ToString(); } else if (nextAbilityTargetable.type == EnemyAbilityScriptableObject.Type.Blocking) { nextAbilityImage.sprite = blockingAbilitySprite; nextAbilityDamage.text = ""; } else if (nextAbilityTargetable.type == EnemyAbilityScriptableObject.Type.Healing) { nextAbilityImage.sprite = healingAbilitySprite; nextAbilityDamage.text = ""; } else if (nextAbilityTargetable.type == EnemyAbilityScriptableObject.Type.Buffing) { nextAbilityImage.sprite = buffingAbilitySprite; nextAbilityDamage.text = ""; } }
public void DoTurn(ref bool doing) { if (doingTurn == false && doneTurn == false) { doingTurn = doing = true; EnemyAbilityScriptableObject nextAbilityTargetable = (EnemyAbilityScriptableObject)nextAbility; StartCoroutine(DoAbility()); } else if (doingTurn == false && doneTurn == true) { doing = false; doneTurn = false; } }