void MakeInstance() { if (instance == null) { instance = this; } }
void OnTriggerEnter2D(Collider2D hitInfo) { // Debug.Log(hitInfo.name); DestroyOffscreen enemy = hitInfo.GetComponent <DestroyOffscreen>(); if (enemy != null) { enemy.TakeDamage(damage); } }
void OnTriggerEnter2D(Collider2D other) { //Debug.Log("OnCollisionEnter");//Debug.Log ("HHHHHH"); //Destroy(other.gameObject); if (this.ActiveMode == true){ if ((other.gameObject.tag != "Player") && (other.gameObject.tag != "Drop" )){ obstacle = other.gameObject.GetComponent<DestroyOffscreen> (); obstacle.OnOutOfBounds(); } } }
void OnTriggerEnter2D(Collider2D hitInfo) { // Debug.Log(hitInfo.name); DestroyOffscreen enemy = hitInfo.GetComponent <DestroyOffscreen>(); if (enemy != null) { enemy.TakeDamage(damage); } // Instantiate(impactEffect, transform.position, transform.rotation); GameObjetcUtil.Destroy(gameObject); }
void ResetGame() { spawner.active = true; //create player and set spawn height player = GameObjectUtility.Instantiate(playerPrefab, new Vector3(0f, (Screen.height / PixelPerfectCamera.pixelsToUnits) / 2 + 100.0f, 0f)); //Get component for destroyOffscreen DestroyOffscreen playerDestroyScript = player.GetComponent <DestroyOffscreen>(); //hook up destroyOffscreen delegate to execute OnPlayerKilled when called playerDestroyScript.DestroyCallback += OnPlayerKilled; gameStarted = true; continueText.canvasRenderer.SetAlpha(0f); timeElapsed = 0f; beatBestTime = false; }
void OnPlayerKilled() { spawner.active = false; //Get component for destroyOffscreen DestroyOffscreen playerDestroyScript = player.GetComponent <DestroyOffscreen>(); //unlink delegate for garbage caller playerDestroyScript.DestroyCallback -= OnPlayerKilled; //reset velocity of player player.GetComponent <Rigidbody2D>().velocity = Vector2.zero; timeManager.ManipulateTime(0f, 5.5f); gameStarted = false; continueText.text = "PRESS ANY BUTTON TO RESTART"; if (timeElapsed > bestTime) { bestTime = timeElapsed; PlayerPrefs.SetFloat("BestTime", bestTime); beatBestTime = true; } }
private void Awake() { _destroyOffscreen = GetComponent <DestroyOffscreen>(); }