private void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <PlayerController>()) { Lose.LoseGame(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <PlayerController>()) { Lose.LoseGame(); } }
// Update is called once per frame void Update() { this.transform.localRotation = Quaternion.identity; if ((Input.GetKeyDown(KeyCode.UpArrow) && onGround) || (SwipeScript.GetTouch() == 0 && onGround)) { GetComponent <ConstantForce2D>().force = new Vector3(0f, 30f, 0f); //animator.SetTrigger("Flip"); this.transform.localScale = new Vector3(0.9764434f, -0.9764434f, 0.9764434f); onGround = false; GetComponent <AudioSource>().Play(); } if ((Input.GetKeyDown(KeyCode.DownArrow) && onGround) || (SwipeScript.GetTouch() == 1 && onGround)) { GetComponent <ConstantForce2D>().force = new Vector3(0f, -30f, 0f); this.transform.localScale = new Vector3(0.9764434f, 0.9764434f, 0.9764434f); onGround = false; GetComponent <AudioSource>().Play(); } if (Input.GetMouseButtonDown(0)) { GetComponent <ConstantForce2D>().force = new Vector3(0f, -1 * GetComponent <ConstantForce2D>().force.y, 0f); this.transform.localScale = new Vector3(this.transform.localScale.x, -1 * transform.localScale.y, transform.localScale.z); onGround = false; GetComponent <AudioSource>().Play(); } if (this.transform.position.x < 0) { Lose.LoseGame(); } }
void Update() { if (_score < 0) { _lose.LoseGame(_score); } }
void FixedUpdate() { _time = _time - Time.deltaTime; if (_time < 0) { _lose.LoseGame(_scoreManager.Output()); } }
void Update() { if (Input.GetKeyDown(KeyCode.Mouse0) && !_pauseMenu._pauseMenuPanel.activeSelf) { MPointerEventData = new PointerEventData(MEventSystem); MPointerEventData.position = Input.mousePosition; List <RaycastResult> results = new List <RaycastResult>(); MRaycaster.Raycast(MPointerEventData, results); bool IsOnClicable = false; if (Time.timeScale == 0f) { IsOnClicable = true; } foreach (RaycastResult result in results) { if (result.gameObject.name.Contains("SimpleBird")) { result.gameObject.GetComponent <DeleteOnClick>().Destroy(); _scoreManager.AddScore(1); _streak += 1; _streakSlider.value = _streak; _clickAudioManager.ClickOnBird(); IsOnClicable = true; break; } if (result.gameObject.name.Contains("Clock")) { result.gameObject.GetComponent <DeleteOnClick>().Destroy(); _timeManager.AddTime(3); _clickAudioManager.ClickOnClock(); IsOnClicable = true; break; } if (result.gameObject.name.Contains("MoreTime")) { result.gameObject.GetComponent <DeleteOnClick>().Destroy(); _timeManager.AddTime(2); _clickAudioManager.ClickOnClock(); IsOnClicable = true; break; } if (result.gameObject.name.Contains("TimeStopper")) { result.gameObject.GetComponent <DeleteOnClick>().Destroy(); GameObject.Find("LevelManager").GetComponent <TimeStopper>().TimeStopperStart(); _clickAudioManager.ClickOnClock(); IsOnClicable = true; break; } if (result.gameObject.name.Contains("Gourgule")) { result.gameObject.GetComponent <DeleteOnClick>().Destroy(); _scoreManager.AddScore(2); _streak += 1; _streakSlider.value = _streak; _clickAudioManager.ClickOnBird(); IsOnClicable = true; break; } if (result.gameObject.name.Contains("Button")) { IsOnClicable = true; break; } if (result.gameObject.name.Contains("Ghost")) { Lose _lose = GameObject.Find("LevelManager").GetComponent <Lose>(); _lose.LoseGame(_scoreManager.Output()); } } if (!IsOnClicable) { DeleteStreak(); } if (_streak == 5) { _spawnManager.SpawnClock(); DeleteStreak(); } } }