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);
                }
            }
        }
        public static void AddItem(string item, string location)
        {
            if (canvas == null)
            {
                Create();
            }

            item = RandomizerMod.Instance.Settings.GetEffectiveItem(item);

            string itemName = Language.Language.Get(LogicManager.GetItemDef(item).nameKey, "UI");
            string areaName = LogicManager.ShopNames.Contains(location)
                ? location.Replace('_', ' ')
                : RandoLogger.CleanAreaName(LogicManager.GetItemDef(location).areaName);

            string msg = itemName + "\nfrom " + areaName;

            GameObject basePanel = CanvasUtil.CreateBasePanel(canvas,
                                                              new CanvasUtil.RectData(new Vector2(200, 50), Vector2.zero,
                                                                                      new Vector2(0.9f, 0.9f), new Vector2(0.9f, 0.9f)));

            string spriteKey = LogicManager.GetItemDef(item).shopSpriteKey;

            CanvasUtil.CreateImagePanel(basePanel, RandomizerMod.GetSprite(spriteKey),
                                        new CanvasUtil.RectData(new Vector2(50, 50), Vector2.zero, new Vector2(0f, 0.5f),
                                                                new Vector2(0f, 0.5f)));
            CanvasUtil.CreateTextPanel(basePanel, msg, 24, TextAnchor.MiddleLeft,
                                       new CanvasUtil.RectData(new Vector2(400, 100), Vector2.zero,
                                                               new Vector2(1.2f, 0.5f), new Vector2(1.2f, 0.5f)),
                                       CanvasUtil.GetFont("Perpetua"));

            items.Enqueue(basePanel);
            if (items.Count > MaxItems)
            {
                Object.Destroy(items.Dequeue());
            }

            UpdatePositions();
        }
예제 #3
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");
        }