Created
January 18, 2017 10:39
-
-
Save uruskan/37069232ffdde598ef4eae6f7ab235ce to your computer and use it in GitHub Desktop.
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; | |
using UnityEngine.UI; | |
public class Can : MonoBehaviour { | |
public int normalcan = 100; | |
public int simdikican; | |
public Slider HPSlider; | |
public Image damageImage; | |
bool ölüm; | |
bool damaged; | |
Karakter karakter; | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Awake() { | |
karakter = GetComponent<Karakter>(); | |
normalcan = simdikican; | |
} | |
public void HasarAl (int saldırıGücü){ | |
damaged = true; | |
simdikican -= saldırıGücü; | |
HPSlider.value = simdikican; | |
if (simdikican <= 0 && !ölüm){ | |
Öldü(); | |
} | |
} | |
void Öldü(){ | |
ölüm = true; | |
Debug.Log("Öldün Çık"); | |
karakter.enabled = false; | |
} | |
void Update () { | |
} | |
} |
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