コード例 #1
0
        // Use this for initialization
        void Start()
        {
            obj    = GameObject.Find("InputManager");
            InpMng = obj.GetComponent <InputManager>();

            score = GameObject.Find("ScoreManager");
            scmn  = score.GetComponent <scoremanage>();

            thre_per = new Dictionary <Finger, int>
            {
                { Finger.Thumb, threshold },
                { Finger.Index, threshold },
                { Finger.Middle, threshold },
                { Finger.Ring, threshold },
                { Finger.Pinky, threshold }
            };

            finger_num = new Dictionary <char, Finger>()
            {
                { 'c', Finger.Thumb },
                { 'v', Finger.Index },
                { 'b', Finger.Middle },
                { 'n', Finger.Ring },
                { 'm', Finger.Pinky }
            };
        }
コード例 #2
0
 private void Awake()
 {
     m_appState    = GameObject.FindObjectOfType <AppState>();
     m_udpHelper   = GameObject.FindObjectOfType <UDPHelper>();
     m_scoreMove   = GameObject.FindObjectOfType <ScoreMove>();
     m_scoremanage = GameObject.FindObjectOfType <scoremanage>();
 }
コード例 #3
0
ファイル: bulletcontrol.cs プロジェクト: a2957360/Tank-Game
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "target")
     {
         GameObject gm = GameObject.Find("Gamescore");
         if (gm != null)
         {
             //get the scoreMgr component and add to the score
             scoremanage sm = gm.GetComponent <scoremanage>();
             if (sm != null)
             {
                 sm.addscore();
                 SEcontrol.PlayImpactSound();
                 Destroy(this.gameObject);
             }
         }
     }
     else
     {
         GameObject gm = GameObject.Find("Gamescore");
         if (gm != null)
         {
             //get the scoreMgr component and add to the score
             scoremanage sm = gm.GetComponent <scoremanage>();
             if (sm != null)
             {
                 sm.delscore();
                 SEcontrol.PlayMissSound();
                 Destroy(this.gameObject);
             }
         }
     }
 }
コード例 #4
0
        // Use this for initialization
        void Start()
        {
            obj    = GameObject.Find("InputManager");
            InpMng = obj.GetComponent <InputManager>();

            score = GameObject.Find("ScoreManager");
            scmn  = score.GetComponent <scoremanage>();
        }
