-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoku.cs
41 lines (34 loc) · 859 Bytes
/
Goku.cs
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
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(Defender))]
public class Goku : MonoBehaviour {
private Animator animator;
private Health health;
private GameObject currentTarget;
// Use this for initialization
void Start () {
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D collider){
GameObject attacker = collider.gameObject;
if(attacker.GetComponent<Attacker>()){
animator.SetBool("isAttacking", true);
Attack(attacker);
}
}
public void Attack(GameObject target){
currentTarget = target;
}
// Performed by animator at attack time
public void StrikeCurrentTarget(float damage){
if(currentTarget){
health = currentTarget.GetComponent<Health>();
if(health){
health.TakeDamage(damage);
}
}
}
}