... | ... | @@ -8,4 +8,128 @@ Defense_Game 만들기 |
|
|

|
|
|
|
|
|
* Tower01Cannon이라는 TowerTemplate 에셋을 생성하고 Tower Prefab에 Tower01 prefab을 넣어준다.
|
|
|
 |
|
|
\ No newline at end of file |
|
|
* 이 때 레벨에 맞는 이미지를 설정하고 값을 설정해준다.
|
|
|

|
|
|
|
|
|
* Projectile.cs에서 damage를 실수형으로 바꿔준다.
|
|
|

|
|
|
|
|
|
* TowerWeapon.cs에 TowerTemplate변수를 선언하고, Tower의 정보를 TowerTemplate로 교체
|
|
|

|
|
|
|
|
|
* Tower01 prefab에 TowerTemplate를 Tower01Cannon으로 등록
|
|
|

|
|
|
|
|
|
* TowerDataViewer.cs에 UpdateTowerData()함수에 타워이미지도 level에 따라 달라지게 설정
|
|
|

|
|
|
|
|
|
* TowerSpawner.cs에서 TowerTemplate변수를 선언하고 Tower의 정보를 TowerTemplate로 교체
|
|
|

|
|
|
|
|
|
* TowerSpawner 컴포넌트의 Tower Template 변수에 Tower01Cannon 에셋을 등록
|
|
|

|
|
|
|
|
|
* TowerSpawner.cs의 Setup함수 매개변수에 playerGold를 추가
|
|
|

|
|
|
|
|
|
* TowerWeapon.cs에 SpriteRenderer와 PlayerGold 변수를 추가
|
|
|

|
|
|
|
|
|
* Setup함수에 매개변수로 PlayerGold를 추가 후 Sprite Renderer와 PlayerGold정보 설정
|
|
|

|
|
|
|
|
|
* Upgrade함수 작성
|
|
|

|
|
|
|
|
|
* TowerDataViewer.cs에 buttonUpgrade변수 선언(최대 레벨일 때 비활성화하기 위해)
|
|
|

|
|
|
|
|
|
* UpdateTowerData함수에 최대 레벨에 도달하면 버튼이 비활성화되는 코드 추가
|
|
|

|
|
|
|
|
|
* OnClickEventTowerUpgrade함수 추가
|
|
|

|
|
|
|
|
|
* ButtonUpgrade오브젝트에 버튼을 클릭하면 OnclickEventTowerUpgrade함수가 호출되게 설정
|
|
|

|
|
|
|
|
|
* TextSystem이라는 TextMeshPro UI를 생성 후 투명도를 0으로 설정
|
|
|

|
|
|
|
|
|
* Extra Setting에 raycast target의 체크를 풀어줌
|
|
|

|
|
|
|
|
|
* TMPAlpha.cs 작성
|
|
|

|
|
|
|
|
|
* SystemTextViewer.cs 작성
|
|
|

|
|
|
|
|
|
* TextSystem컴포넌트에 TMPAlpha.cs와 SystemTextViewer.cs를 추가
|
|
|

|
|
|
|
|
|
* TowerDataViewer.cs에 systemTextViewer변수를 선언하고 OnClickEventTowerUpgrade함수의 else문에 골드가 부족하다는 system알림창이 출력되는 코드 추가
|
|
|

|
|
|

|
|
|
|
|
|
* PanelTower에 SystemTextViewer에 TextSystem 오브젝트를 입력
|
|
|

|
|
|
|
|
|
* TowerSpawner.cs에 systemTextViewer변수 선언
|
|
|

|
|
|
|
|
|
* 타워건설할 골드가 부족할 때 system알림창이 뜨는 코드 추가
|
|
|

|
|
|
|
|
|
* 타워건설이 가능한지 확인하는 조건문에도 불가능하면 system알림창이 뜨는 코드 추가
|
|
|

|
|
|
|
|
|
* Towerspawner 컴포넌트의 systemTextViewer변수에 SystemText 컴포넌트를 등록
|
|
|

|
|
|
|
|
|
> ### 2.타워 판매
|
|
|
|
|
|
* TowerTemplate.cs에 sell 변수 선언
|
|
|

|
|
|
|
|
|
* Tower01Cannon 에셋에 판매했을때의 가격을 정해준다.
|
|
|

|
|
|
|
|
|
* TowerSpawner.cs에서 Setup함수에 tile매개변수 추가
|
|
|

|
|
|
|
|
|
* TowerWeapon.cs에 ownerTile변수 선언
|
|
|

|
|
|
|
|
|
* Setup함수의 매개변수로 ownerTile을 추가
|
|
|

|
|
|
|
|
|
* Sell함수 추가
|
|
|

|
|
|
|
|
|
* TowerDataViewer.cs에 OnClickEventTowerSell함수를 추가
|
|
|

|
|
|
|
|
|
* ButtonSell 오브젝트를 눌렀을 때 OnClickEventTowerSell함수가 호출되게 설정
|
|
|

|
|
|
|
|
|
* EventSystem class사용을 위해 using문 추가, hitTransform변수 선언
|
|
|

|
|
|
|
|
|
* 마우스가 UI에 머물러만 있을때 함수가 실행되지 않게 함수를 빠져나오는 코드 작성
|
|
|

|
|
|
|
|
|
* hitTransform에 hit.transform정보를 저장
|
|
|

|
|
|
|
|
|
* hitTransform 정보가 null이거나 tag가 tower가 아니면 타워정보를 비활성화하는 코드 작성
|
|
|

|
|
|
|
|
|
> ### 3.타워 생성 UI
|
|
|
|
|
|
* PanelBuildTower 패널을 만들고 Grid Layout Group, Content Size Filter 컴포넌트 추가
|
|
|
Grid Layout Group : 자식으로 배치되는 UI들을 격자로 정렬
|
|
|
Content Size Filter : 컴포넌트를 가지고 있는 패널 오브젝트의 크기 설정
|
|
|

|
|
|
|
|
|
* |
|
|
\ No newline at end of file |