Exemplo n.º 1
0
        private void makeModCanvas(int ad)
        {
            if (canvas != null)
            {
                return;
            }

            CanvasUtil.CreateFonts();
            canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
            GameObject go =
                CanvasUtil.CreateTextPanel(canvas, "", 27, TextAnchor.UpperCenter,
                                           new CanvasUtil.RectData(
                                               new Vector2(0, 0),
                                               new Vector2(0, 0),
                                               new Vector2(0, 0),
                                               generateNonAnnoyingLocation(),
                                               new Vector2(0.5f, 0.5f)));


            textObj          = go.GetComponent <Text>();
            textObj.color    = ads[ad].textColor;
            textObj.font     = CanvasUtil.TrajanBold;
            textObj.text     = "";
            textObj.fontSize = 50;
            textObj.text     = ads[ad].textDescription;
            textObj.CrossFadeAlpha(1f, 0f, false);
        }
Exemplo n.º 2
0
        private void MakeCanvas()
        {
            if (CanvasObject == null)
            {
                CanvasObject = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920f, 1080f));
            }

            if (TextCanvas == null)
            {
                CanvasUtil.CreateFonts();
                TextCanvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920f, 1080f));
                GameObject TextPanel = CanvasUtil.CreateTextPanel(TextCanvas, "", 35, TextAnchor.MiddleCenter,
                                                                  new CanvasUtil.RectData(
                                                                      new Vector2(0, 50),
                                                                      new Vector2(0, 45),
                                                                      new Vector2(0, 0),
                                                                      new Vector2(1, 0),
                                                                      new Vector2(0.5f, 0.5f)));
                TextObject          = TextPanel.GetComponent <Text>();
                TextObject.font     = CanvasUtil.TrajanBold;
                TextObject.text     = "";
                TextObject.fontSize = 50;
                TextObject.color    = Color.red;
            }
        }
Exemplo n.º 3
0
        private IEnumerator displayEnemyLevel(int level, Color c)
        {
            yield return(new WaitForSeconds(2f));

            CanvasUtil.CreateFonts();
            GameObject canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
            GameObject go     =
                CanvasUtil.CreateTextPanel(canvas, "", 130, TextAnchor.UpperCenter,
                                           new CanvasUtil.RectData(
                                               new Vector2(0, 0),
                                               new Vector2(0, 0),
                                               new Vector2(0, 0),
                                               new Vector2(1.0f, 0.7f),
                                               new Vector2(0.5f, 0.5f)));


            Text textObj = go.GetComponent <Text>();

            textObj.color    = c;
            textObj.font     = CanvasUtil.TrajanBold;
            textObj.text     = "";
            textObj.fontSize = 170;
            textObj.text     = "Level " + level;
            textObj.CrossFadeAlpha(1f, 1f, false);

            yield return(new WaitForSeconds(3f));

            textObj.CrossFadeAlpha(0f, 3f, false);

            yield return(new WaitForSeconds(3.5f));

            Destroy(go);
            Destroy(canvas);
        }
        public void CreateCanvas()
        {
            if (_canvas != null)
            {
                return;
            }

            CanvasUtil.CreateFonts();
            _canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
            UnityEngine.Object.DontDestroyOnLoad(_canvas);

            GameObject canvas = CanvasUtil.CreateTextPanel
                                (
                _canvas,
                "",
                24,
                TextAnchor.LowerRight,
                new CanvasUtil.RectData
                (
                    new Vector2(0, 50),
                    new Vector2(0, 45),
                    new Vector2(0, 0),
                    new Vector2(1, 0),
                    new Vector2(0.5f, 0.5f)
                )
                                );

            _textObj          = canvas.GetComponent <Text>();
            _textObj.font     = CanvasUtil.TrajanBold;
            _textObj.text     = "";
            _textObj.fontSize = 24;
        }
Exemplo n.º 5
0
        private void Start()
        {
            timeRemaining = (float)infinite_globals.secondsToRun;

            if (canvas != null)
            {
                return;
            }

            CanvasUtil.CreateFonts();
            canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
            GameObject go =
                CanvasUtil.CreateTextPanel(canvas, "", 27, TextAnchor.MiddleCenter,
                                           new CanvasUtil.RectData(
                                               new Vector2(0, 0),
                                               new Vector2(0, 0),
                                               new Vector2(0, 0),
                                               new Vector2(1.9f, 1.9f),
                                               new Vector2(0.5f, 0.5f)));


            textObj          = go.GetComponent <Text>();
            textObj.color    = Color.white;
            textObj.font     = CanvasUtil.TrajanBold;
            textObj.text     = getTimeInCleanFormat((float)infinite_globals.secondsToRun);
            textObj.fontSize = 50;
            textObj.CrossFadeAlpha(1f, 0f, false);
        }
