39 lines
973 B
C#
39 lines
973 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Game14Player : MonoBehaviour{
|
|
|
|
public GameObject death;
|
|
public float moveSpeed = 600f;
|
|
|
|
float movement;
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
if (Input.GetKeyDown(KeyCode.Space)){
|
|
movement = 1;
|
|
}
|
|
|
|
if (Input.GetKeyUp(KeyCode.Space)){
|
|
movement = 0;
|
|
}
|
|
}
|
|
|
|
void FixedUpdate(){
|
|
transform.RotateAround(Vector3.zero, Vector3.forward, movement * Time.fixedDeltaTime * -moveSpeed);
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D col){
|
|
AudioManager.instance.Play("Hit");
|
|
StartCoroutine(Death());
|
|
Time.timeScale = 0;
|
|
death.transform.rotation = Camera.main.transform.rotation;
|
|
death.SetActive(true);
|
|
}
|
|
|
|
IEnumerator Death(){
|
|
yield return new WaitForSecondsRealtime(5f);
|
|
FindObjectOfType<GameController>().LoseGame();
|
|
}
|
|
}
|