public void LoadCheckpoint() { // reset all sections past mSectionInd with 0 // reset mSectionInd with mWaveInd for (int i = mCheckpointSave.mSectionInd + 1; i < mSections.Length; i++) { mSections[i].ResetSection(0); } // mSections[mCheckpointSave.mSectionInd+1].ResetSection(0); mSections[mCheckpointSave.mSectionInd].ResetSection(mCheckpointSave.mWaveInd); mSections[mCheckpointSave.mSectionInd].Prep(); LVL_SectionTrigger trig = mSections[mCheckpointSave.mSectionInd].GetComponentInChildren <LVL_SectionTrigger>(); ActiveSectionPosition.Value = trig.transform.position; // Need to also reset the player, health and position. mPlayer.MovePlayerTo(mCheckpointSave.mPlayerPos, mCheckpointSave.mPlayerRot); mActSection = mCheckpointSave.mSectionInd; // need to re-activate/de-activate all the walls that need to be up. Maybe we can just activate all walls, then deactivate the ones in // deactivate on finish? if (mCheckpointSave.mSectionInd <= 0) { return; } mSections[mCheckpointSave.mSectionInd - 1].DeactivateWallsOnFinish(); }
private void LoadCheckpointFromData(SO_LVL_Checkpoint data) { for (int i = 0; i < mSections.Length; i++) { mSections[i].ResetSection(0); } if (data.mSectionInd != 0) { mSections[data.mSectionInd - 1].DeactivateWallsOnFinish(); // such a goddamn hack. if (data.mSectionInd > 11) { for (int i = 0; i < 11; i++) { mSections[i].DeactivateWallsOnFinish(); } } } // mSections[mCheckpointSave.mSectionInd+1].ResetSection(0); mSections[data.mSectionInd].Prep(); LVL_SectionTrigger trig = mSections[data.mSectionInd].GetComponentInChildren <LVL_SectionTrigger>(); ActiveSectionPosition.Value = trig.transform.position; // Need to also reset the player, health and position. mPlayer.MovePlayerTo(data.mPlayerPos, mPlayer.transform.rotation); mActSection = data.mSectionInd; SaveCheckpoint(); OnCheckpointRestarted.Raise(null); // mActSection = data.mSectionInd; }
// Now sections spawn events when they are completed. public void HandleSectionCompleted() { Debug.Log("Section complete"); mActSection++; if (mActSection >= mSections.Length) { OnAllSectionsBeaten.Raise(null); } else { mSections[mActSection].Prep(); LVL_SectionTrigger trig = mSections[mActSection].GetComponentInChildren <LVL_SectionTrigger>(); ActiveSectionPosition.Value = trig.transform.position; } }