Created
January 18, 2017 10:39
-
-
Save uruskan/e6496a99c4d4b804a33f6f80f673a85b to your computer and use it in GitHub Desktop.
Firing Script in c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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ü); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment