public void spawn(UnitReserve reserve) { //UnitController newUnit = new UnitController(); //units.Add(newUnit); // TODO add rotation Quaternion rotation = reserve.unitPrefab.transform.rotation; if (isEnemy) { rotation = Quaternion.LookRotation(Vector3.left); } else { rotation = Quaternion.LookRotation(Vector3.right); } GameObject newUnitObj = GameObject.Instantiate(reserve.unitPrefab, spawnPositions[reserve.lane], rotation); UnitController unit = newUnitObj.GetComponent <UnitController>(); unit.init(reserve, isEnemy, defenderArmyMaxXPosition); units.Add(unit); }
public void init(UnitReserve reserve, bool isEnemy, float defenderArmyMaxXPosition) { this.lane = reserve.lane; this.isBaddie = isEnemy; this.zDirection = isEnemy ? 1 : -1; this.health = 100; this.defenderArmyMaxXPosition = defenderArmyMaxXPosition; //if(isBaddie) //{ // this.health /= 2; //} this.attackDamage = 20f; //this.attackCooldown = 2; //this.attackCooldownMin = 3f; //this.attackCooldownMin = 2f; this.attackRadius = 2.25f; if (!isBaddie) { // give friendly units first hit this.attackRadius += 0.1f; } }