// Update is called once per frame void FixedUpdate() { if (!hasAuthority) //これがないと自身の操作を分別できない { LerpPosition(); } else { inputHorizontal = MyInput.Direction().x; inputVertical = MyInput.Direction().z; // カメラの方向から、X-Z平面の単位ベクトルを取得 Vector3 cameraForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized; // 方向キーの入力値とカメラの向きから、移動方向を決定 Vector3 moveForward = cameraForward * inputVertical + Camera.main.transform.right * inputHorizontal; // 移動方向にスピードを掛ける。ジャンプや落下がある場合は、別途Y軸方向の速度ベクトルを足す。 rb.velocity = moveForward * moveSpeed + new Vector3(0, rb.velocity.y, 0); // キャラクターの向きを進行方向に if (moveForward != Vector3.zero) { transform.rotation = Quaternion.LookRotation(moveForward); } CmdMove(rb.velocity, transform.rotation); } }
// Use this for initialization void Start() { words = new string[6]; words[1] = "「梅,你还在吗?」\n" + "「不……嗯,我只是想和你说声谢谢」\n" + "「这一天是我经历的最疯狂的一天,直至现在我还是很迷茫」\n" + "「但至少还有你在不是吗」"; words[2] = "「聊天机器人?不,不是这样的」\n" + "「我明白,但是我是认真的,谢谢你」\n" + "「我也不知道明天会发生什么,这一切到底是怎么回事,甚至不知道自己能不能活下来」\n" + "「往前走吧,事情总会有所转机」"; words[3] = "系统日志DL308700400001\n" + "系统逻辑模块自检无异常\n" + "【警告】数据库存在部分重要数据丢失\n" + "网络连接中断,请求硬件设备接入唤醒子系统"; words[4] = "基站状态:封锁 安全等级:优\n" + "模拟对象捕获,情感学习模块正常运转中\n" + "检测到情感阈值有较大起伏,请尽快提交自查报告【该消息已忽略】"; str = words[1]; isPrint = true; myInput = camera.GetComponent <MyInput>(); Debug.Log(str); }
void OnGUI() { if (ShowInv) //vykreslení inventáře { //_inventorySettings.DrawBackGround(); _inventorySettings.DrawEmptyItems(); _armorSettings.DrawEmptyItems(); _inventorySettings.DrawFullItems(); _armorSettings.DrawFullItems(); if (InventorySettings.InventoryItemList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()))) { _inventorySettings.DrawOnHover(); } if (ArmorSettings.ArmorItemList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()))) { _armorSettings.DrawOnHover(); } } if (ShowDrop) //vykreslení dropu { //_drop.DrawEmptyItems(); _drop.DrawFullItems(); } if (ShowInv) //kvůli vykreslovacím vrstvám { _slotManagement.DrawMovingItem(); _armorSettings.DrawItemInfo(); _inventorySettings.DrawItemInfo(); _slotManagement.DrawStacking(); } if (ShowDrop) //kvůli vykreslovacím vrstvám { _drop.DrawItemInfo(); } }
static void Postfix(PersonController __instance, ref Network_Player ___playerNetwork, ref Vector3 ___moveDirection) { if (sprintByDefault && !__instance.crouching && !isCrouching) { __instance.normalSpeed = defaultSprintSpeed; __instance.sprintSpeed = defaultNormalSpeed; } else { __instance.normalSpeed = defaultNormalSpeed; __instance.sprintSpeed = defaultSprintSpeed; } if (crouchIsToggle) { if (MyInput.GetButtonUp("Crouch")) { isCrouching = !isCrouching; } __instance.crouching = isCrouching; ___playerNetwork.Animator.anim.SetBool("Crouching", isCrouching); if (!MyInput.GetButton("Crouch") && isCrouching) { float speed = MyInput.GetButton("Sprint") ? __instance.sprintSpeed : __instance.normalSpeed; ___moveDirection /= speed * Stat_WellBeing.groundSpeedMultiplier; } } }
protected virtual void Update() { if (MyInput.GetKeyDown(myKey) && isAtObject && !isTouch) { Action(); } }
void HandleYInput(float y_input) { if (y_input <= -.5f && drop_routine == null && cont.OverPlatform() && MyInput.GetButtonDown("Jump", jump_buffer)) { if (cont.OverPlatform()) { drop_routine = StartCoroutine(DropRoutine()); } MyInput.ClearBuffer("Jump"); } else if (drop_routine == null && player.can_move && MyInput.GetButtonDown("Drop")) { drop_routine = StartCoroutine(DropRoutine()); } else if (player.can_move && MyInput.GetButtonDown("Jump", jump_buffer)) { if (cont.collisions.below) { Jump(true); } else if (jumps_used < (player.jump_count - (grounded_jump_used ? 0 : 1))) { Jump(false); } } }
public void PUpdate() { // WASDの入力 float h = MyInput.GetAxis("Horizontal"); float v = MyInput.GetAxis("Vertical"); // Shiftの入力でスピードを変更 float s = speed * (1 + MyInput.GetAxis("Dash")); // 移動方向の計算 単位ベクトル化 Vector3 dir = Vector3.Normalize(transform.forward * v + transform.right * h); // コントローラーで移動 controller.SimpleMove(dir * s); // マウス感度の調整 float m = mouseSensi * 0.05f; // マイスの移動量か矢印キーの入力を取得 float mX = MyInput.GetAxis("Mouse X") * m + MyInput.GetAxis("LeftRight") * m * 400f * Time.deltaTime; float mY = MyInput.GetAxis("Mouse Y") * m + MyInput.GetAxis("UpDown") * m * 400f * Time.deltaTime; // 体や首を回転 rot = new Vector3(Mathf.Clamp(rot.x - mY, -80, 80), rot.y + mX, 0f); transform.eulerAngles = new Vector3(0, rot.y, 0); neck.localEulerAngles = new Vector3(rot.x, 0, 0); }
private void StartPlayerInput() { currentInput = inputPlayer; justSwitched = true; //dialogueInput.enabled = false; //playerInput.enabled = true; }
public override void Update(GunController gun) { // To fire state. if (MyInput.GetButtonDown("Fire1")) { if (gun.NBullets > 0) { gun.AddSecondaryState(new GunStateFire()); } else { GameStats._MessageNotifier.PushFloatMessage("Out of bullet"); GameStats._GunsManager.GetComponent <AudioSource>().PlayOneShot(gun.m_emptyFireSound); } } // End aim. if (MyInput.GetButtonUp("Fire2")) { if (gun.IsSecondaryState(this)) { gun.RemoveSecondaryState(); } else { gun.ChangeState(new GunStateIdle()); } } }
// Update is called once per frame void Update() { if (isOpen) { return; } UIController.ChangeChoice(MenuItems, choiceElement); if (MyInput.isButtonDown()) { choiceElement -= (int)MyInput.direction().y; if (choiceElement < 0) { choiceElement = 0; } if (choiceElement >= MenuItems.Length) { choiceElement = MenuItems.Length - 1; } } if (Input.GetKeyDown(KeyCode.Return) && ItemWindows[choiceElement] != null) { ItemWindows[choiceElement].SetActive(true); isOpen = true; } if (Input.GetKeyDown(KeyCode.Backspace)) { this.gameObject.SetActive(false); } }
public static TileNeighborEnum InputToDirection(MyInput input) { switch (input) { case MyInput.DownLeft: return(TileNeighborEnum.DownLeft); case MyInput.DownRight: return(TileNeighborEnum.DownRight); case MyInput.Left: return(TileNeighborEnum.Left); case MyInput.Right: return(TileNeighborEnum.Right); case MyInput.UpLeft: return(TileNeighborEnum.UpLeft); case MyInput.UpRight: return(TileNeighborEnum.UpRight); default: throw new Exception("Input is not a direction!!!"); } throw new Exception("Input is not a direction!!!"); }
public void Update() { if (ExtraSettingsAPI_Loaded && camera != null) { if (persistence.zoomMinimapIn != null && MyInput.GetButton(persistence.zoomMinimapIn)) { ZoomMinimapIn(); } if (persistence.zoomMinimapOut != null && MyInput.GetButton(persistence.zoomMinimapOut)) { ZoomMinimapOut(); } if (persistence.minimapDrag != null && MyInput.GetButtonDown(persistence.minimapDrag)) { InitMinimapDrag(true); } if (persistence.minimapDrag != null && MyInput.GetButton(persistence.minimapDrag)) { OnMinimapDrag(); } if (persistence.minimapDrag != null && MyInput.GetButtonUp(persistence.minimapDrag)) { InitMinimapDrag(false); } if (persistence.caveMode && camera != null) { var playerY = camera.transform.parent.position.y; camera.nearClipPlane = 300 - (playerY + CAVE_MODE_CLIP_TOP); camera.farClipPlane = 300 + (-playerY + CAVE_MODE_CLIP_BOTTOM); } } }
private void Update() { if (over != null && MyInput.GetButtonDown("Interact")) { over.Interact(player); } }
public override MyInput GetInput(GameState gs) { MyInput tmpInput = new MyInput(input.GetCoup(), input.GetDeplacement()); input.Reset(); return(tmpInput); }
public static int myDll(ref MyInput myInput, ref MyOutput myOutput) { int sizeIn, sizeOut; IntPtr ptr_i = IntPtr.Zero, ptr_u = IntPtr.Zero; sizeIn = Marshal.SizeOf(typeof(myInput)); sizeOut = Marshal.SizeOf(typeof(myOutput)); /* Calling C */ try { ptr_i = Marshal.AllocHGlobal(sizeIn); ptr_u = Marshal.AllocHGlobal(sizeOut); Marshal.StructureToPtr(myInput, ptr_i, true); Marshal.StructureToPtr(myOutput, ptr_u, true); dllFunc(ptr_i, ptr_u); myOutput = (MyOutput)(Marshal.PtrToStructure(ptr_u, typeof(MyOutput))); } catch (Exception) { //Return something meaningful (or not) return(-999); } finally { //Free memory Marshal.FreeHGlobal(ptr_i); Marshal.FreeHGlobal(ptr_u); } //Return something to indicate it all went well return(0); }
public void Input_Initialization() { //Test the base input with everything assigned MyInput input = new MyInput { name = "TestInput", axisName = "Horizontal" }; input.UpdateInput(); Debug.Assert(input.GetValue == 0); Debug.Assert(input.PressedThisFrame()); //Test the base input without assigning an axis MyInput input2 = new MyInput { name = "Horizontal" }; Debug.Assert(input2.axisName == "NULL"); input2.UpdateInput(); Debug.Assert(input2.GetValue == 0); Debug.Assert(input2.PressedThisFrame()); }
public void InputManager_Test() { MyInput[] inputs = new MyInput[3]; inputs[0] = new MyInput { name = "Forward" }; inputs[1] = new MyInput { name = "Jump" }; inputs[2] = new MyInput { name = "Crouch" }; //Manually assign the inputs InputManager.inputs = inputs; //Valid Test for Input Debug.Assert(InputManager.GetInput("Forward") == 0); //Test invalid input LogAssert.Expect(LogType.Error, "Invalid input name: NotAnInput"); Debug.Assert(InputManager.GetInput("NotAnInput") == 0); //Test another input Debug.Assert(InputManager.GetInput("Crouch") == 0); //Valid input test Debug.Assert(InputManager.NewInput("Jump") == 0); //Test invalid input LogAssert.Expect(LogType.Error, "Invalid input name: NotAnInput"); Debug.Assert(InputManager.NewInput("NotAnInput") == 0); }
public override void Update(GunController gun) { m_currPlayingFire = gun.m_gunAnimator.GetCurrentAnimatorStateInfo(0).IsName("fire"); // To aim state. if (MyInput.GetButtonDown("Fire2")) { if (gun.IsSecondaryState(this)) { gun.ChangeState(new GunStateAim()); } else { gun.AddSecondaryState(new GunStateAim()); } } // End fire. if ( ((gun.m_fireMode != FireMode.Launcher) && MyInput.GetButtonUp("Fire1")) || ((gun.m_fireMode == FireMode.Launcher) && m_prevPlayingFire && !m_currPlayingFire) ) { if (gun.IsSecondaryState(this)) { gun.RemoveSecondaryState(); } else { gun.ChangeState(new GunStateIdle()); } } m_prevPlayingFire = m_currPlayingFire; }
public Task RunInputQuery() { var field = new Query().GetField("inputQuery"); var userContext = new GraphQlUserContext(); FluentValidationExtensions.AddCacheToContext( userContext, ValidatorCacheBuilder.Instance); var input = new MyInput { Content = "TheContent" }; var dictionary = input.AsDictionary(); var fieldContext = new ResolveFieldContext { Arguments = new Dictionary <string, object> { { "input", dictionary } }, UserContext = userContext }; var result = (Result)field.Resolver.Resolve(fieldContext); return(Verify(result)); }
public void OnRespawn() { CmdOnRespawn(); MyInput.Unlock(); GameStats._EndGameMenu.Disable(); }
private void Action() //장착된 무기의 action을 실행 { if (!PlayManager.Instance.Player.equip.equipedWeapon.onAttack) { if (isDashing) { if (SaveManager.GetSkillUnlockInfo(2)) { PlayManager.Instance.Player.equip.equipedWeapon.DashAttack(atkBuff, attackSpd); StartCoroutine(DashAttacking()); } return; } else if (MyInput.GetKey(MyKeyCode.Down) && !IsGround && !isJumpSkillUsing) { if (SaveManager.GetSkillUnlockInfo(1)) { PlayManager.Instance.Player.equip.equipedWeapon.JumpSkillAction(atkBuff, attackSpd); } return; } else { if (PlayManager.Instance.Player.equip.equipedWeapon.atkCooltime <= 0f) { PlayManager.Instance.Player.equip.equipedWeapon.Action(atkBuff, attackSpd); } } } }
void CalculateMoveDirection() { MoveDirection = new Vector3(0.0f, MoveDirection.y, 0.0f); // Walk. Vector3 dir = new Vector3(MyInput.GetAxis("Horizontal"), 0.0f, MyInput.GetAxis("Vertical")); dir = m_target.transform.TransformDirection(dir); dir.y = 0.0f; if (MyInput.GetButton("Sprint")) { dir *= m_runSpeed; } else { dir *= m_walkSpeed; } MoveDirection += dir; // Jump. if (m_target.isGrounded && MyInput.GetButtonDown("Jump")) { ChangeState(new FPSCharacterStateJump()); } // Character controller don't have gravity support, so apply it here. MoveDirection = new Vector3( MoveDirection.x, MoveDirection.y - m_jumpSpeed * Time.deltaTime, MoveDirection.z ); }
public void NewInput(object sender, NewInputEventArgs e) { if (e.NewInput != MyInput.UNASSIGNED) { CurrentInput = e.NewInput; } }
private Vector2 GetRawMoveVector() { Vector2 move = Vector2.zero; move.x = MyInput.GetAxisRaw(m_HorizontalAxis); move.y = MyInput.GetAxisRaw(m_VerticalAxis); if (MyInput.GetButtonDown(m_HorizontalAxis)) { if (move.x < 0) { move.x = -1f; } if (move.x > 0) { move.x = 1f; } } if (MyInput.GetButtonDown(m_VerticalAxis)) { if (move.y < 0) { move.y = -1f; } if (move.y > 0) { move.y = 1f; } } return(move); }
void ApplyInputCoup(MyInput input) { switch (input.GetCoup()) { case MyInput.Coup.NOTHING: etat = Etat.IDLE; break; case MyInput.Coup.PUNCH: etat = Etat.PUNCH_START; break; case MyInput.Coup.KICK: etat = Etat.KICK_START; break; case MyInput.Coup.UPPERCUT: etat = Etat.UPPERCUT_START; break; case MyInput.Coup.PROTECT: etat = Etat.PROTECT; break; } }
// Update is called once per frame public void Update() { if (!isLocalPlayer) { return; } if (player.isDead) { if (!player.pointFlag) { player.CmdAddPoint(player.EnemyTeam(), 5); player.pointFlag = true; } player.DeadTime(); } if (player.isChange) { player.ChangeType((int)player.Type); return; } if (MyInput.OnTrigger() && trapId != "") { trapPrefab.GetComponent <Trap>().ID = trapId; trapPrefab.GetComponent <Trap>().SetPlayerTeamInfo(player.team); Instantiate(trapPrefab, new Vector3(transform.position.x + -player.moveForward.x, -0.5f, transform.position.z + -player.moveForward.z), Quaternion.identity); ClearTrapInfo(); } }
public override void Load() { path = Application.persistentDataPath + "\\" + filePath; // On récupère notre QTable si elle existe déjà try { BinaryFormatter formatter = new BinaryFormatter(); Stream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); qTable = (QTable)formatter.Deserialize(stream); stream.Close(); stream.Dispose(); // Si elle n'existe pas, on l'initialise :) } catch (Exception e) { Debug.LogError(e.Message); // Initialiser la QTable qTable = new QTable(); foreach (GameState gs in GameState.AllStates()) { foreach (MyInput input in MyInput.AllInputs()) { qTable.table.Add(new QValue(gs, input)); } } } Debug.Log("Taille de la QTable = " + qTable.table.Count); }
void HandleCameraMovement() { Vector3 cameraAdjustmentVector; // On PC, the cursor point is the mouse position var cursorScreenPosition = MyInput.GetMousePosition(); var halfWidth = Screen.width / 2.0f; var halfHeight = Screen.height / 2.0f; var maxHalf = Mathf.Max(halfWidth, halfHeight); // Acquire the relative screen position var posRel = cursorScreenPosition - new Vector3(halfWidth, halfHeight, cursorScreenPosition.z); posRel.x /= maxHalf; posRel.y /= maxHalf; cameraAdjustmentVector = posRel.x * m_screenMovementRight + posRel.y * m_screenMovementForward; cameraAdjustmentVector.y = 0.0f; // Set the target position of the camera to point at the focus point var cameraTargetPosition = transform.position + m_cameraOffsetToPlayer + cameraAdjustmentVector * m_cameraPreview; // Apply some smoothing to the camera movement m_cameraTransform.position = Vector3.SmoothDamp( m_cameraTransform.position, cameraTargetPosition, ref m_cameraVelocity, m_cameraSmoothing); }
// Update is called once per frame void FixedUpdate() { if (isUsingLadder) { if (MyInput.GetKey(MyKeyCode.Right)) { Move(Direction.right); } if (MyInput.GetKey(MyKeyCode.Left)) { Move(Direction.left); } if (MyInput.GetKey(MyKeyCode.Up)) { UpLadder(); } if (MyInput.GetKey(MyKeyCode.Down)) { DownLadder(); } if (MyInput.GetKeyUp(MyKeyCode.Up)) { PlayManager.Instance.Player.IsLadderAction = false; } if (MyInput.GetKeyUp(MyKeyCode.Down)) { PlayManager.Instance.Player.IsLadderAction = false; } } }
static void Main(string[] args) { MyInput myInput = new MyInput(); IntPtr dataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(myInput)); Marshal.StructureToPtr(myInput, dataPtr, true); myFunction(dataPtr); }
internal void SetActiveScript(MyInput.Keyboard_Classes.KeyProcessor kp) { ScriptName = kp.getscript(); this.iop = mfm.iop; }
internal void SetActiveLayout(MyInput.Keyboard_Classes.KeyboardLayout kl) { }