Sprites 폴더 생성

public class PlotManager : MonoBehaviour
{
    void Start()
    {
        
    }

    void Update()
    {
        
    }

    private void OnMouseDown()
    {
        Debug.Log("Clicked");
    }
}

[Plot]

Add Component - PolygonCollider2D

Points의 하위 Element 값 조정해 Collider 크기 맞추기

스크린샷 2023-09-06 160140.png

Collider 설정 후 클릭 시 Console창에 명령어 출력

스크린샷 2023-09-06 160504.png

plant 변수 → active: plant / inactive: harvest

public class PlotManager : MonoBehaviour
{
    bool isPlanted = false;
    public GameObject plant;

    void Update() {}

    private void OnMouseDown()
    {
        if (isPlanted)
        {
            Harvest();
        }
        else
        {
            Plant();
        }
    }

    void Harvest()
    {
        Debug.Log("Harvested");
        isPlanted = false;
        plant.SetActive(false);
    }

    void Plant()
    {
        Debug.Log("Planted");
        isPlanted = true;
        plant.SetActive(true);
    }
}

Plot 클릭 → Planted(true) / Harvest(false)

스크린샷 2023-09-06 161957.png

스크린샷 2023-09-06 162015.png

14:10 timer 설정 전까지