void SpawnCurrentUnit(UnitData unitData) { var spawnedUnit = SpawnController.SpawnUnit(unitData, selfUnit.OwnerPlayerId, spawnPoint); if (spawnedUnit.GetComponent <Harvester>()) // resource harvesters have their own code to move to the resource field. { return; } var order = new MovePositionOrder { movePosition = moveWaypoint.position }; if (unitData.moveType == UnitData.MoveType.Flying) { order.movePosition += new Vector3(Random.Range(-3f, 3f), 0f, Random.Range(-3f, 3f)); } spawnedUnit.AddOrder(order, false); ShuffleUnitsOnExit(order.movePosition, selfUnit); }
void SpawnHarvester() { var spawnedHarvester = SpawnController.SpawnUnit(harversterUnitData, selfUnit.OwnerPlayerId, carryOutResourcesPoint); spawnedHarvester.GetComponent <Harvester>().SetRefinery(this); }