Exemplo n.º 1
0
 public void Update()
 {
     if (Input.GetKeyDown(ScreenshotKeyCode))
     {
         var now = System.DateTime.Now;
         Callable.Call(OnBeforeScreenshot);
         string path = $"{Application.dataPath}/../{Prefix}-{now.Year}{now.Month}{now.Day}-{now.Hour}{now.Minute}{now.Second}{now.Millisecond}.png";
         Debug.Log($"Capturing Screenshot (Supersampled to {SuperSize}x) to the file : {path}");
         ScreenCapture.CaptureScreenshot(path, SuperSize);
         Callable.Call(OnAfterScreenshot);
     }
 }
 public void Update()
 {
     if (m_TTL > 0.0f)
     {
         m_TTL -= Time.deltaTime;
         if (m_TTL <= 0.0f)
         {
             m_TTL = 0.0f;
             Callable.Call(OnTimerFinished);
         }
     }
 }
Exemplo n.º 3
0
        public void Spawn()
        {
            if (SpawnTarget == null || FactoryBlueprints == null || FactoryBlueprints.Length == 0)
            {
                Debug.LogWarning(string.Format("Factory '{0}' : Cannot spawn as there are no spawn target or factory blueprints", gameObject.name));
                return;
            }

            if (m_Instances == null)
            {
                m_Instances = new List <GameObject>();
            }

            if (m_Instances.Count == MaxInstances && SacrificeOldest)
            {
                var oldest = m_Instances[0];
                m_Instances.RemoveAt(0);
                Destroy(oldest);
            }

            if (m_Instances.Count < MaxInstances)
            {
                GameObject newInstance = Spawn(SelectBlueprint(), SpawnTarget);

                switch (spawnLocation)
                {
                case SpawnLocation.Default:
                    break;

                case SpawnLocation.SameSceneAsTarget:
                    UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(newInstance, SpawnTarget.scene);
                    break;

                case SpawnLocation.ChildOfTarget:
                    newInstance.transform.parent = SpawnTarget.transform;
                    break;

                case SpawnLocation.DontDestroyOnLoad:
                    DontDestroyOnLoad(newInstance);
                    break;
                }

                m_Instances.Add(newInstance);

                Callable.Call(OnSpawn, newInstance);
            }
        }
        public void Fade(float duration, FadeMode mode, FadeTimingMode timingMode, Callable[] OnComplete, GameObject instigator = null)
        {
            if (m_Coroutine != null)
            {
                StopCoroutine(m_Coroutine);
                m_Coroutine = null;
            }

            if (duration <= 0.0f)
            {
                var color = FullScreenFadePlane.color;;
                switch (mode)
                {
                case FadeMode.ToBlack:
                    color.a = 1.0f;
                    break;

                case FadeMode.FromBlack:
                    color.a = 0.0f;
                    break;

                default: throw new NotImplementedException();
                }
                FullScreenFadePlane.gameObject.SetActive(color.a == 1.0f);
                FullScreenFadePlane.color = color;
                Callable.Call(OnComplete, instigator);
            }
            else
            {
                switch (mode)
                {
                case FadeMode.ToBlack:
                    m_Coroutine = StartCoroutine(FadeCoroutine(duration, 1.0f, 1.0f, timingMode, OnComplete, instigator));
                    break;

                case FadeMode.FromBlack:
                    m_Coroutine = StartCoroutine(FadeCoroutine(duration, 0.0f, -1.0f, timingMode, OnComplete, instigator));
                    break;

                default: throw new NotImplementedException();
                }
            }
        }
