Mercurial > hg > Members > kazuma > JungleforUnity
comparison Assets/Application/Scripts/DeathZone.cs @ 10:3fefb9f9025d
put Attribute class.
author | Kazuma Takeda |
---|---|
date | Fri, 20 Jan 2017 07:30:26 +0900 |
parents | |
children | b55d586dd4eb |
comparison
equal
deleted
inserted
replaced
9:bbab930748c4 | 10:3fefb9f9025d |
---|---|
1 using System.Collections; | |
2 using System.Collections.Generic; | |
3 using UnityEngine; | |
4 | |
5 public class DeathZone : MonoBehaviour { | |
6 | |
7 private GameObject target; | |
8 private Vector3 firstPoint = new Vector3(0.5f, 2f, 0.5f); | |
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"); | |
19 } | |
20 | |
21 private void Update () { | |
22 Vector3 pos = target.transform.position; | |
23 this.transform.position = new Vector3 (pos.x, this.transform.position.y, pos.z); | |
24 } | |
25 | |
26 private void OnTriggerEnter (Collider col) { | |
27 if (col.tag == "Player") { | |
28 target.transform.position = firstPoint; | |
29 if (hitcallback != null) | |
30 hitcallback (1); | |
31 } | |
32 } | |
33 } |