Exemplo n.º 1
0
 public void OnPlayButton()
 {
     Time.timeScale = 1f;
     musicController.PlaySelectedSound(SoundType.Audience);
     HidePanel(PanelType.MainMenu);
     ShowPanel(PanelType.PlayerSelection);
 }
Exemplo n.º 2
0
    // Returns positive value on damage
    private int calculateDamage(Collision2D other)
    {
        if (other.rigidbody.velocity.magnitude > _rigidbody.velocity.magnitude)
        {
            int hitDamage = 5 + Mathf.FloorToInt(other.rigidbody.velocity.magnitude - _rigidbody.velocity.magnitude);              // Adjust damage
            protectionTime = 0.5f;
            hitPoint      -= hitDamage;
//			Debug.Log(string.Format("{0} received {1} damage! {2} remained.", gameObject.name, hitDamage, hitPoint));
            _hpBar.UpdateHPBar(hitPoint);
            if (hitPoint <= 0)
            {
                isAlive = false;
            }
            else if (hitPoint <= Mathf.FloorToInt(maxHitPoint / 2))
            {
                changeFacialExpression();
            }

            soundManager.PlaySelectedSound(SoundType.Hit);
            return(hitDamage);
        }
        else
        {
            return(0);
        }

        /*
         * Vector3 enemyProjectionVector = Vector3.Project (contactRigidbody.velocity, other.contacts [0].normal);
         * Vector3 ourProjectionVector = Vector3.Project (_rigidbody.velocity, other.contacts [0].normal);
         * damage = enemyProjectionVector.magnitude - ourProjectionVector.magnitude;
         * if (enemyProjectionVector.magnitude > ourProjectionVector.magnitude) {
         *      Debug.Log ("Enemy Vector: " + enemyProjectionVector.magnitude + " Our Vector: " + ourProjectionVector.magnitude);
         *      Debug.Log (this.gameObject.name + " received " + damage);
         *      protectionTime = 0.5f;
         * }
         */
    }