예제 #1
0
    public void PreGame()
    {
        keybindingManager = new KeybindingManager();
        keybindingManager.InitDefualtKeybinds();


        // 127.0.0.1
        Console.WriteLine("play on network? y for yes, n for no");

        if (Console.ReadLine() == "y")
        {
            Console.WriteLine("h for host, c for client");
            bool isHost = Console.ReadLine() == "h";
            network = new Network(isHost);

            if (isHost)
            {
                network.WaitForConnection();
            }
            else
            {
                Console.WriteLine("input ip to connect to");
                network.Connect(Console.ReadLine());
            }
        }
    }
예제 #2
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            foreach (var keybinding in IndexedKeybindings)
            {
                if (info.IsKeyPressed(keybinding.Key))
                {
                    var itemPreviewWindow = UserInterfaceManager.Get <ItemPreviewWindow>();
                    itemPreviewWindow.
                    SetObjectForPreview(InventoryManager.GetSlot <ISlot>(Game.GameSession.Player.Inventory, keybinding.ObjectId).Item.FirstOrDefault().ObjectId);
                    return(true);
                }
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
                return(true);
            }

            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.E)) // REWORK
            {
                Equip();
            }

            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.U))
            {
                Enchant.EnchantSteel(Game.GameSession.Player.Inventory.CurrentWeapon);
            }

            return(false);
        }
예제 #3
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            if (UserInterfaceManager.Get <CharacterKeybindingsWindow>().IndexedKeybindings != null) // IndexedKeybindings is created after this window becomes visible
            {
                foreach (var keybinding in UserInterfaceManager.Get <CharacterKeybindingsWindow>().IndexedKeybindings)
                {
                    if (info.IsKeyPressed(keybinding.Key))
                    {
                        var itemPreviewWindow = UserInterfaceManager.Get <ItemPreviewWindow>();
                        itemPreviewWindow.
                        SetObjectForPreview(keybinding.ObjectId);
                        return(true);
                    }
                }
            }

            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.A))
            {
                Game.GameSession.Player.Experience += 1;
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
            }

            return(false);
        }
예제 #4
0
 public void Start()
 {
     PUI          = GameObject.Find("Player").GetComponent <PlayerUI>();
     Canvas       = Number.transform.parent.gameObject;
     WeaponCanvas = GameObject.Find("WeaponUI");
     ShootPoint   = GameObject.Find("ShootPoint");
     Key          = GameObject.Find("InputManager").GetComponent <KeybindingManager>();
 }
예제 #5
0
        public void Draw()
        {
            Clear();

            Keybindings = KeybindingManager.GetCategoryKeybindings <IKeybinding>(Keybinding.Category.General);
            KeybindingManager.UpdateKeybindings();

            RefractoredDrawKeybindings();
        }
예제 #6
0
    public void Start()
    {
        W  = GameObject.Find("Wheel").GetComponent <Wheel>();
        P  = GameObject.Find("Player").GetComponent <Player>();
        En = GameObject.Find("Engine").GetComponent <Engine>();
        KM = GameObject.Find("InputManager").GetComponent <KeybindingManager>();

        CurHealth = SS.ShipMaxHealth;
    }
예제 #7
0
    public int Update(World world, Network net, KeybindingManager keybindingManager, bool allowSelect)
    {
        Move?move = keybindingManager.GetMove();

        while (move != null)
        {
            switch (move)
            {
            case Move.Right:
                if (HoveredTile % world.WorldWidth < world.WorldWidth - 1)
                {
                    HoveredTile++;
                }
                break;

            case Move.Left:
                if (HoveredTile % world.WorldWidth > 0)
                {
                    HoveredTile--;
                }
                break;

            case Move.Up:
                if (HoveredTile / world.WorldWidth > 0)
                {
                    HoveredTile -= world.WorldWidth;
                }
                break;

            case Move.Down:
                if (HoveredTile / world.WorldWidth < world.WorldWidth - 1)
                {
                    HoveredTile += world.WorldWidth;
                }
                break;

            case Move.Select:
                if (allowSelect)
                {
                    int endState = world.MakeMove(HoveredTile);
                    if (net != null && endState != -1)
                    {
                        net.SendMove(HoveredTile);
                    }
                    return(endState);
                }
                break;

            default:
                break;
            }

            move = keybindingManager.GetMove();
        }

        return(0);
    }
예제 #8
0
 public string KeyToString()
 {
     if (IsNumeric)
     {
         return(KeybindingManager.GetKeyNameNumeric(Key));
     }
     else
     {
         return(Key.ToString());
     }
 }
예제 #9
0
        public GeneralKeybindingsWindow(int width, int height) : base(width, height)
        {
            Position = new Point(Constants.Windows.GeneralKeybindingsX, Constants.Windows.GeneralKeybindingsY);

            KeybindingManager.Initialize();

            Initialize();

            RefractoredDrawKeybindings();

            this.Parent = UserInterfaceManager.Get <KeybindingsWindow>();
        }
