public void Preview(PlayerMove move) { animator.SetTrigger(move.animationName); PlayerSpell spell = move as PlayerSpell; if (spell != null) { StartCoroutine(SpellPreview(spell)); } PlayerSelfBuff buff = move as PlayerSelfBuff; if (buff != null) { AddPerk(buff.buff, 0, true); } }
protected override IEnumerator Attacking() { isAttacking = true; Vector3 startPos = transform.position; Quaternion startRot = transform.rotation; animator.SetBool("blocking", false); hurtbox.enabled = false; yield return(new WaitUntil(() => attackChosen)); yield return(new WaitUntil(() => TargetChosen())); battleManager.CurrentMove = currentMove; try { for (int i = 0; i < currentMove.particleEffects.Length; i++) { StartCoroutine(PlayParticles(currentMove.particleDelay[i], currentMove.particleEffects[i], spellSpawnTransforms[currentMove.particleSpawnPositionID[i]], currentMove.particleDuration[i], currentMove.releaseOnInit[i])); } } catch (NullReferenceException) { Debug.Log("particles are null"); } PlayerMelee melee = currentMove as PlayerMelee; PlayerSpell spell = currentMove as PlayerSpell; PlayerSelfBuff selfBuff = currentMove as PlayerSelfBuff; SpellProjectile projectile = null; if (melee != null) { walkingForward = true; agent.SetDestination(currentTarget.GetAttackPosition().position); agent.stoppingDistance = attackPositionOffset; yield return(new WaitUntil(() => !agent.pathPending)); yield return(new WaitUntil(() => agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance <= attackPositionOffset)); hitboxes[melee.hitboxID].enabled = true; } animator.SetTrigger(name: currentMove.animationName); yield return(new WaitUntil(() => animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains(currentMove.animationName))); PayForAttack(); if (selfBuff != null) { Debug.Log($"{selfBuff.EnhanceDuration(this, selfBuff.buff.duration)}"); AddPerk(selfBuff.buff, selfBuff.EnhanceDuration(this, selfBuff.buff.duration)); } if (spell != null) { if (spell.type == SpellType.Areal) { yield return(new WaitForSeconds(spell.delay[0])); foreach (Enemy enemy in battleManager.GetEnemies()) { for (int i = 0; i < spell.projectile.Length; i++) { //yield return new WaitForSeconds(spell.delay[i]); projectile = Instantiate(spell.projectile[i], spellSpawnTransforms[0].position, transform.rotation, transform.parent); projectile.LockOnTarget(enemy.GetProjectileTarget()); } } } else { bool isMultiple = spell.type == SpellType.Multiple; if (!isMultiple) { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(currentTarget.transform.position - transform.position), Time.deltaTime); } Enemy[] aliveEnemies = battleManager.GetEnemies().FindAll(enemy => !enemy.IsDead()).ToArray(); for (int i = 0; i < spell.projectile.Length; i++) { yield return(new WaitForSeconds(spell.delay[i])); projectile = Instantiate(spell.projectile[i], spellSpawnTransforms[spell.spawnTransformID].position, transform.rotation, transform); projectile.LockOnTarget(isMultiple ? aliveEnemies[Mathf.Min(aliveEnemies.Length - 1, i)].GetProjectileTarget() : currentTarget.GetProjectileTarget()); } } } yield return(new WaitUntil(() => !animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains(currentMove.animationName))); if (melee != null) { walkingForward = false; agent.updateRotation = false; agent.SetDestination(startPos); agent.stoppingDistance = 0f; hitboxes[melee.hitboxID].enabled = false; yield return(new WaitUntil(() => !agent.pathPending)); yield return(new WaitUntil(() => agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance == 0)); agent.updateRotation = true; transform.rotation = startRot; } yield return(new WaitUntil(() => projectile == null)); attackChosen = false; bool doBlock = attributes.probabilityOfBlock + (currentMove as PlayerMove).probOfBlock > UnityEngine.Random.Range(0, 1f); animator.SetBool("blocking", doBlock); hurtbox.enabled = true; yield return(base.Attacking()); }
public void PreviewInfo(PlayerMove move) { perkDescription.gameObject.SetActive(false); moveDescription.SetActive(true); skillName.text = move.name; skillName.gameObject.SetActive(true); PlayerSelfBuff selfBuff = move as PlayerSelfBuff; blockEnable.text = $"({Mathf.RoundToInt(move.probOfBlock * 100)}%)"; if (selfBuff != null) { type.text = "Self Buff"; type.gameObject.SetActive(true); type.transform.parent.gameObject.SetActive(true); moveDescription.SetActive(false); perkDescription.text = selfBuff.buff.descritption + $"\nCurrent duration of buff: {selfBuff.buff.duration + selfBuff.EnhanceDuration(player, selfBuff.buff.duration)} turns"; perkDescription.gameObject.SetActive(true); } else { PlayerAttack attack = move as PlayerAttack; type.text = attack is PlayerMelee ? "Melee" : "Spell"; type.gameObject.SetActive(true); type.transform.parent.gameObject.SetActive(true); (string str, string dex, string inte, string fth, string lck, float critMultiplier) = attack.GetScalingInfo(player); STR.text = $"STR\n" + str; AGL.text = $"AGL\n" + dex; INT.text = $"INT\n" + inte; FTH.text = $"FTH\n" + fth; LCK.text = $"LCK\n" + lck; (float healthDamage, float _, float _, List <Status> statuses, float statusProbability, float luck) = attack.GetAttackInfo(player, true); damage.text = $"{Mathf.RoundToInt(healthDamage)}"; stamina.text = $"{Mathf.RoundToInt(move.staminaCost)}"; mana.text = $"{Mathf.RoundToInt(move.manaCost)}"; int poisonCounter = 0, bleedCounter = 0, burnCounter = 0; bool doesStun = false; foreach (Status status in statuses) { switch (status) { case Status.Poison: poisonCounter++; break; case Status.Bleed: bleedCounter++; break; case Status.Stun: doesStun = true; break; case Status.Burn: burnCounter++; break; default: break; } } string statusInfo = ""; if (poisonCounter == 0 && bleedCounter == 0 && doesStun == false) { this.statusProbability.text = "None"; } else { if (poisonCounter > 0) { statusInfo += $"Poison ({poisonCounter}x) "; } if (bleedCounter > 0) { statusInfo += $"Bleed ({bleedCounter}x) "; } if (burnCounter > 0) { statusInfo += $"Burn ({burnCounter}x)"; } if (doesStun) { statusInfo += "Stun"; } this.statusProbability.text = $"({Mathf.Min(100, Mathf.RoundToInt(statusProbability * 100))}%)"; } status.text = statusInfo; crit.text = $"{Mathf.Min(100, Mathf.RoundToInt(luck * 100))}%/{critMultiplier}"; } }