using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Tilemaps;
    
    public class Box : MonoBehaviour
    {
        const float Gravity = -0.01f;

        //追記4
        const float OffsetY = -0.5f;
        
        [SerializeField]
        Tilemap tilemap;

        Time60  time60;
        Vector3 pos;
        Vector3 checkPos = new Vector3();
        Vector3 speed    = new Vector3();

        // Start is called before the first frame update
        void Start()
        {
            GameObject time60Obj = GameObject.Find("Time60");
            time60 = time60Obj.GetComponent<Time60>();

            //追記5
            pos = this.transform.position;
            checkPos = Vector3.zero;
            speed = Vector3.zero;
        }
        
        // Update is called once per frame
        void Update()
        {
            // 1/60秒ごとに処理をするための門番
            if( time60.CheckFlame() != true) return;

            //現在位置を受け取る
            pos = this.transform.position;

            //追記6
            //チェックする位置を決める
            checkPos = new Vector3(pos.x, pos.y + OffsetY, 0);
 
            //ボックスの自由落下
            speed.y = speed.y + Gravity;
            pos = new Vector3( pos.x, pos.y + speed.y, 0);

            //新しい位置をTransform.Positionに代入する
            transform.position = pos;

        }
    }