public void Enable() { if (_teamUnits._units == null) { _teamUnits.Init(_isPlayer ? eTeam.PLAYER : eTeam.ENEMY); _teamUnits.UpdateItems(); } for (int i = 0; i < _teamUnits.Length; ++i) { UnitStatus us = _teamUnits.GetUnit(i); us.UpdateItems(); _isUnitSpawn[i] = false; _unitCoolIntervals[i] = _unitCoolTimes[i] = us._coolTime; } }
/// <summary> /// UI의 버튼 혹은 설정된 키로 유닛을 스폰 /// </summary> public bool Spawn() #region Function Content { if (_isGameEnd) { return(false); } UnitStatus uStatus = _teamUnits.GetUnit(_curSpawnIndex); if (_isUnitSpawn[_curSpawnIndex]) { return(false); } if (!_isdefaultSpawn) { return(false); } if (_isPlayer) { if (!_inGameSystem.CostConsumption(uStatus._cost)) { return(false); } _costMgr.SetCoolDownUI(_curSpawnIndex, uStatus._coolTime); if (_spawnAreaObject.activeSelf) { _spawnAreaObject.SetActive(false); } } if (_curSpawnObject == null) { return(false); } // 스폰 성공 _isdefaultSpawn = false; _isUnitSpawn[_curSpawnIndex] = true; Vector3 unitPos = _spawnPoint; if (_spawnPoint == Vector3.zero) { int randVal = Random.Range(0, 2); bool isDown = 0 == randVal ? true : false; unitPos = isDown ? transform.position + new Vector3(1, 0, 2.5f) : transform.position + new Vector3(1, 0, .5f); } _curSpawnObject.transform.position = unitPos; UnitController unitCtrl = _curSpawnObject.GetComponent <UnitController>(); unitCtrl._enemyCastleObject = _enemySpawnManager.GetCastle(); if (unitCtrl._status != null) { if (unitCtrl._status._equipedItems != null) { UnitModelManager.Reset(_curSpawnObject.transform.GetChild(0).gameObject, unitCtrl._status._equipedItems); } } UnitStatus newStatus = new UnitStatus(); newStatus._team = _isPlayer ? eTeam.PLAYER : eTeam.ENEMY; newStatus._equipedItems = uStatus._equipedItems; newStatus.UpdateItems(); unitCtrl._status = newStatus; UnitModelManager.Update(_curSpawnObject.transform.GetChild(0).gameObject, unitCtrl._status._equipedItems); unitCtrl.Spawn(); _curSpawnObject.SetActive(true); // 새로운 유닛 오브젝트를 오브젝트풀에서 찾음 _curSpawnObject = null; return(true); }