예제 #1
0
        // Use this for initialization
        void Start()
        {
            playerManager   = PlayerManager.Instance;
            ReadyPlayerList = new Dictionary <int, bool>();
            keyList         = new List <KeyCode>();
            foreach (KeyCode key in System.Enum.GetValues(typeof(KeyCode)))
            {
                string keyName = key.ToString();
                if (keyName.Contains("Joystick") && char.IsDigit(keyName[8]))
                {
                    keyList.Add(key);
                }
            }

            Gamepads = new gamepads[SerialPort.GetPortNames().Length];
            int i = 0;

            foreach (string str in SerialPort.GetPortNames())
            {
                Gamepads[i] = new gamepads((int)char.GetNumericValue(str[str.Length - 1]));
                i++;
            }

            SelectedList = new bool[PersonnageAvailable.Length];

            LoadRatioStatsToBar(HPBarTeam, hpTeam, 950);
            LoadRatioStatsToBar(ShieldBarTeam, shieldTeam, 300);
            LoadRatioStatsToBar(ManaBarTeam, manaTeam, 900);
            HPBarTeam.gameObject.SetActive(true);
            ShieldBarTeam.gameObject.SetActive(true);
            ManaBarTeam.gameObject.SetActive(true);
        }
예제 #2
0
    public Player AddPlayer(int ControllerId, Personnage playerPersonnage, gamepads gamepads = null)
    {
        int        id           = PlayerList.Count + 1;
        GameObject playerObject = new GameObject("Player " + id);
        Player     player       = Instantiate(playerObject, transform).AddComponent <Player>();

        player.LoadPlayer(id, PlayerColorList[id - 1], playerPersonnage, ControllerId, gamepads);
        PlayerList.Add(player);
        Debug.Log("Controller id:" + ControllerId + " added as Player n°" + id);
        return(player);
    }
예제 #3
0
    void Start()
    {
        if (SerialPort.GetPortNames().Length > 0)
        {
            pads = new gamepads((int)char.GetNumericValue(SerialPort.GetPortNames()[0][SerialPort.GetPortNames()[0].Length - 1]));
        }
        //Load Song
        audios      = GetComponent <AudioSource>();
        songInfo    = SongInfoCustom.Instance.currentSong;
        song        = songInfo.song;
        audios.clip = song;

        //UI
        //load Slider
        sliderTime.minValue = 0;
        sliderTime.maxValue = song.length;
        txtPch.text         = audios.pitch.ToString();
        txtNom.text         = song.name;


        //TrackLength
        TrackLengthSlider.value = TrackLength;

        //initialize fields
        crotchet      = 60f / songInfo.bpm;
        songLength    = songInfo.song.length;
        crotchetCount = (int)(songLength / crotchet);
        //Init BPM
        beats = new PrimaryBeat[crotchetCount];
        for (int i = 0; i < crotchetCount; i++)
        {
            beats[i] = Instantiate(prefabsBeats, parentBeats).GetComponent <PrimaryBeat>();
            //Init a 1 car le premier subbeat est le beat lui même
            for (int j = 1; j < BeatDividing; j++)
            {
                Instantiate(prefabsSubBeat, beats[i].transform).GetComponent <subbeat>().subNode = j;
            }
            beats[i].beatId = i + 1;
            beats[i].initSubNode(trackNb, BeatDividing);
        }

        //Partition
        PlayersPartition   = songInfo.partitions;
        CurrentIdPartition = 0;
        UIPartitionId.text = (CurrentIdPartition + 1).ToString();
        LoadPartition();

        //Resize BPM space
        ResizeTracks();
    }
예제 #4
0
 // Use this for initialization
 public void LoadPlayer(int Id, Color Color, Personnage playerPerso, int Controller, gamepads pads = null)
 {
     id           = Id;
     color        = Color;
     Personnage   = playerPerso;
     ControllerId = Controller;
     if (pads != null)
     {
         this.pads = pads;
     }
     else if (Controller >= 0)
     {
         trackKey = LoadTrackKey();
     }
 }
예제 #5
0
 public void AddDebugPlayer()
 {
     if (System.IO.Ports.SerialPort.GetPortNames().Length > 0)
     {
         string   str  = System.IO.Ports.SerialPort.GetPortNames()[0];
         gamepads pads = new gamepads((int)char.GetNumericValue(str[str.Length - 1]));
         AddPlayer(1, DebugPerso, pads);
     }
     else if (Input.GetJoystickNames().Length > 0)
     {
         if (Input.GetJoystickNames()[0] != "")
         {
             AddPlayer(1, DebugPerso);
         }
     }
     else
     {
         AddPlayer(-1, DebugPerso);
     }
 }
예제 #6
0
        public void AddPlayerToLobby(int id, gamepads pads = null)
        {
            /* i = 0;
             * while (SelectedList[i])
             * {
             *  i++;
             * }
             * SelectedList[i] = true;*/
            Player player = playerManager.AddPlayer(id, PersonnageAvailable[0], pads);

            Debug.Log(player.id);
            player.Personnage = PersonnageAvailable[player.id - 1];
            ReadyPlayerList.Add(player.id, false);

            updateUI(player);
            //reset led avant de lui attribuer l'id
            if (pads != null)
            {
                player.pads.SetLed(0);
                player.pads.SetLed(player.id);
            }
        }
예제 #7
0
 public void LoadArduino(gamepads pads)
 {
 }