Ejemplo n.º 1
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            DusmanSec();
        }
        if (Input.GetButtonDown("1"))
        {
            if (secilenBirim != null)
            {
                TemelSaldiri();
            }
        }
        void DusmanSec()
        {
            Ray        isin = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit vurus;

            if (Physics.Raycast(isin, out vurus, 10000))
            {
                if (vurus.transform.tag == "düşman")
                {
                    secilenBirim    = vurus.transform.gameObject;
                    dusmanDurumKodu = secilenBirim.transform.gameObject.transform.GetComponent <DusmanDurumu>();
                }
            }
        }

        void TemelSaldiri()
        {
            dusmanDurumKodu.AlinanHasar(10);
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     oyuncu = GameObject.FindGameObjectWithTag("Player"); //Etiketi oyuncu olan oyun nesnesini bulduk.
     if (saglik != null)
     {
         saglik = GetComponent <IleriSaglik>();
     }
     else
     {
         Debug.Log("Boş referans beklentisi");
     }
     dusmanSagligi = GetComponent <DusmanDurumu>(); // Düşmanın sağlığını belirler.
     anim          = GetComponent <Animator>();     // Animator bileşenini etkinleştirdik.
 }
Ejemplo n.º 3
0
 void Start()
 {
     patlamaEtkisi = new GameObject("patlama", typeof(Rigidbody), typeof(BoxCollider), typeof(MeshRenderer));
     hedef         = GameObject.FindGameObjectWithTag("enemy").transform;
     dusman        = hedef.gameObject.GetComponent <DusmanDurumu>();
 }
Ejemplo n.º 4
0
 void Start()
 {
     hasarlar = GetComponent <DusmanDurumu>();
     hedef    = GameObject.FindGameObjectWithTag("enemy").transform;
     rb       = GetComponent <Rigidbody>();
 }