public void LoadStartingInputs() { //If we're not the master, then it's not our job to load any inputs if (PhotonNetwork.IsMasterClient == false) { return; } //If we don't have any logged match inputs, then we don't need to do anything here if (lstLoggedSerializedMatchInputs == null) { return; } //First, double check that the NetworkMatchSender has been started so we can ask it to send some input for us NetworkMatchSender.Get().Start(); //If we have any loaded logged match inputs, then we can send these all to the matchnetworkreceiver's input buffer for (int i = 0; i < lstLoggedSerializedMatchInputs.Count; i++) { //For the index, just send 0, 1, 2,... in order since we'll be starting from the very beginning of the match NetworkMatchSender.Get().SendInput(i, lstLoggedSerializedMatchInputs[i]); } //Since we're done giving all our logged inputs to the networkreceiver, we cna clear out our locally stored lst of inputs lstLoggedSerializedMatchInputs = null; }
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 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 SubmitNextSkill() { Debug.Assert(ContSkillEngine.Get().matchinputToFillOut != null, "AI input was asked to submit an input, but we're not locally waiting on any input"); Debug.AssertFormat(ContSkillEngine.Get().matchinputToFillOut.iPlayerActing == plyrOwner.id, "Scripted input was asked to submit an input for player {0}, but this controller is for player {1}", ContSkillEngine.Get().matchinputToFillOut.iPlayerActing, plyrOwner.id); //Just randomly select an input that would work for the pending match input ContSkillEngine.Get().matchinputToFillOut.FillRandomly(); //Double check that the input that we're planning to submit is actually valid if (ContSkillEngine.Get().matchinputToFillOut.CanLegallyExecute() == false) { Debug.LogErrorFormat("Warning - resetting input to default since an illegal input {0} was attempted", ContSkillEngine.Get().matchinputToFillOut); //If it wasn't legal, then reset it to some default failsafe that is guaranteed to be legal ContSkillEngine.Get().matchinputToFillOut.ResetToDefaultInput(); } //By this point, we have a valid input, so let's submit it NetworkMatchSender.Get().SendNextInput(ContSkillEngine.Get().matchinputToFillOut); }
public void SubmitNextSkill() { Debug.Assert(ContSkillEngine.Get().matchinputToFillOut != null, "Scripted input was asked to submit an input, but we're not locally waiting on any input"); Debug.AssertFormat(ContSkillEngine.Get().matchinputToFillOut.iPlayerActing == plyrOwner.id, "Scripted input was asked to submit an input for player {0}, but this script is for player {1}", ContSkillEngine.Get().matchinputToFillOut.iPlayerActing, plyrOwner.id); //If we already used all of the inputs in our script, then we should change our inputtype to something more flexible if (nInputIndex >= lstInputScript.Count) { Debug.LogFormat("Finished scripted input for Player {0} - switching to type {1}", plyrOwner, inputtypeToSwitchTo); plyrOwner.SetInputType(inputtypeToSwitchTo); plyrOwner.inputController.StartSelection(); return; } //If we still have inputs in our script, take the appropriate one ContSkillEngine.Get().matchinputToFillOut = lstInputScript[nInputIndex]; //Double check that the input that we're planning to submit is actually valid if (ContSkillEngine.Get().matchinputToFillOut.CanLegallyExecute() == false) { Debug.LogErrorFormat("Warning - resetting input to default since an illegal input {0} was attempted", ContSkillEngine.Get().matchinputToFillOut); //If it wasn't legal, then reset it to some default failsafe that is guaranteed to be legal ContSkillEngine.Get().matchinputToFillOut.ResetToDefaultInput(); } //Since we've grabbed this input, advance our index to be ready for the next requested input nInputIndex++; //By this point, we have a valid input, so let's submit it NetworkMatchSender.Get().SendNextInput(ContSkillEngine.Get().matchinputToFillOut); }