// Use this for initialization void Awake() { item_property itemProperty = gameObject.GetComponent <item_property>(); mID = itemProperty.ID; setBulletSpecial(); }
void presentItem() { if (soldout == false) { //显示道具 GameObject itemPic = transform.FindChild("ui").gameObject.transform.FindChild("itempic").gameObject; item_property itemProperty = itemPic.GetComponent <item_property> (); if (itemProperty) { itemProperty.ID = mID; itemProperty.itemName = itemName; itemPic.SendMessage("resetGameobject"); } } else { //mId=0 时,隐藏道具 itemName = "已售完"; mID = 0; GameObject itemPic = transform.FindChild("ui").gameObject.transform.FindChild("itempic").gameObject; item_property itemProperty = itemPic.GetComponent <item_property> (); if (itemProperty) { itemProperty.ID = mID; itemProperty.itemName = itemName; itemPic.SendMessage("resetGameobject"); } } }
//在玩家背包删除旧的武器图标 public bool changeWeaponIcon(GameObject obj) { item_property itemProperty = obj.GetComponent <item_property>(); int itemId = itemProperty.ID; //constant.getMapLogic().bagAddIcon(itemId); char_property charProperty = gameObject.GetComponent <char_property>(); charProperty.Weapon = constant.getItemFactory().getItemTemplate(itemId); return(true); }
//在玩家背包里留下物品的图标 public bool putInBag(GameObject obj, bool checkBag) { if (checkBag) { return(false); } item_property itemProperty = obj.GetComponent <item_property>(); int itemId = itemProperty.ID; //constant.getMapLogic().bagAddIcon(itemId); char_property charProperty = gameObject.GetComponent <char_property>(); charProperty.addItem(constant.getItemFactory().getItemTemplate(itemId)); return(true); }
public void setItemIcon(tk2dSprite ui, GameObject obj) { item_property itemproperty = obj.GetComponent <item_property>(); GameObject collection = (GameObject)Resources.LoadAssetAtPath("Assets/Sprites/sheet/itemicon/itemIconCollection Data/itemIconCollection.prefab", typeof(Object)); tk2dSpriteCollectionData collectionData = collection.GetComponent <tk2dSpriteCollectionData> (); int iconId = itemproperty.ID; if (iconId != 0) { ui.gameObject.GetComponent <MeshRenderer>().enabled = true; ui.SetSprite(collectionData, "item_" + iconId); } else { ui.gameObject.GetComponent <MeshRenderer>().enabled = false; } }
//玩家是否捡起道具 public bool grapItem(GameObject item) { bool boolGrap = false; bool inbagAlright = false; item_property itemProperty = item.GetComponent <item_property>(); if (itemProperty) { List <itemType> itype = itemProperty.iType; if (itype.Count == 0) { //Debug.Log ("item has no property!"); return(false); } //find each tpye property for (int index = 0; index < itype.Count; index++) { if (itemProperty.iType[index] == itemType.recover) { if (recoverChar(item)) { boolGrap = true; } } if (itemProperty.iType[index] == itemType.enforce) { if (enforceChar(item)) { putInBag(item, inbagAlright); inbagAlright = true; boolGrap = true; } } if (itemProperty.iType[index] == itemType.equipment) { if (equipItem(item)) { putInBag(item, inbagAlright); inbagAlright = true; boolGrap = true; } } if (itemProperty.iType[index] == itemType.treasure) { if (addTreasure(item)) { boolGrap = true; } } if (itemProperty.iType [index] == itemType.weapon) { if (switchWeapon(item)) { dropWeapon(); changeWeaponIcon(item); boolGrap = true; } } if (itemProperty.iType [index] == itemType.bulletEnforce) { if (enforceWeapon(item)) { putInBag(item, inbagAlright); inbagAlright = true; boolGrap = true; } } if (itemProperty.iType [index] == itemType.special) { if (addPassitiveSkill(item)) { putInBag(item, inbagAlright); inbagAlright = true; boolGrap = true; } } } } //check item function if used if (boolGrap) { return(true); } //can not grap this item return(false); }
// Use this for initialization void Awake() { item_property itemProperty = gameObject.GetComponent <item_property>(); mID = itemProperty.ID; }