public void TransferToMatchScene() { if (PhotonNetwork.IsMasterClient == false) { Debug.LogError("A non-master tried to move directly to match - ignoring"); return; } else if (ArePlayersConnected() == false) { Debug.LogError("Tried to move to directly to match when not all characters are connected"); return; } else if (NetworkMatchSetup.HasAllMatchSetupInfo() == false) { Debug.LogError("MatchSetup is not filled out enough to start a match"); return; } if (SceneManager.GetActiveScene().name == "_MATCH") { Debug.Log("We're already in the _MATCH scene, so no need to transfer to it"); } else { Debug.Log(NetworkMatchSetup.MatchSetupToString()); Debug.Log("We as the master are moving us to the Match scene"); PhotonNetwork.LoadLevel("_MATCH"); } }
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"); }
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 IEnumerator SetupMatch() { while (NetworkMatchSetup.HasAllMatchSetupInfo() == false) { //Spin until we have all the match setup info that we need to start the match yield return(null); } while (NetworkMatchSender.Get() == null) { //Spin until the needed networking objects have been spawned and given a chance to initialize // - in particular, the NetworkMatchSender needs to be ready in case we need to immediately send inputs // as part of initializing the match (like for loading a log file) yield return(null); } Debug.Log("Starting match initializations since we have enough information"); ContRandomization.Get().InitGenerator(NetworkMatchSetup.GetRandomizationSeed()); Debug.Log("Finished initializing the randomizer"); InitPlayers(nPlayers); Debug.Log("Finished initializing players"); //Initialize characters InitAllChrs(); Debug.Log("After InitAllChrs"); //Assign local input controllers for each player AssignAllLocalInputControllers(); Debug.Log("After assigning local input controllers"); ContManaDistributer.Get().InitializeRandomReserves(); Debug.Log("After initializing mana reserves"); InitAllChrPositions(); Debug.Log("After initializing positions"); //ContPositions.Get().PrintAllPositions(); ContTurns.Get().InitializePriorities(); Debug.Log("After InitializePriorities"); //Check if the LogManager wants to load in any starting inputs LogManager.Get().LoadStartingInputs(); Debug.Log("After LoadStartingInputs"); LogManager.Get().InitMatchLog(); Debug.Log("Finished initializing the log file"); }
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 LogPositionCoords(int iPlayer) { for (int iChr = 0; iChr < Player.MAXCHRS; iChr++) { Position.Coords poscoords = NetworkMatchSetup.GetPositionCoords(iPlayer, iChr); WriteToMatchLogFile(string.Format("pc:{0}:{1}:{2}:{3}", iPlayer, iChr, Position.SerializeCoords(poscoords), poscoords)); } }
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 void UpdateDropdownOptions() { LibView.SetDropdownOptions(dropdown, CharType.GetAllChrNames()); //Ensure the default-selected option for this dropdown is mirroring the default in the matchsetup dropdown.SetValueWithoutNotify((int)NetworkMatchSetup.GetCharacterSelection(plyrselectorParent.idPlayer, idChr)); dropdown.RefreshShownValue(); }
public void LoadLoggedRandomizationSeed(string[] arsSplitLogs) { Debug.Assert(arsSplitLogs[0] == "rs"); int nRandomizationSeed; if (int.TryParse(arsSplitLogs[1], out nRandomizationSeed) == false) { Debug.LogErrorFormat("Error! {0} was not a valid randomization seed to be loaded", arsSplitLogs[1]); return; } NetworkMatchSetup.SetRandomizationSeed(nRandomizationSeed); }
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 AssignLocalInputController(Player plyr) { //If the player isn't controlled locally, just set the plyr's controller to null since it's not our job to control them if (NetworkMatchSetup.IsLocallyOwned(plyr.id) == false) { plyr.SetInputType(LocalInputType.InputType.NONE); } else { //Otherwise, this character is controlled by this local client - figure out which input type they'll need and add it plyr.SetInputType(NetworkMatchSetup.GetInputType(plyr.id)); } }
public void EditChrLoadout(int iChrToEdit) { if (loadoutselectActive != null) { Debug.LogError("Can't edit another loadout, since we're already editing one"); return; } //Spawn the loadout selector loadoutselectActive = GameObject.Instantiate(pfLoadoutSelector, this.transform.parent).GetComponent <LoadoutSelector>(); loadoutselectActive.BeginSelection(idPlayer, iChrToEdit, CleanupEditLoadout, NetworkMatchSetup.GetLoadout(idPlayer, iChrToEdit)); }
void InitAllChrs() { for (int i = 0; i < nPlayers; i++) { arChrs[i] = new Chr[Player.MAXCHRS]; arPlayers[i].nChrs = Player.MAXCHRS; for (int j = 0; j < arPlayers[i].nChrs; j++) { InitChr(NetworkMatchSetup.GetCharacterSelection(i, j), arPlayers[i], j, NetworkMatchSetup.GetLoadout(i, j)); } } }
//Figure out what type of draft action we were waiting on (foreign/local) and react appropriately to completing it public void EndWaitingOnDraftInput() { //Check what type of input we're waiting on if (NetworkMatchSetup.IsLocallyOwned(draftactionWaitingOn.iPlayer)) { //Let anyone (UI effects probably) know that the current player has finished their selection subEndChooseLocally.NotifyObs(); } else { subEndChooseForeign.NotifyObs(); } //Clear the action we were waiting on draftactionWaitingOn = null; }
public void LogLoadouts(int iPlayer) { for (int iChr = 0; iChr < Player.MAXCHRS; iChr++) { LoadoutManager.Loadout loadout = NetworkMatchSetup.GetLoadout(iPlayer, iChr); string sLoadout = string.Format("lo:{0}:{1}", iPlayer, iChr); int[] arnSerializedLoadout = LoadoutManager.SerializeLoadout(loadout); sLoadout += LibConversions.ArToStr(arnSerializedLoadout); sLoadout += "\n" + loadout; WriteToMatchLogFile(sLoadout); } }
public void FinishSelections() { //Only allow manual selections when the local player is human Debug.Assert(ContTurns.Get().GetNextActingChr().plyrOwner.inputController.GetInputType() == LocalInputType.InputType.HUMAN, "Error - can only submit skills for locally-owned >human<'s characters"); Debug.Assert(NetworkMatchSetup.IsLocallyOwned(ContTurns.Get().GetNextActingChr().plyrOwner.id), "Error - can only submit skills for >locally-owned< human's characters"); //By this point, we have built up our local selectionsInProgress skill selection into a valid selection of targets, // so let's pass a reference into the Skill Engine's matchinputToFillOut so it can be submitted ContSkillEngine.Get().matchinputToFillOut = selectionsInProgress; NetworkMatchSender.Get().SendNextInput(ContSkillEngine.Get().matchinputToFillOut); //Clean up the selection process (clears out the stored selections structure, sends notifications, etc.) ExitSelectionsProcess(); }
public void LoadLoggedInputTypes(string[] arsSplitLogs) { Debug.Assert(arsSplitLogs[0] == "it"); int inputtype0, inputtype1; if (int.TryParse(arsSplitLogs[1], out inputtype0) == false || inputtype0 < 0) { Debug.LogErrorFormat("Error! {0} was not a valid input type to be loaded", arsSplitLogs[1]); return; } if (int.TryParse(arsSplitLogs[2], out inputtype1) == false || inputtype1 < 0) { Debug.LogErrorFormat("Error! {0} was not a valid input type to be loaded", arsSplitLogs[2]); return; } NetworkMatchSetup.SetInputType(0, (LocalInputType.InputType)inputtype0); NetworkMatchSetup.SetInputType(1, (LocalInputType.InputType)inputtype1); }
public void LoadLoggedPlayerOwners(string[] arsSplitLogs) { Debug.Assert(arsSplitLogs[0] == "po"); int playerowner0, playerowner1; if (int.TryParse(arsSplitLogs[1], out playerowner0) == false || playerowner0 < 0) { Debug.LogErrorFormat("Error! {0} was not a valid player owner to be loaded", arsSplitLogs[1]); return; } if (int.TryParse(arsSplitLogs[2], out playerowner1) == false || playerowner1 < 0) { Debug.LogErrorFormat("Error! {0} was not a valid player owner to be loaded", arsSplitLogs[2]); return; } NetworkMatchSetup.SetPlayerOwner(0, playerowner0); NetworkMatchSetup.SetPlayerOwner(1, playerowner1); }
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(); } }
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); } }
public void LoadLoggedCharacterSelections(string[] arsSplitLogs) { Debug.Assert(arsSplitLogs[0] == "cs"); int iPlayer, iChr, nchrSelection; 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; } if (int.TryParse(arsSplitLogs[3], out nchrSelection) == false) { Debug.LogErrorFormat("Error! {0} was not a valid serialized character selections to be loaded", arsSplitLogs[3]); return; } NetworkMatchSetup.SetCharacterSelection(iPlayer, iChr, (CharType.CHARTYPE)nchrSelection); }
public void WaitForDraftInput() { //If we're already waiting, then we don't need to do anything further if (draftactionWaitingOn != null) { return; } //Raise the flag that we're waiting for input draftactionWaitingOn = GetNextDraftPhaseStep(); //Check what type of input we're waiting on if (NetworkMatchSetup.IsLocallyOwned(draftactionWaitingOn.iPlayer)) { //Prompt the local player to select input subBeginChooseLocally.NotifyObs(); } else { //Let anyone (UI effects probably) know that we're waiting for another player to make a selection subBeginChooseForeign.NotifyObs(); } return; }
public void LoadLoggedPositionCoords(string[] arsSplitLogs) { Debug.Assert(arsSplitLogs[0] == "pc"); int iPlayer, iChr, nSerializedCoords; 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; } if (int.TryParse(arsSplitLogs[3], out nSerializedCoords) == false) { Debug.LogErrorFormat("Error! {0} was not a valid serialized coordinates to be loaded", arsSplitLogs[3]); return; } NetworkMatchSetup.SetPositionCoords(iPlayer, iChr, Position.UnserializeCoords(nSerializedCoords)); }
public void OnOwnerSelectChange() { NetworkMatchSetup.SetPlayerOwner(plyrselectorParent.idPlayer, dropdown.value + 1); //Offset by one since our internalplayer ids start at 0 }
public void LogInputTypes() { WriteToMatchLogFile(string.Format("it:{0}:{1}", (int)NetworkMatchSetup.GetInputType(0), (int)NetworkMatchSetup.GetInputType(1))); }
public void LogPlayerOwners() { WriteToMatchLogFile(string.Format("po:{0}:{1}", NetworkMatchSetup.GetPlayerOwner(0), NetworkMatchSetup.GetPlayerOwner(1))); }
public void LogRandomizationSeed() { WriteToMatchLogFile(string.Format("rs:{0}", NetworkMatchSetup.GetRandomizationSeed().ToString())); }
//The main loop that will process the effects of the game. If it needs inputs, it will flag what // it's waiting on and pull input from the network buffer to decide what action should be taken public IEnumerator CRMatchLoop() { //Do any animation processing that needs to be done before the match processing actually starts yield return(StartCoroutine(CRPrepMatch())); //Initially decide if we want to do any fast forwarding from early loaded input HandleFastForwarding(); //Do any initial processing for beginning of match effects yield return(ProcessStackUntilInputNeeded()); //Keep processing effects while the match isn't finished while (!IsMatchOver()) { // At this point, we should have an input field that's been set up that needs to be filled out Debug.Assert(matchinputToFillOut != null); bool bNeedsLocalInput = false; //If we need input, let's check if we already have input waiting in our buffer for that input if (NetworkMatchReceiver.Get().IsCurMatchInputReady() == false) { // Now that input is needed by some player, check if we locally control that player if (NetworkMatchSetup.IsLocallyOwned(matchinputToFillOut.iPlayerActing)) { bNeedsLocalInput = true; //Let the match input prepare to start gathering manual input matchinputToFillOut.StartManualInputProcess(); } else { //If we don't locally control the player who needs to decide an input DebugDisplay.Get().SetDebugText("Waiting for foreign input"); } //Wait until we have input waiting for us in the network buffer while (NetworkMatchReceiver.Get().IsCurMatchInputReady() == false) { //Keep spinning until we get the input we're waiting on DebugDisplay.Get().SetDebugText("Waiting for input"); yield return(null); } //Do any cleanup that we need to do if we were waiting on input //TODO - figure out what needs to be done and under what circumstances - careful of potentially changing local input controllers if (bNeedsLocalInput == true) { //Have the match input let the local input controller know that we're done with gathering input matchinputToFillOut.EndManualInputProcess(); } } //Check if we should be master forwarding through our inputs if we have a bunch stacked up waiting to be processed (like from loading a log file or reconnecting) HandleFastForwarding(); //At this point, we have an input in the buffer that we are able to process MatchInput matchinput = NetworkMatchReceiver.Get().GetCurMatchInput(); //Make a record of which input we're going to be processing in our logs LogManager.Get().LogMatchInput(matchinput); //Clear out the matchinput we prompting to be filled out matchinputToFillOut = null; //Process that match input by deferring to its execute method yield return(matchinput.Execute()); //The execute method should have pushed new executables/clauses onto the stack, so we can process them // Pass control over to the stack-processing loop until it needs player input to continue the simulation yield return(ProcessStackUntilInputNeeded()); //Since we're done processing all the effects that may need access to the most recent input, we can advance to the next needed input NetworkMatchReceiver.Get().FinishCurMatchInput(); } //Do any animation process that needs to be done before we leave the match scene yield return(StartCoroutine(CRCleanUpMatch())); //Do any fill wrap-up for the match FinishMatch(); }
public void OnInputSelectChange() { NetworkMatchSetup.SetInputType(plyrselectorParent.idPlayer, (LocalInputType.InputType)dropdown.value); }
public void InitRandomization() { //Attempt to set the randomization seed (we'll only succeed if we're the master, but we should still try) NetworkMatchSetup.SetRandomizationSeed(Random.Range(0, 1000000)); }