10
|
1 using System.Collections;
|
|
2 using System.Collections.Generic;
|
|
3 using UnityEngine;
|
|
4
|
|
5 public class DeathZone : MonoBehaviour {
|
|
6
|
|
7 private GameObject target;
|
12
|
8 private Vector3 firstPoint;
|
10
|
9
|
|
10 public delegate void HitCallback (int n);
|
|
11 public HitCallback hitcallback;
|
|
12
|
|
13 public void SetHitCallback (HitCallback hc) {
|
|
14 this.hitcallback = hc;
|
|
15 }
|
|
16
|
|
17 private void Start () {
|
|
18 target = GameObject.FindGameObjectWithTag ("Player");
|
12
|
19 firstPoint = target.transform.position;
|
10
|
20 }
|
|
21
|
|
22 private void Update () {
|
|
23 Vector3 pos = target.transform.position;
|
|
24 this.transform.position = new Vector3 (pos.x, this.transform.position.y, pos.z);
|
|
25 }
|
|
26
|
|
27 private void OnTriggerEnter (Collider col) {
|
|
28 if (col.tag == "Player") {
|
|
29 target.transform.position = firstPoint;
|
|
30 if (hitcallback != null)
|
|
31 hitcallback (1);
|
|
32 }
|
|
33 }
|
|
34 }
|