const float shakeIntensityMod = 0.1f; //The amount to scale each shake by (per keyword) public IEnumerator playEffects(CastData d, SpellData s, float delay = 0) { yield return(new WaitForSeconds(delay)); //caster_cutin_animator.Play ("anim_wave_banner_image"); if (d.isHit == false)//Spell misses { Debug.Log(d.Caster.Stats.name + " missed " + d.Target.Stats.name + "!"); //Process miss graphics popp.spawnSprite("popup_miss", POP_TIMER, d.Target.Transform.position + UNDER_OFFSET); AudioPlayer.main.playSFX("sfx_spell_miss"); BattleEffects.main.spriteShift(d.Target.Transform, 0.3f, 0.1f); // sprite moves to the right as a dodge yield break; } //Process repel if (d.repel) { spawnElementPopup(d.element, Elements.vsElement.REPEL, d.Caster.Transform); AnimationPlayer.main.playAnimation("anim_element_reflect", d.Caster.Transform.position, 2f); yield return(new WaitForSeconds(0.333F)); } float shakeIntensity = 0; //Process hit graphics (if not a repelled attack) for (int i = 0; i < d.animData.Length; ++i) { if (d.animData[i] != null) { AudioPlayer.main.setSFX(AudioPlayer.channel_spell_sfx, d.sfxData[i]); AudioPlayer.main.playSFX(AudioPlayer.channel_spell_sfx); //AnimationPlayer.main.playAnimation(d.animData[i], d.Target.Transform.position, 1); AnimationPlayer.main.playAnimation(d.animData[i], d.Target.Transform.position, 2f); if (d.Target.CasterType == ICasterType.PLAYER) { BattleEffects.main.screenShake(0.15f + shakeIntensity / 8, 0.05f + shakeIntensity); } shakeIntensity += shakeIntensityMod; if (d.repel) { popp.spawnText(s.getWord(i).ToUpper() + "!", POP_TIMER - 1, d.Caster.Transform.position, Color.black, new Color(1, 111f / 255f, 1)); } else { popp.spawnText(s.getWord(i).ToUpper() + "!", POP_TIMER - 1, d.Caster.Transform.position, new Color(1, 111f / 255f, 1), Color.white); } yield return(new WaitForSeconds(0.333F)); } } if (d.isCrit && d.vsElement != Elements.vsElement.BLOCK) //Spell is crit { Debug.Log(d.Caster.Stats.name + " scores a critical with " + s.ToString() + " on " + d.Target.Stats.name); if (d.Target.CasterType == ICasterType.ENEMY) { AudioPlayer.main.playSFX("sfx_enemy_weakcrit_dmg"); if (!d.isStun && !d.Target.Is_stunned) { popp.spawnText("<size=48>-1<size=24>SHIELD</size></size>", POP_TIMER, d.Target.Transform.position + UNDER_OFFSET_2, Color.cyan, Color.white); } if (d.isStun) { popp.spawnText("BREAK!", POP_TIMER, d.Target.Transform.position + UNDER_OFFSET_2, Color.cyan, Color.white); } //if (d.Target.Is_stunned) popp.spawnText ("BONUS DMG!", POP_TIMER, d.Target.Transform.position + UNDER_OFFSET_2, Color.red, Color.white); } else if (d.Target.CasterType == ICasterType.PLAYER || d.Target.CasterType == ICasterType.NPC_ALLY) { AudioPlayer.main.playSFX("sfx_party_weakcrit_dmg"); } } else if ((d.vsElement == Elements.vsElement.WEAK || d.vsElement == Elements.vsElement.SUPERWEAK) && d.damageInflicted > 0) { if (d.Target.CasterType == ICasterType.ENEMY) { AudioPlayer.main.playSFX("sfx_enemy_weakcrit_dmg"); if (!d.isStun && !d.Target.Is_stunned) { popp.spawnText("<size=48>-1<size=24>SHIELD</size></size>", POP_TIMER, d.Target.Transform.position + UNDER_OFFSET_2, Color.cyan, Color.white); } if (d.isStun) { popp.spawnText("BREAK!", POP_TIMER, d.Target.Transform.position + UNDER_OFFSET_2, Color.cyan, Color.white); } } else if (d.Target.CasterType == ICasterType.PLAYER || d.Target.CasterType == ICasterType.NPC_ALLY) { AudioPlayer.main.playSFX("sfx_party_weakcrit_dmg"); } } if (d.isStun) { //Process stun graphics Debug.Log(d.Caster.Stats.name + " stuns " + d.Target.Stats.name); AudioPlayer.main.playSFX("sfx_stagger"); } Debug.Log(d.Target.Stats.name + " was hit for " + d.damageInflicted + " " + Elements.toString(d.element) + " damage: " + d.vsElement); //Process elemental wk/resist/drain/repel graphics if (!((d.vsElement == Elements.vsElement.WEAK || d.vsElement == Elements.vsElement.SUPERWEAK) && d.damageInflicted <= 0)) { spawnElementPopup(d.element, d.vsElement, d.Target.Transform); } //Play block/reflect/drain animations if necessary if (d.vsElement == Elements.vsElement.BLOCK) { AnimationPlayer.main.playAnimation("anim_element_block", d.Target.Transform.position, 2f); yield return(new WaitForSeconds(0.333F)); } else if (d.vsElement == Elements.vsElement.DRAIN) { AnimationPlayer.main.playAnimation("anim_element_drain", d.Target.Transform.position, 2f); yield return(new WaitForSeconds(0.333F)); } //Spawn damage number and some other gubs spawnDamagePopup(d, shakeIntensity); }
// pause battle, attack player with specified spell void attackPlayer(SpellData s) { Debug.Log(stats.name + " casts " + s.ToString()); castManager.enemyCast(castManager.spellDict, s, position, target); }
//Enable battle log UI state (call anywhere that the battlemanager pauses to cast) public void log(SpellData cast, ICasterType caster, string talk, string speaker, Vector3 casterPosition) { battleLogCast.SetActive(false); battleLogTalk.SetActive(false); battleLogSub.SetActive(true); string ele = ""; switch (cast.element) { case "agni": battleLogSubSpellIcons [1].sprite = battleLogIcons [1]; battleLogSubSpellIcons [2].sprite = battleLogIcons [1]; ele = "FIRE"; break; case "cryo": battleLogSubSpellIcons [1].sprite = battleLogIcons [2]; battleLogSubSpellIcons [2].sprite = battleLogIcons [2]; ele = "ICE"; break; case "veld": battleLogSubSpellIcons [1].sprite = battleLogIcons [3]; battleLogSubSpellIcons [2].sprite = battleLogIcons [3]; ele = "VOLT"; break; default: battleLogSubSpellIcons [1].sprite = battleLogIcons [0]; battleLogSubSpellIcons [2].sprite = battleLogIcons [0]; ele = "PHYSICAL"; break; } battleLogSubAnimator.Play("anim_sub_battlelog_enter"); battleLogCast.transform.position = casterPosition; battleLogSubText[0].text = cast.ToString(); logCastText.text = "> " + cast.ToString(); logTalkText.text = talk; //logTalkInfo.text = speaker; logCastInfo.text = speaker; if (caster == ICasterType.ENEMY) { castBox.color = enemyColor; talkBox.color = enemyColor; battleLogSubText[1].text = "ENEMY CASTS " + ele; } else if (caster == ICasterType.PLAYER) { castBox.color = playerColor; talkBox.color = playerColor; battleLogSubText[1].text = "PLAYER CASTS " + ele; } else if (caster == ICasterType.NPC_ALLY) { castBox.color = allyColor; talkBox.color = allyColor; battleLogSubText[1].text = "ALLY CASTS " + ele; } else //caster == IcasterType.INVALID (clarke is speaking) { castBox.color = clarkeColor; talkBox.color = clarkeColor; battleLogSubText[1].text = "ERROR CAST"; } }