コード例 #1
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "ball")
        {
            //when the ball hits the enemy, the enemy calculates how much damage is applied to it

            rollValue = Random.Range(1, 21) + dexModifier;
            Debug.Log(rollValue);

            health = health - rollValue;

            if (health <= 0)
            {
                score.IncrementScore(healthValue[rand]);
                Destroy(gameObject, 0.1f);
            }

            if (rollValue == 20f)
            {
                bool isCriticalHit = true;
                damagePopup.Create(transform.position, rollValue, isCriticalHit);

                Instantiate(boom, transform.position, Quaternion.identity);
            }
            else
            {
                bool isCriticalHit = false;
                damagePopup.Create(transform.position, rollValue, isCriticalHit);
            }
        }
    }
コード例 #2
0
ファイル: bossScript.cs プロジェクト: sirofsky/dungeoncaster
    void OnCollisionEnter(Collision col)
    {
        //deduct damage from boss when hit with dice

        if (col.gameObject.tag == "ball" || col.gameObject.tag == "multiball")
        {
            rollValue = Random.Range(1, 21) + dexModifier;
            Debug.Log(rollValue);

            if (rollValue == 20f)
            {
                bool isCriticalHit = true;
                damagePopup.Create(transform.position, rollValue, isCriticalHit);
            }
            else
            {
                bool isCriticalHit = false;
                damagePopup.Create(transform.position, rollValue, isCriticalHit);
            }

            health = health - rollValue;

            score.IncrementScore(rollValue);
        }
    }
コード例 #3
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "ball" || col.gameObject.tag == "multiball")
        {
            //when the ball hits the enemy, the enemy calculates how much damage is applied to it


            rollValue = Random.Range(1, 21) + dexModifier;
            Debug.Log(rollValue);

            health = health - rollValue;

            score.IncrementScore(rollValue);

            if (health <= 0)
            {
                score.IncrementScore(healthValue[rand]);

                if (Random.Range(1, 21) > 12) //frequency of power ups spawning
                {
                    Instantiate(powerUp, transform.position, Quaternion.Euler(90, 0, 0));
                    ;
                }

                Destroy(gameObject, 0.1f); //delayed destroy so the ball bounces off the enemy before destroying
            }

            if (rollValue == 20f)
            {
                bool isCriticalHit = true;
                damagePopup.Create(transform.position, rollValue, isCriticalHit);

                Instantiate(boom, transform.position, Quaternion.identity);
            }
            else
            {
                bool isCriticalHit = false;
                damagePopup.Create(transform.position, rollValue, isCriticalHit);
            }
        }
    }