// Start is called before the first frame update void Start() { GameManager = GameObject.FindWithTag("GameController"); game_manager_script = GameManager.GetComponent <GameManagerScript>(); ItemImageController = game_manager_script.ItemShowImage; gearManager = GameObject.FindWithTag("ItemController").GetComponent <GearManagerScript>(); gear_set_script = GameObject.FindWithTag("ItemController").GetComponent <GearsSetScript>(); //GameObject itemprefab = Instantiate(ItemImageController, ItemImageController.transform); SceneName = game_manager_script.SceneName; foreach (ItemList item in items) { //ロードしたときに作る ItemImagePrefabCreate(item); itemName.Add(item.ItemName); ItemStatus item_status = itemPrefab.GetComponent <ItemStatus>(); ItemGearImageStatus item_gear_status = itemPrefab.GetComponent <ItemGearImageStatus>(); if (item_status.ItemType == ItemList.ItemType.Weapon && !string.IsNullOrEmpty(gearManager.weaponID)) { gearManager.ItemWeaponDescSet(gearManager.WeaponDesc, itemPrefab); } else if (item_status.ItemType == ItemList.ItemType.Gear && !string.IsNullOrEmpty(gearManager.GearID)) { gearManager.ItemGearDescSet(gearManager.GearDesc, itemPrefab, true); //↑ここを通るとGearID文字がにセットされる } } gearManager.GearEquipment(gearManager.GearHead, gearManager.GearLeg, gearManager.GearBody, gearManager.GearArmLeft, gearManager.GearArmRight); /*if (ret < 0) * { * foreach (string wannna_destroy_id in wanna_destroy_item_id) * { * foreach (GameObject item in GameObject.FindGameObjectsWithTag("item")) * { * Debug.Log("I want to be a " + item.GetComponent<ItemAddScript>().itemID + "_" + SceneName); * if (wannna_destroy_id == item.GetComponent<ItemAddScript>().itemID + "_" + SceneName) * { * Destroy(item); * } * } * } * }*/ SceneManager.sceneLoaded += SceneItemLoaded; }
public void OnClick() { //アイテムがクリックされたときのイベントをかく。 float PlayerHP = player_status.HP; //ここはアイテムのステータスをプレイヤーに反映させる。 if (itemStatus.item_weapon_mode) { gear_manager_script.ItemWeaponDescRemove(this.gameObject); } else if (itemStatus.item_weapon_mode == false) { if (itemStatus.ItemType == ItemList.ItemType.Weapon) { gear_manager_script.ItemWeaponDescSet(gear_manager_script.WeaponDesc, this.gameObject); } } if (itemStatus.item_gear_mode) { gear_manager_script.ItemGearDescRemove(this.gameObject); gear_manager_script.GearReset(); } else if (itemStatus.ItemType == ItemList.ItemType.Gear && itemStatus.item_gear_mode == false) { gear_manager_script.ItemGearDescSet(gear_manager_script.GearDesc, this.gameObject); for (int i = 0; i < gears_set_script.GearID.Count; i++) { if (gears_set_script.GearID[i] == itemStatus.itemID) { gear_manager_script.GearEquipment(gears_set_script.Head[i], gears_set_script.Leg[i], gears_set_script.Body[i], gears_set_script.ArmsLeft[i], gears_set_script.ArmsRight[i]); } } } else if (itemStatus.ItemType == ItemList.ItemType.Consumable) { //消費アイテムだったら player_status.HPset(PlayerHP + itemStatus.itemLifeInCrease, this.gameObject); } }