public IEnumerator CRDraftChr(int iPlayer, CharType.CHARTYPE chrDrafted)
    {
        //Ensure the character actually exists
        Debug.Assert(chrDrafted < CharType.CHARTYPE.LENGTH);

        //Ensure this character hasn't already been drafted/banned
        Debug.Assert(arbChrsAvailableToDraft[(int)chrDrafted] == true);

        Debug.Log("Drafting " + chrDrafted + " for " + iPlayer);

        //Ensure the draft selection has been registered in the roomoptions (maybe someone else beat us to it, but that's fine)
        NetworkMatchSetup.SetCharacterSelection(iPlayer, arNumChrsDrafted[iPlayer], chrDrafted);

        //Then ensure that everything locally is tracked and displayed properly
        arDraftedChrs[iPlayer][arNumChrsDrafted[iPlayer]] = chrDrafted;
        arNumChrsDrafted[iPlayer]++;

        arbChrsAvailableToDraft[(int)chrDrafted] = false;

        draftcollection.SetChrAsDrafted((int)chrDrafted);
        arDraftedChrDisplay[iPlayer].UpdateDraftedChrDisplays(arDraftedChrs[iPlayer]);

        yield return(new WaitForSeconds(1.0f));

        Debug.Log("Finished 'waiting' for the draft to finish");
    }
Esempio n. 2
0
    public static List <string> LoadAllLoadoutNamesForChr(CharType.CHARTYPE chartype)
    {
        List <string> lstLoadoutNames = new List <string>();

        for (int i = 0; i < nLOADOUTSLOTS; i++)
        {
            if (PlayerPrefs.HasKey(GetKeyName(chartype, i)) == false)
            {
                //If we try to load the ith slot for this character, but there's no entry for the name of the loadout,
                //  we assume the loadout is blank so we can just save in the default loadout for the character then use it
                Debug.LogFormat("No loadout names for {0} - setting defaults", chartype);

                Loadout loadoutDefault = GetDefaultLoadoutForChar(chartype);
                SaveLoadout(chartype, i, loadoutDefault);

                lstLoadoutNames.Add(loadoutDefault.sName);
            }
            else
            {
                //If the loadout name exists, then just load it
                lstLoadoutNames.Add(PlayerPrefs.GetString(GetKeyName(chartype, i)));
            }
        }

        return(lstLoadoutNames);
    }
Esempio n. 3
0
    public static Loadout LoadSavedLoadoutForChr(CharType.CHARTYPE chartype, int iSlot)
    {
        Debug.Assert(iSlot < nLOADOUTSLOTS, "Cannot load slot " + iSlot + " since we don't allow that many slots");

        if (PlayerPrefs.HasKey(GetKeyName(chartype, iSlot)) == false)
        {
            //If we don't have a stored loadout for this slot, then save a default loadout in this slot and return it

            Debug.LogFormat("No loadout for {0} - setting defaults", chartype);

            Loadout loadoutDefault = GetDefaultLoadoutForChar(chartype);
            SaveLoadout(chartype, iSlot, loadoutDefault);

            return(loadoutDefault);
        }

        //If we get this far, then we have a loadout stored in this slot, so we can load it

        // Fetch the name of the loadout
        string _sName = PlayerPrefs.GetString(GetKeyName(chartype, iSlot));

        // Fetch all the stored standard skill selections
        List <SkillType.SKILLTYPE> _lstChosenSkills = new List <SkillType.SKILLTYPE>();

        for (int i = 0; i < Chr.nTotalCharacterSkills; i++)
        {
            string sKey = GetKeySkills(chartype, iSlot, i);

            Debug.Assert(PlayerPrefs.HasKey(sKey), "No stored entry for " + sKey + " found");

            _lstChosenSkills.Add((SkillType.SKILLTYPE)PlayerPrefs.GetInt(sKey));
        }

        return(new Loadout(_sName, _lstChosenSkills));
    }