Exemplo n.º 6
0
        public override void Initialize()
        {
            if (Instance != null)
            {
                Log("Warning: " + GetType().Name + " is a singleton. Trying to create more than one may cause issues!");
                return;
            }

            Instance = this;
            comms    = new CommunicationNode();
            comms.EnableNode(this);

            Log("Mod Common initializing!");

            SetupDefaulSettings();

            RegisterCallbacks();

            DevLog.Logger.Hide();

            // Setup and prepare the CanvasUtil fonts so that other mods can use them.
            CanvasUtil.CreateFonts();

            Log("Mod Common is done initializing!");
        }
Exemplo n.º 7
0
        public void Awake()
        {
            gameEnd     = false;
            stopped     = true;
            textToggle  = true;
            _remastered = DebugManager.remastered;
            lastCostume = null;

            var ar = AspectRatio.GetAspectRatio(Screen.width, Screen.height);

            if (ar.x == 16f && ar.y == 9f)
            {
                wideAspect = true;
            }
            Logger.LogDebug($"Wide Aspect: {wideAspect}");

            DontDestroyOnLoad(gameObject);
            if (OverlayCanvas == null)
            {
                CanvasUtil.CreateFonts();
                OverlayCanvas      = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
                OverlayCanvas.name = "IGTDisplay";
                DontDestroyOnLoad(OverlayCanvas);

                _background = CanvasUtil.CreateImagePanel(OverlayCanvas, new Color32(0x28, 0x28, 0x28, 0x00),
                                                          wideAspect ? topRightLegacy : topRightHD);
                _textPanel = CanvasUtil.CreateTMProPanel(_background, string.Empty, 24,
                                                         TextAnchor.UpperLeft,
                                                         new CanvasUtil.RectData(new Vector2(-5, -5), new Vector2(0, 0), new Vector2(0, 0), new Vector2(1, 1)));

                tmProObjRef           = _textPanel.GetComponent <TextMeshProUGUI>();
                tmProObjRef.alignment = TextAlignmentOptions.TopRight;
            }
        }
        private void LoadResources()
        {
            CanvasUtil.CreateFonts();

            TrajanBold   = CanvasUtil.TrajanBold;
            TrajanNormal = CanvasUtil.TrajanNormal;

            try
            {
                Arial = Font.CreateDynamicFontFromOSFont
                        (
                    Font.GetOSInstalledFontNames().First(x => x.ToLower().Contains("arial")),
                    13
                        );
            }
            catch
            {
                Logger.LogWarn("Unable to find Arial! Using Perpetua.");
                Arial = CanvasUtil.GetFont("Perpetua");
            }

            if (TrajanBold == null || TrajanNormal == null || Arial == null)
            {
                Benchwarp.instance.LogError("Could not find game fonts");
            }

            Assembly asm = Assembly.GetExecutingAssembly();

            foreach (string res in asm.GetManifestResourceNames())
            {
                if (!res.StartsWith("Benchwarp.Images."))
                {
                    continue;
                }

                try
                {
                    using (Stream imageStream = asm.GetManifestResourceStream(res))
                    {
                        byte[] buffer = new byte[imageStream.Length];
                        imageStream.Read(buffer, 0, buffer.Length);

                        Texture2D tex = new Texture2D(1, 1);
                        tex.LoadImage(buffer.ToArray());

                        string[] split        = res.Split('.');
                        string   internalName = split[split.Length - 2];

                        images.Add(internalName, tex);

                        Benchwarp.instance.Log("Loaded image: " + internalName);
                    }
                }
                catch (Exception e)
                {
                    Benchwarp.instance.LogError("Failed to load image: " + res + "\n" + e);
                }
            }
        }
 private Text _GetOrInitializeTextComponent()
 {
     if (_textComponent == null)
     {
         DebugLog.Log("Initializing textComponent");
         _textComponent = _GetOrInitializeTextObj().AddComponent <Text>();
         _textComponent.horizontalOverflow   = HorizontalWrapMode.Overflow;
         _textComponent.resizeTextForBestFit = true;
         _textComponent.text = "";
         CanvasUtil.CreateFonts();
         _textComponent.font      = CanvasUtil.TrajanNormal;
         _textComponent.fontSize  = 30;
         _textComponent.fontStyle = FontStyle.Normal;
         _textComponent.alignment = TextAnchor.UpperLeft;
         _textComponent.color     = Color.white;
     }
     return(_textComponent);
 }
