-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fire.cs
43 lines (40 loc) · 878 Bytes
/
Fire.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
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ateş : MonoBehaviour {
public float saldırıHızı = 0.5f;
public int saldırıGücü = 10;
GameObject oyuncu;
bool düsmanMenzil;
float zamanlayici;
Can can;
void Awake(){
oyuncu = GameObject.FindGameObjectWithTag("oyuncu");
can = oyuncu.GetComponent<Can>();
}
void OnTriggerEnter(Collider other){
if(other.gameObject == oyuncu){
düsmanMenzil = true;
}
}
void OnTriggerExit(Collider other){
if (other.gameObject == oyuncu){
düsmanMenzil = false;
}
}
void Update () {
zamanlayici += Time.deltaTime;
if(zamanlayici >= saldırıHızı){
Saldır();
}
if(can.simdikican <= 0){
Debug.Log("Öldün by Ateş Script");
}
}
void Saldır(){
zamanlayici = 0f;
if (can.simdikican > 0){
can.HasarAl(saldırıGücü);
}
}
}