Esempio n. 1
0
 public void Start()
 {
     sr = GetComponent <SpriteRenderer>();
     if (isHouse)
     {
         ChooseHouseImage();
     }
     ut = FindObjectOfType <UnitTracker>();
     ut.AddUnitToTargetableList(gameObject);
     UpdateCurrentOwner();
     timeSinceLastMoneyDrop = UnityEngine.Random.Range(0, timeBetweenMoneyDrops);
 }
Esempio n. 2
0
    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();
    }
Esempio n. 3
0
 // 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;
 }
Esempio n. 4
0
 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;
     }
 }