Exemplo n.º 10
0
        public void Start()
        {
            CanvasUtil.CreateFonts();
            canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
            UnityEngine.Object.DontDestroyOnLoad(canvas);
            caliber       = CanvasUtil.CreateTextPanel(canvas, "", 25, TextAnchor.MiddleLeft, new CanvasUtil.RectData(new Vector2(600, 50), new Vector2(-560, 805), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), true).GetComponent <Text>();
            caliber.color = new Color(0.420f, 0.420f, 0.420f, 1f);
            caliber.text  = "";

            ammo       = CanvasUtil.CreateTextPanel(canvas, "", 25, TextAnchor.MiddleLeft, new CanvasUtil.RectData(new Vector2(600, 50), new Vector2(-560, 775), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), true).GetComponent <Text>();
            ammo.color = new Color(0.420f, 0.420f, 0.420f, 1f);
            ammo.text  = "";

            magazine       = CanvasUtil.CreateTextPanel(canvas, "", 25, TextAnchor.MiddleLeft, new CanvasUtil.RectData(new Vector2(600, 50), new Vector2(-560, 745), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), true).GetComponent <Text>();
            magazine.color = new Color(0.420f, 0.420f, 0.420f, 1f);
            magazine.text  = "";
            Modding.Logger.Log("[HOLLOW POINT] HPUI.cs sucessfully initialized!");
        }
Exemplo n.º 11
0
        static Fonts()
        {
            CanvasUtil.CreateFonts();

            FontCache = new Dictionary <string, Font>();
            foreach (Font f in Resources.FindObjectsOfTypeAll <Font>())
            {
                if (FontCache.ContainsKey(f.name))
                {
                    continue;
                }

                FontCache.Add(f.name, f);

                if (Perpetua == null && f.name == "Perpetua")
                {
                    Perpetua = f;
                }
            }
        }
Exemplo n.º 12
0
        IEnumerator EndingTextFade()
        {
            CanvasUtil.CreateFonts();
            canvas      = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920f, 1080f));//1536f, 864f));
            title       = CanvasUtil.CreateTextPanel(canvas, "Propeller Knight by Yacht Club Games", 40, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1000, 1500), new Vector2(0f, 65f), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), false).GetComponent <Text>();
            title.color = new Color(1f, 1f, 1f, 0f);
            title.font  = CanvasUtil.TrajanBold;//CanvasUtil.GetFont("Perpetua");
            for (float i = 0f; i <= 1f; i += 0.05f)
            {
                title.color = new Color(1f, 1f, 1f, i);
                yield return(new WaitForEndOfFrame());
            }
            yield return(new WaitForSeconds(1.7f));

            for (float i = 1; i >= 0f; i -= 0.05f)
            {
                title.color = new Color(1f, 1f, 1f, i);
                yield return(new WaitForEndOfFrame());
            }
            title.text = "";
        }
Exemplo n.º 13
0
        public void Awake()
        {
            DontDestroyOnLoad(gameObject);
            if (OverlayCanvas == null)
            {
                CanvasUtil.CreateFonts();
                OverlayCanvas      = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
                OverlayCanvas.name = "DebugMenu";
                DontDestroyOnLoad(OverlayCanvas);

                GameObject _background = CanvasUtil.CreateImagePanel(OverlayCanvas, new Color32(0x28, 0x28, 0x28, 0x00), topRight);
                _textPanel = CanvasUtil.CreateTMProPanel(_background, string.Empty, 20,
                                                         TextAnchor.UpperLeft,
                                                         new CanvasUtil.RectData(new Vector2(-5, -5), new Vector2(0, 0), new Vector2(0, 0), new Vector2(1, 1)));
                textComp = _textPanel.GetComponent <TextMeshProUGUI>();
            }

            foreach (string fn in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                if (fn.Contains("glass") || fn.Contains("talkVol"))
                {
                    using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(fn))
                    {
                        byte[] imageBuffer = new byte[imageStream.Length];
                        imageStream.Read(imageBuffer, 0, imageBuffer.Length);
                        imageStream.Flush();
                        var assetName = fn.Contains("glass") ? "glass" : "talkVol";
                        modTextures[assetName] = new Texture2D(1, 1);
                        modTextures[assetName].LoadImage(imageBuffer);
                        Logger.Log($"Loaded Texture: {assetName}");
                    }
                }
            }
            warpCam      = gameObject.AddComponent <Camera>();
            warpCam.rect = new Rect(0.75f, 0f, .25f, .25f);
            warpCam.transform.position = Vector3.zero;
            warpCam.enabled            = false;
        }