Esempio n. 4
0
    public void SendDraft(CharType.CHARTYPE chartypeToDraft)
    {
        int indexCurDraftInput = NetworkDraftReceiver.Get().indexCurDraftInput;

        Debug.LogErrorFormat("Sending step {0}: Draft {1}", indexCurDraftInput, chartypeToDraft);

        photonview.RPC("ReceiveDraft", RpcTarget.AllBufferedViaServer, indexCurDraftInput, chartypeToDraft);
    }
Esempio n. 5
0
    public void LogCharacterSelections(int iPlayer)
    {
        for (int iChr = 0; iChr < Player.MAXCHRS; iChr++)
        {
            CharType.CHARTYPE chartype = NetworkMatchSetup.GetCharacterSelection(iPlayer, iChr);

            WriteToMatchLogFile(string.Format("cs:{0}:{1}:{2}:{3}", iPlayer, iChr, (int)chartype, CharType.GetChrName(chartype)));
        }
    }
    public bool IsCharAvailable(CharType.CHARTYPE chr)
    {
        //If the selection is an invalid one (used for no selection)
        if (chr == CharType.CHARTYPE.LENGTH)
        {
            return(false);
        }

        return(arbChrsAvailableToDraft[(int)chr]);
    }
    //The main loop that will spin waiting for outside networked input and process
    //  it, once our local simulation is ready for a new input
    public IEnumerator CRDraftLoop()
    {
        //Do any animation processing that needs to be done before the draft input actually starts
        yield return(StartCoroutine(CRPrepDraft()));

        Debug.Log("Done prepping draft");


        //Keep processing turn events while the draft isn't finished
        while (!IsDraftPhaseOver())
        {
            //Check if we have input waiting for us in the network buffer
            while (NetworkDraftReceiver.Get().IsCurSelectionReady() == false)
            {
                //Keep spinning until we get the input we're waiting on

                WaitForDraftInput();
                yield return(null);
            }
            //If we were waiting on input, then clean up the waiting process
            if (draftactionWaitingOn != null)
            {
                EndWaitingOnDraftInput();
            }

            //At this point, we have an input in the buffer that we are able to process
            DraftAction       draftaction   = GetNextDraftPhaseStep();
            CharType.CHARTYPE chartypeInput = NetworkDraftReceiver.Get().GetCurSelection();

            Debug.Log("Got a draft action of type " + draftaction.draftactionType + " for chr " + chartypeInput);

            //Start a coroutine to process whichever event we need to execute
            if (draftaction.draftactionType == DraftAction.DRAFTACTIONTYPE.DRAFT)
            {
                //Draft the character
                yield return(StartCoroutine(CRDraftChr(draftaction.iPlayer, chartypeInput)));
            }
            else
            {
                //Ban the character
                yield return(StartCoroutine(CRBanChr(draftaction.iPlayer, chartypeInput)));
            }

            //Now that the draft/ban is complete and processed, increment our 'current' indices
            NetworkDraftReceiver.Get().FinishCurSelection();
            FinishDraftPhaseStep();
        }

        //Do any animation process that needs to be done before we leave the draft scene
        yield return(StartCoroutine(CRCleanUpDraft()));

        //Wrap up the draft phase
        FinishDraft();
        yield break;
    }
    public static void SetCharacterSelection(int idPlayer, int iChrSlot, CharType.CHARTYPE chartype)
    {
        Debug.LogFormat("Setting character selection for player {0}'s {1}th character to {2}",
                        idPlayer, iChrSlot, chartype);

        ExitGames.Client.Photon.Hashtable hashNewProperties = new ExitGames.Client.Photon.Hashtable()
        {
            { GetCharSelectionsKey(idPlayer, iChrSlot), chartype }
        };

        PhotonNetwork.CurrentRoom.SetCustomProperties(hashNewProperties);
    }
Esempio n. 9
0
    public static void SaveLoadout(CharType.CHARTYPE chartype, int iSlot, Loadout loadout)
    {
        Debug.Assert(iSlot < nLOADOUTSLOTS, "Cannot save slot " + iSlot + " since we don't allow that many slots");

        // Save the name of the loadout
        PlayerPrefs.SetString(GetKeyName(chartype, iSlot), loadout.sName);

        // Save all the standard skill selections
        for (int i = 0; i < Chr.nTotalCharacterSkills; i++)
        {
            PlayerPrefs.SetInt(GetKeySkills(chartype, iSlot, i), (int)loadout.lstChosenSkills[i]);
        }
    }
