Created
January 18, 2017 21:01
-
-
Save uruskan/7e402fb3985699037550fae50ffce0c1 to your computer and use it in GitHub Desktop.
Çalışan Saldırı , Can ve CanBarı Scriptinde Gece Gece Köklü Değişiklikler Yapmadan Önceki Yedek.
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 hp = 100; | |
public int simdikiCan; | |
public Slider hpslider; | |
public GameObject rpgci; | |
// Use this for initialization | |
void Start () { | |
} | |
public void hasarAl(int saldırıGücü) { | |
simdikiCan = hp - saldırıGücü; | |
hp = simdikiCan; | |
hpslider.value = simdikiCan; | |
if (simdikiCan <= 0) { | |
Debug.Log("Öldüm Çıktım !"); | |
Destroy(gameObject); | |
rpgci.SetActive(false); | |
} | |
if (simdikiCan > 0) { | |
Debug.Log(simdikiCan +"Canım Kaldı."); | |
} | |
} | |
// Update is called once per frame | |
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 RpgciKontrol : MonoBehaviour | |
{ | |
public GameObject EngineRight; | |
public GameObject EngineLeft; | |
public GameObject EngineUpleft; | |
public GameObject EngineUpright; | |
public int güc = 50; | |
GameObject jet; | |
Rigidbody2D rb; | |
// Use this for initialization | |
void Start() | |
{ | |
jet = GameObject.FindGameObjectWithTag("jet"); | |
rb = jet.GetComponent<Rigidbody2D>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKey(KeyCode.W)) | |
{ | |
rb.AddForce(transform.up * güc); | |
EngineUpleft.SetActive(true); | |
EngineUpright.SetActive(true); | |
} | |
else | |
{ | |
EngineUpleft.SetActive(false); | |
EngineUpright.SetActive(false); | |
} | |
if (Input.GetKey(KeyCode.D)) | |
{ | |
rb.AddForce(transform.right * güc); | |
EngineLeft.SetActive(true); | |
} | |
else | |
{ | |
EngineLeft.SetActive(false); | |
} | |
if (Input.GetKey(KeyCode.S)) | |
{ | |
rb.AddForce(-transform.up * güc); | |
EngineUpleft.SetActive(false); | |
EngineUpright.SetActive(false); | |
} | |
if (Input.GetKey(KeyCode.A)) | |
{ | |
rb.AddForce(-transform.right * güc); | |
EngineRight.SetActive(true); | |
} | |
else { | |
EngineRight.SetActive(false); | |
} | |
} | |
} |
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 Saldırı : MonoBehaviour | |
{ | |
public GameObject Silah; | |
public int saldırıGücü = 10; | |
public Can can; | |
public float menzil = 100.0f; | |
public float saldırıAraligi = 0.25f; | |
private float beklemesuresi; | |
// Use this for initialization | |
void Start() | |
{ | |
can = can.GetComponent<Can>(); | |
beklemesuresi = 0f; | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (beklemesuresi > 0) | |
{ | |
beklemesuresi -= Time.deltaTime; | |
} | |
RaycastHit2D hit; | |
hit = Physics2D.Raycast(transform.position, Vector2.right, menzil); | |
Debug.DrawRay(transform.position, Vector2.right, Color.red); | |
if (Input.GetButton("Fire1")) | |
{ | |
if (beklemesuresi <= 0) | |
{ | |
if (hit != null && hit.collider.tag == "hedef") | |
{ | |
Debug.Log(hit.collider.name); | |
can.hasarAl(saldırıGücü); | |
beklemesuresi = beklemesuresi + saldırıAraligi; | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment