12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Player : MonoBehaviour
- {
- public static Player Instance;
- public float MoveSpeed = 1;
- public void OnEnable()
- {
- Instance = this;
- }
- public void MoveL()
- {
- if (transform.position.x > -2)
- {
- transform.position += Vector3.left*0.5f;
- }
- }
- public void MoveR()
- {
- if (transform.position.x < 2)
- {
- transform.position += Vector3.right*0.5f;
- }
- }
- public void SetMoveSpeed(float value)
- {
- MoveSpeed += value;
- }
- public void StartGame()
- {
- _isEnable = true;
- IsOver = false;
- }
- private float _timer;
- private bool _isEnable;
- public bool IsOver;
- public void Update()
- {
- if (_isEnable)
- {
- _timer += Time.deltaTime;
- if (_timer >= 0.3f)
- {
- SetMoveSpeed(0.5f);
- // _isEnable = false;
- _timer = 0;
- }
- transform.position += Vector3.forward * (MoveSpeed * Time.deltaTime);
- if (MoveSpeed >= 10)
- {
- _isEnable = false;
- IsOver = true;
-
- }
- }
- }
- }
|