Esempio n. 10
0
    public static CharType.CHARTYPE[] ArIntToArChrType(int[] arInt)
    {
        if (arInt == null)
        {
            return(null);
        }

        CharType.CHARTYPE[] arChrTypes = new CharType.CHARTYPE[arInt.Length];

        for (int i = 0; i < arInt.Length; i++)
        {
            arChrTypes[i] = (CharType.CHARTYPE)arInt[i];
        }

        return(arChrTypes);
    }
Esempio n. 11
0
    // Will eventually need a clean solution to adding/removing characters
    // while managing ids - some sort of Buffer of unused views will probably help
    void InitChr(CharType.CHARTYPE chartype, Player player, int idChar, LoadoutManager.Loadout loadout)
    {
        GameObject goChr  = Instantiate(pfChr, this.transform);
        Chr        newChr = goChr.GetComponent <Chr>();

        if (newChr == null)
        {
            Debug.LogError("ERROR! NO CHR COMPONENT ON CHR PREFAB!");
        }

        newChr.Start();

        newChr.InitChr(chartype, player, idChar, loadout);

        arChrs[player.id][idChar] = newChr;
        player.arChr[idChar]      = newChr;
    }
    public override void Init()
    {
        //Set up an array for each draft pick # for each player
        for (int i = 0; i < arDraftedChrs.Length; i++)
        {
            arDraftedChrs[i] = new CharType.CHARTYPE[NDRAFTEDCHRSPERPLAYER];
            for (int j = 0; j < arDraftedChrs[i].Length; j++)
            {
                arDraftedChrs[i][j] = CharType.CHARTYPE.LENGTH; //Initially set the chosen character to a flag meaning no selected character yet
            }

            arDraftedChrDisplay[i].UpdateDraftedChrDisplays(arDraftedChrs[i]);
        }

        InitChrsAvailableToDraft();

        InitDraftOrder();
    }
    public void SetChrInSlot(CharType.CHARTYPE _chrInSlot)
    {
        chrInSlot = _chrInSlot;

        if (chrInSlot == CharType.CHARTYPE.LENGTH)
        {
            SetEmptySlot();
            return;
        }

        string sChrName = CharType.GetChrName(chrInSlot);

        txtChrNameLabel.text = sChrName;

        //For some reason, setting the overrideSprite (rather than the normal sprite) works here.  Unity is dumb
        imgPortrait.overrideSprite = Resources.Load("Images/Chrs/" + sChrName + "/img" + sChrName + "neutral", typeof(Sprite)) as Sprite;
        //LibView.AssignSpritePathToObject("Images/Chrs/" + sChrName + "/img" + sChrName + "neutral", this.gameObject);
    }
Esempio n. 14
0
    // Used to initiallize information fields of the Chr
    // Call this after creating to set information
    public void InitChr(CharType.CHARTYPE _chartype, Player _plyrOwner, int _id, LoadoutManager.Loadout loadout)
    {
        chartype  = _chartype;
        sName     = CharType.GetChrName(chartype);
        plyrOwner = _plyrOwner;
        id        = _id;
        globalid  = id + plyrOwner.id * Player.MAXCHRS;

        RegisterChr(this);

        //Initialize this character's disciplines based on their chartype
        InitDisciplines();

        //Initialize any loadout-specific qualities of the character
        InitFromLoadout(loadout);

        view.Init();
    }
    public IEnumerator CRBanChr(int iPlayer, CharType.CHARTYPE chrBanned)
    {
        //Ensure the character actually exists
        Debug.Assert(chrBanned < CharType.CHARTYPE.LENGTH);

        //Ensure this character hasn't already been drafted/banned
        Debug.Assert(arbChrsAvailableToDraft[(int)chrBanned] == true);

        Debug.Log("Banning " + chrBanned);

        //We shouldn't need to save any bans in the room options since it's only relevent in this scene
        // We still need to update our local information and display this ban properly

        arbChrsAvailableToDraft[(int)chrBanned] = false;

        draftcollection.SetChrAsBanned((int)chrBanned);

        yield return(new WaitForSeconds(1.0f));

        Debug.Log("Finished 'waiting' for the ban to finish");
    }
