コード例 #1
0
    public IEnumerator UseObject(UIGrid room, Vector2Int objectPos)
    {
        UIItem item = room.GetItem(objectPos);

        if (item)
        {
            if (item.Available())
            {
                item.Use();
                Debug.Log("Happy");
                m_Happiness += m_HeroesConfig.HappinessUsingObject;

                if (speechBubble)
                {
                    StartCoroutine(speechBubble.SaySomething(SpeechBubble.EReactionType.Happy));
                }
            }
            else
            {
                Debug.Log("Not happy");
                m_Happiness += m_HeroesConfig.HappinessUsingObject;
                if (speechBubble)
                {
                    StartCoroutine(speechBubble.SaySomething(SpeechBubble.EReactionType.Sad));
                }
            }
            yield return(new WaitForSeconds(0.5f));
        }
    }