Exemplo n.º 14
0
 public void InitDisplay()
 {
     if (this.timer != null && this.timer.timerCanvas != null)
     {
         var timerCanvas = this.timer.timerCanvas;
         CanvasUtil.CreateFonts();
         this.pb        = TimeSpan.Zero;
         this.pbDisplay = CanvasUtil.CreateTextPanel(
             timerCanvas,
             this.PbText(),
             HKTimer.settings.textSize * 3 / 4,
             TextAnchor.MiddleRight,
             Timer.CreateTimerRectData(new Vector2(190, 30), new Vector2(-50, -45))
             );
         this.pbStaticTextDisplay = CanvasUtil.CreateTextPanel(
             timerCanvas,
             "PB",
             HKTimer.settings.textSize * 3 / 4,
             TextAnchor.MiddleRight,
             Timer.CreateTimerRectData(new Vector2(50, 30), new Vector2(0, -45))
             );
         this.pbDeltaDisplay = CanvasUtil.CreateTextPanel(
             timerCanvas,
             this.PbDeltaText(),
             HKTimer.settings.textSize / 2,
             TextAnchor.MiddleRight,
             Timer.CreateTimerRectData(new Vector2(120, 20), new Vector2(-50, -70))
             );
         this.pbDeltaDisplay.SetActive(false);
     }
     else
     {
         Modding.Logger.LogError(
             "[HKTimer] Timer canvas is null, not creating trigger display"
             );
     }
 }
Exemplo n.º 15
0
        public void InitDisplay()
        {
            if (menu != null)
            {
                GameObject.DestroyImmediate(menu);
            }
            CanvasUtil.CreateFonts();
            menu           = CanvasUtil.CreateCanvas(UnityEngine.RenderMode.ScreenSpaceOverlay, 100);
            this.showTimer = new UIOption <ToggleOption>(
                CanvasUtil.CreateTextPanel(
                    menu, "Show Timer", 30, TextAnchor.MiddleLeft,
                    new CanvasUtil.RectData(new Vector2(300, 60), new Vector2(-150, 180), MIDDLE, MIDDLE)
                    ),
                CanvasUtil.CreateTextPanel(
                    menu, "", 30, TextAnchor.MiddleRight,
                    new CanvasUtil.RectData(new Vector2(300, 60), new Vector2(150, 180), MIDDLE, MIDDLE)
                    ),
                new Vector2(-330, 180),
                ToggleOption.values,
                (v) => this.timer.ShowDisplay(v.enabled),
                1
                );
            this.resetPb = new UIButton(
                CanvasUtil.CreateTextPanel(
                    menu, "Reset PB", 30, TextAnchor.MiddleCenter,
                    new CanvasUtil.RectData(new Vector2(360, 60), new Vector2(0, 120), MIDDLE, MIDDLE)
                    ),
                new Vector2(-210, 120),
                () => {
                if (this.tm != null)
                {
                    this.tm.ResetPB();
                    this.tm.ShowAlert("Reset PB");
                }
            }
                );

            this.triggerType = new UIOption <TriggerTypeOption>(
                CanvasUtil.CreateTextPanel(
                    menu, "Trigger Type", 30, TextAnchor.MiddleLeft,
                    new CanvasUtil.RectData(new Vector2(300, 60), new Vector2(-150, 0), MIDDLE, MIDDLE)
                    ),
                CanvasUtil.CreateTextPanel(
                    menu, "", 30, TextAnchor.MiddleRight,
                    new CanvasUtil.RectData(new Vector2(300, 60), new Vector2(150, 0), MIDDLE, MIDDLE)
                    ),
                new Vector2(-330, 0),
                TriggerTypeOption.values,
                (e) => this.tm.triggerPlaceType = e.variant
                );
            this.saveTriggers = new UIButton(
                CanvasUtil.CreateTextPanel(
                    menu, "Save Triggers", 30, TextAnchor.MiddleCenter,
                    new CanvasUtil.RectData(new Vector2(360, 60), new Vector2(0, -60), MIDDLE, MIDDLE)
                    ),
                new Vector2(-210, -60),
                () => {
                if (this.tm != null)
                {
                    this.tm.SaveTriggers();
                    this.tm.ShowAlert("Saved Triggers");
                }
            }
                );
            this.loadTriggers = new UIButton(
                CanvasUtil.CreateTextPanel(
                    menu, "Load Triggers", 30, TextAnchor.MiddleCenter,
                    new CanvasUtil.RectData(new Vector2(360, 60), new Vector2(0, -120), MIDDLE, MIDDLE)
                    ),
                new Vector2(-210, -120),
                () => {
                if (this.tm != null)
                {
                    this.tm.LoadTriggers();
                    this.tm.ShowAlert("Loaded Triggers");
                }
            }
                );

            this.reloadSettings = new UIButton(
                CanvasUtil.CreateTextPanel(
                    menu, "Reload Settings", 30, TextAnchor.MiddleCenter,
                    new CanvasUtil.RectData(new Vector2(360, 60), new Vector2(0, -240), MIDDLE, MIDDLE)
                    ),
                new Vector2(-210, -240),
                () => {
                if (this.hktimer != null)
                {
                    this.hktimer.ReloadSettings();
                    if (this.tm != null)
                    {
                        this.tm.ShowAlert("Reloaded Settings");
                    }
                }
            }
                );

            this.cursorDisplay = CanvasUtil.CreateTextPanel(
                menu, ">", 50, TextAnchor.MiddleCenter,
                new CanvasUtil.RectData(new Vector2(60, 60), new Vector2(0, 0), MIDDLE, MIDDLE)
                );

            this.elements = new UIElement[] {
                this.showTimer,
                this.resetPb,
                this.triggerType,
                this.saveTriggers,
                this.loadTriggers,
                this.reloadSettings
            };
            this.SetShown(false);
            this.uiOpen = false;
            GameObject.DontDestroyOnLoad(this.menu);
        }
