blob: d6e980ac0316df54454cff92cf6dfa2910a99bc8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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<FollowerCamera>().Locked = true;
}
target.Die(DeathReason.Kill);
SpriteAnim sourceAnim = source.GetComponent<SpriteAnim>();
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<DeadBody>(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<Renderer>());
KillAnimation.SetMovement(target, true);
if (isParticipant)
{
Camera.main.GetComponent<FollowerCamera>().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();
}
}
|