Beispiel #1
0
    public void EnableTurretsAtDay()
    {
        //On active les tourelles le jour
        foreach (GameObject GOturret in turretsInScene)
        {
            MonoBehaviour[] scripts = GOturret.GetComponent <TurretActivation>().scriptsToActivate;
            for (int i = 0; i < scripts.Length; i++)
            {
                if (GOturret.GetComponent <TurretActivation>().linkedNode.isPoweredByGenerator)
                {
                    scripts[i].enabled = true;
                }
                else
                {
                    scripts[i].enabled = false;
                }
            }
        }



        //On désactive la spotlight le jour
        foreach (GameObject GObuilding in buildingsInScene)
        {
            GObuilding.GetComponent <TurretActivation>().DisableScriptsAtDayIfSpotlight();
        }
    }
Beispiel #2
0
    public void RemoveTurret(GameObject turret)
    {
        //turretsInScene.RemoveAt(turret.GetComponent<UnitIndex>().indexInUnitManager);
        turretsInScene.Remove(turret);

        foreach (GameObject GOturret in turretsInScene)
        {
            if (GOturret != null)
            {
                GOturret.GetComponent <UnitIndex>().indexInUnitManager = turretsInScene.IndexOf(GOturret);
            }
        }
    }
Beispiel #3
0
    public void DisableTurretsAtNight()
    {
        //On désactive les tourelles la nuit
        foreach (GameObject GOturret in turretsInScene)
        {
            if (!GOturret.GetComponent <Unit_Stats>().canSeeDuringNight || !GOturret.GetComponent <TurretActivation>().linkedNode.isAffectedBySpotlight)
            {
                MonoBehaviour[] scripts = GOturret.GetComponent <TurretActivation>().scriptsToActivate;
                for (int i = 0; i < scripts.Length; i++)
                {
                    scripts[i].enabled = false;
                }
            }
        }


        //On active la spotlight la nuit
        foreach (GameObject GObuilding in buildingsInScene)
        {
            GObuilding.GetComponent <TurretActivation>().EnableScriptsAtNightIfSpotlight();
        }
    }