// Use this for initialization void Start() { chestManager = GetComponent <ChestManager>(); if (chestManager == null) { chestTrigger = GetComponent <ChestTrigger>(); } boatRb = GetComponentInParent <Rigidbody>(); lastVelocity = boatRb.velocity; }
protected virtual GameObject CreateRandomChest(int chestID) { GameObject go = GraphicsTools.ManualCreateObject("TempArtist/Prefab/Build/m_other_box", "Chest" + chestID.ToString(), true); ChestTrigger trigger = go.AddComponent <ChestTrigger>() as ChestTrigger; trigger.ChestID = chestID; int index = Random.Range(0, _mChestPosList.Length); go.transform.position = _mChestPosList[index]; _mChestList.Add(chestID, go); // Globals.Instance.MGUIManager.GetGUIWindow<GUIMain>().UpdateCopyChestShow(_mChestList.Count); return(go); }
void InitOneRandomChest(Transform tf, int chestId) { tf.gameObject.SetActiveRecursively(true); UIButton btn = (UIButton)tf.GetComponent(typeof(UIButton)); //btn.SetInputDelegate(OnScreenBtnInputDel); PackedSprite anim = tf.GetComponentInChildren <PackedSprite>() as PackedSprite; if (null != anim) { anim.PlayAnim(0); // Default chest appearance } ChestTrigger trigger = tf.gameObject.AddComponent <ChestTrigger>() as ChestTrigger; trigger.ChestID = chestId; trigger.BoxSize = new Vector3(anim.width, anim.height, 1.0f); }
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"); }
// Use this for initialization void Awake() { chest1Manager = team1chest.GetComponent <ChestTrigger>(); chest2Manager = team2chest.GetComponent <ChestTrigger>(); }