86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SummonsUnit : MonoBehaviour
|
|
{
|
|
public bool isEnemy;
|
|
public List<BuildingInfo> buildings;
|
|
public int campHp;
|
|
|
|
public int[] addMoney;
|
|
|
|
private void Awake()
|
|
{
|
|
buildings = new List<BuildingInfo>();
|
|
campHp = 500;
|
|
buildings.Add(new BuildingInfo());
|
|
buildings.Add(new BuildingInfo());
|
|
buildings.Add(new BuildingInfo());
|
|
buildings.Add(new BuildingInfo());
|
|
buildings.Add(new BuildingInfo());
|
|
addMoney = new int[5];
|
|
for(int n = 0; n < addMoney.Length; n++)
|
|
{
|
|
addMoney[n] = 100;
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (isEnemy)
|
|
{
|
|
//0스테이지 에서 유닛이 세팅되게 시스템 작성
|
|
PlayCtrl.Instance.enemy = this;
|
|
EnemyStageSet(0);
|
|
}
|
|
else
|
|
PlayCtrl.Instance.player = this;
|
|
}
|
|
|
|
public void Summons(int count)
|
|
{
|
|
BuildingInfo buildingInfo = buildings[count];
|
|
int listCount;
|
|
if (buildingInfo.units == null)
|
|
return;
|
|
else
|
|
listCount = buildingInfo.units.Length;
|
|
|
|
for (int n = 0; n < listCount; n++)
|
|
{
|
|
for(int m = 0; m < buildingInfo.level[n]; m++)
|
|
{
|
|
float pos = Random.Range(-3.7f, -0.3f);
|
|
if (isEnemy) //적소환
|
|
Instantiate(buildingInfo.units[n].gameObject, new Vector3(Random.Range(44.0f, 46.0f), pos, pos + 3.8f), Quaternion.identity).GetComponent<UnitCtrl>().UnitBonusSet(isEnemy, buildingInfo.level[n]);
|
|
else //아군 유닛 소환
|
|
Instantiate(buildingInfo.units[n].gameObject, new Vector3(Random.Range(-44.0f, -46.0f), pos, pos + 3.8f), Quaternion.identity).GetComponent<UnitCtrl>().UnitBonusSet(isEnemy, buildingInfo.level[n]);
|
|
|
|
}
|
|
|
|
}
|
|
if (!isEnemy)//자원 생성
|
|
{
|
|
PlayCtrl.Instance.TextUpdate(addMoney[count]);
|
|
}
|
|
}
|
|
|
|
public void EnemyStageSet(int stage)
|
|
{
|
|
List<AI> ai = Statics.excelDatas.GamestageAIList(Statics.chapter, stage);
|
|
for(int n = 0; n < ai.Count; n++)
|
|
{
|
|
switch (ai[n].command)
|
|
{
|
|
case eCommand.add:
|
|
buildings[ai[n].wave].units[ai[n].position - 1] = Statics.stringUnits[ai[n].unit].GetComponent<UnitCtrl>();
|
|
buildings[ai[n].wave].level[ai[n].position - 1]++;
|
|
break;
|
|
case eCommand.upgrade:
|
|
buildings[ai[n].wave].level[ai[n].position - 1]++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|