유닛 생산 건물 생성작업 완료

This commit is contained in:
김판돌 2023-11-01 21:24:10 +09:00
parent fb3e6738a4
commit bed3f2d9fd
3 changed files with 547 additions and 160 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ using MEC;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class BuildingCtrl : MonoBehaviour
{
@ -9,6 +10,10 @@ public class BuildingCtrl : MonoBehaviour
public int lineCount;
public int buildingLevel;
UnitCtrl unitInfo;
Image img;
private void Start()
{
Timing.RunCoroutine(BuildingSet());
@ -19,12 +24,10 @@ public class BuildingCtrl : MonoBehaviour
//uiÀçÁ¤·Ä
RectTransform rt = gameObject.GetComponent<RectTransform>();
RectTransform changeRt = gameObject.GetComponentsInChildren<RectTransform>()[1];
img = changeRt.GetComponent<Image>();
float sizeSet = (rt.sizeDelta.y / 2) - 10;
changeRt.offsetMin = new Vector2(-sizeSet, 10.0f);
changeRt.offsetMax = new Vector2(sizeSet, -10.0f);
//나의정보 playerCtrl에 전달
//PlayCtrl.Instance.player.buildings[lineCount].
}
public void Button()
@ -41,5 +44,38 @@ public class BuildingCtrl : MonoBehaviour
PlayCtrl.Instance.newBuildingUI.SetActive(true);
PlayCtrl.Instance.backButton.SetActive(true);
}
//나의 정보를 PlayCtrl에 전달후 특정 상황이 되면 상호작용 하게 만들기
PlayCtrl.Instance.buildingCtrl = this;
}
public void LevelUp()
{
if (buildingLevel >= 5)
{
Debug.Log("건물이 최대 레벨 입니다.");
return;
}
buildingLevel++;
}
public void DeletBuilding()
{
if (isProduction)
{
Debug.Log("생산건물은 파괴할 수 없습니다.");
return;
}
unitInfo = null;
img.sprite = null;
img.color = Color.clear;
buildingLevel = 0;
}
public void NewBuilding(UnitCtrl unitInfo, Sprite unitImg )
{
this.unitInfo = unitInfo;
img.sprite = unitImg;
img.color = Color.white;
buildingLevel++;
}
}

View File

@ -20,9 +20,12 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
public GameObject newBuildingUI;
public GameObject buildingLevelupUI;
public GameObject backButton;
public UnitCtrl[] units;
public Sprite[] unitImages;
public SummonsUnit player;
public SummonsUnit enemy;
public BuildingCtrl buildingCtrl;
//선택된 ui의 정보를 저장할 수 있게 만들기.
//레벨업 ui만들기
@ -79,6 +82,24 @@ public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
newBuildingUI.SetActive(false);
buildingLevelupUI.SetActive(false);
backButton.SetActive(false);
buildingCtrl = null;
}
public void SelectUnit(int count)
{
buildingCtrl.NewBuilding(units[count], unitImages[count]);
uiExit();
}
public void DeleteBuilding()
{
buildingCtrl.DeletBuilding();
uiExit();
}
public void LevelUpBuilding()
{
buildingCtrl.LevelUp();
uiExit();
}
}