public static string BandDie(RaycastHit2D hit2D, string name, float time, GameObject bandPrefab) { MonoBehaviour com = FindObjectOfType <Component>() as MonoBehaviour; Hub hub = FindObjectOfType <Hub>(); if (hit2D.collider.name == "Player") { Band._health -= Time.deltaTime; if (Band._health == 0f || hub.slider.value == 0f) { Band.speed = 0f; Band._health = 0f; Band.reloadTime = 0f; Instantiate(bandPrefab, hit2D.collider.transform.position, Quaternion.identity); if (Band.animator == null || Band.rb == null) { Band.animator = null; Band.rb = null; } TopDownView.Call(name, time); Debug.Log("player die!"); } } return("Player"); }
private void Update() { start += Time.deltaTime; while (start >= end) { start--; Count(); start = 0; if (baseTime == 0) { Go.gameObject.SetActive(false); baseTime = 0; // Start Coroutine StartCoroutine(TopDownView.Call("Test", time)); Img.gameObject.SetActive(true); } } }
private void FixedUpdate() { RaycastHit2D hit2D = default(RaycastHit2D); if (_band != null) { if (Vector2.Distance(transform.position, _band.position) > stopDist) { //Debug.Log("stop!"); Vector3 enemyDir = new Vector2(_band.position.x, _band.position.y); //Vector2 targetDir = (_band.position - enemyDir).normalized; hit2D = Physics2D.Raycast(transform.position, enemyDir, stopDist + 2f, layer); r2.velocity = enemyDir - transform.position; if (hit2D.collider != null) { print("true!"); if (hit2D.collider.tag == "Player") { Band band = hit2D.collider.GetComponent <Band>(); Debug.DrawLine(transform.position, hit2D.point, Color.red, 100f); Band._health -= Time.deltaTime; Hub hub = FindObjectOfType <Hub>(); if (Band._health == 0f || hub.slider.value == 0f) { Band.speed = 0; Band._health = 0f; Band.reloadTime = 0f; Instantiate(bandPrefab, _band.position, Quaternion.identity).GetComponent <Rigidbody2D>(); StartCoroutine(TopDownView.Call("Menu", 3.5f)); Destroy(band.gameObject, 0.04f); } } } } } }
public void New_Game() { StartCoroutine(TopDownView.Call(name, time)); }
private void Start() { view = new TopDownView(button, button1, button2); }