예제 #1
0
        public void Die()
        {
            SoundEffectBoard.PlayDeath();
            new WaitForSeconds(100);
            Application.LoadLevel(scene.name);


            //Destroy(gameObject);
        }
예제 #2
0
 // Start is called before the first frame update
 void Start()
 {
     if (main == null)
     {
         main   = this;
         player = GetComponent <AudioSource>();
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
예제 #3
0
        public override void OnOverlap(PlayerMovement pm)
        {
            HealthSystem health = pm.GetComponent <HealthSystem>();

            if (health)
            {
                health.TakeDamage(damageAmount);
            }

            //TODO add knock-back

            Vector3 vToPlayer = (pm.transform.position - this.transform.position).normalized;

            SoundEffectBoard.PlayDeath();
            Debug.Log("You fell.");
        }
예제 #4
0
        public override void OnOverlap(PlayerMovement pm)
        {
            HealthSystem health = pm.GetComponent <HealthSystem>();

            if (health)
            {
                health.TakeDamage(damageAmount);
            }

            //TODO add knock-back

            Vector3 vToPlayer = (pm.transform.position - this.transform.position).normalized;

            pm.LaunchPlayer(vToPlayer * 20);
            if (health.health > 25)
            {
                SoundEffectBoard.PlayDamage();
            }
            else
            {
                SoundEffectBoard.PlayDeath();
            }
        }
예제 #5
0
        /// <summary>
        /// Calculating Euler physics on y-axis.
        /// </summary>
        private void CalcVerticalMovement()
        {
            float gravMultiplier = 1;


            bool wantsToJump = Input.GetButtonDown("Jump");

            bool isHoldingJump = Input.GetButton("Jump");

            // Jump!
            if (wantsToJump && isGrounded)
            {
                velocity.y       = jumpImpulse;
                isJumpingUpwards = true;
                isGrounded       = false;

                SoundEffectBoard.PlayJump2();
            }
            if (!isHoldingJump || velocity.y < 0)
            {
                isJumpingUpwards = false;
            }

            if (isJumpingUpwards)
            {
                gravMultiplier = 0.5f;
            }

            // apply force of gravity to our velocity
            velocity.y -= gravity * Time.deltaTime * gravMultiplier;

            //clamp vertical terminal velocity
            if (velocity.y < -terminalVelocity)
            {
                velocity.y = -terminalVelocity;
            }
        }
예제 #6
0
 public override void OnOverlap(PlayerMovement pm)
 {
     pm.LaunchPlayer(new Vector3(0, 20, 0));
     SoundEffectBoard.PlaySpring();
 }
예제 #7
0
        public override void OnOverlap(PlayerMovement pm)
        {
            SoundEffectBoard.PlayCoin();

            Destroy(this.gameObject);
        }