Esempio n. 16
0
    void AddInputToBuffer(int indexDraftInput, CharType.CHARTYPE chartype)
    {
        if (indexDraftInput != indexCurDraftInput)
        {
            Debug.LogErrorFormat("ALERT!  Received draftinput index {0}, but we are expecting index {1}", indexDraftInput, indexCurDraftInput);
        }

        //Ensure that our received index is within the bounds of our buffer
        while (indexDraftInput > lstDraftInputBuffer.Count)
        {
            IncreaseDraftInputsReceivedCapacity();
        }

        //Check if this entry in the buffer is already filled (LENGTH indicates an unfilled selection)
        if (lstDraftInputBuffer[indexDraftInput] != CharType.CHARTYPE.LENGTH)
        {
            Debug.LogErrorFormat("ALERT! Filled index {0} received another selection of {1}", indexDraftInput, chartype);
            return;
        }

        lstDraftInputBuffer[indexDraftInput] = chartype;
    }
    public void OnDraftableChrClicked(CharType.CHARTYPE chrClicked)
    {
        //Check if we've been told by the master to choose a character to draft/ban
        if (draftactionWaitingOn == null)
        {
            Debug.Log("We aren't waiting on any input right now");
            return;
        }

        //Check if it's even our turn to draft
        if (NetworkMatchSetup.IsLocallyOwned(draftactionWaitingOn.iPlayer) == false)
        {
            Debug.LogError("Can't draft/ban since it's not your turn");
            return;
        }

        //Check if this character is available to draft/ban
        if (IsCharAvailable(chrClicked) == false)
        {
            Debug.LogError("Can't draft/ban an unavailable character");
            return;
        }

        Debug.Log("Current step of draft is " + GetNextDraftPhaseStep().draftactionType);

        //At this point, it's valid to pick/ban the character so send along the appropriate signal to the Master
        if (GetNextDraftPhaseStep().draftactionType == DraftAction.DRAFTACTIONTYPE.BAN)
        {
            Debug.Log("Sending ban of " + chrClicked);
            NetworkDraftSender.Get().SendBan(chrClicked);
        }
        else if (GetNextDraftPhaseStep().draftactionType == DraftAction.DRAFTACTIONTYPE.DRAFT)
        {
            Debug.Log("Sending draft of " + chrClicked);
            NetworkDraftSender.Get().SendDraft(chrClicked);
        }
    }
Esempio n. 18
0
 public static string GetKeySkills(CharType.CHARTYPE chartype, int iSlot, int iSkillType)
 {
     return(string.Format(SKEYSKILLS, (int)chartype, iSlot, iSkillType));
 }
Esempio n. 19
0
 public static List <SkillTypeInfo> GetSkillInfosUnderDisciplines(CharType.CHARTYPE chartype)
 {
     return(GetSkillInfosUnderDisciplines(CharType.GetDisciplines(chartype)));
 }
Esempio n. 20
0
 void ReceiveDraft(int indexDraftInput, CharType.CHARTYPE chartypeToDraft)
 {
     Debug.LogErrorFormat("Received input #{0}: Draft {1}", indexCurDraftInput, chartypeToDraft);
     AddInputToBuffer(indexDraftInput, chartypeToDraft);
 }
Esempio n. 21
0
 public static Loadout GetDefaultLoadoutForChar(CharType.CHARTYPE chartype)
 {
     return(dictDefaultLoadouts[chartype]);
 }
Esempio n. 22
0
 public static string GetKeyName(CharType.CHARTYPE chartype, int iSlot)
 {
     return(string.Format(SKEYNAME, (int)chartype, iSlot));
 }