Exemplo n.º 16
0
        public IEnumerator UI_Initializer()
        {
            while (HeroController.instance == null || PlayerData.instance == null)
            {
                yield return(null);
            }


            try
            {
                CanvasUtil.CreateFonts();

                canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));

                canvasGroup = canvas.GetComponent <CanvasGroup>();
                canvas.GetComponent <Canvas>().sortingOrder = 1;

                grenadeAmountText       = CanvasUtil.CreateTextPanel(canvas, "", 21, TextAnchor.MiddleLeft, new CanvasUtil.RectData(new Vector2(600, 50), new Vector2(-200, 898), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), true).GetComponent <Text>();
                grenadeAmountText.color = new Color(1f, 1f, 1f, 0f);
                grenadeAmountText.text  = "";

                firesupportAmountText       = CanvasUtil.CreateTextPanel(canvas, "", 21, TextAnchor.MiddleLeft, new CanvasUtil.RectData(new Vector2(600, 50), new Vector2(-200, 877), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), true).GetComponent <Text>();
                firesupportAmountText.color = new Color(1f, 1f, 1f, 0f);
                firesupportAmountText.text  = "";

                /*
                 * LoadAssets.spriteDictionary.TryGetValue("heatbarsprite.png", out Texture2D bar);
                 *
                 * Sprite spriteMain = Sprite.Create(bar, new Rect(0, 0, bar.width, bar.height),
                 * new Vector2(0.5f, 0.5f), 25);
                 *
                 * LoadAssets.spriteDictionary.TryGetValue("heatbarspriteestimate.png", out Texture2D barEstimate);
                 *
                 * Sprite spriteEstimate = Sprite.Create(barEstimate, new Rect(0, 0, bar.width, bar.height),
                 * new Vector2(0.5f, 0.5f), 25);
                 *
                 * LoadAssets.spriteDictionary.TryGetValue("heatbarborder.png", out Texture2D barBorder);
                 *
                 * Sprite spriteBorder = Sprite.Create(barBorder, new Rect(0, 0, barBorder.width, barBorder.height),
                 * new Vector2(0.5f, 0.5f), 25);
                 */
                //HEAT BAR

                /*
                 * CanvasUtil.RectData rectDataBorder = new CanvasUtil.RectData(new Vector2(275, 30), new Vector2(0, 0), new Vector2(0.12f, 0.70f), new Vector2(0.12f, 0.70f), new Vector2(0.50f, 0.50f));
                 * heatbar_go_border = CanvasUtil.CreateImagePanel(canvas, spriteBorder, rectDataBorder);
                 *
                 * CanvasUtil.RectData rectData = new CanvasUtil.RectData(new Vector2(175, 25), new Vector2(0, 0), new Vector2(0.12f, 0.70f), new Vector2(0.12f, 0.70f), new Vector2(0.50f, 0.50f));
                 *
                 * heatbar_go = CanvasUtil.CreateImagePanel(canvas, spriteMain, rectData);
                 * heatbar_go.transform.position = new Vector3(heatbar_go.transform.position.x, heatbar_go.transform.position.y, 0);
                 * heatbar_go_estimate = CanvasUtil.CreateImagePanel(canvas, spriteEstimate, rectData);
                 * heatbar_go_estimate.transform.position = new Vector3(heatbar_go.transform.position.x, heatbar_go.transform.position.y, 1);
                 *
                 * heatbarImage = heatbar_go.GetComponent<Image>();
                 * heatbarImage.type = Image.Type.Filled;
                 * heatbarImage.fillMethod = Image.FillMethod.Horizontal;
                 * heatbarImage.preserveAspect = false;
                 *
                 * heatbarImageEstimate = heatbar_go_estimate.GetComponent<Image>();
                 * heatbarImageEstimate.type = Image.Type.Filled;
                 * heatbarImageEstimate.fillMethod = Image.FillMethod.Horizontal;
                 * heatbarImageEstimate.preserveAspect = false;
                 */


                //ENERGY BAR

                /*
                 * LoadAssets.spriteDictionary.TryGetValue("heatbarsprite.png", out Texture2D energybar);
                 *
                 * spriteMain = Sprite.Create(energybar, new Rect(0, 0, bar.width, bar.height),
                 * new Vector2(0.5f, 0.5f), 25);
                 *
                 * rectDataBorder = new CanvasUtil.RectData(new Vector2(275, 30), new Vector2(0, 0), new Vector2(0.12f, 0.67f), new Vector2(0.12f, 0.67f), new Vector2(0.50f, 0.50f));
                 * energybar_go_border = CanvasUtil.CreateImagePanel(canvas, spriteBorder, rectDataBorder);
                 *
                 * rectData = new CanvasUtil.RectData(new Vector2(175, 25), new Vector2(0, 0), new Vector2(0.12f, 0.67f), new Vector2(0.12f, 0.67f), new Vector2(0.50f, 0.50f));
                 *
                 * energybar_go = CanvasUtil.CreateImagePanel(canvas, spriteMain, rectData);
                 * energybar_go.transform.position = new Vector3(energybar_go.transform.position.x, energybar_go.transform.position.y, 0);
                 *
                 * energybarImage = energybar_go.GetComponent<Image>();
                 * energybarImage.type = Image.Type.Filled;
                 * energybarImage.fillMethod = Image.FillMethod.Horizontal;
                 * energybarImage.preserveAspect = false;
                 */

                //HP_DamageNumber.damageNumberGO = new GameObject("damageNumberClone", typeof(HP_DamageNumber), typeof(TextMesh), typeof(MeshRenderer));
                DontDestroyOnLoad(canvas);
                DontDestroyOnLoad(canvasGroup);
            }
            catch (Exception e)
            {
                Modding.Logger.Log(e.StackTrace);
            }
        }
