Beispiel #1
0
 private void Update()
 {
     if (playerHealth <= 0)
     {
         player.Die();
     }
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (PlayerHealthcount == 0)
     {
         PlayerDeath.Die();
     }
 }
Beispiel #3
0
    private void OnCollisionStay(Collision other)
    {
        PlayerDeath playerDeath = other.gameObject.GetComponent <PlayerDeath>();

        if (playerDeath != null)
        {
            playerDeath.Die();
        }
    }
Beispiel #4
0
 /*
  * private void OnCollisionEnter2D(Collision2D collision)
  * {
  *  if(collision.collider.tag == "Player")
  *  {
  *      Debug.Log("collided with player");
  *      if(GameManager.manager.invincible <= 0)
  *      {
  *          player_death.Die();
  *      }
  *      else
  *      {
  *          Die();
  *      }
  *  }
  *  if(collision.collider.tag == "PlayerProjectile")
  *  {
  *      Die();
  *  }
  * }
  *
  * private void OnCollisionStay2D(Collision2D collision)
  * {
  *  if (collision.collider.tag == "Player")
  *  {
  *      Debug.Log("touching player");
  *      if (GameManager.manager.invincible <= 0)
  *      {
  *          player_death.Die();
  *      }
  *      else
  *      {
  *          Die();
  *      }
  *  }
  *  if (collision.collider.tag == "PlayerProjectile")
  *  {
  *      Die();
  *  }
  * }
  */
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         if (!GameManager.manager.dead && !GameManager.manager.movingReset)
         {
             if (GameManager.manager.invincible <= 0)
             {
                 player_death.Die();
             }
             else
             {
                 Die();
             }
         }
     }
     if (collision.tag == "PlayerProjectile")
     {
         Die();
     }
 }
Beispiel #5
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         //hit player
         player_death.Die();
     }
     else if (collision.tag == "PlayerProjectile")
     {
         //get ienemy take dmg?
         boss.Take_Dmg();
     }
 }
Beispiel #6
0
    private void Attack()
    {
        attackTimer = Random.Range(-attackRate * attackVariance, 0);
        //these next 2 lines are referencing drag-and-drop fields that I drag the animations and sounds to using the serializeFields from lines 12-13.
        gunSound.Play();
        gunFlash.Play();
        playerHealth.TakeDamage(attackDamage);
        if (playerHealth.currentHealth < 1)
        {
            death.Die();
        }
        //get a physical bullet from the pool that is not in use
        GameObject currentBullet = PoolingManager.Instance.GetBullet();

        //put bullet in front of firepoint.
        currentBullet.transform.position = FirePoint.transform.position + FirePoint.transform.forward;
        currentBullet.transform.forward  = (FirePoint.transform.forward);
    }
    private void Update()
    {
        myIsJumping   = myPlayerInput.IsJumping();
        myIsQuitting  = myPlayerInput.IsQuitting();
        myHasCollided = myPlayerCollision.HasCollided();

        if (myIsQuitting)
        {
            Application.Quit();
        }

        if (myHasCollided)
        {
            myPlayerCollision.ResetCollided();
            myCamera.TriggerShake(myShakeDurationRocks, myShakeMagnitudeRocks);

            if (!myGrounded && myAirMovement.y < 0)
            {
                myPlayerJump.Bounce(ref myAirMovement, myJumpForce);
                return;
            }

            myPlayerDeath.Die();
            myCurrentSpeed = myBaseSpeed;
            mySplineManager.ResetAllSplines();
            ResetSpline();
        }

        if (myGrounded)
        {
            myPlayerBobbing.Bob();

            if (myIsJumping)
            {
                myPlayerJump.Jump(myCurrentPoints, myPointsIndex, myJumpForce, myCurrentSpeed, ref myAirMovement);
                ResetSpline();
                return;
            }

            if (!myPlayerSpline.SplineMovement(myCurrentPoints, ref myCurrentSpeed, ref myPointsIndex, ref mySplineT, myGravity, myBoost))
            {
                myPlayerSpline.ReleaseSpline(myCurrentPoints, myCurrentSpeed, ref myAirMovement, myPointsIndex);
                ResetSpline();
            }
            return;
        }

        myPlayerAir.AirMovement(myGravity, ref myAirMovement);

        if (myIsJumping)
        {
            myPlayerBackflip.Backflip(myFlipRotationSpeed);
        }
        else
        {
            myPlayerAir.AirRotation(myRotationResetSpeed);
        }

        if (myAirMovement.y < 0)
        {
            if (myPlayerSpline.AttemptToCatchSpline(mySplineManager, myReach, ref myTooCloseToOldSpline, ref myPointsIndex, ref myCurrentPoints, ref myOldPoints, ref myBoost))
            {
                myCamera.TriggerShake(myShakeDurationSplines, myShakeMagnitudeSplines);
                myGrounded = true;
                mySplineT  = 0;
            }
        }
    }