public IEnumerator RespawnPlayerCo() { //Generate Death Particle Instantiate(DeathParticle, Player.transform.position, Player.transform.rotation); //Hide Player //Player.enabled = false; Player2.SetActive(false); Player.GetComponent <Renderer> ().enabled = false; // Gravity Reset GravityStore = Player.GetComponent <Rigidbody2D>().gravityScale; Player.GetComponent <Rigidbody2D>().gravityScale = 0f; Player.GetComponent <Rigidbody2D>().velocity = Vector2.zero; // Point Penalty ScoreManager1.AddPoints(-PointPenatlyOnDeath); // Debug Message Debug.Log("Player Respawn"); //Respawn Delay yield return(new WaitForSeconds(RespawnDelay)); //Gravity Restore Player.GetComponent <Rigidbody2D>().gravityScale = GravityStore; //Match Players transform position Player.transform.position = CurrentCheckPoint.transform.position; //Show Player // Player.enabled = true; Player2.SetActive(true); Player.GetComponent <Renderer> ().enabled = true; //Spawn Particle Instantiate(RespawnPartile, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation); }
// Use this for initialization void Start() { platformStartPoint = platformGenerator.position; playerStartPoint = thePlayer.transform.position; theScoreManager1 = FindObjectOfType <ScoreManager1>(); }
void OnTriggerEnter2D(Collider2D Other) { if (Other.GetComponent <Rigidbody2D> () == null) { return; } ScoreManager1.AddPoints(PointsToAdd); Destroy(gameObject); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Enemy") { Instantiate(EnemyDeath, other.transform.position, other.transform.rotation); Destroy(other.gameObject); ScoreManager1.AddPoints(PointsForKill); // SubProjectile.SubAmmo(1); } Destroy(gameObject); }
// Start is called before the first frame update void Start() { theScoreManager = FindObjectOfType <ScoreManager1>(); }
// Use this for initialization void Start() { theScoreManager1 = FindObjectOfType <ScoreManager1>(); coinSound = GameObject.Find("maitoo").GetComponent <AudioSource>(); }
// Update is called once per frame void Update() { thescoreManager = FindObjectOfType <ScoreManager1> (); }
void Update() { if (SceneManager.GetActiveScene().buildIndex == 1 && transform.position.y < -5) { //audios.PlayOneShot (death); //rb.velocity=new Vector2(0,0); gameObject.SetActive(false); } else { rb.velocity = new Vector2(moveSpeed, rb.velocity.y); } for (int i = 0; i < jumpPointutorial.Length; i++) { if ((transform.position.x > jumpPointutorial [i].transform.position.x - 0.2) && (transform.position.x < jumpPointutorial [i].transform.position.x + 0.2)) { if (SceneManager.GetActiveScene().buildIndex == 0) { rb.velocity = new Vector2(7 * moveSpeed, jumpForce); } else { rb.velocity = new Vector2(moveSpeed, jumpForce); } } } for (int i = 0; i < dbJump.Length; i++) { if ((transform.position.x > dbJump[i].transform.position.x - 0.2) && (transform.position.x < dbJump[i].transform.position.x + 0.2)) { rb.velocity = new Vector2(moveSpeed, doubleJumpForce); } } thescoreManager = FindObjectOfType <ScoreManager1> (); //grounded = Physics2D.IsTouchingLayers (thisCollider, whatIsGround); //grounded = Physics2D.OverlapCircle(pengSpot.position, pengSpotRadius, whatIsGround); grounded = Physics2D.OverlapArea(overlap1.position, overlap2.position, whatIsGround); hitWall = Physics2D.OverlapArea(wallSlide1.position, wallslide2.position, whatIsGround); if (SceneManager.GetActiveScene().buildIndex == 1) { if (!grounded && hitWall) { moveSpeed = 0; } if (transform.position.x > mileStoneDistance) { mileStoneDistance = mileStoneDistance + mileStoneDistanceAdd; mileStoneDistanceAdd = mileStoneDistance * Multiplier; moveSpeed = moveSpeed * Multiplier; } //rbvelocity = rb.velocity.x; /*if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began && grounded) { * jumped=true; * * } * if (jumped && Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Ended) { * jumped = false; * } */ if (Input.GetMouseButtonDown(0)) { /*if (maxHeldinside > 0) {*/ if (grounded) { rb.velocity = new Vector2(rb.velocity.x, jumpForce); stoppedJumping = false; jumpedOnce = true; } if (!grounded && canDoubleJump && jumpedOnce == true && rb.velocity.y >= 0) { canDoubleJump = false; rb.velocity = new Vector2(rb.velocity.x, dbljump); stoppedJumping = false; } } /*if (Input.GetMouseButton (0) && !stoppedJumping) { * * if (jumpTimeCounter > 0) { * rb.velocity = new Vector2 (rb.velocity.x, jumpForce); * jumpTimeCounter -= Time.deltaTime; * } * * } */ /* * * * if (!jumped && Input.GetMouseButtonDown (0)) { * * timeHeld += Time.deltaTime; * if (timeHeld <= maxHeldinside) { * * rb.velocity = new Vector2 (rb.velocity.x, jumpForce); * } * } * */ if (Input.GetMouseButtonUp(0)) { stoppedJumping = true; //canDoubleJump = false; jumpTimeCounter = 0; } if (grounded && yesJumped) { jumpTimeCounter = 0; } if (grounded == true && stoppedJumping) { canDoubleJump = true; jumped = false; jumpTimeCounter = jumpTime; timeHeld = 0; jumpedOnce = false; } } myAnimator.SetBool("grounded", grounded); myAnimator.SetFloat("speed", moveSpeed); myAnimator.SetBool("gothat", gotHat); myAnimator.SetBool("iceGot", gotIce); if (transform.position.y < -5 && SceneManager.GetActiveScene().buildIndex == 1) { gameManager.died(); } }
void Update() { instance = this; UiManager.instance.UpdateScoreText(playerOneScore); UiManager.instance.UpdateScoreText2(playerTwoScore); }