게임 플레이 1사이클 완성

This commit is contained in:
김판돌 2023-11-08 06:54:39 +09:00
parent 43545b3fc0
commit 6efe663f80
6 changed files with 76 additions and 15 deletions

View File

@ -253,6 +253,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 54711397} - component: {fileID: 54711397}
- component: {fileID: 54711396} - component: {fileID: 54711396}
- component: {fileID: 54711398}
m_Layer: 0 m_Layer: 0
m_Name: Camera m_Name: Camera
m_TagString: Untagged m_TagString: Untagged
@ -326,6 +327,18 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &54711398
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 54711394}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f97d481d44cb90a469c35682cc60c385, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &84361459 --- !u!1 &84361459
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1829,7 +1842,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 704811668} m_TargetGraphic: {fileID: 704811668}
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 54711398}
m_TargetAssemblyTypeName: GameCtrl, Assembly-CSharp
m_MethodName: StartPlay
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &440143456 --- !u!114 &440143456
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameCtrl : MonoBehaviour
{
public void StartPlay()
{
GameManager.Instance.NextScene(GameManager.eScene.Play);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f97d481d44cb90a469c35682cc60c385
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -32,6 +32,9 @@ public class BuildingCtrl : MonoBehaviour
public void Button() public void Button()
{ {
if(isProduction || buildingLevel != 0)//생산건물 이거나 일반건물 레벨업 if(isProduction || buildingLevel != 0)//생산건물 이거나 일반건물 레벨업
{
if (!isProduction)
{ {
int sell = 0; int sell = 0;
for (int n = 0; n < buildingLevel; n++) for (int n = 0; n < buildingLevel; n++)
@ -40,6 +43,13 @@ public class BuildingCtrl : MonoBehaviour
} }
sell /= 3; sell /= 3;
PlayCtrl.Instance.LevelupBuyAndSellText(unitInfo.unit.buy[buildingLevel], sell); PlayCtrl.Instance.LevelupBuyAndSellText(unitInfo.unit.buy[buildingLevel], sell);
}
else
{
PlayCtrl.Instance.LevelupBuyAndSellText(500 * buildingLevel, 0);
}
PlayCtrl.Instance.buildingLevelupUI.SetActive(true); PlayCtrl.Instance.buildingLevelupUI.SetActive(true);
PlayCtrl.Instance.newBuildingUI.SetActive(false); PlayCtrl.Instance.newBuildingUI.SetActive(false);
PlayCtrl.Instance.backButton.SetActive(true); PlayCtrl.Instance.backButton.SetActive(true);

View File

@ -44,6 +44,7 @@ public class UnitCtrl : MonoBehaviour
PlayCtrl.Instance.player.campHp -= unit.attack; PlayCtrl.Instance.player.campHp -= unit.attack;
if(PlayCtrl.Instance.player.campHp <= 0) if(PlayCtrl.Instance.player.campHp <= 0)
{ {
Debug.Log("패배!");
PlayCtrl.Instance.isEndGame = true; PlayCtrl.Instance.isEndGame = true;
} }
} }
@ -52,6 +53,7 @@ public class UnitCtrl : MonoBehaviour
PlayCtrl.Instance.enemy.campHp -= unit.attack; PlayCtrl.Instance.enemy.campHp -= unit.attack;
if (PlayCtrl.Instance.enemy.campHp <= 0) if (PlayCtrl.Instance.enemy.campHp <= 0)
{ {
Debug.Log("승리!");
PlayCtrl.Instance.isEndGame = true; PlayCtrl.Instance.isEndGame = true;
} }
} }

View File

@ -31,6 +31,7 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
public SummonsUnit enemy; public SummonsUnit enemy;
public BuildingCtrl buildingCtrl; public BuildingCtrl buildingCtrl;
public bool isEndGame; public bool isEndGame;
private float delay;
public int money; public int money;
@ -46,6 +47,7 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
money = 0; money = 0;
moneyText.text = money.ToString(); moneyText.text = money.ToString();
isEndGame = false; isEndGame = false;
delay = 0.0f;
uiExit(); uiExit();
} }
@ -62,7 +64,12 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
{ {
if (isEndGame) if (isEndGame)
{ {
Debug.Log("게임종료"); delay += Time.deltaTime;
if(delay > 3.0f)
{
//게임씬으로 이동
GameManager.Instance.NextScene(GameManager.eScene.Game);
}
return; return;
} }
float deltaTime = Time.deltaTime; float deltaTime = Time.deltaTime;
@ -92,6 +99,8 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
} }
public void uiExit() public void uiExit()
{ {
newBuildingUI.SetActive(false); newBuildingUI.SetActive(false);
@ -136,10 +145,3 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
moneyText.text = money.ToString(); moneyText.text = money.ToString();
} }
} }
/*
//1. 유닛 생성 자원
//2. 강화 조건 정하기
//3. 건물 철거 반환자원 조건 정하기
4. UI적용
*/