private static KeyBinds GetKeyBinds(PlayerIndex playerIndex) { KeyBinds output; switch (playerIndex) { case PlayerIndex.One: output = new KeyBinds(Keys.Q, Keys.E, Keys.W, Keys.S, Keys.A, Keys.D); break; case PlayerIndex.Two: output = new KeyBinds(Keys.R, Keys.Y, Keys.T, Keys.G, Keys.F, Keys.H); break; case PlayerIndex.Three: output = new KeyBinds(Keys.U, Keys.O, Keys.I, Keys.K, Keys.J, Keys.L); break; case PlayerIndex.Four: output = new KeyBinds(Keys.LeftControl, Keys.NumPad0, Keys.Up, Keys.Down, Keys.Left, Keys.Right); break; default: throw new ArgumentOutOfRangeException(nameof(playerIndex), playerIndex, null); } return(output); }
void Update() { if (chatInput.isFocused) { InputState.SetInput("chat", true); } else { InputState.SetInput("chat", false); if (!InputState.KeyInputActive() && Input.GetKeyDown(KeyBinds.Binding("Chat"))) { if (chatActive) { canvas.enabled = false; InputState.chatfocus = false; InputState.dragging = false; chatActive = false; } else { canvas.enabled = true; chatActive = true; } } } }
// void SelectBullet(int bulletNumber) determines what bullet gets shot out //public void ShootBulletButton(int bulletNumber) shoot bullet on based on fireRate //public void ShootBullet() // Start is called before the first frame update void Start() { donut = GameObject.Find("Donut"); characterS = donut.GetComponent <CharacterSwapping>(); keyB = donut.GetComponent <KeyBinds>(); playerSkillTree = donut.GetComponent <SkillTree>(); }
public Player(PlayerIndex playerIndex, InputMethod preferredInputMethod, CustomModel model, CustomModel[] axisModels) { _playerIndex = playerIndex; _preferredInputMethod = preferredInputMethod; keyBinds = GetKeyBinds(_playerIndex); customModel = model; rotationalAxisModels = axisModels; }
/// <summary> /// Associate a KeyBind with a KEy /// </summary> /// <param name="bind"></param> /// <param name="key"></param> public void Bind(KeyBinds bind, Keys key) { if (keyDict.ContainsKey(bind)) { keyDict.Remove(bind); } keyDict.Add(bind, key); }
void Awake() { dialogueOption = DialogueOption.Instance(); displayManager = DisplayManager.Instance(); keyBinds = GameObject.FindObjectOfType <KeyBinds>(); yesEvent = new UnityAction(TestAccept); noEvent = new UnityAction(TestDecline); }
// Use this for initialization void Start() { _EnableDynamicNavMeshGeneration = false; _EnableDeveloperLogs = EnableDeveloperLogs; _KeyBindsSettings = KeyBindsSettings; _GameSettings = GameSettings; _GameState = GameStates.Game; _ScriptHolder = gameObject; }
void Start() { //player = GameObject.Find("Player").GetComponent<PlayerController>(); //question = GameObject.Find("Question").GetComponent<Text>(); //acceptButton = GameObject.Find("Yes Button").GetComponent<Button>(); //declineButton = GameObject.Find("No Button").GetComponent<Button>(); //window = GameObject.FindGameObjectWithTag("DialogueText"); keyBinds = GameObject.FindObjectOfType <KeyBinds>(); textBoxManager = gameObject.GetComponent <TextBoxManager>(); }
public bool RemoveKeyBind(KBind kBind) { int index = KeyBinds.IndexOf(kBind); if (index < 0) { return(false); } return(RemoveListener(kBind, index)); }
private void Awake() { if (Instance != null) { Destroy(this); } else { Instance = this; } }
private void Update() { if (inSettings) { return; } if (Input.GetKeyDown(KeyBinds.GetKeyBind(KeyBinds.Action.Refresh))) { OnClickRefresh(); } if (Input.GetKeyDown(KeyBinds.GetKeyBind(KeyBinds.Action.Restart))) { OnClickRestart(); } if (!isSearchBarSelected) { if (Input.GetKeyDown(KeyBinds.GetKeyBind(KeyBinds.Action.StartGame)) && !startedGame) { OnClickStart(); } } /* timer logic*/ if (startedGame && timerAmountInSeconds != 0) { timer -= Time.deltaTime; if (timer <= 0) { timerCountdownText.text = "0.0"; /* stop the timer */ startedGame = false; DisableCardsInSlots(); } else { int seconds = (int)timer % 60; int minutes = (int)timer / 60 % 60; timerCountdownText.text = $"{minutes.ToString("00")}:{seconds.ToString("00")}"; } } else { timerCountdownText.gameObject.SetActive(false); } }
private static void setUnbind(string args) { if (args == "all") { KeyBinds.Reset(); Pigeon.Console.Log("all custom binds reset"); } else { var key = KeyBinds.ParseToKey(args); KeyBinds.UnbindKey(key); displayKeybind(key); } }
//public string[] lines; //public Text line; // Start is called before the first frame update void Start() { //textboxGameObject = GameObject.FindGameObjectWithTag("TextBox"); //textbox = textboxGameObject.GetComponent<TextBoxManager>(); textbox = FindObjectOfType <TextBoxManager>(); keyBinds = GameObject.FindObjectOfType <KeyBinds>(); characterSwapper = FindObjectOfType <CharacterSwapping>(); //line = GameObject.FindGameObjectWithTag("TextBoxText").GetComponent<Text>(); //if (end == 0) //if endline is unspecified, go to the end //{ // end = lines.Length - 1; //} }
public bool AddAxisBind(AxBind axisBind) { int index = (!string.IsNullOrEmpty(axisBind.name)) ? KeyBinds.FindIndex(kb => kb.name == axisBind.name) : -1; if (index < 0) { AxisBinds.Add(axisBind); if (updateText) { UpdateCurrentKeyBindText(); } return(true); } return(false); }
/// <summary> /// Returns true if the key has been initially pressed /// </summary> /// <param name="bind"></param> /// <returns></returns> public bool IsKeyPressed(KeyBinds bind) { if (!(keyDict.ContainsKey(bind))) { return(false); } getState(); Keys k = keyDict[bind]; if (!lastState.IsKeyDown(k) && keyState.IsKeyDown(k)) { return(true); } return(false); }
public bool AddKeyBind(KBind kBind) { int index = (!string.IsNullOrEmpty(kBind.name)) ? KeyBinds.FindIndex(kb => kb.name == kBind.name) : -1; KBindChange kindOfChange = KBindChange.Add; if (index >= 0) { kindOfChange = KBindChange.Update; // will cause lists to Remove then re-Add return(false); } else { KeyBinds.Add(kBind); } return(UpdateKeyBindGroups(kBind, kindOfChange)); }
/// <summary> /// Constructs the player object. /// </summary> /// <param name="game"></param> /// <param name="GameScreen"></param> /// <param name="keyBinds"></param> public Player(GameRoot game, GameScreen GameScreen, KeyBinds keyBinds) : base(game, GameScreen) { this.KeyBinds = keyBinds; this.keyHandler = new KeyHandler(); // The players texture is set here instead of load // content because the StartPosition requires the textures size this.Texture = GameRoot.ResourceManager.GetTexture("BluePlayer"); this.shootingSound = GameRoot.ResourceManager.GetSound("PlayerShoot"); this.damageSound = GameRoot.ResourceManager.GetSound("Destroy"); this.MaxHealth = 150; this.Health = MaxHealth; this.Speed = 450.0f; this.exhaustAnimation = new Animation(GameRoot, GameScreen, GameRoot.ResourceManager.GetTexture("ExhaustAnimation"), 0.075f, true); this.GameScreen.Components.Add(exhaustAnimation); }
public static void setKeyBinds(int controls1, int controls2) { switch (controls1) { case 0: p1 = new KeyBinds(KeyCode.W, KeyCode.A, KeyCode.S, KeyCode.D, KeyCode.LeftShift); break; case 1: p1 = new KeyBinds(KeyCode.I, KeyCode.J, KeyCode.K, KeyCode.L, KeyCode.Space); break; case 2: p1 = new KeyBinds(KeyCode.UpArrow, KeyCode.LeftArrow, KeyCode.DownArrow, KeyCode.RightArrow, KeyCode.RightShift); break; default: p1 = new KeyBinds(); break; } switch (controls2) { case 0: p2 = new KeyBinds(KeyCode.W, KeyCode.A, KeyCode.S, KeyCode.D, KeyCode.LeftShift); break; case 1: p2 = new KeyBinds(KeyCode.I, KeyCode.J, KeyCode.K, KeyCode.L, KeyCode.Space); break; case 2: p2 = new KeyBinds(KeyCode.UpArrow, KeyCode.LeftArrow, KeyCode.DownArrow, KeyCode.RightArrow, KeyCode.RightShift); break; default: p2 = new KeyBinds(); break; } }
void Start() { textbox = GameObject.FindGameObjectWithTag("TextBox"); keyBinds = GameObject.FindObjectOfType <KeyBinds>(); if (textfile != null) { textlines = (textfile.text.Split('\n')); } if (endatline == 0) //if endline is unspecified, go to the end { endatline = textlines.Length - 1; } if (isActive) { enable(); } else { disable(); } }
private static void setBind(string args) { if (string.IsNullOrWhiteSpace(args)) { Pigeon.Console.Log("current keybinds:"); foreach (var boundKey in KeyBinds.GetAllKeyBinds().Keys) { displayKeybind(boundKey); } return; } string[] splitArgs = args.Split(new[] { ' ' }, 2); Keys key = KeyBinds.ParseToKey(splitArgs[0]); if (splitArgs.Length == 2) // create a new bind { KeyBinds.BindKey(key, splitArgs[1]); } // if no command is given, just display current bind for that key displayKeybind(key); }
private static void displayKeybind(Keys key) { Pigeon.Console.Log(string.Format("{0}: {1}", key, KeyBinds.GetKeyBind(key) ?? "<unbound>")); }
void Start() { keyBinds = GameObject.FindObjectOfType <KeyBinds>(); characterSwapper = GetComponent <CharacterSwapping>(); }
private void Awake() { player = GetComponent <Player>(); keyBinds = ControllerMapping.GetKeyBinds(player.ID); }
void Start() { keyBinds = GameObject.FindObjectOfType <KeyBinds>(); }
private bool RemoveListener(KBind kBind, int kBindIndex) { KeyBinds.RemoveAt(kBindIndex); UpdateKeyBindGroups(kBind, KBindChange.Remove); return(true); }
protected void RestoreKB(KeyBinds keyBinds) { KeyBinds.Default.Exit = Keys.Escape; }
public void LateStart() { /* * //Print player ship model size * Vector3 meshFilterSize = transform.GetChild(0).GetChild(0).GetComponent<MeshFilter>().mesh.bounds.size; * Debug.Log( * "x: " + meshFilterSize.x + ", y: " + meshFilterSize.y + ", z: " + meshFilterSize.z + ); */ //KeyBinds binds = control.binds; //Upgrades upgradeLevels = new int[control.commerce.upgradeDictionary.GetLength(0)]; upgradesInitialized = true; UpdateUpgrades(); //Camera centreMountTran = centreMount.transform; centreMountPitch = centreMountTran.localRotation.x; centreMountYaw = centreMountTran.localRotation.y; centreMountRoll = centreMountTran.localRotation.z; SetCameraSettings(); //Vitals //We have to work with odd-numbered multiples of the inverse of the flash rate to end smoothly (end while it is transparent) warningUIFlashTotalDuration *= (1f / WARNING_UI_FLASH_RATE); //ORE ore = new double[3]; //0 = Platinoids, 1 = PreciousMetal, 2 = Water //Update resources UI control.ui.UpdateAllPlayerResourcesUI(); //Collection sound soundSourceOreCollected.clip = soundClipOreCollected; //WEAPONS //Called in update anyway //UpdateWeaponSelected(); //AUDIO //Play the first song 0 to 30 seconds after startup musicPlayTime = Time.time + UnityEngine.Random.Range(0f, musicPlayTime); //Init sounds soundSourceRocket.clip = soundClipRocket; soundSourceLaser0.clip = soundClipLaser; soundSourceLaser1.clip = soundClipLaser; soundSourceLaser2.clip = soundClipLaser; soundSourceLaser3.clip = soundClipLaser; soundSourceLaserReload.clip = soundClipLaserReload; soundSourceCoins.clip = soundClipCoins; soundSourceCollision.clip = soundClipCollision; //Start rocket sound soundSourceRocket.Play(); //Setup particle system GetComponent <ParticlesDamageRock>().SetParticleSystemDamageColour(tpModel.transform.Find("Ship").transform, 0.7f); GetComponent <ParticlesDamageRock>().partSysShurikenDamageEmitCount = 150; GetComponent <ParticlesDamageRock>().partSysShurikenDamageShapeRadius = 0.15f; GetComponent <ParticlesDamageRock>().partSysShurikenDamageSizeMultiplier = 0.2f; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); // Window options var options = new BrowserWindowOptions { // Relative path to icon from Casterr exe is wwwroot/branding/icons/512x512.png ... // ... But need to get full path so browserWindows.js can see it Icon = Path.GetFullPath(Path.Combine("wwwroot", "branding", "icons", "512x512.png")), // Applications title, currently overwritten by <title> in _Host.cshtml Title = "Casterr", Width = 1200, Height = 650, MinWidth = 800, MinHeight = 500, Frame = false, Show = false }; // Open Electron window Task.Run(async() => { var mainWindow = await Electron.WindowManager.CreateWindowAsync(options); mainWindow.OnReadyToShow += () => mainWindow.Show(); }); // Setup all keybinds KeyBinds kb = new KeyBinds(); kb.RegisterAll(); // Run some tasks before fully closing program Electron.App.WillQuit += (args) => Task.Run(() => { // Unregister all keybinds created Electron.GlobalShortcut.UnregisterAll(); }); }
void readKeyBoardInput(KeyboardState kstate, Level level) { if (kstate.IsKeyDown(KeyBinds.Instance().Slow)) { this.MoveSpeed = PrecisionSpeed; } else { this.MoveSpeed = this.mobBase.MoveSpeed; } if (kstate.IsKeyDown(KeyBinds.Instance().Fire)) { Fire(level); } if (kstate.IsKeyDown(KeyBinds.Instance().Up) && Position.Y > Constants.BORDER + Constants.PLAYER_RADIUS) { UpdatePosition("up"); } else if (kstate.IsKeyDown(KeyBinds.Instance().Down) && Position.Y < Constants.HEIGHT - Constants.BORDER - Constants.PLAYER_RADIUS) { UpdatePosition("down"); } else if (kstate.IsKeyDown(KeyBinds.Instance().Left) && Position.X > Constants.BORDER + Constants.PLAYER_RADIUS) { UpdatePosition("left"); } else if (kstate.IsKeyDown(KeyBinds.Instance().Right) && Position.X < Constants.PLAYABLE_WIDTH - Constants.PLAYER_RADIUS) { UpdatePosition("right"); } else if (kstate.IsKeyDown(KeyBinds.Instance().UpLeft)) { if (Position.X > Constants.BORDER + Constants.PLAYER_RADIUS) { UpdatePosition("left"); } if (Position.Y > Constants.BORDER + Constants.PLAYER_RADIUS) { UpdatePosition("up"); } } else if (kstate.IsKeyDown(KeyBinds.Instance().UpRight)) { if (Position.X < Constants.PLAYABLE_WIDTH - Constants.PLAYER_RADIUS) { UpdatePosition("right"); } if (Position.Y > Constants.BORDER + Constants.PLAYER_RADIUS) { UpdatePosition("up"); } } else if (kstate.IsKeyDown(KeyBinds.Instance().DownRight)) { if (Position.X < Constants.PLAYABLE_WIDTH - Constants.PLAYER_RADIUS) { UpdatePosition("right"); } if (Position.Y < 500) { UpdatePosition("down"); } } else if (kstate.IsKeyDown(KeyBinds.Instance().DownLeft)) { if (Position.X > Constants.BORDER + Constants.PLAYER_RADIUS) { UpdatePosition("left"); } if (Position.Y < 500) { UpdatePosition("down"); } } }
public void ManualUpdate() { if (gameEntity.IsPlayer()) { if (Input.GetKeyDown(KeyBinds.Binding("RunWalk"))) { if (playerSpeed == 0f) { playerSpeed = 1f; } else { playerSpeed = 0f; } } } else { playerSpeed = inputController.GetFloat(GMKeyCode.PlayerSpeed); } if (terrainCollisionHandler != null) { terrainCollisionHandler.CollisionCheck(); } if (gameEntity.IsDead()) { velocity.y -= gravity * Time.deltaTime; SetAnimation(AnimationName.Dead); return; } if (gameEntity.MovementDisabled()) { velocity.y -= gravity * Time.deltaTime; SetAnimation(AnimationName.Idle); return; } // If on the ground, allow jumping if (grounded) { if (inputController.GetBool(GMKeyCode.Jumping)) { velocity.y = jumpPower; grounded = false; } } if (gameEntity.IsOtherPlayer()) { Quaternion wanted = Quaternion.Euler(0, inputController.GetFloat(GMKeyCode.Heading), 0); transform.rotation = Quaternion.Slerp(transform.rotation, wanted, Time.deltaTime * speed); } if (gameEntity.IsPlayer()) { if (OnBoat()) { onBoat = true; } else { onBoat = false; } } else { onBoat = false; } if (transform.position.y <= swimLevel) { swimDirection = 0; float angleY = inputController.GetFloat(GMKeyCode.AngleY); if (angleY >= 40f) { swimDirection = 1; } swimming = true; if (Mathf.Abs(transform.position.y - swimLevel) <= 0.1f) { underWater = false; } else { underWater = true; if (angleY <= -30f || Input.GetButton("Jump")) { swimDirection = 2; } } grounded = true; } else { swimming = false; } float input_modifier = (inputX != 0.0f && inputY != 0.0f) ? 0.7071f : 1.0f; inputX = inputController.GetFloat(GMKeyCode.Haxis); inputY = inputController.GetFloat(GMKeyCode.Vaxis); // If the user is not holding right-mouse button, rotate the player with the X axis instead of strafing if (!inputController.GetBool(GMKeyCode.MouseRight) && inputX != 0) { transform.Rotate(new Vector3(0, inputX * (turnSpeed / 2.0f), 0)); inputX = 0; } // Movement direction and speed if (swimming) { speed = swimSpeed; } else { if (inputY < 0) { speed = backSpeed; } else { if (inputController.GetFloat(GMKeyCode.PlayerSpeed) == 1f) { speed = runSpeed; } else { speed = walkSpeed; } } } // If on the ground, test to see if still on the ground and apply movement direction if (grounded) { if (swimming) { velocity = new Vector3(inputX * input_modifier, -antiBump, inputY * input_modifier); velocity = transform.TransformDirection(velocity) * speed; //_velocity = new Vector3 (_velocity.x, y, _velocity.z); } else { velocity = new Vector3(inputX * input_modifier, -antiBump, inputY * input_modifier); velocity = transform.TransformDirection(velocity) * speed; } if (lastPosition == Vector3.zero) { lastPosition = transform.position; } moveSpeed = (transform.position - lastPosition).magnitude; lastPosition = transform.position; } // npc's always grounded if (gameEntity.IsNpc()) { grounded = true; } else { //if (!Physics.Raycast(transform.position, -Vector3.up, 0.2f)) { // grounded = false; //} } UpdateAnimations(); if (swimming) { if (swimDirection == 2) { swimVelocity = 2f; } else if (swimDirection == 1) { swimVelocity = -2f; } else { swimVelocity = 0f; } velocity.y = swimVelocity; } else { velocity.y -= gravity * Time.deltaTime; } if (gameEntity.IsPlayer()) { if (activePlatform == null) { characterController.Move(velocity * Time.deltaTime); } else { if (onBoat) { MoveOnPlatform(); if (!controllingBoat) { characterController.Move(velocity * Time.deltaTime); } PlatformPostCalc(); } } } else { ServerMove(velocity.y, speed); } }