コード例 #1
0
        //The function that checks if the projectile is touching either an enemy or the player
        private void TouchDetection(float deltaTime)
        {
            if (Hitbox == null)
            {
                return;
            }

            //Ensures that only the players bullets hit the boss
            if (_friendly)
            {
                if (Hitbox.DetectCollision(Enemy.Instance.HitBox))
                {
                    Parent.RemoveChild(this);
                    Enemy.Instance.TakeDamage();
                }
            }

            //Prevents the players from shooting themselves
            else if (!_friendly)
            {
                if (Hitbox.DetectCollision(Player.Instance.HitBox))
                {
                    Parent.RemoveChild(this);
                    Player.Instance.TakeDamage();
                }
            }
        }