Esempio n. 1
0
    //[SerializeField]
    //AudioPeerManager _apm; // korean apm :worry:

    // Use this for initialization
    void Start()
    {
        //_source = gameObject.GetComponent<AudioSource>();

        _bufferhighList.Add(new float[64]);
        _highList.Add(new float[64]);
        _highSection = 0;
        _highBeat    = 0.0f;

        for (int i = 0; i < 64; ++i)
        {
            _freqbeat[i]           = false;
            _historyBufferArray[i] = new float[43];
            //_highs[i] = new float[21600];
            // who the f**k puts a song thats 24 hours long? ok
            // this is enough.
        }

        for (int i = 0; i < _offset.Length; ++i)
        {
            _offset[i] = 1.0f;
        }

        //print(_source.clip.name.ToString());

        // _detectedFinish = checkSong(_apm._sample.name) && checkSong(_apm._sample2.name);
        _detectedFinish = checkSong(_source.clip.name);

        _isbeatSaved = _mp.checkSong();
        //(Saving.LoadingFromFile("MusicData.txt", (List<string> _data) =>
        //{
        //    return _data.Contains("<FreqName>" + _source.clip.name);
        //}
        //));

        print(_isbeatSaved);

        _highBeat = 60.0f / _ba.GetBpm();

        _eightBPM = _ba.GetBeatTime() * 0.125f;

        //if (!_detectedFinish)
        //{
        //    _songInfo.Add(_source.clip.name.ToString(), _ba.GetBpm());
        //}

        // this being last is essential
        _source.Play();
    }
Esempio n. 2
0
    //private bool isBeat()
    //{
    //    return BPM._bpmbeat;
    //}

    private void beatCube()
    {
        if (_beatTime > _ba.GetBeatTime())
        {
            transform.localScale = new Vector3(
                _originalScale.x * _scaleMultiplier,
                _originalScale.y * _scaleMultiplier,
                _originalScale.z * _scaleMultiplier);

            if (_beatTime > (_ba.GetBeatTime() * 1.1f))
            {
                _beatTime = 0.0;
            }
        }
        else
        {
            transform.localScale = _originalScale;
        }
    }
Esempio n. 3
0
    public BaseState CreateBaseState(string _clipname, AudioClip _clip, float multiplier = 1f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        // ba.FindBpm();

        double beattime = ba.GetBeatTime() * multiplier;//0.5357; // 0.588 //ba.GetBeatTime()

        BaseState.Attack att = () =>
        {
            Vector3 pos    = gameObject.GetComponent <Transform>().position;
            Vector3 target = new Vector3(-1, -1, 0);
            Object  o      = Resources.Load("Prefabs/Projectile1");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo.GetComponent <Projectile>().SetDir(target);
            newgo.GetComponent <Projectile>().SetSpeed(10 / multiplier);


            for (int i = 0; i < 4; ++i)
            {
                GameObject newergo = Instantiate(newgo, pos, Quaternion.identity);
                target.x += 0.5f;

                newergo.GetComponent <Projectile>().SetDir(target);
                newergo.GetComponent <Projectile>().SetSpeed(10 / multiplier);
            }
        };

        BaseState.Attack att2 = () =>
        {
            Vector3 pos    = gameObject.GetComponent <Transform>().position;
            Vector3 target = new Vector3(-0.75f, -1, 0);
            Object  o      = Resources.Load("Prefabs/Projectile1");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo.GetComponent <Projectile>().SetDir(target);
            newgo.GetComponent <Projectile>().SetSpeed(10 / multiplier);

            for (int i = 0; i < 3; ++i)
            {
                GameObject newergo = Instantiate(newgo, pos, Quaternion.identity);
                target.x += 0.5f;

                newergo.GetComponent <Projectile>().SetDir(target);
                newergo.GetComponent <Projectile>().SetSpeed(10 / multiplier);
            }
        };

        //int beatcount = 0;
        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
            result.AddAttack(time + beattime / 2, att2);

            result.m_audioManager = ap;
        }

        m_StateMap[_clipname] = result;
        result.Sort();
        return(result);
    }