Exemplo n.º 5
0
        public void Update()
        {
#if ENABLE_LEGACY_INPUT_MANAGER
            if (Input.GetKeyDown(ScreenshotKeyCode))
#elif ENABLE_INPUT_SYSTEM
            if (InputSystemUtility.GetButton(ScreenshotKey).wasPressedThisFrame)
#else
            if (false)
#endif
            {
#if MODULE_SCREENCAPTURE
                var now = System.DateTime.Now;
                Callable.Call(OnBeforeScreenshot);
                string path = $"{Application.dataPath}/../{Prefix}-{now.Year}{now.Month}{now.Day}-{now.Hour}{now.Minute}{now.Second}{now.Millisecond}.png";
                Debug.Log($"Capturing Screenshot (Supersampled to {SuperSize}x) to the file : {path}");
                ScreenCapture.CaptureScreenshot(path, SuperSize);
                Callable.Call(OnAfterScreenshot);
#else
                Debug.Log("Screenshot Manager Cannot Take Screenshot : Unity Module Screen Capture is Disabled.");
#endif
            }
        }
        IEnumerator FadeCoroutine(float duration, float target, float sign, FadeTimingMode timingMode, Callable[] OnComplete, GameObject instigator)
        {
            FullScreenFadePlane.gameObject.SetActive(true);
            Color c = FullScreenFadePlane.color;

            while (sign > 0 ? FullScreenFadePlane.color.a <= target : FullScreenFadePlane.color.a >= target)
            {
                float t;
                switch (timingMode)
                {
                case FadeTimingMode.GameTime:
                    t = Time.deltaTime;
                    break;

                default:
                case FadeTimingMode.UnscaledGameTime:
                    t = Time.unscaledDeltaTime;
                    break;
                }
                c    = FullScreenFadePlane.color;
                c.a += sign * t / duration;
                FullScreenFadePlane.color = c;
                yield return(new WaitForEndOfFrame());
            }

            Color finalColor = FullScreenFadePlane.color;

            finalColor.a = target;
            FullScreenFadePlane.color = finalColor;
            Callable.Call(OnComplete, instigator);
            FullScreenFadePlane.gameObject.SetActive(target != 0.0f);

            yield return(new WaitForEndOfFrame());

            m_Coroutine = null;
        }
Exemplo n.º 7
0
        IEnumerator FadeCoroutine(float duration, float target, float sign, Callable[] OnComplete, GameObject instigator)
        {
            FullScreenFadePlane.gameObject.SetActive(true);
            Color c = FullScreenFadePlane.color;

            while (sign > 0 ? FullScreenFadePlane.color.a <= target : FullScreenFadePlane.color.a >= target)
            {
                c    = FullScreenFadePlane.color;
                c.a += sign * Time.unscaledDeltaTime / duration;
                FullScreenFadePlane.color = c;
                yield return(new WaitForEndOfFrame());
            }

            Color finalColor = FullScreenFadePlane.color;

            finalColor.a = target;
            FullScreenFadePlane.color = finalColor;
            Callable.Call(OnComplete, instigator);
            FullScreenFadePlane.gameObject.SetActive(target != 0.0f);

            yield return(new WaitForEndOfFrame());

            m_Coroutine = null;
        }
 public void Restart(GameObject instigator = null)
 {
     m_TTL = Hours * 3600 + Minutes * 60 + Seconds + Milliseconds * 0.001f;
     Callable.Call(OnTimerStart, instigator);
 }
Exemplo n.º 9
0
 public void LoadUserSave(byte index)
 {
     currentUserIndex = index;
     Callable.Call(OnLoad);
     currentUserSaveEntries = LoadFile(string.Format(userSaveName, index));
 }
Exemplo n.º 10
0
 public void SaveSystemSave()
 {
     SaveFile(systemSaveName, systemSaveEntries);
     Callable.Call(OnSave);
 }
Exemplo n.º 11
0
 public void LoadSystemSave()
 {
     systemSaveEntries = LoadFile(systemSaveName);
     Callable.Call(OnLoad);
 }
Exemplo n.º 12
0
 public void Start()
 {
     currentLevel = int.MinValue;
     Callable.Call(OnGameStart);
     Manager.Get <GameSaveManager>().LoadUserSave(0);
 }