//static public GameObject powerUI; void Start() { //początkowe wartości PlayerFighting = false; ChangeToZero = true; YouGetBoard.SetActive(false); YouGet.text = " "; for (int i = 0; i < note.Length; i++) { note[i] = 0; } LevelId = Application.loadedLevel; save = gameObject.GetComponent <Saveing>(); DeadScreenImage.SetActive(false); NewLevelInstantiate = false; // data = gameObject.GetComponent<itemDataBase>(); awake = true; soundHolder = GameObject.Find("SoundHolder").GetComponent <SoundHolder>(); keyMenager = GameObject.Find("KeyMenager").GetComponent <KeyMenager>(); soundHolder.isloading = true; eq = GameObject.Find("Equipment").GetComponent <CanvasEkwipunek>(); saving = false; loadScene = false; player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Controller>(); playerAtckScript = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAttack>(); loadScript = gameObject.GetComponent <LoadTargetScript>(); itd = gameObject.GetComponent <itemDataBase>(); Debug.Log("itd nie jest null"); save.Load(); itemDataBaseChest = gameObject.GetComponent <itemDataBaseChest>(); if (itemDataBaseChest != null) //jezeli znajduje się skrzynia na planszy { Debug.Log("itemDataBaseChest nie jest null"); save.ChestLoad(LevelId); } RefreshEqStats(); soundHolder.isloading = false; if (PlayerPrefs.HasKey("difficultLevel")) //załadowanie poziomu trudności { difficultLevel = PlayerPrefs.GetInt("difficultLevel"); } settings.load(); //załadowanie ustawień exp_Slider = GameObject.Find("SkillUI").GetComponent <Exp_Slider>(); }
void Start() { trans = GetComponent <Transform>(); itd = GameObject.FindGameObjectWithTag("GameMaster").GetComponent <itemDataBase>(); if (gameObject.name == "Chest") //items data base chest { itdch = GameObject.FindGameObjectWithTag("GameMaster").GetComponent <itemDataBaseChest>(); } gm = GameObject.FindGameObjectWithTag("GameMaster").GetComponent <Game_Master>(); eq = GameObject.Find("Equipment").GetComponent <CanvasEkwipunek>(); child = gameObject.GetComponentInChildren <ElementEq>(); audioSource = gameObject.GetComponent <AudioSource>(); audioSource.clip = audioClip; }
void Update() { TimePowerChoose = 0.4f + (TimePowerChooseBasic * difficultLevel / 10f); if (settings.gameObject.activeSelf) { difficultLevel = settings.qualityindex; } //progi punktowe if (PlayerLevel == 0) { nextLevel = 50f; } if (PlayerLevel == 1) { nextLevel = 75f; } if (PlayerLevel > 1) //obliczanie progów punktowych { nextLevel = PlayerLevel * PlayerLevel * PlayerLevel * 10f - PlayerLevel * PlayerLevel * 20f + 100f; } //ile pozostało do nastepnego poziomu i jakie punkty należy przyznać graczowi if (nextLevel > 0) { if (nextLevel <= exp) { exp_Slider.NewLevel(); PDPoint += 1; if (PlayerLevel % 10 == 0) { SkillPDPoint += 1; } if (NewLevelTimer >= 1) { NewLevelInstantiate = true; } PlayerLevel += 1; } } //przyznanie poziomu if (NewLevelInstantiate) { NewLevelTimer = 0; GameObject particle = Instantiate(NewLevel, PlayerNewLevelTransform.position, transform.rotation); particle.GetComponent <LevelUp>().target = PlayerNewLevelTransform; NewLevelInstantiate = false; } else { if (NewLevelTimer < 1) { NewLevelTimer += Time.deltaTime; } else { NewLevelTimer = 1f; } } //obliczenie ilości noży w ekwipunktu if (Secon_Weapon_Slot.transform.childCount > 0) { ElementEq Second_Weapon = Secon_Weapon_Slot.GetComponentInChildren <ElementEq>(); knifeId = Second_Weapon.Id; knifeCount = Second_Weapon.Count; } else { knifeCount = 0; } //wczytywanie i zapisywanie if (awake) { GameStart(); } if (dead) { GameEnd(); } if (saving) { if (gameObject.GetComponent <itemDataBaseChest>() != null) { itemDataBaseChest = gameObject.GetComponent <itemDataBaseChest>(); save.ChestSave(LevelId); Debug.Log("saveing chest"); } save.Save(); } //przeskakiwanie miedzy poziomami if (loadScene == true && saving == false) { player.blockMove = true; ScreenImage.SetActive(true); ScreenImage.GetComponent <Animator>().SetBool("FadeOut", true); fade = true; } if (fade) { Cursor.lockState = CursorLockMode.Locked; //Zablokowanie kursora myszy. Cursor.visible = false; //Ukrycie kursora. TimeToFade -= Time.deltaTime; if (TimeToFade <= 0) { //50 line loadScript.LoadScreenNum(SceneIdToLoad, Application.loadedLevel); } } if (PlayerSpeed == 0) //obliczanie kosztów ruchów { BackDashCost = BasicBackDashCost; JumpDownSpecialAttackCost = BasicJumpDownSpecialAttackCost; JumpSpecialAttackCost = BasicJumpSpecialAttackCost; RunSpecialAttackCost = BasicRunSpecialAttackCost; AttackCost = BasicAttackCost; AttackRunCost = BasicAttackRunCost; JumpCost = BasicJumpCost; } else { BackDashCost = BasicBackDashCost - (5 * PlayerSpeed); JumpDownSpecialAttackCost = BasicJumpDownSpecialAttackCost - (2 * (PlayerSpeed + PlayerSwordStaminaLevel)); JumpSpecialAttackCost = BasicJumpSpecialAttackCost - (2 * (PlayerSpeed + PlayerSwordStaminaLevel)); RunSpecialAttackCost = BasicRunSpecialAttackCost - (2 * (PlayerSpeed + PlayerSwordStaminaLevel)); AttackCost = BasicAttackCost - (1 * PlayerSpeed + PlayerSwordStaminaLevel); AttackRunCost = BasicAttackRunCost - (2 * (PlayerSpeed + PlayerSwordStaminaLevel)); JumpCost = BasicJumpCost - (5 * PlayerSpeed); } if (BackDashCost <= 5) { BackDashCost = 5f; } if (JumpDownSpecialAttackCost <= 10) { JumpDownSpecialAttackCost = 10; } if (JumpSpecialAttackCost <= 15) { JumpSpecialAttackCost = 15; } if (RunSpecialAttackCost <= 20) { RunSpecialAttackCost = 20; } if (AttackCost <= 1) { AttackCost = 1; } if (AttackRunCost <= 5) { AttackRunCost = 5f; } if (JumpCost <= 5) { JumpCost = 5f; } //zatrzymanie czasu if (ChangeToZero) { active_menu = 0; ChangeToZero = false; } if (active_menu == 0) { Time.timeScale = 1; player.blockMove = true; Cursor.lockState = CursorLockMode.Locked; //Zablokowanie kursora myszy. Cursor.visible = false; //Ukrycie kursora. if (StopTimePowerChoose) { Time.timeScale = TimePowerChoose; } } else { Time.timeScale = 0; //player.CanMove = false; Cursor.lockState = CursorLockMode.None; //Odblokowanie kursora myszy. Cursor.visible = true; //Pokazanie kursora. } //wyswietlanie podpowiedzi if (timeToShow < 1f) { YouGetBoard.GetComponent <Animator>().SetBool("disappear", true); } if (timeToShow > 0) { timeToShow -= Time.deltaTime; YouGetBoard.SetActive(true); } else { YouGetBoard.SetActive(false); YouGet.text = " "; } }
public void ChestLoad(int id) { Debug.Log("Loading Chest.."); //ładowanie skrzyni idbch = gameObject.GetComponent <itemDataBaseChest>(); if (GameObject.FindGameObjectWithTag("chest") == null) //jeżeli znajduje się taki przedmiot na mapie { return; } ChestTrigger chest = GameObject.FindGameObjectWithTag("chest").GetComponent <ChestTrigger>(); // File.Delete(Application.persistentDataPath + "/ChestRecord" + id + ".data"); //Zanim odczytamy dane upewnijmy się, że jest co czytać. //Sprawdzamy czy plik zapisu istnieje. if (File.Exists(Application.persistentDataPath + "/ChestRecord" + id + ".data")) { //Odczytujemy/pobieramy dane z pliku. FileStream file = File.Open(Application.persistentDataPath + "/ChestRecord" + id + ".data", FileMode.Open); //Posłuży do odczytu danych do pliku. BinaryFormatter bf = new BinaryFormatter(); // Deserializujemy dane z pliku i przekształcamy je na obiekt GraczData. ChestData chdata = (ChestData)bf.Deserialize(file); file.Close(); //Plik odczytany zamykamy plik. //Ustawiamy dane; chest.visited = chdata.visited; for (int i = 0; i < chdata.AmuletsCount.Length; i++) { Debug.Log("zerowanie"); idbch.AmuletsCount[i] = 0; } for (int i = 0; i < chdata.Main_WeaponCount.Length; i++) { idbch.Main_WeaponCount[i] = 0; Debug.Log("zerowanie"); } for (int i = 0; i < chdata.Secon_WeaponCount.Length; i++) { idbch.Secon_WeaponCount[i] = 0; Debug.Log("zerowanie"); } for (int i = 0; i < chdata.TasksCount.Length; i++) { idbch.TasksCount[i] = 0; Debug.Log("zerowanie"); } for (int i = 0; i < chdata.ArmorsCount.Length; i++) { idbch.ArmorsCount[i] = 0; Debug.Log("zerowanie"); } for (int i = 0; i < chdata.BootsCount.Length; i++) { idbch.BootsCount[i] = 0; Debug.Log("zerowanie"); } for (int i = 0; i < chdata.LegsCount.Length; i++) { idbch.LegsCount[i] = 0; Debug.Log("zerowanie"); } for (int i = 0; i < chdata.AmuletsCount.Length; i++) { Debug.Log(i); idbch.AmuletsCount[i] = chdata.AmuletsCount[i]; } for (int i = 0; i < chdata.Main_WeaponCount.Length; i++) { idbch.Main_WeaponCount[i] = chdata.Main_WeaponCount[i]; } for (int i = 0; i < chdata.Secon_WeaponCount.Length; i++) { idbch.Secon_WeaponCount[i] = chdata.Secon_WeaponCount[i]; } for (int i = 0; i < chdata.TasksCount.Length; i++) { idbch.TasksCount[i] = chdata.TasksCount[i]; } for (int i = 0; i < chdata.ArmorsCount.Length; i++) { idbch.ArmorsCount[i] = chdata.ArmorsCount[i]; } for (int i = 0; i < chdata.BootsCount.Length; i++) { idbch.BootsCount[i] = chdata.BootsCount[i]; } for (int i = 0; i < chdata.LegsCount.Length; i++) { idbch.LegsCount[i] = chdata.LegsCount[i]; } } idbch.Instantiate(); Debug.Log("Loading Chest END"); }
//Klasa zapisująca dane o skrzynie z poziomu public void ChestSave(int id) { gameMaster.saving = true; if (GameObject.FindGameObjectWithTag("chest") == null) { //jeżeli znajduje się taki przedmiot na mapie return; } ChestTrigger chest = GameObject.FindGameObjectWithTag("chest").GetComponent <ChestTrigger>(); idbch = gameObject.GetComponent <itemDataBaseChest>(); Debug.Log("Saveing..Chest"); //Posłuży do przesyłania danych do pliku. FileStream plik = File.Create(Application.persistentDataPath + "/ChestRecord" + id + ".data"); ChestData chdata = new ChestData(); for (int i = 0; i < chdata.AmuletsCount.Length; i++) { chdata.AmuletsCount[i] = idbch.AmuletsCount[i]; } for (int i = 0; i < chdata.Main_WeaponCount.Length; i++) { chdata.Main_WeaponCount[i] = idbch.Main_WeaponCount[i]; } for (int i = 0; i < chdata.Secon_WeaponCount.Length; i++) { chdata.Secon_WeaponCount[i] = idbch.Secon_WeaponCount[i]; } for (int i = 0; i < chdata.TasksCount.Length; i++) { chdata.TasksCount[i] = idbch.TasksCount[i]; } for (int i = 0; i < chdata.ArmorsCount.Length; i++) { chdata.ArmorsCount[i] = idbch.ArmorsCount[i]; } for (int i = 0; i < chdata.BootsCount.Length; i++) { chdata.BootsCount[i] = idbch.BootsCount[i]; } for (int i = 0; i < chdata.LegsCount.Length; i++) { chdata.LegsCount[i] = idbch.LegsCount[i]; } chdata.visited = chest.visited; //Posłuży do zapisywania danych do pliku. BinaryFormatter bf = new BinaryFormatter(); //Serializujemy/zapisujemy dane do pliku bf.Serialize(plik, chdata); plik.Close();//Zamykamy plik (kończymy operacje na pliku). gameMaster.saving = false; Debug.Log("Saveing chest - save all"); }