public void saveBoss() { //path = Application.dataPath + "/SAVES/testSave.txt"; turrets = GameObject.FindGameObjectsWithTag("turret Main"); for (int i = 0; i < turrets.Length; i++) { saveTurretSubwave temp = SaveSubwaveStorage(turrets[i].GetComponent <turretSubwaveStorage>()); SaveText += JsonUtility.ToJson(temp) + "\n"; } #if UNITY_STANDALONE var SaveWindowBuild = StandaloneFileBrowser.SaveFilePanel( "Save texture as PNG", "", "boss name" + ".txt", "txt"); if (SaveWindowBuild.Length != 0) { File.WriteAllText(SaveWindowBuild, SaveText); } #endif }
IEnumerator loadBossTile() { spawnedTurret = Instantiate(turret, new Vector3(0, 0, 0), transform.rotation) as GameObject; save = new saveTurretSubwave(); JsonUtility.FromJsonOverwrite(lines[NumOfTurretsLeft], save); load = LoadSubwaveStorage(save); setAll(load, spawnedTurret.GetComponent <turretSubwaveStorage>(), spawnedTurret); spawnedTurret.transform.parent = boss.transform; spawnedTurret.transform.localPosition = spawnedTurret.GetComponent <turretSubwaveStorage>().turretLocation; NumOfTurrets = spawnedTurret.GetComponent <turretSubwaveStorage>().TotalNumberOfTurrets; //Debug.Log(spawnedTurret.GetComponent<turretSubwaveStorage>().spiralDirection[0, 0]); boss.transform.GetChild(0).GetComponent <bossWaveControl>().setArrays(); boss.transform.GetChild(0).GetComponent <bossWaveControl>().setValues(0); NumOfTurretsLeft++; if (NumOfTurretsLeft >= NumOfTurrets) { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); } else { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); StartCoroutine(loadBossTile()); } }
//sets all the values in the saveTurretSubwave script with the values in temp public saveTurretSubwave SaveSubwaveStorage(turretSubwaveStorage temp) { save = new saveTurretSubwave(); save.totalWaveCount = temp.totalWaveCount; save.SubwaveCount = temp.SubwaveCount; save.TotalNumberOfTurrets = temp.TotalNumberOfTurrets; save.turretLocation = temp.turretLocation; save.activeInWave = temp.activeInWave; save.isDestroyable = temp.isDestroyable; save.numberActiveStreams = temp.numberActiveStreams; save.subwaveDuration = temp.subwaveDuration; save.turretHealth = temp.turretHealth; //Loops int count = 0; //Debug.Log(""); for (int i = 0; i < 4; i++) { for (int j = 0; j < 16; j++) { //Debug.Log(count + " ," + i+ " ,"+j); save.streamEnabled[count] = temp.streamEnabled[j, i]; save.turretSavedOnce[count] = temp.turretSavedOnce[j, i]; save.fireType[count] = temp.fireType[j, i]; save.targetingType[count] = temp.targetingType[j, i]; save.rotateSpeed[count] = temp.rotateSpeed[j, i]; //public Vector4[] temp = new Vector4[16]; // Target player settings save.smoothTarget[count] = temp.smoothTarget[j, i]; save.smoothTargetSpeed[count] = temp.smoothTargetSpeed[j, i]; save.targetPlayerOffsetAmmount[count] = temp.targetPlayerOffsetAmmount[j, i]; // arc targetting settings save.rotateAngleDirection[count] = temp.rotateAngleDirection[j, i]; save.rotateAngleWidth[count] = temp.rotateAngleWidth[j, i]; // spiral targetting settings save.spiralDirection[count] = temp.spiralDirection[j, i]; //single direction settings save.singleDirDirection[count] = temp.singleDirDirection[j, i]; //Bullet fire variables save.bulletFormation[count] = temp.bulletFormation[j, i]; save.numOfBullets[count] = temp.numOfBullets[j, i]; //firerate determines the gap between each burst of shots save.firerate[count] = temp.firerate[j, i]; //bullet delay determins the gap between each individual bullet in a burst (if they are staggered) save.bulletDelay[count] = temp.bulletDelay[j, i]; save.bulletSpeedIncreaseAmmount[count] = temp.bulletSpeedIncreaseAmmount[j, i]; save.angleBetweenBullets[count] = temp.angleBetweenBullets[j, i]; save.bulletRandomRange[count] = temp.bulletRandomRange[j, i]; save.shotgunStraight[count] = temp.shotgunStraight[j, i]; save.bulletSpeedIncreaseCheck[count] = temp.bulletSpeedIncreaseCheck[j, i]; //individual bullet settings (what movement type they use their speed etc) save.bulletMovementType[count] = temp.bulletMovementType[j, i]; save.bulletBaseSpeed[count] = temp.bulletBaseSpeed[j, i]; //sin wave storage save.bulletAmplitude[count] = temp.bulletAmplitude[j, i]; save.bulletFrequency[count] = temp.bulletFrequency[j, i]; //variable speed storage save.bulletMaxSpeed[count] = temp.bulletMaxSpeed[j, i]; save.bulletMinSpeed[count] = temp.bulletMinSpeed[j, i]; save.bulletSpeedChangeFrequency[count] = temp.bulletSpeedChangeFrequency[j, i]; //travel then target storage save.timeUntilChange[count] = temp.timeUntilChange[j, i]; save.newTargetingType[count] = temp.newTargetingType[j, i]; save.speedAfterTarget[count] = temp.speedAfterTarget[j, i]; save.bulletType[count] = temp.bulletType[j, i]; count++; } //count++; } return(save); }