Payment.cs 1.35 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;


public class Payment : MonoBehaviour
{
    public GameObject Pay;
    public GameObject menu2;
    public GameObject Tim;
    [SerializeField] Text payText;
    [SerializeField] Text Time_left;
    float starttime = 0f;
    float tim = 3f;

    public void pay_money(int x)
    {
        menu2.SetActive(false);
        Pay.SetActive(true);
        ShowPoint.point2 += x;
    }

    public void change()
    {
        Pay.SetActive(false);
        menu2.SetActive(true);
        payText.text = "터치를\n3초 이상\n유지해주세요\n지문인식으로\n결제됩니다...";
    }

    // Update is called once per frame
    void Update()
    {
        tim -= 1 * Time.deltaTime;
        if (tim < 0)
            tim = 0;
        Time_left.text = Math.Round(tim, 1).ToString();

        if (Input.GetMouseButtonDown(0))
        {
            tim = 3f;
            Tim.SetActive(true);
            starttime = Time.time;
            

        }
        if (Input.GetMouseButtonUp(0))
        {
            Tim.SetActive(false);
            float delta = Time.time - starttime;
            if(delta > 3f)
            {
                payText.text = "결제가\n완료되었습니다!";
                Invoke("change", 2);
            }
        }
    }
}