コード例 #5
0
    public static void Read_midi(byte[] midi_byte, GameObject obj, int tick, int freq, List <int> fingers, bool multifinger_mode, AppState m_appState, UDPHelper m_udpHelper, ScoreMove m_scoreMove, KeyManager m_keyManager, scoremanage m_scoremanage, GameObject BarObj)
    {
        Stack <Vector3> notes = new Stack <Vector3>();

        notes.Push(new Vector3(0, -100, 0.01f));

        int[]                     noteOn_time    = new int[128]; //各キーのnote-onの時間
        int                       tick_time      = 0;            //delta_time累積値
        bool                      in_MTrk        = false;
        float                     min_noteLength = 4 / (float)freq;
        float                     scale          = 50.0f;
        SortedSet <int>           keySet         = new SortedSet <int>();
        List <KeyManager.KeyInfo> ListKeyInfo    = new List <KeyManager.KeyInfo>();


        List <Color> FingerColor = new List <Color>()
        {
            new Color(1, 0.5f, 0.5f, 1),
            new Color(1, 1, 0.5f, 1),
            new Color(0.5f, 1, 0.5f, 1),
            new Color(0.5f, 1, 1, 1),
            new Color(0.5f, 0.5f, 1, 1)
        };

        GameObject origin, pre_note = Instantiate(obj);

        origin = GameObject.Find("ScoreOrigin");
        pre_note.transform.SetParent(origin.transform);
        pre_note.GetComponent <RectTransform>().localPosition = new Vector3(0.0f, -100f, 0.0f);

        m_keyManager.KeyInfoInit();

        for (int i = 4; i < midi_byte.Length; i++)
        {
            //トラックチャンク初め(4D 54 72 6B)と終わり(00 FF 2F 00)
            if (midi_byte[i] == 77 && midi_byte[i + 1] == 84 && midi_byte[i + 2] == 114 && midi_byte[i + 3] == 107)
            {
                in_MTrk = true;
                i      += 8; //MTrkとlengthを飛ばす
            }
            else if (midi_byte[i] == 0 && midi_byte[i + 1] == 255 && midi_byte[i + 2] == 47 && midi_byte[i + 3] == 0)
            {
                in_MTrk = false;
                break;
            }

            if (in_MTrk)
            {
                int[] tuple_time_size = Variable2int(midi_byte, i);  //(delta_time, data size of delta_time)
                tick_time += tuple_time_size[0];
                i         += tuple_time_size[1];

                if (midi_byte[i] == 144)   //90: note on
                {
                    int key = midi_byte[i + 1];
                    noteOn_time[key] = tick_time;    //noteの先頭の位置

                    i += 2;
                }
                else if (midi_byte[i] == 128) //80: note off
                {
                    int key = midi_byte[i + 1];
                    keySet.Add(key);

                    KeyManager.KeyInfo m_keyInfo;
                    m_keyInfo.key     = key;
                    m_keyInfo.OnTime  = noteOn_time[key] / (float)tick;
                    m_keyInfo.OffTime = tick_time / (float)tick;

                    m_keyInfo.tag = 0;

                    ListKeyInfo.Add(m_keyInfo);

                    i += 2;
                }
                else if (midi_byte[i] == 192)   //C0
                {
                    i += 1;
                }
                else if (midi_byte[i] == 176 || midi_byte[i] == 224)   //B0, E0
                {
                    i += 2;
                }
                else if (midi_byte[i] == 255)   //FF
                {
                    i += midi_byte[i + 2] + 2;
                }
            }
        }

        //Assign notes to five buttons
        int[] keyMap = new int[128];
        //Debug.Log("fingers: " + fingers.Count);
        int assignNum = fingers[0], ind = 0;

        foreach (var key in keySet)
        {
            keyMap[key] = assignNum;
            ind         = (ind + 1) % fingers.Count;
            assignNum   = fingers[ind];
        }
        foreach (var _keyinfo in ListKeyInfo)
        {
            // Spawn the note object
            float      note_height = _keyinfo.OffTime - _keyinfo.OnTime;
            Vector3    pos         = new Vector3((assignNum - 2) * fingerInterval, _keyinfo.OnTime, 0);
            Vector2    siz         = new Vector2(noteWidth, Mathf.Max(note_height, (float)(1.0 / 8.0)));
            GameObject note        = Instantiate(obj);
            note.transform.SetParent(origin.transform);
            note.GetComponent <RectTransform>().sizeDelta = siz;
            note.GetComponent <RawImage>().color          = FingerColor[assignNum];
            float   pre_y    = pre_note.GetComponent <RectTransform>().localPosition.y;
            float   pre_size = pre_note.GetComponent <RectTransform>().sizeDelta.y;
            Vector3 SendVec; //(fin_num, y_position, Height)
            if (pos.y - pre_y < min_noteLength || (assignNum == keyMap[_keyinfo.key] && pos.y - (pre_y + pre_size) < 1.0 / 8.0))
            {                //結合
                note_height = pos.y + siz.y - pre_y;

                note.GetComponent <RectTransform>().localPosition = new Vector3(pos.x, pre_y, 0);
                note.GetComponent <RectTransform>().sizeDelta     = new Vector3(noteWidth, note_height);

                Destroy(pre_note);
                notes.Pop();

                SendVec = new Vector3(assignNum, pre_y / scale, note_height / scale);
                notes.Push(SendVec);
            }
            else
            {
                assignNum = keyMap[_keyinfo.key];
                note.GetComponent <RectTransform>().localPosition = pos = new Vector3((assignNum - 2) * fingerInterval, _keyinfo.OnTime, 0);;
                note.GetComponent <RawImage>().color = FingerColor[assignNum];

                SendVec = new Vector3(assignNum, pos.y / scale, note_height / scale);
                notes.Push(SendVec);
            }

            /*
             * if (multifinger_mode)
             * {
             *  Clone(note, fingers);
             * }
             */
            m_keyManager.KeyInfoList[assignNum].Add(_keyinfo);
            note.GetComponent <BoxCollider>().center = new Vector3(0, note_height / 2.0f, 0);
            note.GetComponent <BoxCollider>().size   = new Vector3(0.5f, note_height, 0.2f);

            pre_note = note;
        }


        for (int i = 0; i < m_keyManager.KeyInfoList.Count; i++)
        {
            m_keyManager.KeyInfoList[i].Sort((a, b) => FloatSort(a.OnTime, b.OnTime));
        }
        m_keyManager.KeyInit();

        int LastTime = tick_time / tick;

        if (tick_time % tick != 0)
        {
            LastTime++;
        }
        m_scoreMove.MusicLength = LastTime;
        for (int i = 0; i < LastTime; i++)
        {
            GameObject barInstance = Instantiate(BarObj);
            barInstance.transform.SetParent(origin.transform);
            barInstance.GetComponent <RectTransform>().localPosition = new Vector3(0, i, 0);
            barInstance.transform.SetAsFirstSibling();
        }

        NetOutMessage outMessage = new NetOutMessage();

        outMessage.WriteInt32((int)MessageType.Command.Control);
        outMessage.WriteInt32((int)MessageType.ControlType.SpawnNote);

        int NumberofNotes = notes.Count;

        m_scoremanage.NofNote = notes.Count - 1;
        outMessage.WriteInt32(NumberofNotes);
        //Debug.Log("Number of notes is " + (NumberofNotes - 1));

        while (notes.Count > 0)
        {
            outMessage.WriteVector3(notes.Peek());
            notes.Pop();
        }

        outMessage.WriteInt32(LastTime);

        m_udpHelper.Send(outMessage, m_appState.HololensIP, Constants.NETWORK_PORT);
    }