protected void doAnimToDirection(string s) { if (currentDirection == Direction.Right) { enemySprite.DoAnim(s + " " + "(R)"); } else { enemySprite.DoAnim(s + " " + "(L)"); } lastAnimation = s; }
void doAnimToDirection(string s) { if (lastMovement == Direction.Right) { playerSprite.DoAnim(s + " " + "(R)"); } else { playerSprite.DoAnim(s + " " + "(L)"); } lastAnimation = s; }
public void doSkill2() { if (grounded) { wasCastingSkill2 = true; cantMove = atkAnimation_cooldown; doAnimToDirection("Attacking"); isDefending = false; if (lastMovement == Direction.Right) { skillSprite.DoAnim("Vengeance Charge (R)"); } else { skillSprite.DoAnim("Vengeance Charge (L)"); } } }
void doAnimToDirection(string s) { if (s == "Nothing") { sprites.DoAnim(s); lastAnimation = s; return; } if (currentDirection == Direction.Right) { sprites.DoAnim(s + " " + "(R)"); } else { sprites.DoAnim(s + " " + "(L)"); } lastAnimation = s; }
// Update is called once per frame void Update() { if (isActive) { sprites.DoAnim("Effect"); } else { sprites.StopAnim(); } }
// Update is called once per frame void Update() { if (Time.time - startTime < sprites.GetAnim("Start").GetDuration()) { sprites.DoAnim("Start"); } else if (Time.time - startTime > sprites.GetAnim("Start").GetDuration() + duration && Time.time - startTime < sprites.GetAnim("Start").GetDuration() + duration + sprites.GetAnim("End").GetDuration()) { sprites.DoAnim("End"); GetComponent <BoxCollider>().enabled = false; if (!control) { audio.clip = soundEffectDestroy; audio.volume = 0.7f; audio.Play(); control = true; } } else if (Time.time - startTime > sprites.GetAnim("Start").GetDuration() + duration + sprites.GetAnim("End").GetDuration() + 1) { Destroy(gameObject); } if (test) { transform.position = transform.position + new Vector3(0, 0, 0.1f); test = false; } else { transform.position = transform.position + new Vector3(0, 0, -0.1f); test = true; } }
// Update is called once per frame void Update() { if (Time.time - startTime < sprites.GetAnim("Effect").GetDuration()) { sprites.DoAnim("Effect"); } else if (Time.time - startTime > sprites.GetAnim("Effect").GetDuration()) { Destroy(gameObject); } if (test) { transform.position = transform.position + new Vector3(0, 0, 0.1f); test = false; } else { transform.position = transform.position + new Vector3(0, 0, -0.1f); test = true; } }
private void skillCurseInvoked() { float preCooldown; if (isNearPlayer) { preCooldown = 0; } else { preCooldown = skillTeleport.GetAnim("Departure (L)").GetDuration() + skillTeleport.GetAnim("Arrival (L)").GetDuration(); } if (Time.time - lastCastTime < sprites.GetAnim("Casting 1 (L)").GetDuration() + preCooldown) { doAnimToDirection("Casting 1"); skillCurse.DoAnim("Effect"); if (!controlCurse) { audio.PlayOneShot(sound_curse); controlCurse = true; } } else { player.GetComponent <PlayerAttributes>().curse(4); Instantiate(bat); lastCastTime = -1; wasCasting = false; wasCastingCurse = false; controlCurse = false; doAnimToDirection("Standing"); curCurseCooldown = curseCooldown; curGlobalCooldown = globalCooldown; } }
private void skillLifeDrainInvoked() { float preCooldown; if (isNearPlayer) { preCooldown = 0; } else { preCooldown = skillTeleport.GetAnim("Departure (L)").GetDuration() + skillTeleport.GetAnim("Arrival (L)").GetDuration(); } float conjurationTime1 = sprites.GetAnim("Casting 1 (L)").GetDuration(); float conjurationTime2 = 1; if (Time.time - lastCastTime < preCooldown + conjurationTime1) { doAnimToDirection("Casting 1"); } else if (Time.time - lastCastTime < preCooldown + conjurationTime1 + conjurationTime2 * 1 && !magicInterrupted) { doAnimToDirection("Casting 2"); skillLifeDrainPlayer.GetComponent <LifeDrainPlayer>().activate(); skillLifeDrain.DoAnim("Effect"); float stolenHP; if (controlLifeDrain == 0) { audio.PlayOneShot(sound_drain); float stealDamage = 10; stolenHP = player.GetComponent <PlayerAttributes>().maxHP *stealDamage / 100; player.GetComponent <Controls>().gotDamaged(stolenHP, Controls.Enemy.BossLifeDrain); curHP += stolenHP * 1.5f; if (curHP > maxHP) { curHP = maxHP; } controlLifeDrain = 1; moreSkillsSprite.DoAnim("LifeDrain"); } } else if (Time.time - lastCastTime < preCooldown + conjurationTime1 + conjurationTime2 * 2 && !magicInterrupted) { doAnimToDirection("Casting 2"); skillLifeDrain.DoAnim("Effect"); float stolenHP; if (controlLifeDrain == 1) { float stealDamage = 10; stolenHP = player.GetComponent <PlayerAttributes>().maxHP *stealDamage / 100; player.GetComponent <Controls>().gotDamaged(stolenHP, Controls.Enemy.BossLifeDrain); curHP += stolenHP * 1.5f; if (curHP > maxHP) { curHP = maxHP; } controlLifeDrain = 2; moreSkillsSprite.DoAnim("LifeDrain"); } } else if (Time.time - lastCastTime < preCooldown + conjurationTime1 + conjurationTime2 * 3 && !magicInterrupted) { doAnimToDirection("Casting 2"); skillLifeDrain.DoAnim("Effect"); float stolenHP; if (controlLifeDrain == 2) { float stealDamage = 10; stolenHP = player.GetComponent <PlayerAttributes>().maxHP *stealDamage / 100; player.GetComponent <Controls>().gotDamaged(stolenHP, Controls.Enemy.BossLifeDrain); curHP += stolenHP * 1.5f; if (curHP > maxHP) { curHP = maxHP; } controlLifeDrain = 3; moreSkillsSprite.DoAnim("LifeDrain"); } } else { skillLifeDrain.StopAnim(); lastCastTime = -1; wasCasting = false; wasCastingLifeDrain = false; skillLifeDrainPlayer.GetComponent <LifeDrainPlayer>().desactivate(); controlLifeDrain = 0; doAnimToDirection("Standing"); curLifeDrainCooldown = lifeDrainCooldown; curGlobalCooldown = globalCooldown; } }
void Update() { decreaseCooldowns(); if (lastCastTime != -1) { doAnimToDirection(lastAnimation); if (wasCasting) { if (wasCastingSummon) { if (isCentralized) { skillSummonInvoked(); } else { if (positionizeSkillInvoked(teleportPoint_central)) { skillSummonInvoked(); } } return; } if (wasCastingIcicle) { skillIcicleInvoked(); return; } if (wasCastingBlame) { if (isCentralized) { skillBlameInvoked(); } else { if (positionizeSkillInvoked(teleportPoint_central)) { skillBlameInvoked(); } } return; } if (wasCastingCurse) { if (isNearPlayer) { skillCurseInvoked(); } else { List <GameObject> unsafePoints = unsafeTeleportPoints(); int pos = random.Next(0, unsafePoints.Count); if (positionizeSkillInvoked(unsafePoints[pos])) { skillCurseInvoked(); } } } if (wasCastingLifeDrain) { if (isNearPlayer) { skillLifeDrainInvoked(); } else { List <GameObject> unsafePoints = unsafeTeleportPoints(); int pos = random.Next(0, unsafePoints.Count); if (positionizeSkillInvoked(unsafePoints[pos])) { skillLifeDrainInvoked(); } } } if (wasCastingTeleport) { skillTeleportInvoked(null); return; } } if (Time.time - lastCastTime > sprites.GetAnim("Hitted (L)").GetDuration() && gotHit) { gotHit = false; lastCastTime = -1; } if (Time.time - lastCastTime > sprites.GetAnim("Dead (L)").GetDuration() && isDying) { sprites.StopAnim(); sprites.Hide(true); } if (Time.time - lastCastTime > sound_dying.length && isDying) { Instantiate(victory); for (int i = 0; i < instancedMob.Count; i++) { Destroy(instancedMob[i]); } instancedMob.Clear(); Destroy(gameObject); } magicInterrupted = false; return; } if (curHP == 0) { doAnimToDirection("Dead"); audio.PlayOneShot(sound_dying); Physics.IgnoreCollision(player.GetComponent <CharacterController>().collider, GetComponent <CharacterController>().collider, true); lastCastTime = Time.time; isDying = true; return; } if (curGlobalCooldown > 0) { doAnimToDirection("Standing"); return; } if (curLifeDrainCooldown == 0 && curHP < maxHP * 25 / 100) { wasCasting = true; wasCastingLifeDrain = true; lastCastTime = Time.time; if (nearPlayer(gameObject)) { isNearPlayer = true; } else { isNearPlayer = false; } } else if (curSummonCooldown == 0) { wasCasting = true; wasCastingSummon = true; lastCastTime = Time.time; if (transform.position == teleportPoint_central.transform.position) { isCentralized = true; } else { isCentralized = false; } } else if (curCurseCooldown == 0) { wasCasting = true; wasCastingCurse = true; lastCastTime = Time.time; if (nearPlayer(gameObject)) { isNearPlayer = true; } else { isNearPlayer = false; } } else if (curIcicleCooldown == 0) { wasCasting = true; wasCastingIcicle = true; lastCastTime = Time.time; } else if (curBlameCooldown == 0) { wasCasting = true; wasCastingBlame = true; lastCastTime = Time.time; if (transform.position == teleportPoint_central.transform.position) { isCentralized = true; } else { isCentralized = false; } } else if (curTeleportCooldown == 0 && nearPlayer(gameObject)) // there is no cooldown to attack, try to run { doAnimToDirection("Casting 1"); wasCasting = true; wasCastingTeleport = true; lastCastTime = Time.time; if (currentDirection == Direction.Left) { skillTeleport.DoAnim("Departure (L)"); } else { skillTeleport.DoAnim("Departure (R)"); } audio.PlayOneShot(sound_teleport); } else { doAnimToDirection("Standing"); } }