Пример #1
0
        public IEnumerator ShowAlert(string text)
        {
            var canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, 100);
            var tp     = CanvasUtil.CreateTextPanel(
                canvas,
                text,
                20,
                TextAnchor.LowerRight,
                new CanvasUtil.RectData(
                    new Vector2(1920, 80),
                    new Vector2(-40, 40),
                    new Vector2(1, 0),
                    new Vector2(1, 0),
                    new Vector2(1, 0)
                    )
                );

            GameObject.DontDestroyOnLoad(canvas);
            var cg = tp.AddComponent <CanvasGroup>();

            yield return(CanvasUtil.FadeInCanvasGroup(cg));

            yield return(new WaitForSeconds(3f));

            yield return(CanvasUtil.FadeOutCanvasGroup(cg));

            GameObject.DestroyImmediate(canvas);
        }
Пример #2
0
        private void Update()
        {
            if (!Input.GetKeyDown(KeyCode.F9))
            {
                return;
            }

            StartCoroutine
            (
                Canvas.activeSelf
                    ? CanvasUtil.FadeOutCanvasGroup(_group)
                    : CanvasUtil.FadeInCanvasGroup(_group)
            );
        }
        private IEnumerator ShowMenu(MenuScreen menu)
        {
            gameManager.inputHandler.StopUIInput();
            if (menu.screenCanvasGroup != null)
            {
                StartCoroutine(CanvasUtil.FadeInCanvasGroup(menu.screenCanvasGroup));
            }

            if (menu.title != null)
            {
                StartCoroutine(CanvasUtil.FadeInCanvasGroup(menu.title));
            }

            if (menu.topFleur != null)
            {
                yield return(StartCoroutine(gameManager.timeTool.TimeScaleIndependentWaitForSeconds(0.1f)));

                menu.topFleur.ResetTrigger("hide");
                menu.topFleur.SetTrigger("show");
            }

            yield return(StartCoroutine(gameManager.timeTool.TimeScaleIndependentWaitForSeconds(0.1f)));

            if (menu.content != null)
            {
                StartCoroutine(CanvasUtil.FadeInCanvasGroup(menu.content));
            }

            if (menu.controls != null)
            {
                StartCoroutine(CanvasUtil.FadeInCanvasGroup(menu.controls));
            }

            if (menu.bottomFleur != null)
            {
                menu.bottomFleur.ResetTrigger("hide");
                menu.bottomFleur.SetTrigger("show");
            }

            yield return(StartCoroutine(gameManager.timeTool.TimeScaleIndependentWaitForSeconds(0.1f)));

            gameManager.inputHandler.StartUIInput();
            yield return(null);

            menu.HighlightDefault();
        }
Пример #4
0
        private IEnumerator ShowShop()
        {
            GameObject background = CanvasUtil.CreateImagePanel(gameObject,
                                                                RandomizerMod.GetSprite("UI.Shop.Background"),
                                                                new CanvasUtil.RectData(new Vector2(810, 813), Vector2.zero, new Vector2(0.675f, 0.525f),
                                                                                        new Vector2(0.675f, 0.525f)));

            GameObject bottomFleur = CanvasUtil.CreateImagePanel(gameObject,
                                                                 RandomizerMod.GetSprite("Anim.Shop.BottomFleur.0"),
                                                                 new CanvasUtil.RectData(new Vector2(811, 241), Vector2.zero, new Vector2(0.675f, 0.3f),
                                                                                         new Vector2(0.675f, 0.3f)));

            StartCoroutine(AnimateImage(bottomFleur, bottomFrames, 12));
            StartCoroutine(TweenY(bottomFleur, 0.3f, 0.2f, 60, 15));

            GameObject topFleur = CanvasUtil.CreateImagePanel(gameObject,
                                                              RandomizerMod.GetSprite("Anim.Shop.TopFleur.0"),
                                                              new CanvasUtil.RectData(new Vector2(808, 198), Vector2.zero, new Vector2(0.675f, 0.6f),
                                                                                      new Vector2(0.675f, 0.6f)));

            StartCoroutine(AnimateImage(topFleur, topFrames, 12));
            StartCoroutine(TweenY(topFleur, 0.6f, 0.85f, 60, 15));

            yield return(StartCoroutine(CanvasUtil.FadeInCanvasGroup(background.AddComponent <CanvasGroup>())));

            CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Selector"),
                                        new CanvasUtil.RectData(new Vector2(340, 113), Vector2.zero, new Vector2(0.57f, 0.5825f),
                                                                new Vector2(0.57f, 0.5825f)));
            CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Shitpost"),
                                        new CanvasUtil.RectData(new Vector2(112, 112), Vector2.zero, new Vector2(0.6775f, 0.92f),
                                                                new Vector2(0.6775f, 0.92f)));

            ResetItems();

            StartCoroutine(ListenForInput());
        }
