void OnTriggerEnter2D(Collider2D collision) { //Debug.Log (collision.name); if (!isInvincible && collision.CompareTag("Obstacle")) { StartCoroutine(Invincible(InvincibleTime)); if (collision.name.Contains("Bird")) { collision.GetComponent <Bird> ().AfterDamage(); } ComboManager.ComboBreak(); Debug.Log("Collide with house"); } if (collision.CompareTag("Gift")) { //Destroy(collision.gameObject); collision.gameObject.GetComponent <GiftController>().Collected(); GiftManager.GiftSentNum++; TimeManager.AddTime(3f); ComboManager.ComboUp(); //Debug.Log("Gift delivered"); } if (collision.CompareTag("Cadan")) { //Destroy(collision.gameObject); collision.transform.parent.GetComponent <Bird>().BirdGG(); TimeManager.AddTime(3f); ComboManager.ComboUp(); //Debug.Log("Gift delivered"); } }
private void StartGameClick() { // 开始计时 _timeManager.AddTime(gameTime, TimeCallBack); ScoreManager.Restart(); InvokeRepeating("CreateGopher", 0, 3); startBtn.gameObject.SetActive(false); }
void Start() { StartCoroutine(GenerateBlocks(45)); scoreManager = gameObject.AddComponent <ScoreManager>(); feverManager = gameObject.AddComponent <FeverManager>(); timeManager = gameObject.AddComponent <TimeManager>(); feverManager.RegisterOnFeverCallBack(() => timeManager.AddTime(5)); }
private void OnTriggerEnter2D(Collider2D collision) { scoreManager.AddToScore(score); if (plusTime != 0) { timeManager.AddTime(plusTime); } if (destroyable) { Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { if (other.GetComponent <BubbleMovement>() != null) { BubbleMovement bm = other.transform.GetComponent <BubbleMovement>(); switch (bm.bubbleType) { case BubbleMovement.BubbleType.bubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(pop, other.transform.position, other.transform.rotation); Destroy(other.transform.gameObject); break; case BubbleMovement.BubbleType.timeBubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(input.timePop, other.transform.position, other.transform.rotation); Destroy(other.transform.gameObject); break; case BubbleMovement.BubbleType.explodingBubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(input.explosion, other.transform.position, other.transform.rotation); Destroy(other.transform.gameObject); break; case BubbleMovement.BubbleType.laserBubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(input.laserpop, other.transform.position, other.transform.rotation); Destroy(other.transform.gameObject); input.laserModeCooldown = input.laserModeDelay; input.laserMode = true; break; } } }
public void Damage(float amount, Transform source) { // Refactor Enemy e = GetComponent <Enemy>(); e.Life -= amount; if (e.Life <= 0) { Target = null; CurrentDirection = Vector2.zero; StopAllCoroutines(); PlaySound(DyingSound); //Animator.SetTrigger("Dying"); Animator.Play("Dying"); enabled = false; GetComponent <BoxCollider2D>().enabled = false; TimeManager.AddTime(TimeBonus); if (Home != null) { Home.MemberKilled(AlienType); } return; // Make item drop, maybe add a animation for fading //Destroy(gameObject); } if (Target == null) { Target = source; } StopAllCoroutines(); StartCoroutine(ChaseTarget()); }
void OnTriggerEnter(Collider other) { if (other.GetComponent <BubbleMovement>() != null) { BubbleMovement bm = other.transform.GetComponent <BubbleMovement>(); switch (bm.bubbleType) { case BubbleMovement.BubbleType.bubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(pop, other.transform.position, other.transform.rotation); Destroy(other.transform.gameObject); break; default: break; } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Ball") { scoreManager.AddScore(scoreValue); timeManager.AddTime(timeValue, collectableColor); soundEffectsManager.audioSource.PlayOneShot(collectableAudioClip); Destroy(gameObject); if (scoreValue <= 0) { Instantiate(deathEffect.gameObject, transform.position, transform.rotation); Destroy(collision.gameObject); timeManager.ballDestroyed = true; } } if (collision.gameObject.tag == "Collectable") { Destroy(gameObject); } }
private void OnTriggerEnter(Collider other) { TimeControl.AddTime(TimeRecover); gameObject.SetActive(false); }
void AndroidControl() { if (Input.touchCount > 0) { /* Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); * RaycastHit hit; * if (Physics.Raycast(ray, out hit, Mathf.Infinity, bubbleLayer)) * { * Debug.Log(hit.point); * Destroy(hit.transform.gameObject); * } */ foreach (Touch t in Input.touches) { Ray ray = Camera.main.ScreenPointToRay(t.position); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, bubbleLayer)) { BubbleMovement bm = hit.transform.GetComponent <BubbleMovement>(); switch (bm.bubbleType) { case BubbleMovement.BubbleType.bubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(deathpop, hit.transform.position, hit.transform.rotation); Destroy(hit.transform.gameObject); break; case BubbleMovement.BubbleType.deathBubble: tm.LoseTime(bm.timeFracture); Instantiate(pop, hit.transform.position, hit.transform.rotation); Destroy(hit.transform.gameObject); break; case BubbleMovement.BubbleType.timeBubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(timePop, hit.transform.position, hit.transform.rotation); Destroy(hit.transform.gameObject); break; case BubbleMovement.BubbleType.explodingBubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(explosion, hit.transform.position, hit.transform.rotation); Destroy(hit.transform.gameObject); break; case BubbleMovement.BubbleType.laserBubble: sh.AddScore(); tm.AddTime(bm.timeFracture); Instantiate(laserpop, hit.transform.position, hit.transform.rotation); Destroy(hit.transform.gameObject); laserMode = true; break; } /* * if (bm.hostile) * { * tm.LoseTime(bm.timeFracture); * Instantiate(pop, hit.transform.position, hit.transform.rotation); * Destroy(hit.transform.gameObject); * } * else if (!bm.hostile) * { * sh.AddScore(); * tm.AddTime(bm.timeFracture); * Instantiate(deathpop, hit.transform.position, hit.transform.rotation); * Destroy(hit.transform.gameObject); * } * */ } } } }
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(); } } }