summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Avatar/Avatar_Hurt.cs
blob: c6b840b9f96c98bf2d106613a0599a7cd24235fe (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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public partial class Avatar : MonoBehaviour, IInteractable
{
    void ApplyHit(HitDefination hit)
    {
        if(hit.hurtAddForce.magnitude != 0)
        {
            m_Body.AddForce(hit.hurtAddForce);
        }

		// 切换到受击状态
		switch(hit.type)
		{
			case HitType.Light: m_StateController.SwitchToState(m_StateLightHurt); break;
			case HitType.Midium: m_StateController.SwitchToState(m_StateMidiumHurt); break;
			case HitType.Heavy: m_StateController.SwitchToState(m_StateHeavyHurt); break;
			case HitType.Ground: m_StateController.SwitchToState(m_StateGroundHurt); break;
			case HitType.Air: m_StateController.SwitchToState(m_StateAirHurt); break;
			default:
				m_StateController.SwitchToState(m_StateLightHurt);
				break;
		}

        // spark
        if(hit.sparkName != string.Empty)
        {
            if(hit.sparkHostType == HitSparkHost.Center)
            {
                SparksManager.Instance.PlaySpark(hit.sparkName, m_Hips);
            }
        }

	}

}