示例#1
0
        /// <summary>
        /// Calculating Euler physics on Y axis.
        /// </summary>
        private void MovementVertical()
        {
            float gravMultiplier = 1;

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

            if (wantsToJump && isGrounded)
            {
                velocity.y       = jumpInpulse;
                isJumpingUpwards = true;
                isGrounded       = false;

                SoundEffectBoard.PlayJump();
            }
            if (!isHoldingJump)
            {
                isJumpingUpwards = false;
            }
            if (isJumpingUpwards)
            {
                gravMultiplier = 0.5f;
            }

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

            //clamp vertical speed to create terminal velocity
            if (velocity.y < -terminalVelocity)
            {
                velocity.y = -terminalVelocity;
            }
        }
示例#2
0
 void Start()
 {
     if (main == null)
     {
         main   = this;
         player = GetComponent <AudioSource>();
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
示例#3
0
        public void OnOverlap(EnemyBasicController be)
        {
            HealthSystem health = be.GetComponent <HealthSystem>();

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

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

            //be.LaunchPlayer(vToPlayer * 15);

            SoundEffectBoard.PlayHit();
        }
示例#4
0
        public override void OnOverlap(PlayerMovement pm)
        {
            HealthSystem health = pm.GetComponent <HealthSystem>();

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

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

            pm.LaunchPlayer(vToPlayer * 15);

            SoundEffectBoard.PlayHit();
        }
        public void OnTriggerEnter(Collider other)
        {
            HealthSystem   health = other.GetComponent <HealthSystem>();
            PlayerMovement pm     = other.GetComponent <PlayerMovement>();

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

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

            //be.LaunchPlayer(vToPlayer * 15);

            SoundEffectBoard.PlayHit();
        }
        void SpawnProjectile()
        {
            if (timerSpawnBullet > 0)
            {
                return;                       // wait longer to fire again...
            }
            if (roundsInClip <= 0)
            {
                return;                    // no ammo!
            }
            Projectile p = Instantiate(prefabProjectile, transform.position, Quaternion.identity);

            p.InitBullet(transform.forward * 20);

            roundsInClip--;
            timerSpawnBullet = 1 / roundsPerSecond;

            SoundEffectBoard.PlayShot();
        }
示例#7
0
        public void OnTriggerEnter(Collider other)
        {
            HealthSystem         health = other.GetComponent <HealthSystem>();
            EnemyBasicController be     = other.GetComponent <EnemyBasicController>();
            BossController       boss   = other.GetComponent <BossController>();

            if (health && be || health && boss)
            {
                health.TakeDamage(damageAmount);
                Destroy(gameObject);
            }


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

            //be.LaunchPlayer(vToPlayer * 15);


            SoundEffectBoard.PlayHit();
        }
示例#8
0
 public void Die()
 {
     Destroy(gameObject);
     SoundEffectBoard.PlayDie();
 }
示例#9
0
 public override void OnOverlap(PlayerMovement pm)
 {
     pm.LaunchPlayer(new Vector3(0, 20, 0));
     SoundEffectBoard.PlaySpring();
 }