forked from liuxq/TestGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
162 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEngine.UI; | ||
using UnityEngine.EventSystems; | ||
using KBEngine; | ||
|
||
public class HotBarProcess : MonoBehaviour, IPointerDownHandler | ||
{ | ||
public static HotBarProcess _instance; | ||
private Inventory inventory = null; | ||
private int itemId = -1; | ||
|
||
private Text text; //text for the itemValue | ||
private Image image_icon; //图标 | ||
private Image image_cool; //冷却 | ||
// Use this for initialization | ||
void Start () { | ||
UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas"); | ||
if (canvas.transform.Find("Panel - Inventory(Clone)") != null) | ||
inventory = canvas.transform.Find("Panel - Inventory(Clone)").GetComponent<Inventory>(); | ||
|
||
this.gameObject.SetActive(false); | ||
} | ||
|
||
void Awake() | ||
{ | ||
_instance = this; | ||
image_icon = transform.GetChild(0).GetComponent<Image>(); | ||
text = transform.GetChild(1).GetComponent<Text>(); //get the text(itemValue GameObject) of the item | ||
image_cool = transform.GetChild(2).GetComponent<Image>(); | ||
} | ||
void Update() | ||
{ | ||
if (itemId == -1) | ||
return; | ||
//如果快捷栏有物品,则刷新物品状态 | ||
if (inventory == null) | ||
{ | ||
UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas"); | ||
inventory = canvas.transform.Find("Panel - Inventory(Clone)").GetComponent<Inventory>(); | ||
} | ||
if (inventory == null) | ||
return; | ||
//物品已使用完或者消失 | ||
UnityEngine.GameObject itemobject = inventory.getItemGameObject(itemId); | ||
if (itemobject == null) | ||
{ | ||
this.itemId = -1; | ||
this.gameObject.SetActive(false); | ||
return; | ||
} | ||
|
||
image_icon.sprite = itemobject.GetComponent<ItemOnObject>().item.itemIcon; | ||
text.rectTransform.localPosition = itemobject.transform.GetChild(1).GetComponent<Text>().transform.localPosition; | ||
text.enabled = true; | ||
text.text = itemobject.transform.GetChild(1).GetComponent<Text>().text; | ||
image_cool.sprite = itemobject.transform.GetChild(2).GetComponent<Image>().sprite; | ||
} | ||
//放到快捷栏 | ||
public void upItem(int itemId) | ||
{ | ||
this.itemId = itemId; | ||
this.gameObject.SetActive(true); | ||
} | ||
//点击使用 | ||
public void OnPointerDown(PointerEventData data) | ||
{ | ||
UnityEngine.GameObject itemobject = inventory.getItemGameObject(itemId); | ||
if (itemobject != null) | ||
{ | ||
KBEngine.Avatar p = (KBEngine.Avatar)KBEngineApp.app.player(); | ||
if (p != null) | ||
{ | ||
p.useItemRequest(itemobject.GetComponent<ItemOnObject>().item.itemIndex); | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Assets/InventoryMaster/Scripts/Hotbar/HotBarProcess.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
|
||
class LimitCD | ||
{ | ||
|
||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.