Exemplo n.º 1
0
    /*
     * Execute order!!!
     * IMPORATNT - tohle jako první kód vůbec!!!!
     */
    void Awake()
    {
        #region -- LOAD DAT
        // Data z Resources
        PoolObjectSO[] poole_object_types = Resources.LoadAll <PoolObjectSO>(Settings.POOL_OBJECTS_PATH);

        // Načteme soubory z resources
        highlightMaterial = Resources.Load <Material>(Settings.MATERIALS + "/" + Settings.HIGHLIGHT_MAT);



        // Načteme si objekty do poolu
        objectsToPool = new GeneralObjectPool(poole_object_types.OfType <PoolObjectSO>().ToList());
        // Inicializujeme pool objekty
        objectsToPool.InitializeObjectsToPool();

        #endregion

        #region -- LOAD KAMERY
        Settings.isGameLoaded = ManagerLoad.LoadCamera();
        if (Settings.loadedScenes == null)
        {
            Debug.LogError("Nepodařilo se načíst hlavní kameru.");
        }

        // Debug.Log(Settings.isGameLoaded);
        #endregion

        #region  -- LOAD SCÉN

        Settings.loadedScenes = Settings.GetLoadedScenes(); // TODO: Podle mě je to zbytečné
        if (Settings.loadedScenes == null)
        {
            Debug.LogError("Nepodařilo se získat načtené scény.");
        }

        /*
         * 1. Loadneme UI
         */
        Settings.isGameLoaded = ManagerLoad.LoadScreenUIScene();
        if (!Settings.isGameLoaded)
        {
            Debug.LogError("Nepodařilo se načíst scrren UI scénu.");
        }

        /*
         * 2. Vytvoříme WorldBuilder(pokud neni)
         */
        Settings.isGameLoaded = ManagerLoad.LoadWorldBuilder();
        if (!Settings.isGameLoaded)
        {
            Debug.LogError("Nepodařilo se načíst WorldBuilder.");
        }
        #endregion

        #region -- LOAD GIZMOS
        // Grida
        Settings.isGameLoaded = ManagerLoad.LoadGizmos();
        #endregion
    }
Exemplo n.º 2
0
    private void Awake()
    {
        if (Instance != null)
        {
            throw new ColdCry.Exception.SingletonException("There can be only one object of PigeonFactory on scene!");
        }
        Instance = this;

        pigeons    = new ObjectPool <Pigeon>(pigeon, 6, "Pigeons");
        bodies     = new GeneralObjectPool(8, "BodyParts");
        frontWings = new GeneralObjectPool(8, "FrontWingsPart");
        backWings  = new GeneralObjectPool(8, "BackWingsPart");

        for (var i = 0; i < eachPart; i++)
        {
            bodies.Add(Instantiate(ColdCry.Utility.Random.FromArray(bodiesPrefabs)));
            frontWings.Add(Instantiate(ColdCry.Utility.Random.FromArray(frontWingsPrefabs)));
            backWings.Add(Instantiate(ColdCry.Utility.Random.FromArray(backWingsPrefabs)));
        }
    }
