コード例 #1
0
        /// <summary>
        /// Called before GameContext.Start()
        /// </summary>
        static void Load()
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            BaseObjects.Populate();
            SRCallbacks.OnLoad();
            PrefabUtils.ProcessReplacements();
            KeyBindManager.ReadBinds();
            GameContext.Instance.gameObject.AddComponent <ModManager>();
            GameContext.Instance.gameObject.AddComponent <KeyBindManager.ProcessAllBindings>();
            try
            {
                SRModLoader.LoadMods();
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                ErrorGUI.CreateError($"{e.GetType().Name}: {e.Message}");
                return;
            }
            PostLoad();
        }
コード例 #2
0
        public override bool Execute(string[] args)
        {
            if ((args?.Length ?? 0) == 0)
            {
                Console.LogError("Please supply a key!");
                return(false);
            }
            Key key;

            try
            {
                key = (Key)Enum.Parse(typeof(Key), args[0], true);
            }
            catch
            {
                Console.LogError("Please supply valid key!");
                return(false);
            }


            KeyBindManager.RemoveBinding(key);
            KeyBindManager.SaveBinds();

            return(true);
        }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: ReesMorris/from-zero
    void Start()
    {
        // Set the default settings
        settingsMenu.SetActive(true);
        SettingsMenus(true);

        Cursor.visible = true;
        Time.timeScale = 1f;         // if coming from pause screen
        lm             = GetComponent <LanguageManager>();
        kbm            = GetComponent <KeyBindManager>();
        editionManager = GetComponent <EditionManager>();

        bottomBar.SetActive(false);
        episodes.SetActive(false);
        confirmation.SetActive(false);
        confirmation2.SetActive(false);

        lm.languageChanged += UpdatePlayButton;

        SetEdition();
        SetResolution();
        ManageButtons();

        // If coming from a game scene
        if (PlayerPrefs.GetInt("showSettings") == 1)
        {
            Settings();
        }
    }
コード例 #4
0
 // Update is called once per frame
 void Update()
 {
     MFText.text     = KeyBindManager.GetMoveForward();
     MBText.text     = KeyBindManager.GetMoveBackward();
     MLText.text     = KeyBindManager.GetMoveLeft();
     MRText.text     = KeyBindManager.GetMoveRight();
     JumpText.text   = KeyBindManager.GetJump();
     SprintText.text = KeyBindManager.GetSprint();
 }
コード例 #5
0
    public void Start()
    {
        backStack = new Stack();
        kbm       = GameObject.FindObjectOfType <KeyBindManager>();
        uiSource  = GameObject.FindObjectOfType <UISoundInitializer>();

        Color col = maskingPanel.GetComponent <Image>().color;

        foreach (GameObject g in UIParents)
        {
            Animator anim = g.GetComponent <Animator>();
            anim.SetTrigger("BecomeNext");
        }
        UIParents[0].GetComponent <Animator>().SetTrigger("BecomeCurrFromNext"); // Make sure MainMenuObject is index 0
        curr = UIParents[0];
    }
コード例 #6
0
    void Start()
    {
        GameObject scene = GameObject.Find("Main Menu");

        if (scene != null)
        {
            // Main menu
            keyBindManager = GameObject.Find("Main Menu").GetComponent <KeyBindManager>();
        }
        else
        {
            // In game
            keyBindManager = GameObject.Find("GameManager").GetComponent <KeyBindManager>();
        }

        displayText.text = keyBindManager.GetDefaultKey(inputKey);

        GetComponent <Button>().onClick.AddListener(OnClick);
    }
コード例 #7
0
ファイル: BindCommand.cs プロジェクト: veesusmikelheir/SRML
        public override bool Execute(string[] args)
        {
            if (args.Length != 2)
            {
                Console.LogError("Wrong number of arguments (try putting the command you're binding in quotes)!");
                return(false);
            }

            Key key;

            try
            {
                key = (Key)Enum.Parse(typeof(Key), args[0], true);
            }
            catch
            {
                Console.LogError("Invalid key!");
                return(false);
            }

            KeyBindManager.CreateBinding(args[1], key);
            KeyBindManager.SaveBinds();
            return(true);
        }