Пример #5
0
        public void Update()
        {
            if (Input.GetKeyDown(KeyCode.F11))
            {
                _visible = !_visible;
                var cg = OverlayCanvas.GetComponent <CanvasGroup>();
                StartCoroutine(_visible
                    ? CanvasUtil.FadeInCanvasGroup(cg)
                    : CanvasUtil.FadeOutCanvasGroup(cg));
            }

            textComp.text = "";

            if (!_enabled || !_visible || PlayerMachine == null)
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.F1) || Input.GetKeyDown(KeyCode.Keypad1))
            {
                bool?a = PlayerMachine.CoyoteFrameEnabled;
                PlayerMachine.CoyoteFrameEnabled =
                    a.HasValue ? (a.Value ? false : new bool?()) : true;
            }

            if (Input.GetKeyDown(KeyCode.LeftBracket))
            {
                if (--currentCostIdx < 0)
                {
                    currentCostIdx = costumeNames.Length - 1;
                }
            }
            else if (Input.GetKeyDown(KeyCode.RightBracket))
            {
                currentCostIdx = (currentCostIdx + 1) % (costumeNames.Length);
            }
            else if (Input.GetKeyDown(KeyCode.F2) || Input.GetKeyDown(KeyCode.Keypad2))
            {
                PlayerMachine.SetCostume((Costumes)currentCostIdx);
                GameObject.FindGameObjectWithTag("Manager").GetComponent <DialogueSystem>().UpdateCostumePortrait();
            }

            if (dialogueCache.Count > 0)
            {
                if (Input.GetKeyDown(KeyCode.Comma))
                {
                    if (--currentNpcIdx < 0)
                    {
                        currentNpcIdx = dialogueCache.Count - 1;
                    }
                }
                else if (Input.GetKeyDown(KeyCode.Period))
                {
                    currentNpcIdx = (currentNpcIdx + 1) % dialogueCache.Count;
                }
                else if (Input.GetKeyDown(KeyCode.F3))
                {
                    GameObject.FindGameObjectWithTag("Manager").GetComponent <DialogueSystem>().Begin(dialogueCache[currentNpcIdx].TextAsset, null);
                }
            }

            if (Input.GetKeyDown(KeyCode.F4) || Input.GetKeyDown(KeyCode.Keypad4))
            {
                if (Time.timeScale > 0)
                {
                    float timeScale = Time.timeScale / 2;
                    if (timeScale < 0.25f)
                    {
                        timeScale = 2.0f;
                    }
                    Time.timeScale = timeScale;
                }
            }

            if ((Input.GetKeyDown(KeyCode.F5) || Input.GetKeyDown(KeyCode.Keypad5) || Input.GetMouseButtonDown(4)) &&
                !PlayerMachine.currentState.Equals(PlayerStates.Loading))
            {
                PlayerMachine.EndScene();
            }

            if (Input.GetKeyDown(KeyCode.F6) || Input.GetKeyDown(KeyCode.Keypad6))
            {
                ++QualitySettings.vSyncCount;
                QualitySettings.vSyncCount %= 3;
            }

            bool inVoid = SceneManager.GetActiveScene().name == "void";

            if ((Input.GetKeyDown(KeyCode.F7) || Input.GetKeyDown(KeyCode.Keypad7)) && !PlayerMachine.currentState.Equals(PlayerStates.Loading))
            {
                var pizza = FindObjectOfType <PizzaBox>();
                if (pizza == null)
                {
                    Logger.LogError("No PizzaBox!");
                }
                else
                {
                    string level = (!inVoid) ? "void" : levelNames[currentLvlIdx];
                    deathPlaneStatus = true;
                    GameObject.Find("Global Manager").GetComponent <Manager>().LoadScene(level, pizza.ExitId, pizza.gameObject);
                }
            }
            else if (inVoid && Input.GetKeyDown(KeyCode.L))
            {
                do
                {
                    currentLvlIdx = (currentLvlIdx + 1) % levelNames.Length;
                } while (levelNames[currentLvlIdx] == SceneManager.GetActiveScene().name);
            }

            if (!inVoid && Input.GetKeyDown(KeyCode.K))
            {
                var key = FindObjectsOfType <Key>();
                foreach (var k in key)
                {
                    if (!k.pickedUp)
                    {
                        k.transform.position = PlayerMachine.gameObject.transform.position;
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.G))
            {
                talkVolumeRenderFlag = !talkVolumeRenderFlag;
                if (talkVolumeRenderFlag)
                {
                    tvRadiusCache.UpdateCache(TalkVolumeCreator, talkVolumeRenderFlag);
                }
                else
                {
                    tvRadiusCache.ToggleAllObjects(talkVolumeRenderFlag);
                }
            }

            if (Input.GetKeyDown(KeyCode.T) && !PlayerMachine.currentState.Equals(PlayerStates.Loading))
            {
                SetupNoClip(!NoClipActive);
            }

            if (Input.GetKeyDown(KeyCode.M))
            {
                var deathPlanes = FindObjectsOfType <VoidOut>();
                deathPlaneStatus = !deathPlaneStatus;
                foreach (var d in deathPlanes)
                {
                    d.setActive(deathPlaneStatus);
                }
            }
            else if (Input.GetKeyDown(KeyCode.V))
            {
                collisionRenderFlag = !collisionRenderFlag;
                if (collisionRenderFlag)
                {
                    collPlaneCache.UpdateCache(VoidOutCreator, collisionRenderFlag);
                }
                else
                {
                    collPlaneCache.ToggleAllObjects(collisionRenderFlag);
                }
            }

            if ((Input.GetMouseButtonDown(3) || Input.GetKeyDown(KeyCode.R)) &&
                (PlayerMachine.currentState.Equals(PlayerStates.Jump) ||
                 PlayerMachine.currentState.Equals(PlayerStates.Loading)) &&
                warpCam.enabled)
            {
                MoveWarpCam();

                yaw   = warpCam.transform.eulerAngles.y;
                pitch = warpCam.transform.eulerAngles.x;
            }
            else if (Input.GetMouseButton(2))
            {
                yaw   += Input.GetAxis("Mouse X") * 2f;
                pitch -= Input.GetAxis("Mouse Y") * 2f;
                warpCam.transform.eulerAngles = new Vector3(pitch, yaw, 0f);
            }
            else if (Input.GetKeyDown(KeyCode.B))
            {
                warpCam.enabled = !warpCam.enabled;
            }

            if (Input.GetKeyDown(KeyCode.N) && modTextures.ContainsKey("glass"))
            {
                if (Physics.Raycast(
                        PlayerMachine.transform.position + PlayerMachine.controller.up * PlayerMachine.controller.height * 0.85f,
                        PlayerMachine.lookDirection,
                        out RaycastHit objHit))
                {
                    Logger.LogFine($"Hit an object: {objHit.collider.gameObject.name}");
                    var renderer = objHit.collider.gameObject.GetComponent <Renderer>();
                    var shader   = Shader.Find("psx/trasparent/vertexlit");
                    if (renderer && shader)
                    {
                        for (int i = 0; i < renderer.materials.Length; ++i)
                        {
                            var matl = renderer.materials[i];
                            matl.shader = shader;
                            matl.SetTexture("_MainTex", modTextures["glass"]);
                            matl.SetColor("_Color", Color.blue);
                            renderer.materials[i] = matl;
                        }
                        GameObject go    = new GameObject();
                        Vector3    start = PlayerMachine.transform.position + PlayerMachine.controller.up * PlayerMachine.controller.height * 0.85f;
                        go.transform.position = start;
                        var lineRenderer = go.AddComponent <LineRenderer>();
                        lineRenderer.material = new Material(Shader.Find("Standard"));
                        lineRenderer.material.SetColor("_Color", Color.red);
                        lineRenderer.startColor = Color.red;
                        lineRenderer.endColor   = Color.red;
                        lineRenderer.startWidth = 0.1f;
                        lineRenderer.SetPosition(0, start);
                        lineRenderer.SetPosition(1, objHit.point);
                        Destroy(go, 0.3f);
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.F8) || Input.GetKeyDown(KeyCode.Keypad8))
            {
                CamEventReset = !CamEventReset;
            }

            deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
            bool?b = PlayerMachine.CoyoteFrameEnabled;

            textBuilder.Length = 0;

            textBuilder.AppendFormat("FPS: {0:F3}\n", 1f / deltaTime);
            textBuilder.AppendFormat("<F1>: Coyote Frames: {0}\n", b.HasValue ? OnOffStr(b.Value) : "Default");
            textBuilder.Append("<F2><[]>: Set Costume: ").AppendLine(costumeNames[currentCostIdx]);
            if (dialogueCache.Count > 0)
            {
                textBuilder.AppendFormat("<F3><,.>: Dialogue: ").AppendLine(dialogueCache[currentNpcIdx].NpcName);
            }
            textBuilder.Append("<F4>: Time Scale: x").AppendLine(Time.timeScale.ToString("F2"));
            textBuilder.Append("<F5>: Text Storage/Warp\n");
            textBuilder.AppendFormat("<F6>: VSync Count :{0}\n", QualitySettings.vSyncCount);
            textBuilder.AppendFormat("<F7><L>: Level Load: {0}\n", !inVoid ? "void" : levelNames[currentLvlIdx]);
            if (camEventsFound)
            {
                textBuilder.AppendFormat("<F8>: Repeat Cam Events: {0}\n", OnOffStr(CamEventReset));
            }
            textBuilder.Append("<V>: Render Death Planes: ").AppendLine(OnOffStr(collisionRenderFlag));
            textBuilder.Append("<M>: Active Death Planes: ").AppendLine(OnOffStr(deathPlaneStatus));
            textBuilder.Append("<G>: Show NPC Talk Zone: ").AppendLine(OnOffStr(talkVolumeRenderFlag));
            textBuilder.Append("<K>: Get All Keys\n");
            textBuilder.Append("<R><noparse><B></noparse>: Warp Cam Move/Toggle\n");
            textBuilder.Append("<N>: Set Obj Transparent\n");
            textBuilder.Append("<T>: NoClip: ").AppendLine(OnOffStr(NoClipActive));
            textBuilder.Append("<F11> Toggle UI\n").AppendLine();

            textBuilder.Append("Move Dir:").AppendLine(PlayerMachine.moveDirection.ToString());
            textBuilder.Append("Pos:").AppendLine(PlayerMachine.transform.position.ToString());
            textBuilder.Append("SpawnPos:").AppendLine(PlayerMachine.LastGroundLoc.ToString());
            textBuilder.Append("Look Dir:").AppendLine(PlayerMachine.lookDirection.ToString());
            textBuilder.Append("Player State:").AppendLine(PlayerMachine.currentState.ToString());

            if (bossController)
            {
                textBuilder.AppendLine();
                textBuilder.Append("Boss Health: ").AppendLine(bossController.Health.ToString());
                textBuilder.Append("Boss State: ").AppendLine(bossStates[(int)BossController.State]);
            }
            if (warpCam.enabled)
            {
                textBuilder.AppendLine();
                textBuilder.Append("LGP:").AppendLine(PlayerMachine.controller.LastGroundPos.ToString());
                textBuilder.Append("LGO:").AppendLine(PlayerMachine.controller.LastGroundOffset.ToString());
                textBuilder.Append("LGR:").AppendLine(PlayerMachine.controller.LastGroundRot.ToString());
                textBuilder.Append("CG:").AppendLine(PlayerMachine.controller.currentGround.transform.position.ToString());
                textBuilder.Append("CR:").AppendLine(PlayerMachine.controller.currentGround.transform.rotation.ToString());
                textBuilder.Append("Warp Pos:").AppendLine(warpSimPos.ToString());
            }

            // Set text causes visual glitches
            textComp.text += textBuilder.ToString();
        }
 public void FadeIn()
 {
     _coroutineStarter.StartCoroutine(CanvasUtil.FadeInCanvasGroup(canvasGroup));
 }