public void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Wall") { die(); } if (other.tag == "Enemy") { passedEnemies.Add(other.gameObject); Transform laser = Instantiate(lineRenderer.transform, transform.position, transform.rotation); MoveLaser moveLaser = laser.GetComponent <MoveLaser>(); moveLaser.originProjectile = transform.gameObject; moveLaser.destinationEnemy = other.gameObject; lasers.Add(moveLaser.gameObject); } if (other.tag == "Player" && currentTimeInAir > 0.5) { foreach (GameObject enemy in passedEnemies) { enemy.GetComponent <SimpleMob>().health -= damage; } die(); } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Right) { RightMove.Start(); } if (e.KeyCode == Keys.Left) { LeftMove.Start(); } if (e.KeyCode == Keys.Up) { UpMove.Start(); } if (e.KeyCode == Keys.Down) { DownMove.Start(); } if (e.KeyCode == Keys.Space) { if (canFire == true) { lasers[0].Location = new Point(player.Location.X + 20, player.Location.Y - 0); MoveLaser.Start(); } } }
private void MoveLaser_Tick(object sender, EventArgs e) { for (int i = 0; i < lasers.Length; i++) { if (lasers[i].Top > 0) { canFire = false; lasers[i].Visible = true; lasers[i].Top -= laserSpeed; } else { canFire = true; lasers[i].Visible = false; MoveLaser.Stop(); } } }
public void Shoot() { AS.clip = game.GetComponent <Ultimates>().clip[0]; AS.Play(); for (int i = 0; i < firePoint.Length; i++) { GameObject laser = Instantiate(LaserPrefab, firePoint[i].transform.position, firePoint[i].transform.rotation); laser.transform.Rotate(0, 0, 90); laser.transform.position = new Vector3(laser.transform.position.x, laser.transform.position.y, 3); MoveLaser ml = laser.GetComponent <MoveLaser>(); ml.speedBullet = bulletSpeed; ml.player = gameObject; ml.Damage = gameObject.GetComponent <Player>().Damage; laser.transform.localScale = new Vector2(laser.transform.localScale.x * scaleBlast, laser.transform.localScale.y * scaleBlast); if (isFury) { laser.GetComponent <MoveLaser>().isFury = true; } if (isFreeze) { laser.GetComponent <MoveLaser>().isFreeze = true; } if (isForamnis) { laser.GetComponent <MoveLaser>().isForamnis = true; } if (isHole) { laser.GetComponent <MoveLaser>().isHole = true; } if (isFor) { laser.GetComponent <MoveLaser>().isFor = true; } if (isMad2) { laser.GetComponent <MoveLaser>().isMad2 = true; } Destroy(laser, bulletSpeed); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.CompareTag("ItemBase1")) { popup.SetActive(true); switch ((int)collision.gameObject.GetComponent <PowerDown>().pde) { case 0: addForce++; pop.reset("<b>SHAKE</b>\n\nDon't stay too close to lasers."); break; case 1: hideNext(); pop.reset("<b>CROP SCREEN</b>\n\nNom nom nom."); break; case 3: changeCommand(); pop.reset("<b>CHANGE KEYS</b>\n\nHere's your new config:" + "\nUp: " + up + ", Down: " + down + ", Left: " + left + ", Right: " + right); break; case 4: increaseDeriv(); pop.reset("<b>AIM</b>\n\nNot the best day for sniping."); break; case 5: pop.reset("<b>NONE</b>"); break; case 6: if (secondWeapon) { secondWeapon = false; pop.reset("<b>NO SECONDARY GUN</b>\n\nOnly main weapon now."); } break; case 7: disableAllLasers(); pop.reset("<b>LASER VISION</b>\n\nYou can't see them but they are still here."); break; case 8: GameObject player = Instantiate(gameObject, new Vector2(-1.268f, -4.23f), Quaternion.identity); PlayerController pc2 = player.GetComponent <PlayerController>(); pc2.pause = pause; pc2.popup = popup; pc2.pop = pop; pop.reset("<b>DUPLICATE</b>\n\nWhich one is the real one ? They both are!"); break; case 9: currTime = 0f; timer.color = Color.red; pop.reset("<b>TIMER</b>\n\n20 seconds left."); break; case 10: GameObject enemy = Instantiate(runEnemy, transform.position + transform.up, Quaternion.identity); enemy.GetComponent <KillPlayer>().player = gameObject; MoveLaser mv = enemy.GetComponentInChildren <MoveLaser>(); mv.gameOver = gameOver; mv.pc = this; pop.reset("<b>TRAP</b>\n\n Surprise!"); break; case 2: if (cd.levelPlaying == 1) { SceneManager.LoadScene("EasterEgg"); } else if (cd.levelPlaying == 2) { SceneManager.LoadScene("EasterEgg2"); } break; default: break; } Destroy(collision.gameObject); if (cd.levelPlaying == 3) { cd.score += 10; } score = objectTakeText.text[0] - '0' + 1; objectTakeText.text = score.ToString() + "/8"; if (score == 8 && (cd.levelPlaying < 4 || cd.levelPlaying == 7)) { if (cd.levelPlaying == 7) { SceneManager.LoadScene("Victory"); } else if (cd.levelPlaying == 3) { cd.score += 250; SceneManager.LoadScene("DeathScene"); } else { SceneManager.LoadScene("Victory"); cd.increaseFile(1); cd.currLevel = 1; } } } else if (collision.collider.CompareTag("ItemSup")) { Destroy(collision.gameObject); relicTakeText.text = "1/1"; } else if ((collision.collider.CompareTag("Bullet") || collision.collider.CompareTag("Bullet2") || collision.collider.CompareTag("BulletFreeze")) && collision.collider.GetComponent <DeleteCollision>().owner != gameObject) { float angle = Mathf.Atan2(collision.transform.position.y - transform.position.y, collision.transform.position.x - transform.position.x); impulse = Quaternion.Euler(0, 0, (180 / Mathf.PI) * (angle - 89.5f)) * Vector2.up * -10; Destroy(collision.gameObject); } }