示例#1
0
    public void LoadLoggedLoadouts(string[] arsSplitLogs)
    {
        Debug.Assert(arsSplitLogs[0] == "lo");

        int iPlayer, iChr;

        if (int.TryParse(arsSplitLogs[1], out iPlayer) == false || iPlayer < 0 || iPlayer >= Player.MAXPLAYERS)
        {
            Debug.LogErrorFormat("Error! {0} was not a valid player id to be loaded", arsSplitLogs[1]);
            return;
        }
        if (int.TryParse(arsSplitLogs[2], out iChr) == false || iChr < 0 || iChr >= Player.MAXCHRS)
        {
            Debug.LogErrorFormat("Error! {0} was not a valid chr id to be loaded", arsSplitLogs[2]);
            return;
        }

        int[] arnSerializedLoadout = new int[arsSplitLogs.Length - 3];

        //Copy and translate all the logged strings into serialized ints in an array
        for (int i = 0; i < arnSerializedLoadout.Length; i++)
        {
            if (int.TryParse(arsSplitLogs[i + 3], out arnSerializedLoadout[i]) == false)
            {
                Debug.LogErrorFormat("Error! {0} was not a valid serialized loadout entry to be loaded", arsSplitLogs[i + 3]);
                return;
            }
        }

        NetworkMatchSetup.SetLoadout(iPlayer, iChr, LoadoutManager.UnserializeLoadout(arnSerializedLoadout));
    }
    public void CleanupEditLoadout()
    {
        //Save the generated loadout in the slot for the character we were editing
        NetworkMatchSetup.SetLoadout(idPlayer, loadoutselectActive.iChrSelectingFor, loadoutselectActive.loadoutCur);

        //Once the loadout editing is done, we can just destroy the loadout selector window, and clear out our reference to it
        GameObject.Destroy(loadoutselectActive.gameObject);
        loadoutselectActive = null;
    }
    public void OnChrSelectChange()
    {
        Debug.Assert(0 <= idChr && idChr < 3);

        NetworkMatchSetup.SetCharacterSelection(plyrselectorParent.idPlayer, idChr, (CharType.CHARTYPE)dropdown.value);

        //Now that our character has been reselected, we need to load in a starting loadout for that character
        NetworkMatchSetup.SetLoadout(plyrselectorParent.idPlayer, idChr,
                                     LoadoutManager.LoadSavedLoadoutForChr(NetworkMatchSetup.GetCharacterSelection(plyrselectorParent.idPlayer, idChr), 0));

        Debug.LogFormat("Changed chr to {0} with a starting loadout of {1}", NetworkMatchSetup.GetCharacterSelection(plyrselectorParent.idPlayer, idChr),
                        NetworkMatchSetup.GetLoadout(plyrselectorParent.idPlayer, idChr));
    }
    public void Start()
    {
        lstLoadoutSelected = new List <LoadoutManager.Loadout>();

        //Initially save the selected loadouts as just being the default loadout for the default character in that position
        for (int i = 0; i < arDropdownCharSelect.Length; i++)
        {
            //Initially set the selected char to the default for that player+slot combo
            NetworkMatchSetup.SetCharacterSelection(idPlayer, i, CHRSELECTIONSDEFAULT[idPlayer, i]);

            //Set the loadout to be the default loadout for the selected player
            NetworkMatchSetup.SetLoadout(idPlayer, i, LoadoutManager.LoadSavedLoadoutForChr(CHRSELECTIONSDEFAULT[idPlayer, i], 0));

            //Set the default position of that character
            NetworkMatchSetup.SetPositionCoords(idPlayer, i, POSITIONSDEFAULT[idPlayer, i]);

            //Ensure our character selection dropdown is initialized
            arDropdownCharSelect[i].UpdateDropdownOptions();
        }
    }