Пример #1
0
    public virtual void Attack()
    {
        if (!can_attack)
        {
            return;
        }
        if (updateInput)
        {
            GetInput();
        }
        // Create hitbox, start cooldown coroutine
        transform.parent.GetComponentInChildren <ParticleController> ().Play(0);
        if (audioClip <= 0)
        {
            if (damageMult == 1f)
            {
                transform.parent.GetComponentInChildren <AudioManager> ().Play(0);
            }
            else
            {
                transform.parent.GetComponentInChildren <AudioManager> ().Play(4);
            }
        }
        else
        {
            transform.parent.GetComponentInChildren <AudioManager> ().Play(audioClip);
        }

        can_attack = false;
        GameObject temp = Instantiate(hitbox, transform.position, Quaternion.Euler(new Vector3(0f, 0f, Mathf.Rad2Deg * Mathf.Atan2(-v, h))));

        currentBullet      = temp.GetComponent <BulletScript> ();
        currentBullet.team = GetComponentInParent <MovementScript> ().team;
        CircleCollider2D col = temp.GetComponent <CircleCollider2D> ();

        Physics2D.IgnoreCollision(col, GetComponent <CapsuleCollider2D>());
        currentBullet.id     = player_num;
        currentBullet.damage = Mathf.Ceil(currentBullet.damage * (personalDamageMult * damageMult) * damageRed);
        if (damageMult > 1f)
        {
            currentBullet.PowerupParticles();
        }
//		Rigidbody2D bulletBody = temp.GetComponent<Rigidbody2D> ();
        //Debug.Log ("V: " + v + "\nH: " + h);
        //bulletBody.velocity = Vector2.ClampMagnitude(new Vector2 (h,v) * currentBullet.move_speed,currentBullet.move_speed);
        StartCoroutine(Cooldown());
    }