void CheckKeyboardInput() { if (!UIManager.IsInputFocus && GameData.IsInGame && CustomNetworkManager.Instance.IsClientConnected()) { // Perform escape key action if (CommonInput.GetKeyDown(KeyCode.Escape)) { if (EscapeKeyTarget.TargetStack.Count > 0) { EscapeKeyTarget escapeKeyTarget = EscapeKeyTarget.TargetStack.Peek().GetComponent <EscapeKeyTarget>(); escapeKeyTarget.OnEscapeKey.Invoke(); if (escapeKeyTarget.DisableOnEscape) { GUI_IngameMenu.Instance.CloseMenuPanel(EscapeKeyTarget.TargetStack.Peek()); } } else { GUI_IngameMenu.Instance.OpenMenuPanel(GUI_IngameMenu.Instance.mainIngameMenu); } } // Perform the checks for all key actions which have functions defined here foreach (KeyValuePair <KeyAction, DualKeyCombo> entry in keybindManager.userKeybinds) { if (!keyActionFunctions.ContainsKey(entry.Key)) { continue; } if (CheckComboEvent(entry.Value.PrimaryCombo) || CheckComboEvent(entry.Value.SecondaryCombo)) { // Call the function associated with the KeyAction enum keyActionFunctions[entry.Key](); } } } }
private void CheckMouseInput() { if (EventSystem.current.IsPointerOverGameObject()) { //don't do any game world interactions if we are over the UI return; } if (UIManager.IsMouseInteractionDisabled) { //still allow tooltips CheckHover(); return; } //do we have a loaded gun var loadedGun = GetLoadedGunInActiveHand(); if (CommonInput.GetMouseButtonDown(0)) { //check ctrl+click for dragging if (KeyboardInputManager.IsControlPressed()) { //even if we didn't drag anything, nothing else should happen CheckInitiatePull(); return; } //check the alt click and throw, which doesn't have any special logic if (CheckAltClick()) { return; } if (CheckThrow()) { return; } if (loadedGun != null) { //if we are on harm intent with loaded gun, //don't do anything else, just shoot (trigger the AimApply). if (UIManager.CurrentIntent == Intent.Harm) { CheckAimApply(MouseButtonState.PRESS); } else { //proceed to normal click interaction CheckClickInteractions(true); } } else { //we don't have a loaded gun //Are we over something draggable? var draggable = GetDraggable(); if (draggable != null) { //We are over a draggable. We need to wait to see if the user //tries to drag the object or lifts the mouse. potentialDraggable = draggable; dragStartOffset = MouseWorldPosition - potentialDraggable.transform.position; clickDuration = 0; } else { //no possibility of dragging something, proceed to normal click logic CheckClickInteractions(true); } } } else if (CommonInput.GetMouseButton(0)) { //mouse button being held down. //increment the time since they initially clicked the mouse clickDuration += Time.deltaTime; //If we are possibly dragging and have exceeded the drag distance, initiate the drag if (potentialDraggable != null) { var currentOffset = MouseWorldPosition - potentialDraggable.transform.position; if (((Vector2)currentOffset - dragStartOffset).magnitude > MouseDragDeadzone) { potentialDraggable.BeginDrag(); potentialDraggable = null; } } //continue to trigger the aim apply if it was initially triggered CheckAimApply(MouseButtonState.HOLD); } else if (CommonInput.GetMouseButtonUp(0)) { //mouse button is lifted. //If we were waiting for mouseup to trigger a click, trigger it if we're still within //the duration threshold if (potentialDraggable != null) { if (clickDuration < MaxClickDuration) { //we are lifting the mouse, so AimApply should not be performed but other //clicks can. CheckClickInteractions(false); } clickDuration = 0; potentialDraggable = null; } //no more triggering of the current aim apply triggeredAimApply = null; secondsSinceLastAimApplyTrigger = 0; } else { CheckHover(); } }
/// <summary> /// Checks if the left or right alt key has been pressed (AltGr sends RightAlt) /// </summary> public static bool IsAltPressed() { return(CommonInput.GetKey(KeyCode.LeftAlt) || CommonInput.GetKey(KeyCode.RightAlt)); }
/// <summary> /// Check if the left or right control or command keys have been pressed /// </summary> public static bool IsControlPressed() { return(CommonInput.GetKey(KeyCode.LeftControl) || CommonInput.GetKey(KeyCode.LeftControl) || CommonInput.GetKey(KeyCode.LeftCommand) || CommonInput.GetKey(KeyCode.LeftCommand)); }
/// <summary> /// Check if escape has been pressed /// </summary> public static bool IsEscapePressed() { return(CommonInput.GetKeyDown(KeyCode.Escape)); }
/// <summary> /// Check if enter (the return or numpad enter keys) has been pressed /// </summary> public static bool IsEnterPressed() { return(CommonInput.GetKeyDown(KeyCode.Return) || CommonInput.GetKeyDown(KeyCode.KeypadEnter)); }
// Update is called once per frame void Update() { // 現在のアニメーター・ステートに紐づいたデータ AcStateRecordable astateRecord = AControl.Instance.GetCurrentAcStateRecord(animator); #region 入力受付と途中参加 CommonInput.PlayerInput input = CommonInput.Update((PlayerIndex)playerIndex); // 人間の途中参加受付 if ( CommonScript.Player_to_computer[playerIndex] && // コンピュータープレイヤーの場合 ( // レバーはコンピューターもいじっているので、区別できない。 // 0 != leverX || // 0 != leverY || 0 != input.leverX || 0 != input.leverY || input.pressingLP || input.pressingMP || input.pressingHP || input.pressingLK || input.pressingMK || input.pressingHK || input.pressingPA || input.pressingCA )) { Debug.Log("途中参加 " + playerIndex + " プレイヤー" + " leverX = " + input.leverX + " leverY = " + input.leverY); // コンピューター・プレイヤー側のゲームパッドで、何かボタンを押したら、人間の参入。 CommonScript.Player_to_computer[playerIndex] = false; // FIXME: 硬直時間を入れたい。 return; } if (CommonScript.Player_to_computer[playerIndex]) { input.leverX = Random.Range(-1.0f, 1.0f); input.pressingLP = false; input.pressingMP = false; input.pressingHP = false; input.pressingLK = false; input.pressingMK = false; input.pressingHK = false; input.pressingPA = false; input.pressingCA = false; } else { input.leverX = Input.GetAxisRaw(CommonInput.PlayerAndInput_to_inputName[playerIndex, (int)InputIndex.Horizontal]); } #endregion if (AControl.Instance.StateHash_to_record[Animator.StringToHash(Select_Cursor_AbstractAControl.BASELAYER_STAY)].Name == astateRecord.Name) { //カーソル移動中でなければ。 if (CommonScript.Player_to_computer[playerIndex])// コンピュータープレイヤーの場合 { if (Select_CameraScript.READY_TIME_LENGTH < mainCameraScript.ReadyingTime) { input.pressingLP = (0.5 < Random.Range(0.0f, 1.0f)); // たまにパンチ・キーを押して決定する。 } } if ( input.pressingLP || input.pressingMP || input.pressingHP || input.pressingLK || input.pressingMK || input.pressingHK || input.pressingPA ) { // 何かボタンを押したら、キャラクター選択。 animator.SetTrigger(SceneCommon.TRIGGER_SELECT); } else if (input.leverX != 0.0f)//左か右を入力したら { //Debug.Log("slide lever x = " + leverX.ToString()); if (input.leverX < 0.0f) { cursorColumn--; if (cursorColumn < 0) { cursorColumn = 2; } } else { cursorColumn++; if (2 < cursorColumn) { cursorColumn = 0; } } //Debug.Log("slide pos = " + cursorColumn[iPlayerIndex]); animator.SetTrigger(SceneCommon.TRIGGER_MOVE); ChangeCharacter(); //入力方向へ移動 //rigidbody2Ds[iPlayerIndex].velocity = new Vector2(leverX * cursorSpeed, rigidbody2Ds[iPlayerIndex].velocity.y); SlideIn(); } else // ボタン押下も、レバー左右入力もしていなかったら { //横移動の速度を0にしてピタッと止まるようにする myRigidbody2D.velocity = new Vector2(0, myRigidbody2D.velocity.y); } } else if (AControl.Instance.StateHash_to_record[Animator.StringToHash(Select_Cursor_AbstractAControl.BASELAYER_MOVE)].Name == astateRecord.Name) { } else if (AControl.Instance.StateHash_to_record[Animator.StringToHash(Select_Cursor_AbstractAControl.BASELAYER_READY)].Name == astateRecord.Name) { // キャラクター選択済みのとき if ( !CommonScript.Player_to_computer[playerIndex] // 人間プレイヤーの場合 && ( input.pressingLK || input.pressingMK || input.pressingHK || input.pressingCA )) { // キック・ボタンを押したら、キャンセル☆ animator.SetTrigger(SceneCommon.TRIGGER_STAY); } } }
//void OnCollisionEnter2D(Collider2D col) //{ // Debug.Log("物体だ☆! col.tag = " + col.tag); //} /// <summary> /// BoxCollider2D(等のPhysics2D), Rigidbody2D の2つをアタッチしているものと接触したとき。 /// </summary> /// <param name="col"></param> void OnTriggerEnter2D(Collider2D col) { #region 当たり判定 if (col.tag == playerScript.OpponentHitboxTag)// 相手の 攻撃当たり判定くん が重なった時 { // ブロックしているかどうか判定☆ //CommonInput.PlayerInput input = CommonInput.player_to_input[playerIndex]; CommonInput.PlayerInput input = CommonInput.Update((PlayerIndex)playerIndex); if (FacingOpponentMoveFwBkSt.Back == playerScript.GetFacingOpponentMoveFwBkSt(input.leverX)) { //if ((int)PlayerIndex.Player1==playerIndex) //{ // Debug.Log("ブロック☆! col.tag = " + col.tag + " input.leverX = " + input.leverX + " Time.deltaTime = " + Time.deltaTime); //} audioSources[1].PlayOneShot(audioSources[1].clip);// 効果音を鳴らすぜ☆ playerScript.Animator.SetTrigger(SceneCommon.TRIGGER_BLOCK); } else { //if ((int)PlayerIndex.Player1 == playerIndex) //{ // Debug.Log("痛っ☆! col.tag = " + col.tag + " input.leverX = " + input.leverX + " Time.deltaTime = " + Time.deltaTime); //} playerScript.DamageHitCount++; // 攻撃を受けた回数。 audioSources[0].PlayOneShot(audioSources[0].clip); // 効果音を鳴らすぜ☆ // 爆発の粒子を作るぜ☆ TakoyakiParticleScript.Add(transform.position.x, transform.position.y); // HPメーター { float damage = playerScript.MainCameraScript.Player_to_attackPower[(int)playerScript.Opponent]; float value = damage * (playerIndex == (int)PlayerIndex.Player1 ? -1 : 1); playerScript.MainCameraScript.OffsetBar(value); if (10 <= playerScript.DamageHitCount) { // ダウン・アニメーションの開始 playerScript.Pull_Down(); } else if (100.0f <= damage) { // ダメージ・アニメーションの開始 playerScript.Pull_DamageH(); } else if (50.0f <= damage) { // ダメージ・アニメーションの開始 playerScript.Pull_DamageM(); } else { // ダメージ・アニメーションの開始 playerScript.Pull_DamageL(); } } // 手番 { // 攻撃を受けた方の手番に変わるぜ☆(^▽^) playerScript.MainCameraScript.SetTeban(playerScript.Opponent); } } } else { //Debug.Log("相手の攻撃じゃないものに当たった☆! col.tag = " + col.tag); } #endregion }
private void Update() { // return if visualisation is disabled or distance is greater than interaction distance if (!cablePlacementVisualisation.activeSelf) { return; } // get releative mouse position Vector2 releativeMousePosition = Camera.main.ScreenToWorldPoint(CommonInput.mousePosition) - cablePlacementVisualisation.transform.position; // get nearest point int x = Mathf.RoundToInt(releativeMousePosition.x * 2); int y = 2 - Mathf.RoundToInt(releativeMousePosition.y * 2); // clamp to be sure that value is in range <0, 2> x = Mathf.Clamp(x, 0, 2); y = Mathf.Clamp(y, 0, 2); Vector2Int point = new Vector2Int(x, y); Connection currentConnection = GetConnectionByPoint(point); // if mouse down - start drawing if (CommonInput.GetMouseButtonDown(0)) { startPoint = currentConnection; target = MouseUtils.GetOrderedObjectsUnderMouse().FirstOrDefault(); SetConnectionPointColor(startPoint, startPointColor); } // if mouse up - stop drawing and check if can build else if (CommonInput.GetMouseButtonUp(0)) { endPoint = currentConnection; Build(); ResetValues(); return; } // check if position has changed if (currentConnection != lastConnection) { // check if last point isn't startPoint or endPoint (to not override color) if (lastConnection != startPoint && lastConnection != endPoint) { SetConnectionPointColor(lastConnection, defaultPointColor); } SetConnectionPointColor(currentConnection, onHoverPointColor); if (startPoint != Connection.NA) { lineRenderer.SetPositions(new Vector3[] { connectionPointRenderers[startPoint].transform.localPosition, // position of start point connectionPointRenderers[currentConnection].transform.localPosition // position of current point }); } lastConnection = currentConnection; } }
void Update() { //if ((int)PlayerIndex.Player1 == playerIndex) //{ // //ebug.Log("Update Time.deltaTime = " + Time.deltaTime); //} // 現在のアニメーター・ステートに紐づいたデータ AcState astateRecord = (AcState)AControl.Instance.GetCurrentAcStateRecord(animator); #region 入力受付 CommonInput.PlayerInput input = CommonInput.Update((PlayerIndex)playerIndex); if (isComputer) { if (input.buttonDownLP || input.buttonDownMP || input.buttonDownHP || input.buttonDownLK || input.buttonDownMK || input.buttonDownHK || input.buttonDownPA) { // 人間プレイヤーの乱入☆ 次のフレームから☆ isComputer = false; input.leverX = 0; input.leverY = 0; } else { // コンピューター・プレイヤーの場合。 input.leverX = Random.Range(-1.0f, 1.0f); input.leverY = Random.Range(-1.0f, 1.0f); if (-0.980f < input.leverX && input.leverX < 0.980f) { // きょろきょろするので落ち着かせるぜ☆(^~^) input.leverX = 0.0f; } if (-0.995f < input.leverY && input.leverY < 0.995f) { // ジャンプばっかりするので落ち着かせるぜ☆(^~^) input.leverY = 0.0f; } if (input.pressingLP) { input.buttonUpLP = (0.900f < Random.Range(0.0f, 1.0f)); } else { input.buttonUpLP = false; input.buttonDownLP = (0.900f < Random.Range(0.0f, 1.0f)); } if (input.pressingMP) { input.buttonUpMP = (0.990f < Random.Range(0.0f, 1.0f)); } else { input.buttonUpMP = false; input.buttonDownMP = (0.990f < Random.Range(0.0f, 1.0f)); } if (input.pressingHP) { input.buttonUpHP = (0.995f < Random.Range(0.0f, 1.0f)); } else { input.buttonUpHP = false; input.buttonDownHP = (0.995f < Random.Range(0.0f, 1.0f)); } if (input.pressingLK) { input.buttonUpLK = (0.900f < Random.Range(0.0f, 1.0f)); } else { input.buttonUpLK = false; input.buttonDownLK = (0.900f < Random.Range(0.0f, 1.0f)); } if (input.pressingMK) { input.buttonUpMK = (0.990f < Random.Range(0.0f, 1.0f)); } else { input.buttonUpMK = false; input.buttonDownMK = (0.990f < Random.Range(0.0f, 1.0f)); } if (input.pressingHK) { input.buttonUpHK = (0.995f < Random.Range(0.0f, 1.0f)); } else { input.buttonUpHK = false; input.buttonDownHK = (0.995f < Random.Range(0.0f, 1.0f)); } //buttonUpPA = (0.999f < Random.Range(0.0f, 1.0f)); //buttonDownPA = (0.999f < Random.Range(0.0f, 1.0f)); } } #endregion FacingOpponentMoveFwBkSt facingOpponentMoveFwBkSt = GetFacingOpponentMoveFwBkSt(input.leverX); if (astateRecord.Tags.Contains((int)Animator.StringToHash(AControl.TAG_BLOCK))) { // ブロック中 if (FacingOpponentMoveFwBkSt.Back != facingOpponentMoveFwBkSt) { // バックを解除している場合。 animator.SetTrigger(SceneCommon.TRIGGER_DEBLOCK); } } #region ジャンプ { // キャラクターの下半身に、接地判定用の垂直線を引く // transform.up が -1 のとき、方眼紙の1マス分ぐらい下に相当? isGrounded = Physics2D.Linecast( transform.position + transform.up * 0, // スプライトの中央 transform.position - transform.up * 1.1f, // 足元を少しはみ出すぐらい groundLayer // Linecastが判定するレイヤー // LayerMask.GetMask("Water")// ); //if ((int)PlayerIndex.Player1 == playerIndex) //{ // //ebug.Log("B playerIndex = " + playerIndex + " isGrounded = " + isGrounded + " transform.position.y = " + transform.position.y + " Rigidbody2D.velocity.y = " + Rigidbody2D.velocity.y); //} //Animatorへパラメーターを送る animator.SetFloat(SceneCommon.FLOAT_VEL_Y, Rigidbody2D.velocity.y); // y方向へかかる速度単位,上へいくとプラス、下へいくとマイナス //ebug.Log("Jumping velY="+animator.GetFloat(SceneCommon.FLOAT_VEL_Y)); animator.SetBool(SceneCommon.BOOL_IS_GROUNDED, isGrounded); } #endregion #region 弾を撃つ // 弾を撃つぜ☆ if ( (3 == animator.GetInteger(SceneCommon.INTEGER_LEVER_X_NEUTRAL) % (30)) // レバーを放して、タイミングよく攻撃ボタンを押したとき && ( input.buttonDownLP || input.buttonDownMP || input.buttonDownHP || input.buttonDownLK || input.buttonDownMK || input.buttonDownHK ) ) { float startY; if (0 < input.leverY)// 上段だぜ☆ { startY = 1.2f; } else if (0 == input.leverY)// 中段だぜ☆ { startY = 0.6f; } else // 下段だぜ☆ { startY = 0.0f; } // 弾の作成☆ GameObject newBullet = Instantiate(bullet, transform.position + new Vector3(0f, startY, 0f), transform.rotation); SpriteRenderer newBulletSpriteRenderer = newBullet.GetComponent <SpriteRenderer>(); // 弾の画像を差し替えたいぜ☆(^~^) { int r = Random.Range(0, 14); Sprite[] sprites = Resources.LoadAll <Sprite>("Sprites/Bullet0"); Sprite sprite2; switch (r) { case 0: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_0")); break; //歩 case 1: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_1")); break; //香 case 2: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_2")); break; //桂 case 3: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_3")); break; //銀 case 4: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_4")); break; //金 case 5: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_5")); break; //角 case 6: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_6")); break; //飛 case 7: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_7")); break; //玉 case 8: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_8")); break; //と case 9: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_9")); break; //杏 case 10: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_10")); break; //圭 case 11: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_11")); break; //全 case 12: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_12")); break; //馬 default: sprite2 = System.Array.Find <Sprite>(sprites, (sprite) => sprite.name.Equals("Bullet0_13")); break; //竜 } newBulletSpriteRenderer.sprite = sprite2; } } #endregion #region レバーの押下時間の更新 // レバー・ニュートラル時間と、レバー・プレッシング時間は、8フレームほど重複する部分がある。 if (input.leverX != 0)//左か右を入力したら { animator.SetInteger(SceneCommon.INTEGER_LEVER_X_PRESSING, animator.GetInteger(SceneCommon.INTEGER_LEVER_X_PRESSING) + 1); animator.SetInteger(SceneCommon.INTEGER_LEVER_X_NEUTRAL, 0); animator.SetInteger(SceneCommon.INTEGER_LEVER_X_IDOL, 0); } else //左も右も入力していなかったら { // 感覚的に、左から右に隙間なく切り替えたと思っていても、 // 入力装置的には、左から右(その逆も)に切り替える瞬間、どちらも押していない瞬間が発生する。 if (8 < animator.GetInteger(SceneCommon.INTEGER_LEVER_X_IDOL))// レバーを放した 数フレーム目から、レバーが離れた判定をすることにする。 { animator.SetInteger(SceneCommon.INTEGER_LEVER_X_PRESSING, 0); animator.SetInteger(SceneCommon.INTEGER_LEVER_X_NEUTRAL, animator.GetInteger(SceneCommon.INTEGER_LEVER_X_NEUTRAL) + 1); } else { animator.SetInteger(SceneCommon.INTEGER_LEVER_X_IDOL, animator.GetInteger(SceneCommon.INTEGER_LEVER_X_IDOL) + 1); } } if (0 != input.leverY)// 上か下キーを入力していたら { animator.SetInteger(SceneCommon.INTEGER_LEVER_Y_PRESSING, animator.GetInteger(SceneCommon.INTEGER_LEVER_Y_PRESSING) + 1); animator.SetInteger(SceneCommon.INTEGER_LEVER_Y_NEUTRAL, 0); animator.SetInteger(SceneCommon.INTEGER_LEVER_Y_IDOL, 0); } else // 下も上も入力していなかったら { // 感覚的に、左から右に隙間なく切り替えたと思っていても、 // 入力装置的には、下から上(その逆も)に切り替える瞬間、どちらも押していない瞬間が発生する。 if (8 < animator.GetInteger(SceneCommon.INTEGER_LEVER_Y_IDOL))// レバーを放した 数フレーム目から、レバーが離れた判定をすることにする。 { animator.SetInteger(SceneCommon.INTEGER_LEVER_Y_PRESSING, 0); animator.SetInteger(SceneCommon.INTEGER_LEVER_Y_NEUTRAL, animator.GetInteger(SceneCommon.INTEGER_LEVER_Y_NEUTRAL) + 1); } else { animator.SetInteger(SceneCommon.INTEGER_LEVER_Y_IDOL, animator.GetInteger(SceneCommon.INTEGER_LEVER_Y_IDOL) + 1); } } #endregion #region レバー操作によるアクション //if (!anim.GetBool(CommonScript.BOOL_JMOVE0))//ジャンプ時の屈伸中ではないなら //{ if (input.leverX != 0)//左か右を入力したら { if (!astateRecord.Tags.Contains(Animator.StringToHash(AControl.TAG_BUSYX))) { //入力方向へ移動 Rigidbody2D.velocity = new Vector2(Mathf.Sign(input.leverX) * speedX, Rigidbody2D.velocity.y); } DoFacingOpponent(GetFacingOfOpponentLR()); //ebug.Log("さあ、どっちだ☆ input.leverX = " + input.leverX + " facingOpponentMoveFwBkSt = " + facingOpponentMoveFwBkSt + " Time.deltaTime = " + Time.deltaTime); if (FacingOpponentMoveFwBkSt.Forward == facingOpponentMoveFwBkSt)// 相手に向かってレバーを倒したとき { //if ((int)PlayerIndex.Player1 == playerIndex) //{ // //ebug.Log("相手に向かっていくぜ☆ input.leverX = " + input.leverX); //} Pull_Forward(); //if (isGrounded)// 接地していれば //{ //} //if ((int)ActioningIndex.Dash != anim.GetInteger(CommonScript.INTEGER_ACTIONING)) //{ // // ダッシュ・アニメーションの開始 // //if ((int)PlayerIndex.Player1 == playerIndex) // //{ // // //ebug.Log("Rigidbody2D.velocity.x = " + Rigidbody2D.velocity.x + " ダッシュ!"); // //} //} //else //{ // // 既にダッシュ中なら何もしない //} } else if (FacingOpponentMoveFwBkSt.Back == facingOpponentMoveFwBkSt)// 相手と反対の方向にレバーを倒したとき(バックステップ) { //if ((int)PlayerIndex.Player1 == playerIndex) //{ // //ebug.Log("相手の反対側に向かっていくぜ☆ input.leverX = " + input.leverX); //} Pull_Back(); } else // レバーを倒していない時(ここにはこない?) { //if ((int)PlayerIndex.Player1 == playerIndex) //{ // //ebug.Log("止まっているぜ☆ input.leverX = " + input.leverX); //} } } else// 左も右も入力していなかったら { if (isGrounded)// 接地していれば { // 横移動の速度を0にしてピタッと止まるようにする Rigidbody2D.velocity = new Vector2(0, Rigidbody2D.velocity.y); } // 感覚的に、左から右に隙間なく切り替えたと思っていても、 // 入力装置的には、左から右(その逆も)に切り替える瞬間、どちらも押していない瞬間が発生する。 if (8 < animator.GetInteger(SceneCommon.INTEGER_LEVER_X_NEUTRAL))// レバーを放した 数フレーム目から、レバーが離れた判定をすることにする。 { //if ((int)PlayerIndex.Player1 == playerIndex) //{ // //ebug.Log("Rigidbody2D.velocity.x = " + Rigidbody2D.velocity.x + " ストップ!"); //} if (isGrounded)// 接地していれば { animator.SetInteger(SceneCommon.INTEGER_ACTIONING, (int)TilesetfileType.Stand); } } } //ebug.Log("leverY = "+ leverY + " player_to_rigidbody2D[" + iPlayer + "].velocity = " + player_to_rigidbody2D[iPlayer].velocity); if (0 != input.leverY)// 上か下キーを入力していたら { if (!astateRecord.Tags.Contains(Animator.StringToHash(AControl.TAG_BUSYY))) { if (0 < input.leverY) // 上キーを入力したら { if (isGrounded) // 接地していれば { // ジャンプするぜ☆ Pull_Jump(); } } else if (input.leverY < 0) // 下キーを入力したら { if (isGrounded) // 接地していれば { // 屈むぜ☆ Pull_Crouch(); } } } } else // 下も上も入力していなかったら { } //} #endregion #region 行動 //if (buttonDownHP && buttonDownHK) //{ // //ebug.Log("投了☆!"); // Resign(); //} //else if (input.buttonDownLP) { //ebug.Log("button BUTTON_03_P1_LP"); Pull_LightPunch(); } else if (input.buttonDownMP) { //ebug.Log("button BUTTON_04_P1_MP"); Pull_MediumPunch(); } else if (input.buttonDownHP) { //ebug.Log("button BUTTON_05_P1_HP"); Pull_HardPunch(); } else if (input.buttonDownLK) { //ebug.Log("button BUTTON_06_P1_LK"); Pull_LightKick(); } else if (input.buttonDownMK) { //ebug.Log("button BUTTON_07_P1_MK"); Pull_MediumKick(); } else if (input.buttonDownHK) { //ebug.Log("button BUTTON_08_P1_HK"); Pull_HardKick(); } else if (input.buttonDownPA) { //ebug.Log("button BUTTON_09_P1_PA"); } #endregion if (SceneCommon.READY_TIME_LENGTH < mainCameraScript.ReadyingTime) { // 当たり判定くん Motor.Instance.Update(animator, AControl.Instance, playerIndex, transform, hitboxsSpriteRenderer, weakboxCollider2D); } }
void Update() { if (Initialised) { List <RadialButton> CurrentOptions = CurrentOptionsDepth [CurrentMenuDepth]; MousePosition = new Vector2(CommonInput.mousePosition.x, CommonInput.mousePosition.y); toVector2M = new Vector2(CommonInput.mousePosition.x, CommonInput.mousePosition.y); double IndividualItemDegrees = 0; Vector2 Relativecentre = toVector2M - centercirlce; //Logger.Log (Relativecentre.ToString ()+ " Relativecentre" , Category.RightClick); double Angle = (Mathf.Atan2(Relativecentre.y, Relativecentre.x) * Mathf.Rad2Deg); //off sets the Angle because it starts as -180 to 180 Angle += -90; Angle = Angle + SelectionRange[CurrentMenuDepth][1]; if (Angle > 0) { Angle += -360; } Angle = Angle * -1; //Turns it from negative to positive //Logger.Log (Angle.ToString () + " old Angle", Category.RightClick); //Logger.Log (((int)((Angle) / (SelectionRange[CurrentMenuDepth][0] / CurrentOptions.Count))).ToString () + " old MenuItem", Category.RightClick); //Logger.Log (Angle.ToString ()+ " Angle" , Category.RightClick); IndividualItemDegrees = SelectionRange[CurrentMenuDepth][0] / CurrentOptions.Count; Angle = Angle + ((IndividualItemDegrees) / 2); //Offsets by half a menu so So the different selection areas aren't in the middle of the menu if (Angle > 360) //Makes sure it's 360 { Angle += -360; } MenuItem = (int)((Angle) / (IndividualItemDegrees)); //Logger.Log ((IndividualItemDegrees).ToString () + " Density", Category.RightClick); //Logger.Log (Angle.ToString () + " Angle", Category.RightClick); //Logger.Log (SelectionRange[CurrentMenuDepth][0].ToString () + " Range", Category.RightClick); //Logger.Log (SelectionRange[CurrentMenuDepth][1].ToString () + " MinimumAngle", Category.RightClick); //Logger.Log (MenuItem.ToString () + "MenuItem", Category.RightClick); //Logger.Log (CurrentOptions.Count.ToString () + "CurrentOptions.Count", Category.RightClick); if (!(MenuItem > (CurrentOptions.Count - 1)) && !(MenuItem < 0)) //Ensures its in range Of selection { LastInRangeSubMenu = Time.time; Selected = CurrentOptions [MenuItem]; if (!(LastSelected == Selected)) { if (LastSelectedset) { if (LastSelected.MenuDepth == CurrentMenuDepth) { LastSelected.title.text = ""; LastSelected.transform.SetSiblingIndex(LastSelected.DefaultPosition); LastSelected.SetColour(LastSelected.DefaultColour); } else { ResetDepthOnDestroy [CurrentMenuDepth] = LastSelected; } } CurrentOptions [MenuItem].title.text = CurrentOptions [MenuItem].Hiddentitle; CurrentOptions [MenuItem].DefaultColour = CurrentOptions [MenuItem].ReceiveCurrentColour(); CurrentOptions [MenuItem].DefaultPosition = CurrentOptions[MenuItem].transform.GetSiblingIndex(); CurrentOptions [MenuItem].SetColour(CurrentOptions [MenuItem].DefaultColour + (Color.white / 3f)); CurrentOptions [MenuItem].transform.SetAsLastSibling(); LastSelected = CurrentOptions [MenuItem]; LastSelectedset = true; LastSelectedTime = Time.time; //Logger.Log (LastSelectedTime.ToString (), Category.RightClick); } if (LastSelectedset) { if ((Time.time - LastSelectedTime) > 0.4f) //How long it takes to make a menu { if ((!(DepthMenus [CurrentMenuDepth] [MenuItem].SubMenus == null)) && DepthMenus [CurrentMenuDepth] [MenuItem].SubMenus.Count > 0) { Logger.Log(MenuItem.ToString() + " Selected", Category.RightClick); int NewMenuDepth = CurrentMenuDepth; LastSelectedTime = Time.time; NewMenuDepth = NewMenuDepth + 100; int InitialAngle = MenuItem * (360 / CurrentOptions.Count); SpawnButtons(DepthMenus [CurrentMenuDepth] [MenuItem].SubMenus, NewMenuDepth, InitialAngle); } } } } else { if ((Time.time - LastInRangeSubMenu) > 0.3f && (CurrentMenuDepth > 100)) //How long it takes to exit a menu //Logger.Log ("yo am Destroying", Category.UI); { if (ResetDepthOnDestroy.ContainsKey(CurrentMenuDepth)) { ResetDepthOnDestroy [CurrentMenuDepth].title.text = ""; ResetDepthOnDestroy [CurrentMenuDepth].transform.SetSiblingIndex(ResetDepthOnDestroy [CurrentMenuDepth].DefaultPosition); ResetDepthOnDestroy [CurrentMenuDepth].SetColour(ResetDepthOnDestroy [CurrentMenuDepth].DefaultColour); } else { LastSelected.transform.SetSiblingIndex(LastSelected.DefaultPosition); LastSelected.SetColour(LastSelected.DefaultColour); LastSelected.title.text = ""; LastSelected = null; LastSelectedset = false; } List <RadialButton> Acopy = CurrentOptions; for (int i = 0; i < Acopy.Count; i++) { Destroy(CurrentOptions[i].gameObject); } //Cleans up the dictionarys SelectionRange.Remove(CurrentMenuDepth); CurrentOptionsDepth.Remove(CurrentMenuDepth); DepthMenus.Remove(CurrentMenuDepth); ResetDepthOnDestroy.Remove(CurrentMenuDepth); CurrentMenuDepth = CurrentMenuDepth - 100; LastSelectedset = false; } } } if (CommonInput.GetMouseButtonUp(1)) { if (Selected) { Selected.Action?.Invoke(); //Logger.Log ("yo this "+Selected.title.text , Category.RightClick); } LastSelectedset = false; Destroy(gameObject); } }
private void Update() { if (state == State.SELECTING) { // ignore when we are over UI if (EventSystem.current.IsPointerOverGameObject()) { return; } //check which objects we are over, pick the top one to spawn if (CommonInput.GetMouseButtonDown(0)) { //NOTE: Avoiding multiple enumeration by converting IEnumerables to lists. var hitGOs = MouseUtils.GetOrderedObjectsUnderMouse(layerMask, go => go.GetComponent <CustomNetTransform>() != null) .Select(r => r.GetComponentInParent <CustomNetTransform>().gameObject).ToList(); //warn about objects which cannot be cloned var nonPooledHits = hitGOs .Where(go => PoolManager.DeterminePrefab(go) == null).ToList(); if (nonPooledHits.Any()) { foreach (GameObject nonPooled in nonPooledHits) { Logger.LogWarningFormat("Object {0} does not have a PoolPrefabTracker component and its name" + " did not match one of our existing prefabs " + "therefore cannot be cloned (because we wouldn't know which prefab to instantiate). " + "Please attach this component to the object and specify the prefab" + " to allow it to be cloned.", Category.ItemSpawn, nonPooled.name); } } var pooledHits = hitGOs.Where(go => PoolManager.DeterminePrefab(go) != null).ToList(); if (pooledHits.Any()) { toClone = pooledHits.First(); ToState(State.DRAWING); } } } else if (state == State.DRAWING) { cursorObject.transform.position = Camera.main.ScreenToWorldPoint(CommonInput.mousePosition); if (CommonInput.GetMouseButtonDown(0)) { Vector3Int position = cursorObject.transform.position.RoundToInt(); position.z = 0; if (MatrixManager.IsPassableAt(position, false)) { if (CustomNetworkManager.IsServer) { PoolManager.NetworkClone(toClone, position); } else { DevCloneMessage.Send(toClone, (Vector3)position); } } } } }
public void LaunchingTheApplication() { CommonInput objInput = new CommonInput(TestContext.DataRow); }
private void Update() { if (ControlledByPlayer == NetworkInstanceId.Invalid) { return; } //don't start it too early: if (!isServer && !PlayerManager.LocalPlayer) { return; } //only perform the rest of the update if the weapon is in the hand of the local player or //we are the server if (!isServer && PlayerManager.LocalPlayer != ClientScene.FindLocalObject(ControlledByPlayer)) { return; } //update the time until the next shot can happen if (FireCountDown > 0) { FireCountDown -= Time.deltaTime; //prevents the next projectile taking miliseconds longer than it should if (FireCountDown < 0) { FireCountDown = 0; } } //this will only be executed on the server since only the server //maintains the queued actions if (queuedShots.Count > 0 && FireCountDown <= 0) { //fire the next shot in the queue DequeueAndProcessServerShot(); } if (queuedUnload && queuedShots.Count == 0) { // done processing shot queue, // perform the queued unload action, causing all clients and server to update their version of this Weapon //due to the syncvar hook MagNetID = NetworkInstanceId.Invalid; queuedUnload = false; } if (queuedLoadMagNetID != NetworkInstanceId.Invalid && queuedShots.Count == 0) { //done processing shot queue, perform the reload, causing all clients and server to update their version of this Weapon //due to the syncvar hook MagNetID = queuedLoadMagNetID; queuedLoadMagNetID = NetworkInstanceId.Invalid; } //rest of the Update is only needed for the weapon if it is held by the local player if (PlayerManager.LocalPlayer != ClientScene.FindLocalObject(ControlledByPlayer)) { return; } //check if burst should stop if the weapon is held by the local player if (CommonInput.GetMouseButtonUp(0)) { StopAutomaticBurst(); } }
public static EAPOutput Send <T>(CommonInput inputObj) where T : CommonInput { EAPOutput output = new EAPOutput(); try { lock (SyncObj) { EAPInput input = new EAPInput(); input.InputMessage = inputObj.GetInputMessage <T>((T)inputObj); Log.Logger.Info(String.Format("[ATS Request]:{0}", input.InputMessage)); output = _MessageExchangeServiceClient.EAPRequest(input); XDocument xdoc; try { Log.Logger.DebugFormat("[MES Reply]::ErrorCode: {0}, CnErrorText: {1}, EnErrorText: {2}", output.ErrCode, output.CNErrMsg, output.ENErrMsg); if (String.IsNullOrEmpty(output.OutputMessage)) { throw new MessageIsEmptyException(); } xdoc = XDocument.Parse(output.OutputMessage); var formattedXml = (xdoc.Declaration != null ? xdoc.Declaration + "\r\n" : "") + xdoc.ToString(); Log.Logger.InfoFormat("[MES Reply]:Message:{0}", formattedXml.ToString()); } catch (Exception e) { Log.Logger.DebugFormat("[MES Reply]: OutputMessage: {0}", output.OutputMessage); throw e; } String equipmentId = xdoc.Root.Element("EquipmentId").Value; String transactionId = xdoc.Root.Element("TransactionId").Value; if (xdoc.Root.Name.Equals(inputObj.GetReplyRootName)) { throw new MesReplyMisMatchException(); } if (!inputObj.EquipmentId.Equals(equipmentId)) { throw new EquipmentIdMisMatchException(); } if (!inputObj.TransactionId.Equals(transactionId)) { throw new TransactionIdMisMatchException(); } return(output); } } catch (MessageIsEmptyException ex) { Log.Logger.Error(ex.Message); LogShown.RecordLog((String)Application.Current.FindResource("WariningMessage_TrackInToMesOutputMessageIsEmpty"), LogLevel.Warn); output.ErrCode = "2000"; output.ENErrMsg = (String)CommonParameter.EnLangResourceDictionary["WariningMessage_TrackInToMesOutputMessageIsEmpty"]; } catch (EquipmentIdMisMatchException ex) { Log.Logger.Error(ex.Message); LogShown.RecordLog((String)Application.Current.FindResource("WariningMessage_TrackInToMesEquipmentIdMisMatch"), LogLevel.Warn); output.ErrCode = "2001"; output.ENErrMsg = (String)CommonParameter.EnLangResourceDictionary["WariningMessage_TrackInToMesEquipmentIdMisMatch"]; } catch (TransactionIdMisMatchException ex) { Log.Logger.Error(ex.Message); LogShown.RecordLog((String)Application.Current.FindResource("WariningMessage_TrackInToMesTransactionIdMisMatch"), LogLevel.Warn); output.ErrCode = "2002"; output.ENErrMsg = (String)CommonParameter.EnLangResourceDictionary["WariningMessage_TrackInToMesTransactionIdMisMatch"]; } catch (EndpointNotFoundException ex) { Log.Logger.Error(ex.Message); LogShown.RecordLog((String)Application.Current.FindResource("WariningMessage_TrackInToMesEndpointNotFound"), LogLevel.Warn); output.ErrCode = "2003"; output.ENErrMsg = (String)CommonParameter.EnLangResourceDictionary["WariningMessage_TrackInToMesEndpointNotFound"]; } catch (TimeoutException ex) { Log.Logger.Error(ex.Message); LogShown.RecordLog((String)Application.Current.FindResource("WariningMessage_TrackInToMesTimeout"), LogLevel.Warn); output.ErrCode = "2004"; output.ENErrMsg = (String)CommonParameter.EnLangResourceDictionary["WariningMessage_TrackInToMesTimeout"]; } catch (Exception ex) { Log.Logger.Error(ex); LogShown.RecordLog(String.Format((String)Application.Current.FindResource("ErrorMessage_TrackInToMesUnknownError"), ex.Message), LogLevel.Error); output.ErrCode = "2999"; output.ENErrMsg = "[ATS] TrackIn to MES Unkown Error"; } return(output); }