// Use this for initialization
    void Start()
    {
        this.UIPanels     = this.gameObject.GetComponentsInChildren <UIPanel>(includeInactive: true).ToList();
        this.LevelManager = GameObject.FindObjectOfType <LevelManager>();

        this.shieldGenerator = (ShieldGeneratorScript)this.LevelManager.BuildingManager.Buildings.Where(b => b.Name == BuildingName.ShieldGenerator).FirstOrDefault();
        if (this.shieldGenerator == null)
        {
            throw new System.Exception("UIManager unable to locate Shield Generator (building). The level maybe corrupted or set up incorrectly.");
        }

        this.ShieldStatusTextbox     = this.UIPanels[0].gameObject.GetComponentInChildren <Text>();
        this.PowerStatusTextboxes    = this.UIPanels[1].gameObject.GetComponentsInChildren <Text>();
        this.ResourceStatusTextboxes = this.UIPanels[2].gameObject.GetComponentsInChildren <Text>();

        UIBuildingPanel[]  uiBuildingPanels  = GameObject.FindObjectsOfType <UIBuildingPanel>();
        UIBuildingButton[] uiBuildingButtons = GameObject.FindObjectsOfType <UIBuildingButton>();

        foreach (UIBuildingPanel panel in uiBuildingPanels)
        {
            panel.gameObject.SetActive(false);
        }

        foreach (UIBuildingButton button in uiBuildingButtons)
        {
            button.Initialize(uiBuildingPanels, this.LevelManager.MouseManager);
        }
    }
    public void Initialize(Map map, float SecondsBeforeStormStarts)
    {
        this.GraphicTransform.localScale = new Vector3(map.Width + 2, map.Length + 2);
        Vector3 center = map.GetMapCenter();

        center.x -= 1f;
        center.y -= 0.9f;
        center.z -= 1f;
        this.gameObject.transform.position = center;
        this.stormStartTimer = SecondsBeforeStormStarts;

        this.shieldGenerator = GameObject.FindObjectOfType <ShieldGeneratorScript>();
        this.StormHasStarted = false;
    }
Exemple #3
0
    private void InstantiateAndInitialize_Buildings()
    {
        this.BuildingManager = Instantiate
                               (
            BuildingManagerPrefab,
            Vector3.zero,
            Quaternion.identity
                               ).GetComponent <BuildingManager>();

        this.BuildingManager.gameObject.transform.SetParent(this.gameObject.transform);
        this.BuildingManager.gameObject.name = "Buildings";

        this.BuildingManager.Initialize(this);

        this.ShieldGenerator = GameObject.FindObjectOfType <ShieldGeneratorScript>();
    }