public static ShopEventSystem Instance() { if (instance == null) { instance = GameObject.FindObjectOfType <ShopEventSystem> (); } return(instance); }
// Use this for initialization void Start() { var myCollider = GetComponent <Collider2D> (); var info = MetaInformation.Instance(); if (Game.current.Phase == GamePhase.DayPhase) { var evtSys = ShopEventSystem.Instance(); if (evtSys == null) { Debug.Log("ShopEventSystem not found."); } else { ShopEventSystem.Instance().RegisterClickListener(myCollider, delegate { var craftingPanel = CraftingPanelScript.TryFindInstance(); if (craftingPanel != null) { craftingPanel.craftableItems = new List <ItemType> (); foreach (uint craftableID in craftableItemIDs) { ItemType myItem = info.GetItemTypeByID(craftableID); if (myItem != null) { craftingPanel.craftableItems.Add(myItem); } else { Debug.LogErrorFormat("Bad Item ID: {0}", craftableID); } } craftingPanel.transform.SetAsLastSibling(); craftingPanel.gameObject.SetActive(true); } else { Debug.LogError("Could not find the CraftingPanelScript in scene; not displaying crafting screen."); } }); } } }
// Use this for initialization void Start() { Collider2D col = GetComponent <Collider2D> (); if (col == null) { col = gameObject.AddComponent <BoxCollider2D> (); } ShopEventSystem shop = ShopEventSystem.Instance(); if (shop != null && Game.current.Phase == GamePhase.DayPhase) { shop.RegisterClickListener(col, () => BeginDisplayingMessage()); } }
void Start() { if (FurnitureTypeID == 0) { Debug.Log("FurnitureTypeID is 0, so furniture will not be saved. Did you instantiate properly? Use Furniture.InstantiateFurnitureByID ()."); } if (Game.current.Phase == GamePhase.EditPhase) { ShopEventSystem evt = ShopEventSystem.Instance(); if (evt != null) { evt.RegisterClickListener(myCollider, () => { ReturnToInventory(); }); } } }