コード例 #8
0
        public override void draw(SpriteBatch batch)
        {
            batch.Draw(keyboardTexture, keyboardRect, Color.White * .7f);
            foreach (Rectangle keyRect in inputMap.Keys)
            {
                if (keyRect.Contains(mouseLoc))
                {
                    batch.Draw(Game1.block, keyRect, Color.White * .3f);
                }
            }

            KeyBindManager bindManager = Game1.keyBindManager;

            foreach (string str in bindManager.bindings.Keys)
            {
                if (reverseInputMap.ContainsKey(bindManager.bindings[str]) && reverseActionMap.ContainsKey(str))
                {
                    Rectangle inputRectangle  = reverseInputMap[bindManager.bindings[str]];
                    Rectangle actionRectangle = reverseActionMap[str];
                    if (inputRectangle.Contains(mouseLoc) || actionRectangle.Contains(mouseLoc))
                    {
                        Game1.DrawLine(batch, inputRectangle.Center.ToVector2(), actionRectangle.Center.ToVector2(), Color.RosyBrown);
                        batch.Draw(Game1.block, inputRectangle, Color.RosyBrown * .5f);
                        batch.Draw(Game1.block, actionRectangle, Color.RosyBrown * .5f);
                    }
                    batch.Draw(Game1.block, reverseInputMap[bindManager.bindings[str]], Color.White * .5f);
                }
            }


            if (runTex != null)
            {
                batch.Draw(runTex, new Rectangle(moveLeftIcon.X - runTex.Width / 2 + moveLeftIcon.Width / 2, moveLeftIcon.Y - runTex.Height / 2 + moveLeftIcon.Height / 2, runTex.Width, runTex.Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
                batch.Draw(runTex, new Rectangle(moveRightIcon.X - runTex.Width / 2 + moveRightIcon.Width / 2, moveRightIcon.Y - runTex.Height / 2 + moveRightIcon.Height / 2, runTex.Width, runTex.Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0);
            }

            if (jumpTex != null)
            {
                batch.Draw(jumpTex, new Rectangle(jumpIcon.X - jumpTex.Width / 2 + jumpIcon.Width / 2, jumpIcon.Y + jumpTexOffset - jumpTex.Height / 2 + jumpIcon.Height / 2, jumpTex.Width, jumpTex.Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0);
            }

            batch.Draw(Game1.backpackTex, viewInventoryIcon, Color.White);
            batch.Draw(Game1.UIInventory_BuildButton, buildIcon, Color.White);


            for (int i = 0; i < world.player.keyedItems.Length; i++)
            {
                batch.Draw(Game1.UIInventory_KeyedItem, keyedItemRects[i], Color.DarkGray);

                if (world.player.keyedItems[i] != null)
                {
                    Rectangle drawItemRect = new Rectangle(
                        keyedItemRects[i].X + 15,
                        keyedItemRects[i].Y + 15,
                        world.player.keyedItems[i].texture.Width,
                        world.player.keyedItems[i].texture.Height
                        );

                    batch.Draw(world.player.keyedItems[i].texture, drawItemRect, Color.White * .5f);
                }
            }

            if (world.player.cards[0] != null || world.player.cards[1] != null || reverseInputMap[Game1.keyBindManager.bindings["Ability_0"]].Contains(mouseLoc))
            {
                batch.Draw(Game1.abilityUIElement, cardRect0, Color.White);
            }
            if (world.player.cards[0] != null || world.player.cards[1] != null || reverseInputMap[Game1.keyBindManager.bindings["Ability_1"]].Contains(mouseLoc))
            {
                batch.Draw(Game1.abilityUIElement, cardRect1, null, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0);
            }


            batch.Draw(Game1.handTex, useRect, Color.White);

            if (world.player.cards[0] != null && world.player.cards[0].usable)
            {
                batch.Draw(world.player.cards[0].iconTex, new Rectangle(cardRect0.X + 42, cardRect0.Y + 5, world.player.cards[0].iconTex.Width, world.player.cards[0].iconTex.Height), Color.White);
            }

            if (world.player.cards[1] != null && world.player.cards[1].usable)
            {
                batch.Draw(world.player.cards[1].iconTex, new Rectangle(cardRect1.X + 42, cardRect1.Y + 5, world.player.cards[1].iconTex.Width, world.player.cards[1].iconTex.Height), Color.White);
            }

            if (drawLineToMouse)
            {
                batch.Draw(Game1.block, selectedRect, Color.RosyBrown * .7f);
                Game1.DrawLine(batch, mouseLoc.ToVector2(), selectedRect.Center.ToVector2(), Color.RosyBrown);
            }
        }