using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockController : MonoBehaviour
{
// 落下タイマー
float fallTimerMax = 0.5f;
float fallTimer;
// Start is called before the first frame update
void Start()
{
fallTimer = fallTimerMax;
}
// Update is called once per frame
void Update()
{
// 落下タイマー消化
fallTimer -= Time.deltaTime;
// 移動する方向
Vector3 movePosition = Vector3.zero;
// 左移動
if(Input.GetKeyUp(KeyCode.LeftArrow))
{
movePosition = Vector3.left;
}
// 右移動
else if (Input.GetKeyUp(KeyCode.RightArrow))
{
movePosition = Vector3.right;
}
// 下移動
else if (Input.GetKeyUp(KeyCode.DownArrow))
{
movePosition = Vector3.down;
}
// 回転
else if (Input.GetKeyUp(KeyCode.UpArrow))
{
transform.Rotate(new Vector3(0, 0, 1), 90);
}
// 時間経過で下移動
if(fallTimer < 0)
{
movePosition = Vector3.down;
fallTimer = fallTimerMax;
}
// 移動
transform.position += movePosition;
}
}