Game Development Reference
In-Depth Information
void OnTriggerExit2D(Collider2D col)
{
DialogVisible(false);
}
Now that we can tell when the player is in front of the shop, we just need to capture
whether they have pressed the up arrow button to enter the shop. We do that in the Up-
date method as follows:
void Update()
{
if (canEnterShop && Input.GetKeyDown(KeyCode.UpArrow))
{
if (NavigationManager.CanNavigate(this.tag))
{
NavigationManager.NavigateTo(this.tag);
}
}
}
Finally, we add a little GUI touch as follows to let the player know that they can enter the
shop when they are in front of it:
void OnGUI()
{
if (canEnterShop)
{
//layout start
GUI.BeginGroup(
new Rect(
Screen.width / 2 - 150,
50,
300,
50));
//the menu background box
GUI.Box(new Rect(0, 0, 300, 250), "");
Search WWH ::




Custom Search