Exemplo n.º 3
0
    void Start()
    {
        //Canvas UI objektů na SCREEN
        // 2 Šance zda se najde UI věc, pokud ani jedno, tak..., tak ERROR typu => X-|
        // Nemělo by dojít k searchi, vše ručně ve scéně, ale kdyby náhodou...
        mainScreenCanvas = Settings.IsComponentLoaded <Canvas>(mainScreenCanvas, Settings.UI_TAG_SCREEN_CANVAS, "ScreenUICanvas");
        if (timersHolder == null)
        {
            timersHolder = mainScreenCanvas.transform as RectTransform;
            Debug.LogError("timersHolder byl defaultně přiřazen canvas!!!!"); // Pozn. Nechtělo se mi přidávat další zbytečný tag na dohledání...
        }


        #region ZVÝRAZNĚNÍ - OBRAZOVKA

        //Highlighty
        if (highlightMaskComponent == null)
        {
            highlightMaskComponent = GameObject.FindGameObjectWithTag(Settings.UI_TAG_SCREEN_HIGHLIGHT).GetComponent <Image>();
            Debug.LogError("highlightMask component(reference) se musel dohledat - zbytečné žraní výkonu(ScreeUIHolder)"); // TODO: v budoucnu udělat highlight tak, aby se nemuselo maskovat
        }

        if (highlightMaskComponent != null)
        {
            UI.ScreenHighlightState(true); // Jen Kvůli inicializaci ostatních komponentů
            if (screenHighlightComponent == null)
            {
                screenHighlightComponent = Settings.FindComponentInChildrenWithTag <Image>(highlightMaskComponent.transform, Settings.UI_TAG_IMAGE);
            }
        }
        else
        {
            Debug.LogError("highlightMask component(reference) se nenašel (ScreeUIHolder)");
        }

        // Dafultně zvýraznění vypneme
        UI.ScreenHighlightState(false);
        #endregion


        // Canvas hlavní statické okno
        mainScreenStaticCanvas = Settings.IsComponentLoaded <Canvas>(mainScreenStaticCanvas, Settings.UI_TAG_STATIC_SCREEN, "StaticScreenUI");


        // -- Statické UI panely
        if (mainScreenStaticCanvas != null)
        {
            // Levý panel
            //  leftPanel.mainContainer = Settings.FindComponentInChildrenWithTag<RectTransform>(mainScreenStaticCanvas.transform, Settings.UI_TAG_STATIC_LEFT_PANEL);
            // Spodní panel
            bottomPanel.mainContainer = Settings.FindComponentInChildrenWithTag <RectTransform>(mainScreenStaticCanvas.transform, Settings.UI_TAG_STATIC_BOTTOM_PANEL);
        }


        //Canvas UI objektů ve WORLD
        mainWorldCanvas = Settings.IsComponentLoaded <Canvas>(mainWorldCanvas, Settings.UI_TAG_WORLD_CANVAS, "WorldUICanvas");

        #region STATICKÉ UI - JEDNOTLIVÉ OBJEKTY

        // -- Objekty levého panelu

        /* if (leftPanel.mainContainer != null){
         *   if(leftPanel.enableGrid == null)
         *       leftPanel.enableGrid = Settings.FindComponentInChildrenWithTag<Toggle>(leftPanel.mainContainer, Settings.UI_TAG_TOGGLE);
         * }*/

        // -- Objekty spodního panelu
        if (bottomPanel.mainContainer != null)
        {
            if (bottomPanel.destroyBlockBtn == null) // DEstrukce bloků todo: buildmode static UI možná?
            {
                Debug.LogError("NEBYLO NALEZENO TLAČÍTKO DESTRUKCE BLOKU (LEVÝ PANEL SCREEN_UI_HOLDER.cs)");
            }

            if (bottomPanel.buildModeOn == null) // Builed mode ON tlačítko
            {
                Debug.LogError("NEBYLO NALEZENO TLAČÍTKO ZAPNUTÍ BUILDMODU (LEVÝ PANEL SCREEN_UI_HOLDER.cs)");
            }
        }

        // Inicializujeme tlačítka, image apod. statických panelů
        // UI.InitializeScreenStaticUI();
        #endregion


        //TODO: Možná zrušit - (je to takové zbytečně zamotané)
        #region  ÁSTEČNÉ UI(dynamické..) // Např. build okna/tlačítka

        if (buildMode.container != null)
        {
            buildMode.container.gameObject.SetActive(true);

            if (buildMode.top_title != null)
            {
                buildMode.top_title.text = TextHolder.BUILDMODE_TITLE;
            }
            else
            {
                Debug.LogError("NEBYLO NALEZENO HLAVNÍ OKNO BUILDMODU SCREEN_UI_HOLDER.cs)");
            }

            buildMode.container.gameObject.SetActive(false);
        }
        else
        {
            Debug.LogError("NEBYLO NALEZENO HLAVNÍ OKNO BUILDMODU SCREEN_UI_HOLDER.cs)");
        }


        #endregion

        // -- Float bloky
        #region KNIHOVNA BLOKŮ

        // Build window
        buildLibraryWindow.container = Settings.IsComponentLoaded <RectTransform>(buildLibraryWindow.container, Settings.UI_TAG_BUILD_LIBRARY, "ScreenUIHolder");
        buildLibraryWindow.container.gameObject.SetActive(true);

        if (buildLibraryWindow.container != null)
        {
            //Najdeme buildWindow dítě, podle tagu
            if (buildLibraryWindow.buildLibraryBlockContainer == null) // KARTY
            {
                buildLibraryWindow.buildLibraryBlockContainer = Settings.FindComponentInChildrenWithTag <RectTransform>(buildLibraryWindow.container, Settings.UI_TAG_SCROLL_WINDOW);
            }
            if (buildLibraryWindow.title == null) // TITLE
            {
                buildLibraryWindow.title = Settings.FindComponentInChildrenWithTag <TextMeshProUGUI>(buildLibraryWindow.container, Settings.UI_TAG_TITLE);
            }
            if (buildLibraryWindow.closeBtn == null) // CLOSE BTN
            {
                buildLibraryWindow.closeBtn = Settings.FindComponentInChildrenWithTag <Button>(buildLibraryWindow.container, Settings.UI_TAG_BT_CLOSE);
            }

            // Vypneme knihovnu (Debug: true) - Tady natvrdo
            UI.BlockLibraryWindowState(false);
        }

        #endregion


        #region OKNO DETAILU BLOKU

        // Okno detailu bloku
        blockDetailWindow.container = Settings.IsComponentLoaded <RectTransform>(blockDetailWindow.container, Settings.UI_TAG_DETAIL_WINDOW, "Block detail window");

        if (blockDetailWindow.container != null)
        {
            // Při loadu zapneme
            blockDetailWindow.container.gameObject.SetActive(true);


            if (blockDetailWindow.closeBtn == null) // CLOSE BTN
            {
                blockDetailWindow.closeBtn = Settings.FindComponentInChildrenWithTag <Button>(blockDetailWindow.container, Settings.UI_TAG_BT_CLOSE);
            }
            if (blockDetailWindow.editBtn == null) // BUILD BTN
            {
                blockDetailWindow.editBtn = Settings.FindComponentInChildrenWithTag <Button>(blockDetailWindow.container, Settings.UI_TAG_BT_TRUE);
            }
            if (blockDetailWindow.title == null) // TITLE
            {
                blockDetailWindow.title = Settings.FindComponentInChildrenWithTag <TextMeshProUGUI>(blockDetailWindow.container, Settings.UI_TAG_TITLE);
            }

            if (blockDetailWindow.editBtn != null)
            {
                if (blockDetailWindow.editBtnText == null)
                {
                    blockDetailWindow.editBtnText = Settings.FindComponentInChildrenWithTag <TextMeshProUGUI>(blockDetailWindow.editBtn.transform, Settings.UI_TAG_TEXT);
                }
            }

            if (blockDetailWindow.closeBtnText != null)
            {
                if (blockDetailWindow.closeBtnText == null)
                {
                    blockDetailWindow.closeBtnText = Settings.FindComponentInChildrenWithTag <TextMeshProUGUI>(blockDetailWindow.closeBtn.transform, Settings.UI_TAG_TEXT);
                }
            }



            /*  // Bar HEALTH TODO:
             *  blockDetailWindow.healthBar = Settings.FindComponentInChildrenWithTag<Image>(blockDetailWindow.container, Settings.UI_SCEEN_NAME);*/// Ba                                                                                                                                        blockDetailWindow.healthBar = Settings.FindComponentInChildrenWithTag<Image>(blockDetailWindow.container, Settings.UI_TAG_BT_TRUE);*/

            // zavřeme - Tady natvrdo
            UI.BlockDetailWindowState(false); // Vypneme block window
        }

        #endregion

        // -- Jednoduchá okna --

        #region Y/N OKNO
        // Najdeme Y/N Dialog
        //  askDialogWindow.askDialogueContainer = Settings.IsComponentLoaded<RectTransform>(askDialogWindow.askDialogueContainer, Settings.UI_TAG_ASK_DIALOGUE, "AskDialogue");
        //  if (askDialogWindow.askDialogueContainer != null)
        //  {
        //          // Při loadu zapneme
        //          askDialogWindow.askDialogueContainer.gameObject.SetActive(true);
        //
        //          if (askDialogWindow.acceptBtn == null) // ACCEPT BUTTON
        //              askDialogWindow.acceptBtn = Settings.FindComponentInChildrenWithTag<Button>(askDialogWindow.askDialogueContainer, Settings.UI_TAG_BT_TRUE); // Accept_btn
        //          if (askDialogWindow.rejectBtn == null) // REJECT BUTTON
        //              askDialogWindow.rejectBtn = Settings.FindComponentInChildrenWithTag<Button>(askDialogWindow.askDialogueContainer, Settings.UI_TAG_BT_FALSE); // Reject_btn
        //          if (askDialogWindow.message == null) // MESSAGE
        //              askDialogWindow.message = Settings.FindComponentInChildrenWithTag<TextMeshProUGUI>(askDialogWindow.askDialogueContainer, Settings.UI_TAG_TITLE); // Reject_btn
        //
        //          // Kontrolér
        //          if (askDialogWindow.controller == null)
        //          {
        //              askDialogWindow.controller = askDialogWindow.askDialogueContainer.GetComponent<AskDialogueWindowController>();
        //
        //              if (askDialogWindow.controller == null)
        //                  askDialogWindow.controller = askDialogWindow.askDialogueContainer.gameObject.AddComponent<AskDialogueWindowController>();
        //          }
        //
        //           UI.BlockBuildAskDialogueState(false);
        //  }

        #endregion

        #region GIZMOS

        gizmos.container = Settings.IsComponentLoaded <RectTransform>(gizmos.container, Settings.UI_TAG_ASK_DIALOGUE, "AskDialogue");
        gizmos.container.gameObject.SetActive(true);
        if (gizmos.container != null)
        {
            if (gizmos.rotateGizmos == null)
            {
                Debug.Log("Nebyl přiřazen riotační UI gizmos");//gizmos.rotateGizmos =
            }
            if (gizmos.rotateLBtn == null)
            {
                Debug.Log("Nebyl nalezen UI gizmos");
            }
            if (gizmos.rotateRBtn == null)
            {
                Debug.Log("Nebyl nalezen UI gizmos");
            }

            // Kontrolér
            if (gizmos.controller == null)
            {
                gizmos.controller = gizmos.container.GetComponent <UIGizmosController>();

                if (gizmos.controller == null)
                {
                    gizmos.controller = gizmos.container.gameObject.AddComponent <UIGizmosController>();
                }
            }
        }
        UI.BlockBuildGizmosState(false);

        #endregion

        #region Ostatní
        #region UIPOOL

        // Inicializace UI pool
        // Data s Resources
        PoolObjectSO[] poole_UI_object_types = Resources.LoadAll <PoolObjectSO>(Settings.POOL_UI_OBJECTS_PATH);

        // Načteme si objekty do poolu
        UIPoolList = new GeneralObjectPool(poole_UI_object_types.OfType <PoolObjectSO>().ToList());
        UIPoolList.InitializeObjectsToPool();

        #endregion
        #endregion
    }