// TODO: optimize. Do not call GetComponent in Update
 void Update()
 {
     if (animating && animateAdvCam)
     {
         advCamera.transform.position = cam.transform.position;
         if (cam)
         {
             advCamera.SetNewCameraSize(cam.orthographicSize);
         }
         if (elroy && elroy.IsWalking())
         {
             animating = false;
             PersistentEngine.activeCamera             = advCamera.GetComponent <Camera>();
             advCamera.transform.position              = cam.transform.position;
             advCamera.GetComponent <Camera>().enabled = true;
             advCamera.forcedCameraBoundaries          = true;
             advCamera.inCloseUp          = false;
             advCamera.followCameraObject = false;
             advCamera.canZoom            = true;
             advCamera.SetNewCameraSize(advCamStartSize);
             cam.enabled = false;
         }
     }
 }
Ejemplo n.º 2
0
        void Awake()
        {
            float starttime = Time.realtimeSinceStartup;

            Debug.Log("Global Awake: Init: " + starttime);

            if (SceneManager.GetActiveScene().buildIndex == 0)
            {
                initialized = false;
                state       = new Hashtable();
                Initialize();
            }
            isMobileScreen = isSmallScreenL;

            var men = Resources.Load("prefabs/Menus") as GameObject;

            var meni = Instantiate(men);

            meni.name = "Menus";

            var dt  = Resources.Load("prefabs/CharacterDialogText") as GameObject;
            var dti = Instantiate(dt);

            dti.name = "CharacterDialogText";

            var dc  = Resources.Load("prefabs/DialogControl") as GameObject;
            var dci = Instantiate(dc);

            dci.name = "DialogControl";

            PersistentEngine.characterDialogText = dti.GetComponent <CharacterDialogText>();

            player = GameObject.FindObjectOfType <Player>() ? GameObject.FindObjectOfType <Player>().GetComponent <Player>() : null;

            advCamera = GameObject.Find("MainCamera") ? GameObject.Find("MainCamera").GetComponent <AdvCamera>() : null;

            if (advCamera == null)
            {
                advCamera = GameObject.Find("Main Camera Runner") ? GameObject.Find("Main Camera Runner").GetComponent <AdvCamera>() : null;
            }

            navMeshAgent = GameObject.Find("NavmeshAgent") ? GameObject.Find("NavmeshAgent").GetComponent <UnityEngine.AI.NavMeshAgent>() : null;

            scene = GameObject.Find("Scene") ? GameObject.Find("Scene").GetComponent <Scene>() : null;

            customCursor = GameObject.Find("CustomCursor") ? GameObject.Find("CustomCursor").GetComponent <CustomCursor>() : null;
            customCursor.gameObject.SetActive(true);
            if (advCamera && PersistentEngine.activeCamera == null)
            {
                PersistentEngine.activeCamera = advCamera.GetComponent <Camera>();
            }

            if (PersistentEngine.activeCamera == null && Camera.main)
            {
                PersistentEngine.activeCamera = Camera.main;
            }

            bool   inBuildSettings = true;
            String current         = SceneManager.GetActiveScene().path;

            var bf = Resources.Load("prefabs/BlackFade") as GameObject;

            var bfi = Instantiate(bf);

            bfi.name = "BlackFade";
            GameObject Fade = GameObject.Find("BlackFade");

            blackFade = Fade.GetComponent <SpriteRenderer>();

            if (!inBuildSettings || SceneManager.GetActiveScene().buildIndex < SceneManager.sceneCountInBuildSettings - 1)
            {
                audioManager = GameObject.Find("AudioManager").GetComponent <AudioManager>();

                audioManager.Initialise();

                SetMusic(GetState("Global music") == 1 || GetState("Global music") == -1);
                SetSound(GetState("Global sound") == 1 || GetState("Global sound") == -1);
                int?savegameSlot = GetState("Global Savegame");
                if (savegameSlot == null)
                {
                    savegameSlot = 1;
                }
                SetSavegame((int)savegameSlot);


                if (SceneManager.GetActiveScene().buildIndex > 0 && GetState("Global level") != SceneManager.GetActiveScene().buildIndex)
                {
                    SetState("Global level", SceneManager.GetActiveScene().buildIndex, true);
                }

                float endTime = Time.realtimeSinceStartup;

                float timePassed = endTime - starttime;

                Debug.Log("Global Awake: Init End: " + endTime + " time passed: " + timePassed);
            }

            blackFade.color = new Color(1, 1, 1, 1);

            if (string.IsNullOrEmpty(GetArrivalDoor()) && !string.IsNullOrEmpty(arrivalDoor))
            {
                SetArrivalDoor(arrivalDoor);
            }
        }