public override void changeAnimation(string animationName, tk2dAnimatedSprite.AnimationCompleteDelegate callback) { if (getSprite().clipId == -1 || getSprite().anim.clips[getSprite().clipId].name.ToLower() != animationName.ToLower() || !getSprite().isPlaying()) { getSprite().Play(animationName); getSprite().animationCompleteDelegate = callback; if (attackAnimations.Contains(animationName.ToLower()) && characterSprite.anim.clips[characterSprite.clipId].name.ToLower() != animationName.ToLower()) { characterSprite.Play(animationName); characterSprite.animationCompleteDelegate = backToIdleAfterAttack; } else if (animationName.ToLower() == "open") { characterSprite.Play(animationName); characterSprite.animationCompleteDelegate = backToIdleAfterAttack; } else if (animationName.ToLower() == "harmed") { characterSprite.Play(animationName); characterSprite.animationCompleteDelegate = null; } else if (animationName.ToLower() == "death") { characterSprite.Play(animationName); characterSprite.animationCompleteDelegate = null; } else if (animationName.ToLower() == "idle") { characterSprite.Play("idle"); characterSprite.animationCompleteDelegate = null; } } }
public override void changeAnimation(string animationName, tk2dAnimatedSprite.AnimationCompleteDelegate callback) { string currentAnim = getSprite().anim.clips[getSprite().clipId].name; float time = 0.0f; //if is a new animation if (currentAnim.ToLower() != animationName.ToLower()) { getSprite().Play(animationName); getSprite().animationCompleteDelegate = callback; } else //is the current animation, so get its time { time = getSprite().getClipTime(); } //if the weapon has the same animation if (getWeaponSprite() != null && getWeaponSprite().anim.GetClipIdByName(animationName) != -1) { getWeaponSprite().Play(animationName, time); } //if the shield has the same animation if (getShieldSprite() != null && getShieldSprite().anim.GetClipIdByName(animationName) != -1) { getShieldSprite().Play(animationName, time); } /* * if(getSprite().anim.clips[getSprite().clipId].name.ToLower()!=animationName.ToLower() || !getSprite().isPlaying()) * { * getSprite().Play(animationName); * getSprite().animationCompleteDelegate = callback; * charAnim = true; * } * * if(getWeaponSprite() != null) * { * if(charAnim && getWeaponSprite().anim.GetClipIdByName(animationName)!=-1) * { * getWeaponSprite().Play(animationName); * } * } * * if(getShieldSprite() != null) * { * if(charAnim && getShieldSprite().anim.GetClipIdByName(animationName)!=-1) * { * getShieldSprite().Play(animationName); * } * } */ }
public virtual void changeAnimation(string animationName, tk2dAnimatedSprite.AnimationCompleteDelegate callback) { tk2dAnimatedSprite sprite = GetComponent <tk2dAnimatedSprite>(); if (sprite) { if (sprite.anim.GetClipIdByName(animationName) != -1) { sprite.Play(animationName); } } }
public override void changeAnimation(string animationName, tk2dAnimatedSprite.AnimationCompleteDelegate callback) { if (currentAttack != null && animationName.ToLower() == currentAttack.attackAnimation.ToLower()) { hasEndAttackChain = false; } if (animationName == "idle" || animationName == "run") { swordIsVisible = true; } else { swordIsVisible = false; } base.changeAnimation(animationName, callback); }
public tk2dAnimatedSprite getEffect(string name, Vector3 pos, Transform parent, bool isLoop = true, tk2dAnimatedSprite.AnimationCompleteDelegate completeDelegate = null) { tk2dAnimatedSprite eff = getAnimatedSprite(); eff.gameObject.SetActive(true); //eff.gameObject.name = name; eff.transform.parent = parent; eff.transform.position = pos; eff.Play(name, 0.0f); if (isLoop) { eff.CurrentClip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop; eff.animationCompleteDelegate = null; //completeGetPopEffect; } else { eff.CurrentClip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; eff.animationCompleteDelegate = completeDelegate; } return(eff); }