예제 #10
0
        /// <summary>
        /// Initialises necessary objects for game start.
        /// Most notably initialises the game state machine
        /// </summary>
        protected override void Initialize()
        {
            this.IsMouseVisible = true;

            globalBindings = new KeybindingManager();
            //Bind the fullscreen toggle to the global bindings
            globalBindings.BindKeyEvent(Keys.F11, InputState.down, ToggleFullScreen);
            //Bind the escape button to the Exit action
            globalBindings.BindKeyEvent(Keys.Escape, InputState.down, Exit);

            GameData.Initialise();

            eventManager = new GameEventManager();
            GameEventManager.Instance = eventManager;

            camera            = new Camera(graphics.GraphicsDevice.Viewport);
            camera.Position   = new Vector2(0, 0);
            Camera.mainCamera = camera;

            //Default background
            defaultBackgroundTex = Content.Load <Texture2D>("PlatformerGraphicsDeluxe/Backgrounds/bg");
            background           = new Graphics.Background(defaultBackgroundTex, Vector2.One, Color.White);

            GameStateMachine = new FSM();
            //NOTE spaces don't seem to scale correctly, so tabs are used.
            TextScreen startScreenState = new StartScreen(this, "Explorer", "Press    enter    to    continue", Keys.Enter);

            startScreenState.Name = "Start";

            PlayGame playGameState = new PlayGame(this);

            TextScreen loseScreenState = new EndScreen(this, "YOU    LOSE", "Press    enter    to    continue", Keys.Enter);

            loseScreenState.Name = "Lose";

            TextScreen winScreenState = new EndScreen(this, "YOU    WIN", "Press    enter    to    continue", Keys.Enter);

            winScreenState.Name = "Win";

            startScreenState.AddTransition(playGameState, () => { return(startScreenState.done); });
            loseScreenState.AddTransition(startScreenState, () => { return(loseScreenState.done); });
            winScreenState.AddTransition(startScreenState, () => { return(winScreenState.done); });
            playGameState.AddTransition(loseScreenState, () => { return(playGameState.GameLost); });
            playGameState.AddTransition(winScreenState, () => { return(playGameState.GameWon); });

            GameStateMachine.AddStates(startScreenState, playGameState, loseScreenState, winScreenState);

            base.Initialize();
        }
예제 #11
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            if (info.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.H))
            {
                ChopWood();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
            }

            return(false);
        }
예제 #12
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            foreach (var keybinding in IndexedKeybindings)
            {
                if (info.IsKeyPressed(keybinding.Key))
                {
                    var player = EntityManager.Get <IEntity>(Game.GameSession.Player.ObjectId); // Todo: make gamesession player less accessible
                    EntityManager.TravelEntityToArea((Player)player, keybinding.ObjectId);
                    return(true);
                }
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Back)))
            {
                this.FullTransition(UserInterfaceManager.Get <GameWindow>());
            }

            return(false);
        }
예제 #13
0
    public void Start()
    {
        LoadPrefs();
        Key      = GameObject.Find("InputManager").GetComponent <KeybindingManager>();
        movement = GetComponent <PlayerMovement>();
        PUI      = GetComponent <PlayerUI>();
        cam      = GameObject.Find("Main Camera");
        ML       = cam.GetComponent <MouseLook>();

        if (Reset)
        {
            ResetPos();
        }

        PUI.HealthSlider.maxValue  = settings.MaxHealth;
        PUI.HealthSlider.value     = _health;
        PUI.StaminaSlider.maxValue = settings.MaxStamina;
        PUI.StaminaSlider.value    = _stamina;
        transform.position         = new Vector3(XPos, YPos, ZPos);
    }
예제 #14
0
        public override bool ProcessKeyboard(Keyboard info)
        {
            // TODO: SOMETIMES THROWS NULL REFERENCE
            if (UserInterfaceManager.Get <LocationKeybindingsWindow>().IndexedKeybindings != null)
            {
                foreach (var keybinding in UserInterfaceManager.Get <LocationKeybindingsWindow>().IndexedKeybindings)
                {
                    if (info.IsKeyPressed(keybinding.Key))
                    {
                        EntityManager.TravelEntityToLocation(Game.GameSession.Player, keybinding.ObjectId);
                        return(true);
                    }
                }
            }


            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Character)))
            {
                OpenCharacterWindow();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Inventory)))
            {
                OpenInventoryWindow();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Travel)))
            {
                OpenTravelWindow();
                return(true);
            }

            if (info.IsKeyPressed(KeybindingManager.GetKeybinding <IKeybinding>(Keybinding.Keybindings.Chop)))
            {
                OpenChoppingWindow();
            }

            return(false);
        }
예제 #15
0
 public void Start()
 {
     Player = GameObject.Find("Player");
     key    = GameObject.Find("InputManager").GetComponent <KeybindingManager>();
 }
예제 #16
0
 private void UpdateKeybindingVisibility()
 {
     KeybindingManager.UpdateVisibility(Keybindings.Chop, WorldObjectManager.ContainsWorldObject(Game.GameSession.Player.CurrentLocation,
                                                                                                 GameObjects.WorldObjectBase.Objects.Tree) && this.IsFocused);
 }
예제 #17
0
 public void Start()
 {
     key = GameObject.Find("InputManager").GetComponent <KeybindingManager>();
     en  = GameObject.Find("Engine").GetComponent <Engine>();
 }
 public virtual void InitKeybindings()
 {
     keybindingManager = new KeybindingManager();
 }
예제 #19
0
 public void Initialize()
 {
     Keybindings = KeybindingManager.GetCategoryKeybindings <IKeybinding>(Keybinding.Category.General);
 }