---(전략)---
void SpawnEnemy(EnemyWaveData enemyData)
{
int positionPointer = 1;
int shiftPosition = 0;
// 생성할 위치 값으로 생성할 유닛 수 판단.
enemyData.amount = positionToAmount[enemyData.spawnPosition];
// 웨이브 표시.
waveLb.text = enemyData.waveNo.ToString();
---(후략)---
@GM 게임 오브젝트의 GamePlayManager에 아래 사항 연결
속성
값
Farm HPSlier
HPBar 게임 오브젝트
Score Lb
ScoreLabel 게임 오브젝트
Wave Lb
WaveLabel 게임 오브젝트
일시 정지 버튼과 배속 버튼 처리
예제 3-56: GamePlayManager.cs
---(전략)---
public partial class GamePlayManager : MonoBehaviour, IDamageable {
---(후략)---
예제 3-57: GamePlayManager.Button.cs
using UnityEngine;
using System.Collections;
// 유저 인터페이스를 통해서 호출되는 메서드를 관리.
public partial class GamePlayManager {
}
예제 3-58: GamePlayManager.Button.cs
---(전략)---
// 일시 정지 화면.
public GameObject pauseWindow;
---(후략)---
예제 3-59: GamePlayManager.Button.cs
---(전략)---
public void ClickPauseButton()
{
// 게임을 일시 정지 시킨다.
Time.timeScale = 0;
// 일시 정지 화면을 화면에 나타나도록 한다.
pauseWindow.SetActive(true);
}
---(후략)---
예제 3-60: GamePlayManager.Button.cs
---(전략)---
public UILabel speedButtonTextLb;
---(중략)---
public void ClickSpeedButton()
{
// 게임이 정지된 상태라면 더이상 처리하지 못하도록 예외처리.
if( Time.timeScale == 0.0f) return;
// 현재 배속을 참조하여 배속 변경.
if(Time.timeScale == 1.0f)
{
Time.timeScale = 2.0f;
speedButtonTextLb.text = "2x";
}
else
{
Time.timeScale = 1.0f;
speedButtonTextLb.text = "1x";
}
}
---(후략)---
PauseButton 게임 오브젝트의 UIButton에 아래 사항 연결
속성
값
Notify
@GM 게임 오브젝트
Method
GamePlayManager/ClickPauseButton
SpeedButton 게임 오브젝트의 UIButton에 아래 사항 연결
속성
값
Notify
@GM 게임 오브젝트
Method
GamePlayManager/ClickSpeedButton
예제 3-61: GamePlayManager.Button.cs
---(전략)---
public void ClickPauseReloadButton()
{
Time.timeScale = 1;
// 씬을 다시 로딩하여 새로 게임이 시작되도록 한다.
Application.LoadLevel("PlayScene");
}
public void ClickPausePlayButton()
{
// 게임 재개.
if( speedButtonTextLb.text == "2x" )
{
Time.timeScale = 2.0f;
}
else
{
Time.timeScale = 1.0f;
}
// 일시 정지 화면을 화면에서 사라지도록 한다.
pauseWindow.SetActive(false);
}
public void ClickPauseHomeButton()
{
// TODO: 다른 씬으로 전환한다.
}
---(후략)---
예제 3-62: GamePlayManager.cs
---(전략)---
public enum GameState {ready, idle, gameOver, wait, loading}
---(후략)---
예제 3-63: GamePlayManager.Button.cs
---(전략)---
public void ClickPauseReloadButton()
{
// 중복으로 로딩되지 못하도록 한다.
if( nowGameState == GameState.loading ) return;
nowGameState = GameState.loading;
Time.timeScale = 1;
// 씬을 다시 로딩하여 새로 게임이 시작되도록 한다.
Application.LoadLevel("PlayScene");
}
---(후략)---