public void Start() { sr = GetComponent <SpriteRenderer>(); if (isHouse) { ChooseHouseImage(); } ut = FindObjectOfType <UnitTracker>(); ut.AddUnitToTargetableList(gameObject); UpdateCurrentOwner(); timeSinceLastMoneyDrop = UnityEngine.Random.Range(0, timeBetweenMoneyDrops); }
private void SpawnNextUnitInQueue() { GameObject unitBlueprint = unitsInQueue[0]; int iffToSpawnWith = unitBlueprint.GetComponentInChildren <IFF>().GetIFFAllegiance(); Vector3 spawnPos = cm.FindNearestCitySquare(playerAtComputer.transform, iffToSpawnWith).transform.position; GameObject newActualUnit = Instantiate(unitBlueprint, spawnPos, Quaternion.identity) as GameObject; Debug.Log("Made a new unit: " + newActualUnit.name); ut.AddUnitToTargetableList(newActualUnit); unitsInQueue.RemoveAt(0); DecrementQueueStack(); }
// Start is called before the first frame update public override void OnStartServer() { base.OnStartServer(); ut = FindObjectOfType <UnitTracker>(); ownIFF = GetComponent <IFF>(); attackRange = weaponLifetime * weaponSpeed; sh = GetComponentInChildren <StealthHider>(); ss = GetComponentInChildren <StealthSeeker>(); ss.OnSeekerDetection += EvaluateDetectedObject; ss.OnSeekerLostContact += HandleLostContact; ut.AddUnitToTargetableList(gameObject); ownIFF.OnChangeIFF += CheckForAlliesAsTargetsAfterIFFChange; }
protected virtual void Start() { ut = FindObjectOfType <UnitTracker>(); ut.AddUnitToTargetableList(gameObject); move = GetComponentInChildren <Movement>(); attack = GetComponentInChildren <Attack>(); targetGO = GameObject.FindGameObjectWithTag("Player"); iff = GetComponent <IFF>(); cm = FindObjectOfType <CityManager>(); health = GetComponentInChildren <Health>(); am = FindObjectOfType <AllegianceManager>(); if (TryGetComponent <NavMeshAgent>(out nma)) { nma.updateRotation = false; } }