Exemplo n.º 17
0
        private void Start()
        {
            if (!DoH.Instance.IsInHall)
            {
                return;
            }
            CanvasUtil.CreateFonts();
            canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1536f, 864f));
            UnityEngine.Object.DontDestroyOnLoad(canvas);
            textExample       = CanvasUtil.CreateTextPanel(canvas, "", 35, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(700, 100), new Vector2(-0, 50), new Vector2(0.5f, 0), new Vector2(0.5f, 0), new Vector2(0.5f, 0.5f)), true).GetComponent <Text>();
            textExample.color = new Color(1f, 1f, 1f, 1f);
            textExample.font  = CanvasUtil.GetFont("Perpetua");
            timeLeft          = 2f;

            // No stunning
            Destroy(_stunControl);

            // 1500hp
            _hm.hp = 1800;

            // Disable Knockback
            _recoil.enabled = false;

            // Speed up some attacks.
            try
            {
                foreach (KeyValuePair <string, float> i in _fpsDict)
                {
                    _anim.GetClipByName(i.Key).fps = i.Value;
                }

                Log("attempt at music was made");
                //_sceneFSM.ChangeTransition("Statue Level", "1", "Boss Statue Alt");
                Log("attempt at music was made2");
                //_sceneFSM.RemoveAction("Boss Statue Alt", 0);
            }
            catch (System.Exception e)
            {
                Log(e);
            }

            // Stop pointless standing in place
            _control.GetAction <WaitRandom>("Idle", 9).timeMax = 0f;
            _control.GetAction <WaitRandom>("Idle", 9).timeMin = 0f;

            // Stop pointless running
            _control.GetAction <WaitRandom>("Run", 6).timeMax = 0f;
            _control.GetAction <WaitRandom>("Run", 6).timeMin = 0f;

            //Make Hornet hold her sphere for 5 seconds
            go1 = _control.GetAction <ActivateGameObject>("Sphere Recover A", 1).gameObject.GameObject.Value;
            go2 = _control.GetAction <ActivateGameObject>("Sphere Recover", 1).gameObject.GameObject.Value;
            IEnumerator ActivateSphereA()
            {
                _control.ChangeTransition("In Air", "AIRDASH", "Land");
                if (firstPhase)
                {
                    Log("Hornet: Activate Air turbo sphere mode, DIE little Ghost.");
                    go1.SetActive(true);
                    _control.ChangeTransition("Move Choice A", "AIRDASH", "GDash Antic");
                    _control.ChangeTransition("Move Choice B", "AIRDASH", "CA Antic");
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "GDash Antic");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "CA Antic");
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");
                    yield return(new WaitForSeconds(3f));

                    go1.SetActive(false);
                    _control.ChangeTransition("Move Choice A", "AIRDASH", "Set ADash");
                    _control.ChangeTransition("Move Choice B", "AIRDASH", "Set ADash");
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "Set Sphere A");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "Set Sphere A");
                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");
                }
                else if (secondPhase)
                {
                    //This might cause problems in the future
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "Set ADash");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "Set ADash");
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");
                    go1.SetActive(false);
                    yield return(new WaitForSeconds(1f));

                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "Set Sphere A");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "Set Sphere A");
                }
                else if (finalPhase)
                {
                    //This might cause problems in the future
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "Set ADash");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "Set ADash");
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");
                    _control.GetAction <WaitRandom>("Idle", 7).timeMax = 1.2f;
                    _control.GetAction <WaitRandom>("Idle", 7).timeMin = 1.2f;
                    go1.SetActive(false);
                    yield return(new WaitForSeconds(1.2f));

                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "Set Sphere A");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "Set Sphere A");
                    _control.GetAction <WaitRandom>("Idle", 7).timeMax = 0.2f;
                    _control.GetAction <WaitRandom>("Idle", 7).timeMin = 0.2f;
                }
                _control.ChangeTransition("In Air", "AIRDASH", "ADash Antic");
                yield return(new WaitForSeconds(1f));

                canSphere = false;
            }

            IEnumerator ActivateSphereG()
            {
                if (firstPhase)
                {
                    Log("Hornet: Activate Ground turbo sphere mode, DIE little Ghost.");
                    go2.SetActive(true);
                    _control.ChangeTransition("G Sphere?", "SPHERE G", "Move Choice B");
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");

                    _control.ChangeTransition("Move Choice A", "AIRDASH", "GDash Antic");
                    _control.ChangeTransition("Move Choice B", "AIRDASH", "CA Antic");
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "GDash Antic");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "CA Antic");
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");
                    yield return(new WaitForSeconds(3f));

                    go2.SetActive(false);
                    _control.ChangeTransition("G Sphere?", "SPHERE G", "Sphere Antic G");
                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");

                    _control.ChangeTransition("Move Choice A", "AIRDASH", "Set ADash");
                    _control.ChangeTransition("Move Choice B", "AIRDASH", "Set ADash");
                    _control.ChangeTransition("Move Choice A", "SPHERE A", "Set Sphere A");
                    _control.ChangeTransition("Move Choice B", "SPHERE A", "Set Sphere A");
                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");
                }
                else if (secondPhase)
                {
                    //This might cause problems in the future
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");
                    _control.ChangeTransition("G Sphere?", "SPHERE G", "Move Choice B");
                    go2.SetActive(false);
                    yield return(new WaitForSeconds(1f));

                    _control.ChangeTransition("G Sphere?", "SPHERE G", "Sphere Antic G");
                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");
                }
                else if (finalPhase)
                {
                    //This might cause problems in the future
                    _control.ChangeTransition("Move Choice A", "THROW", "GDash Antic");
                    _control.ChangeTransition("G Sphere?", "SPHERE G", "Move Choice B");
                    go2.SetActive(false);
                    _control.GetAction <WaitRandom>("Idle", 7).timeMax = 1.2f;
                    _control.GetAction <WaitRandom>("Idle", 7).timeMin = 1.2f;

                    yield return(new WaitForSeconds(1.2f));

                    _control.GetAction <WaitRandom>("Idle", 7).timeMax = 0.2f;
                    _control.GetAction <WaitRandom>("Idle", 7).timeMin = 0.2f;
                    _control.ChangeTransition("G Sphere?", "SPHERE G", "Sphere Antic G");
                    _control.ChangeTransition("Move Choice A", "THROW", "Throw Antic");
                }
            }

            _control.CopyState("Sphere Recover", "Sphere Recover Old");
            _control.CopyState("Sphere Recover A", "Sphere Recover A Old");
            _control.RemoveAction("Sphere Recover A", 1);
            _control.RemoveAction("Sphere Recover", 1);
            _control.InsertCoroutine("Sphere Recover A", 1, ActivateSphereA);
            _control.InsertCoroutine("Sphere Recover", 1, ActivateSphereG);

            //Make Hornet Dash after needle throw
            var removeNeedle = _control.GetAction <ActivateGameObject>("Throw Recover", 0);

            try
            {
                Log("is throw working?");
                _control.GetAction <SetVelocityAsAngle>("Throw", 7).speed = 30f;
            }
            catch (System.Exception e)
            {
                Log(e);
            }
            // _control.InsertAction("Throw Antic", removeNeedle, 0);
            removeNeedle.gameObject.GameObject.Value.LocateMyFSM("Control").ChangeTransition("Out", "FINISHED", "Notify");
            _control.CopyState("Jump", "Jump2");
            _control.CopyState("ADash Antic", "ADash Antic 2");
            _control.GetAction <GetAngleToTarget2D>("ADash Antic 2", 1).offsetY.Value += 3f;
            _control.ChangeTransition("Throw", "FINISHED", "Jump2");
            _control.ChangeTransition("Jump2", "FINISHED", "ADash Antic 2");

            //Make a better G Dash for attacking you while you heal
            var lookAtKnight = _control.GetAction <FaceObject>("GDash Antic", 2);

            _control.CopyState("G Dash", "G Dash 2");
            _control.InsertAction("G Dash 2", new FaceObject
            {
                objectA          = lookAtKnight.objectA,
                objectB          = lookAtKnight.objectB,
                spriteFacesRight = lookAtKnight.spriteFacesRight,
                playNewAnimation = lookAtKnight.playNewAnimation,
                newAnimationClip = lookAtKnight.newAnimationClip,
                resetFrame       = lookAtKnight.resetFrame,
                everyFrame       = lookAtKnight.everyFrame
            }, 0);
            _control.ChangeTransition("G Dash 2", "FINISHED", "CA Antic");

            Log("Remove Evade when hit because it's dumb and also makes it so when hit hornet has a higher chance of either attacking or jumping");
            _control.GetAction <SendRandomEvent>("Dmg Response", 0).weights[0] = 0f;
            _control.GetAction <SendRandomEvent>("Dmg Response", 0).weights[1] = 0f;
            _control.GetAction <SendRandomEvent>("Dmg Response", 0).weights[2] = 0.5f;
            _control.GetAction <SendRandomEvent>("Dmg Response", 0).weights[3] = 0.5f;
            _control.ChangeTransition("Dmg Response", "JUMP", "Jump Antic");
            _control.ChangeTransition("Dmg Response", "Counter", "CA Antic");
            _control.RemoveAction("Set Jump Only", 1);
            _control.RemoveAction("Set Jump Only", 0);


            Log("Skip waiting for player to hit her counter and never do the dumb evade move");
            _control.GetAction <Wait>("Counter Stance", 1).time = 0f;
            _control.ChangeTransition("Counter Stance", "FINISHED", "CA Antic");

            Log("Choose Counter over Evade");
            _control.GetAction <SendRandomEvent>("Ev Or Counter", 0).weights[0] = 0f;
            _control.GetAction <SendRandomEvent>("Ev Or Counter", 0).weights[1] = 1f;

            Log("Choose GDash over Evade");
            _control.ChangeTransition("Run", "EVADE", "GDash Antic");

            //Removing useless barbs
            _control.RemoveAction("Barb?", 0);
            _control.ChangeTransition("Barb?", "BARB", "Barb Throw");
            _control.ChangeTransition("Barb Throw", "FINISHED", "Can Throw?");
            _control.GetAction <Wait>("Barb Throw", 2).time = 0.4f;

            //Stops the dumb freeze effect when the counter occurs
            _control.RemoveAction("CA Antic", 1);

            _control.GetAction <Wait>("Sphere", 4).time   = 0.3f;
            _control.GetAction <Wait>("Sphere A", 4).time = 0.3f;

            for (int i = 0; i < needles.Length; i++)
            {
                needles[i] = Instantiate(_control.GetAction <SetPosition>("Throw", 4).gameObject.GameObject.Value);
                Destroy(needles[i].LocateMyFSM("Control"));
                needles[i].AddComponent <TinkEffect>();
                UnityEngine.Object.Destroy(needles[i].GetComponent <NonBouncer>());
                var tink = UnityEngine.Object.Instantiate(GameObject.Find("Needle Tink")).AddComponent <ModCommon.NeedleTink>();
                tink.SetParent(needles[i].transform);
                needles[i].transform.SetPosition2D(gameObject.transform.GetPositionX(), gameObject.transform.GetPositionY());
                needles[i].GetComponent <Rigidbody2D>().velocity = new Vector2(-15f, i * 5f);
                needles[i].SetActive(false);
            }

            _control.InsertCoroutine("Throw", 0, needleSpread);

            Log("fin.");
            try
            {
                var ball = _control.GetAction <ActivateGameObject>("Sphere A", 0).gameObject.GameObject.Value;
                Log("2");
                var ballfsm = ball.LocateMyFSM("Grow");
                Log("3");
                ballfsm.RemoveAction("Grow", 0);
            }
            catch (System.Exception e)
            {
                Log(e);
            }

            _control.InsertMethod("Fire", 0, AirDashCounter);
            //_control.InsertMethod("Land Y", 0, ResetADash);
            _control.InsertMethod("In Air", 0, InAirChecker); //Had to increase num by 1
            _control.ChangeTransition("Jump R", "FINISHED", "Land");
            _control.ChangeTransition("Jump L", "FINISHED", "Land");
        }