public override void InputStateUpdate() { //Debug.Log("PieceOperation"); // 游戏场景射线检测 GetHoverGameObject(); // GUI射线检测 GetHoverGUI(); GameObject CurrentHoverHandCard = GetHoverHandCard(); GameObject CurrentHoverPiece = GetHoverPiece(); GameObject CurrentHoverOperatableTargetMove = GetHoverOperatableTargetMove(); GameObject CurrentHoverContainUnitIcon = GetHoverContainUnitIcon(); if (CurrentHoverPiece != null) { //Debug.Log(CurrentHoverPiece.transform.parent.name); } if (CurrentHoverHandCard != null) { // 如果此时鼠标悬停在一个GUI物体上 if (Input.GetMouseButtonDown(0)) { // 如果此时鼠标悬停在一个手牌物体上 if (Input.GetMouseButtonDown(0)) { // 如果在“棋子操作”状态下点击手牌则取消选择当前操作棋子并进入“手牌操作”状态 DisselectCurrentOperationPiece(); MainCardDisplayController.MainDisplayCardDisplayOff(); // 将点击的手牌作为当前操作手牌并进入“手牌操作”状态 SelectCurrentOperationHandCard(CurrentHoverHandCard); } else { // 如果鼠标没有按下(悬停处理) // 展示该手牌对应的卡牌大图 CurrentHoverHandCard.GetComponent <HandCardController>().GetCard().FetchInfoFromHandCard(MainCardDisplayController); MainCardDisplayController.MainDisplayCardDisplayOn(); } } } else if (CurrentHoverPiece != null) { // 如果此时鼠标悬停在一个棋子物体上 if (Input.GetMouseButtonDown(0)) { // 如果此时鼠标左键点击一个棋子(按下处理) //SelectCurrentOperationPiece(CurrentHoverPiece); // 如果点击棋子是敌对并且可以攻击则进行攻击结算并返回状态idle if (MainDiplomacyManager.GetDiplomacy(GetCurrentPlayerID(), CurrentHoverPiece.GetComponent <PieceStateController>().GetOwner()) == 0) { Debug.Log("Attack a piece"); // 并且这个棋子在当前操作棋子的攻击范围内 if (CurrentHoverPiece.GetComponent <PieceStateController>().IsAttackTarget == true) { GetCurrentOperationPiece().GetComponent <PieceOperationController>().AttackTarget(CurrentHoverPiece.transform.parent.gameObject); } DisselectCurrentOperationPiece(); } // 如果点击棋子是自己的则切换当前操作棋子,状态仍然留在“棋子操作状态” if (GetCurrentPlayerID() == CurrentHoverPiece.GetComponent <PieceStateController>().GetOwner()) { SelectCurrentOperationPiece(CurrentHoverPiece.transform.parent.gameObject); } } else { // 如果鼠标没有按下(悬停处理) // 展示该棋子对应的卡牌大图 MainCardDisplayController.LoadInfoFromPiece(CurrentHoverPiece); MainCardDisplayController.MainDisplayCardDisplayOn(); } } else if (CurrentHoverOperatableTargetMove != null) { // 如果此时鼠标悬停在一个可移动位置上 if (Input.GetMouseButtonDown(0)) { // 其实这里要发送一个移动请求给服务器 // 如果此时鼠标左键点击该可移动位置则调用棋子的位移函数移动棋子 GetCurrentOperationPiece().GetComponentInChildren <PieceOperationController>().MoveToTareget(CurrentHoverOperatableTargetMove); DisselectCurrentOperationPiece(); } } else if (CurrentHoverContainUnitIcon != null) { } else { // 如果鼠标悬停在其他什么物体或者没有悬停在什么物体上 if (Input.GetMouseButtonDown(0)) { Debug.Log("Piece selesct canceled."); // 单击左键取消当前单位选择 DisselectCurrentOperationPiece(); } MainCardDisplayController.MainDisplayCardDisplayOff(); } }
public override void InputStateUpdate() { //Debug.Log("Idle"); // 游戏场景射线检测 GetHoverGameObject(); // GUI射线检测 GetHoverGUI(); // 因为在Idle状态下玩家只能点击棋子和手牌,悬停棋子和手牌,所以只检测棋子和手牌即可 GameObject CurrentHoverHandCard = GetHoverHandCard(); GameObject CurrentHoverPiece = GetHoverPiece(); if (CurrentHoverHandCard != null) { //Debug.Log("233333"); // 如果此时鼠标悬停在一个手牌物体上并且当前回合是当前客户端对应玩家的回合 if (Input.GetMouseButtonDown(0) && IsCurrentPlayerRound()) { Debug.Log("click handcard"); MainCardDisplayController.MainDisplayCardDisplayOff(); // 将点击的手牌作为当前操作手牌并进入“手牌操作”状态 SelectCurrentOperationHandCard(CurrentHoverHandCard); if (GetCurrentInputState() == "HandCardOperation") { Debug.Log("GetCurrentInputState() == HandCardOperation"); } } else { //Debug.Log("233333"); // 如果鼠标没有按下(悬停处理) // 展示该手牌对应的卡牌大图 CurrentHoverHandCard.GetComponent <HandCardController>().GetCard().FetchInfoFromHandCard(MainCardDisplayController); MainCardDisplayController.MainDisplayCardDisplayOn(); } } else if (CurrentHoverPiece != null) { Debug.Log(CurrentHoverPiece.GetComponent <PieceStateController>().GetOwner() == GetCurrentPlayerID()); // 如果此时鼠标悬停在一个棋子物体上并且当前回合是当前客户端对应玩家的回合 if (Input.GetMouseButtonDown(0) && IsCurrentPlayerRound() && CurrentHoverPiece.GetComponent <PieceStateController>().GetOwner() == GetCurrentPlayerID()) { MainCardDisplayController.MainDisplayCardDisplayOff(); // 如果此时鼠标左键按下(按下处理) // 将点击的棋子作为当前操作棋子并进入“棋子操作”状态 SelectCurrentOperationPiece(CurrentHoverPiece); } else { // 如果鼠标没有按下(悬停处理) // 展示该棋子对应的卡牌大图 MainCardDisplayController.LoadInfoFromPiece(CurrentHoverPiece); MainCardDisplayController.MainDisplayCardDisplayOn(); } } else { MainCardDisplayController.MainDisplayCardDisplayOff(); } // 游戏场景射线检测 // UI层射线检测 // 悬停处理 // 鼠标左键按下处理 //if (GetCurrentInputState() == "HandCardOperation") //{ // Debug.Log("GetCurrentInputState() == HandCardOperation"); //} }