using System; using System.Collections; using PowerTools; using UnityEngine; public class KillAnimation : MonoBehaviour { public AnimationClip BlurAnim; public DeadBody bodyPrefab; public Vector3 BodyOffset; public IEnumerator CoPerformKill(PlayerControl source, PlayerControl target) { bool isParticipant = PlayerControl.LocalPlayer == source || PlayerControl.LocalPlayer == target; PlayerPhysics sourcePhys = source.MyPhysics; KillAnimation.SetMovement(source, false); KillAnimation.SetMovement(target, false); if (isParticipant) { Camera.main.GetComponent().Locked = true; } target.Die(DeathReason.Kill); SpriteAnim sourceAnim = source.GetComponent(); yield return new WaitForAnimationFinish(sourceAnim, this.BlurAnim); source.NetTransform.SnapTo(target.transform.position); sourceAnim.Play(sourcePhys.IdleAnim, 1f); KillAnimation.SetMovement(source, true); DeadBody deadBody = UnityEngine.Object.Instantiate(this.bodyPrefab); Vector3 vector = target.transform.position + this.BodyOffset; vector.z = vector.y / 1000f; deadBody.transform.position = vector; deadBody.ParentId = target.PlayerId; target.SetPlayerMaterialColors(deadBody.GetComponent()); KillAnimation.SetMovement(target, true); if (isParticipant) { Camera.main.GetComponent().Locked = false; } yield break; } public static void SetMovement(PlayerControl source, bool canMove) { source.moveable = canMove; source.MyPhysics.ResetAnim(false); source.NetTransform.enabled = canMove; source.MyPhysics.enabled = canMove; source.NetTransform.Halt(); } }