PlaySound() 공개 메소드

public PlaySound ( string name, bool loop = false ) : void
name string
loop bool
리턴 void
예제 #1
0
    /// <summary>
    /// ////////////////////////////// SPAM GAME MODE FUNCTIONS /////////////////////////////////
    /// </summary>

    void CheckIfIShouldBeBanned()
    {
        for (int i = 0; i < chatModerators.Length; i++)
        {
            if (chatModerators[i].activityStatus == "Online")
            {
                amIBanned = true;
                m_soundPlayer.PlaySound("Ban Sound");
                banTimeStart = Time.time;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (setInactiveNextFrame)
        {
            gameObject.SetActive(false);
            setInactiveNextFrame = false;
        }

        if (isActive)
        {
            float dx = (Input.GetAxis("Horizontal") + m_hftInput.GetAxis("Horizontal")) * speed * Time.deltaTime;
            float dy = (Input.GetAxis("Vertical") - m_hftInput.GetAxis("Vertical")) * speed * Time.deltaTime;

            GetComponent <Rigidbody2D> ().velocity = new Vector2(dx * speed, dy * speed);
            //GetComponent<Rigidbody2D> ().AddForce (new Vector2 (dx * 10, dy * 10));
            if (Input.GetKey(KeyCode.Space))
            {
                weapon.fire(this);
            }


            var horizontalDirection = m_hftInput.GetAxis("Horizontal2");
            var verticalDirection   = m_hftInput.GetAxis("Vertical2");

            if (horizontalDirection != 0 || verticalDirection != 0)
            {
                var angle =
                    horizontalDirection > 0 && verticalDirection == 0 ?  90
                                        : horizontalDirection < 0 && verticalDirection == 0 ? -90
                                        : horizontalDirection > 0 && verticalDirection < 0 ? 135
                                        : horizontalDirection < 0 && verticalDirection > 0 ? -35
                                        : horizontalDirection > 0 && verticalDirection > 0 ? 45
                                        : horizontalDirection < 0 && verticalDirection < 0 ? -135
                                        : horizontalDirection == 0 && verticalDirection > 0 ? 0
                                        : horizontalDirection == 0 && verticalDirection < 0 ? 180
                                        : 0f;

                transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
                if (weapon.fire(this))
                {
                    m_soundPlayer.PlaySound(weapon.soundName);
                }
            }



            // keep the player in the bounds of the game
            Vector3 pos = Camera.main.WorldToViewportPoint(transform.position);
            pos.x = Mathf.Clamp01(pos.x);
            pos.y = Mathf.Clamp01(pos.y);
            transform.position = Camera.main.ViewportToWorldPoint(pos);
        }
    }