public void DeleteRow() { for (int y = 0; y < gridHeight; y++) { if (IsFullRowAt(y)) { DestroyRow(y); MoveRowDown(y + 1); PlayLineClearedAudio(); shake.CamShake(); y--; } } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == "Planet 1") { ContactPoint2D contact = collision.contacts[0]; Vector2 pos = contact.point; ShowEffeccct(playerHitEffecct, pos); transform.position = pos; SetPlayerUp(gameObject.transform, collision.gameObject.transform); gameObject.transform.SetParent(collision.collider.gameObject.transform); isGrounded = true; shake.CamShake(); } }
void OnTriggerEnter(Collider col) { if (col.tag == "Block") { shake.CamShake(); rb.isKinematic = true; FindObjectOfType <AudioManager>().Play("Knife"); score.PinCount++; if (score.PinCount > PlayerPrefs.GetInt("HighScore", 0)) { PlayerPrefs.SetInt("HighScore", score.PinCount); highScore.text = score.PinCount.ToString(); } } else { Restart(); } }
private void ProcessHit(DamageDealer damageDealer) { health -= damageDealer.GetDamage(); damageDealer.Hit(); //Lost Relic sr.material = matWhite; if (health <= 0) { Die(); } //Lost Relic else { Invoke("ResetMaterial", flashLength); shake.CamShake(); } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { // Get a reference to the player component. Player player = other.transform.GetComponent <Player>(); // check for null. if (player != null) { // assign 1 damage to the player. player.setPlayerDamage(1); camShakeAnim.CamShake(); } //_explosionSound.Play(); // Now destroy this Laser. Destroy(this.gameObject, 2.8f); } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { shake.CamShake(); Instantiate(Effect, transform.position, Quaternion.identity); other.GetComponent <Player>().Health -= Damage; FindObjectOfType <AudioManager>().Play("Impact"); if (other.GetComponent <Player>().Health >= 1) { FindObjectOfType <AudioManager>().Play("PainSound"); } if (other.GetComponent <Player>().Health == 0) { FindObjectOfType <AudioManager>().Play("Explosion"); } Debug.Log("Awww the pain...." + other.GetComponent <Player>().Health); Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { Instantiate(Killeffect, transform.position, Quaternion.identity); player.currentHealth--; Destroy(gameObject); } if (other.CompareTag("Projectile")) { Destroy(other.gameObject); camRipple.RippleEffect(); shake.CamShake(); EnemyHealth--; if (EnemyHealth <= 0) { Score.scoreValue += 1; Instantiate(Killeffect, transform.position, Quaternion.identity); Destroy(gameObject); } } }
void OnCollisionEnter2D(Collision2D hit) { if (hit.gameObject.tag == "Nave") { if (gameObject.tag == "Meteor") { if (!animacionOff) { shake.CamShake(); effectMeteor = Instantiate(effectMeteor); effectMeteor.transform.position = this.transform.position; Destroy(this.gameObject); Destroy(effectMeteor, 1f); FindObjectOfType <AudioManager>().Play("hit"); } } else { Destroy(this.gameObject); } } }
// Update is called once per frame public void Damage() { if (isDead == true) { return; } Health--; isHit = true; if (Health <= 0 && !isDead) { isDead = true; Destroy(gameObject); Instantiate(effect, transform.position, Quaternion.identity); shake.CamShake(); } }
void Update() { if (timeBtwAttack <= 0) { if (Input.GetKey(KeyCode.Space)) { anim.SetTrigger("attack"); shake.CamShake(); Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemy); for (int i = 0; i < enemiesToDamage.Length; i++) { enemiesToDamage[i].GetComponent <Enemy>().TakeDamage(damage); Debug.Log("damged"); } } timeBtwAttack = startTimeBtwAttack; } else { timeBtwAttack -= Time.deltaTime; } }
void Update() { healthDisplay.text = health.ToString(); for (int i = 0; i < hearts.Length; i++) { if (i < health) { hearts[i].enabled = true; } else { hearts[i].enabled = false; } } if (health <= 0) { gameOver.SetActive(true); Destroy(gameObject); } transform.position = Vector2.MoveTowards(transform.position, targetPos, speed * Time.deltaTime); // Mobile input if (Input.touchCount > 0) { Touch touch = Input.touches[0]; if (touch.phase == TouchPhase.Began) { if ((touch.position.y > Screen.height / 2) && transform.position.y < maxHeight) { Instantiate(effect, transform.position, Quaternion.identity); Instantiate(tapSound, transform.position, Quaternion.identity); shake.CamShake(); targetPos = new Vector2(transform.position.x, transform.position.y + yStep); } else if ((touch.position.y < Screen.height / 2) && transform.position.y > minHeight) { Instantiate(effect, transform.position, Quaternion.identity); Instantiate(tapSound, transform.position, Quaternion.identity); shake.CamShake(); targetPos = new Vector2(transform.position.x, transform.position.y - yStep); } } } // PC input if (Input.GetKeyDown(KeyCode.UpArrow) && transform.position.y < maxHeight) { Instantiate(effect, transform.position, Quaternion.identity); Instantiate(tapSound, transform.position, Quaternion.identity); shake.CamShake(); targetPos = new Vector2(transform.position.x, transform.position.y + yStep); } else if (Input.GetKeyDown(KeyCode.DownArrow) && transform.position.y > minHeight) { Instantiate(effect, transform.position, Quaternion.identity); Instantiate(tapSound, transform.position, Quaternion.identity); shake.CamShake(); targetPos = new Vector2(transform.position.x, transform.position.y - yStep); } }
void OnCollisionEnter2D(Collision2D collisionInfo) //this helps reset the jump , this void collision also detects enemy projectiles for witchtime { if (collisionInfo.gameObject.tag == "Floor") //if you collide with the tagged floor object { onFloor = true; //Then you are on the floor hasDashed = false; downDash = false; } if (collisionInfo.gameObject.tag == "Door" && hasDashed == true) { shake.CamShake(); //calls cam shake anim ticksound.PlayOneShot(SmashSound, 0.7f); Instantiate(doorEffect, transform.position, Quaternion.identity); //instantiates the particle system Destroy(collisionInfo.gameObject); } if (collisionInfo.gameObject.tag == "Key") { Destroy(collisionInfo.gameObject); Instantiate(keyUnlockEffect, transform.position, Quaternion.identity); //instantiates the particle system UnlockedMech1 = true; ticksound.PlayOneShot(GotKey, 0.7f); } if (collisionInfo.gameObject.tag == "SecondKey") { Destroy(collisionInfo.gameObject); Instantiate(keyUnlockEffect, transform.position, Quaternion.identity); //instantiates the particle system UnlockedMech2 = true; ticksound.PlayOneShot(GotKey, 0.7f); } if (collisionInfo.gameObject.tag == "DownSmash" && downDash == true) { shake.CamShake(); //calls cam shake anim ticksound.PlayOneShot(SmashSound, 0.7f); Instantiate(doorEffect, transform.position, Quaternion.identity); //instantiates the particle system Destroy(collisionInfo.gameObject); } else if (collisionInfo.gameObject.tag == "DownSmash" && downDash == false) { onFloor = true; //Then you are on the floor } if (collisionInfo.gameObject.tag == "Lava" && EnteredPoint1 == true) { transform.position = spawnpoint.position; shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Lava" && EnteredPoint2 == true) { shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system transform.position = spawnpoint2.position; ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Lava" && EnteredPoint3 == true) { shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system transform.position = spawnpoint3.position; ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Lava" && EnteredPoint4 == true) { shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system transform.position = spawnpoint4.position; ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Lava" && EnteredPoint5 == true) { shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system transform.position = spawnpoint5.position; ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Lava" && EnteredPoint6 == true) { shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system transform.position = spawnpoint6.position; ticksound.PlayOneShot(Death, 0.7f); } if (collisionInfo.gameObject.tag == "SwitchOff") { myBody.velocity = new Vector2(myBody.velocity.x, myBody.velocity.y + boostamount); //X axis velo is unaffected, but Y axis is affected by public Jump Height float. Allow double jump. Destroy(collisionInfo.gameObject); } if (collisionInfo.gameObject.tag == "Enemy" && EnteredPoint1 == true) { transform.position = spawnpoint.position; shake.CamShake(); //calls cam shake anim Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Enemy" && EnteredPoint2 == true) { shake.CamShake(); //calls cam shake anim transform.position = spawnpoint2.position; Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Enemy" && EnteredPoint3 == true) { shake.CamShake(); //calls cam shake anim transform.position = spawnpoint3.position; Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Enemy" && EnteredPoint4 == true) { shake.CamShake(); //calls cam shake anim transform.position = spawnpoint4.position; Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Enemy" && EnteredPoint5 == true) { shake.CamShake(); //calls cam shake anim transform.position = spawnpoint5.position; Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } else if (collisionInfo.gameObject.tag == "Enemy" && EnteredPoint6 == true) { shake.CamShake(); //calls cam shake anim transform.position = spawnpoint6.position; Instantiate(dashEffect, transform.position, Quaternion.identity); //instantiates the particle system ticksound.PlayOneShot(Death, 0.7f); } }
void Movement() { float moveX = 0f; float moveY = 0f; if (Input.GetKey(KeyCode.W)) { moveY = +1f; } if (Input.GetKey(KeyCode.S)) { moveY = -1f; } if (Input.GetKey(KeyCode.A)) { moveX = -1f; } if (Input.GetKey(KeyCode.D)) { moveX = +1f; } transform.position += new Vector3(moveX, moveY) * playerSpeed * Time.deltaTime; bool isIdle = moveX == 0 && moveY == 0; if (!isIdle) { anim.SetTrigger("Move"); } else { anim.SetTrigger("Idle"); } //face mouse position Vector3 mousePosition = Input.mousePosition; mousePosition = Camera.main.ScreenToWorldPoint(mousePosition); //Debug.Log(mousePosition); Vector2 direction = new Vector2(mousePosition.x - transform.position.x, mousePosition.y - transform.position.y); transform.right = direction; if (Input.GetKeyDown(KeyCode.Mouse0)) { //anim.SetTrigger("Shoot"); //Transform bulletTransform = Instantiate(bullet,gunEndPoint.transform.position,Quaternion.identity); //Vector3 shootDirection = (mousePosition - gunEndPoint.transform.position).normalized; //bulletTransform.GetComponent<Bullet>().Setup(shootDirection); float bulletForce = 20f; GameObject bulletTransform = Instantiate(bullet, gunEndPoint.transform.position, gunEndPoint.rotation); Rigidbody2D rb = bulletTransform.GetComponent <Rigidbody2D>(); rb.AddForce(gunEndPoint.up * bulletForce, ForceMode2D.Impulse); shake.CamShake(5f, 0.1f); audio.PlayOneShot(audio.clip); GameObject bulletFallRigid = Instantiate(bulletFall, gunEndPoint.transform.position, gunEndPoint.rotation); Rigidbody2D rb2 = bulletFallRigid.GetComponent <Rigidbody2D>(); rb2.AddForce(bulletFallRigid.transform.right * -5f, ForceMode2D.Impulse); rb2.AddTorque(60f, ForceMode2D.Impulse); Destroy(bulletFallRigid, 0.5f); } }
private void Update() { try { playerTop = GameObject.Find("PlayerTop(Clone)"); playerBot = GameObject.Find("PlayerBot(Clone)"); playerTopPos = playerTop.transform.position; playerBotPos = playerBot.transform.position; } catch (Exception e) { return; } if (transform.position.y > -10) { playerNearby = Math.Abs(transform.position.x - playerTopPos.x) <= 20 || Math.Abs(transform.position.x - playerBotPos.x) <= 20; } else { playerNearby = Math.Abs(transform.position.x - playerTopPos.x) <= 25 || Math.Abs(transform.position.x - playerBotPos.x) <= 25; } currentHealth = GetComponent <Enemy>().currentHealth; isGrounded = IsGrounded(); if (playerNearby && !started) { movingToPhase2 = true; started = true; GameObject objective = GameObject.Find("Canvas").transform.Find("ObjImage").transform.Find("Objective") .gameObject; objective.GetComponent <TextMeshProUGUI>().text = "Objective : Chase Blob King"; } if (movingToPhase2) { if (Math.Abs(transform.position.x - waypoints[0].transform.position.x) > 0) { transform.position = Vector2.MoveTowards(transform.position, new Vector2(waypoints[0].transform.position.x, transform.position.y), speed * Time.deltaTime); } else { movingToPhase2 = false; phase2 = true; } } if (phase2 && nbJump < nbJumpBeforeDestruction) { if (!isCastlePhasePlaying) { isCastlePhasePlaying = true; coroutine = StartCoroutine(CastlePhase()); } if (transform.position.y > 0) { falling = true; } if (isGrounded && falling) { nbJump += 1; DestroyTiles(); // photonView.RPC("DestroyTiles", RpcTarget.All); photonView.RPC("InstanciateGroundParticles", RpcTarget.All, JumpGroundParticles.name, transform.position.x, transform.position.y); // PhotonNetwork.Instantiate(JumpGroundParticles.name, transform.position, Quaternion.identity, 1); falling = false; // Shake Camera // photonView.RPC("ShakeCamera1", RpcTarget.All); shake.camAnim = GameObject.Find("Camera1").GetComponent <Animator>(); shake.CamShake(); } } else if (phase2 && nbJump >= nbJumpBeforeDestruction && isGrounded && !hasdestroyedCastleAndGround) { photonView.RPC("DestroyCastleAndGround", RpcTarget.All); phase2 = false; isCastlePhasePlaying = true; movingToPhase3 = true; isGrounded = false; hasdestroyedCastleAndGround = true; } if (movingToPhase3 && IsGrounded()) { rigidbody2d.isKinematic = true; rigidbody2d.simulated = false; if (Math.Abs(transform.position.x - waypoints[1].transform.position.x) <= 0.1) { // CHECK IF there is a player nearby if (playerNearby) { movingToPhase3 = false; phase3 = true; GameObject objective = GameObject.Find("Canvas").transform.Find("ObjImage").transform.Find("Objective") .gameObject; objective.GetComponent <TextMeshProUGUI>().text = "Objective : \nKill the harpies to stop the king from escaping"; } } transform.position = Vector2.MoveTowards(transform.position, new Vector2(waypoints[1].transform.position.x, transform.position.y), speed * Time.deltaTime); } if (phase3) { // Harpies deploy cables if (!hasCalledHarpies) { CallHarpies(); hasCalledHarpies = true; } else { if (!hasCalledIgnition) { foreach (var rocketHarpy in rocketHarpies) { rocketHarpy.ignition = true; } hasCalledIgnition = true; } } // Everybody moves UP at same speed Vector2 dest = new Vector2(transform.position.x, waypoints[3].transform.position.y); // if all harpies are dead you win, the bitch falls in lava if (CheckWinCondition() && !hasDestroyedlast) { abdcef = true; photonView.RPC("callPlayers", RpcTarget.All); rigidbody2d.isKinematic = false; rigidbody2d.simulated = true; if (isGrounded && !hasDestroyedlast) { // Shake Camera shake.camAnim = GameObject.Find("CameraOnBlob").GetComponent <Animator>(); shake.CamShake(); photonView.RPC("DestroyLastTilemap", RpcTarget.All); hasDestroyedlast = true; } } else { if (hasDestroyedlast) { if (isTouchingDanger()) { GetComponent <Enemy>().TakeDamage(167); } } else { // MOVE UP WITH THEM // CHeck if one of them is unreachable if (HarpiesEscaped()) { isEscaping = true; photonView.RPC("callPlayers2", RpcTarget.All); } transform.position = Vector2.MoveTowards(transform.position, dest, escapeSpeed * Time.deltaTime); } } } modifyPhysics(); }
private void OnTriggerEnter2D(Collider2D other) { AddScore(); shake.CamShake(); }
private void OnTriggerEnter(Collider col) { shake.CamShake(); GM.instance.LoseLife(); }