[숙제 설명]
내가 만들고 싶은 게임을 직접 찾아봅시다!
지금까지 만들었던 게임을 바탕으로 내가 만들고 싶은 게임을 찾아봅시다!
[필수 숙제]
구글 플레이스토어(iOS 앱스토어)에 접속합니다.
스토어에서 모바일 게임 중, 내가 만들고 싶은 게임을 찾아봅니다.
마음에 드는 게임을 찾아 아래의 양식을 채워 어떤 메커닉이 있을 지 적어봅시다!
게임 이름 : 길건너 친구들
게임에 대한 간단한 설명 : Player 캐릭터가 자동차, 트럭, 기차 등의 장애물을 피해 코인을 모아가며 최고 거리 기록을 달성하는 게임
게임 플레이 순서
// 플레이어의 위치 지정
transform.position += Vector3
// 클릭 시 반응 구현(터치는 GetTouch?)
if(Input.GetMouseButtonDown(0))
// 충돌 현상 구현
private void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("충돌");
}
private void OnCollisionEnter3D(Collision2D collision)
{
// 장애물과 충돌이 발생했을 때
if(collision.gameObject.CompareTag("Enemy"))
{
// 게임 종료
GameManager.Instance.GameOver();
}
}
public GameObject endPanel;
public Animator anim;
public Text nowScore;
int totalScore;
public void GameOver()
{
isPlay = false;
anim.SetBool("isDie", true);
nowScore.text = totalScore;
endPanel.SetActive(true);
Time.timeScale = 0.0f;
}
public void GameOver()
{
Invoke("TimeStop", 1f);
}
void TimeStop()
{
Time.timeScale = 0.0f;
}
using UnityEngine.SceneManagement;
public class RetryButton : MonoBehaviour
{
public void Retry()
{
SceneManager.LoadScene("MainScene");
}
}
~~~~~~
public class GameManager : MonoBehaviour
{
private void Awake()
{
Time.timeScale = 1.0f;
}
}
void Start()
{
float x = Random.Range(0f, 0f);
float y = Random.Range(0f, 0f);
float z = Random.Range(0f, 0f);
transform.position = new Vector3(x, y, z);
}
void Start()
{
int type = Random.Range(1, 4);
if(type == 1)
{
// Car
}
else if(type == 2)
{
// Truck
}
else if(type == 3)
{
// Bus
}
}
public GameObject car;
void Start()
{
// 0초 이후에 5초마다 "MakeCar"
InvokeRepeating("MakeCar", 0f, 5f);
}
void MakeCar()
{
// car 게임 오브젝트 생성
Instantiate(car);
}
void Start()
{
int[] arr = { 0, 1, 2, 3, 4, 5 };
arr = arr.OrderBy(x => Random.Range(0f, 0f)).ToArray();
for(int i = 0; i < 6; i++)
{
GameObject go = Instantiate(car, this.transform);
float x = (i % 0) * 0f;
float y = (i / 0) * 0f;
go.transform.position = new Vector2(x, y);
go.GetComponent<Card>().Setting(arr[i]);
}
}
public Text totalScoreTxt;
int totalScore;
public void AddScore(int score)
{
// 총 점수에다 score를 계속 넣어준다.
totalScore += score;
totalScoreTxt.text = totalScore.ToString();
}
if( // 플레이어가 앞으로 한 칸 이동)
{
GameManager.Instance.AddScore(score);
}
string key = "bestScore";
// 최고점수가 있다면
if(PlayerPrefs.HasKey(key))
{
float best = PlayerPrefs.GetFloat(key);
// 최고점수 < 현재점수
if(best < nowScore)
{
// 현재점수를 최고점수에 저장한다.
PlayerPrefs.SetFloat(key, nowScore);
bestScore.text = nowScore.text;
}
else
{
bestScore.text = best;
}
}
// 최고점수가 없다면
else
{
// 현재 점수를 저장한다.
PlayerPrefs.SetFloat(key, nowScore);
bestScore.text = nowScore.text;
}