public void OnAttackChess(int attackChess, int beAttackChess) { InputManager.ClearSelectChess(); ChessEntity attack = ChessManager.FindEntityByID(attackChess); ChessEntity beAttack = ChessManager.FindEntityByID(beAttackChess); if (attack == null || beAttack == null) { return; } Vector3 selfPos = attack.transform.localPosition; Vector3 beAttackpos = new Vector3(ChessEntity.ChessInterval * (int)beAttack.chessObj.chess_index_x, 0, ChessEntity.ChessInterval * (int)beAttack.chessObj.chess_index_z); // 刚开始不能直接移动到要攻击的棋子旁边 Vector3 pos = (beAttackpos - selfPos).normalized; pos *= Vector3.Distance(beAttackpos, selfPos) - ChessEntity.ChessInterval; pos += selfPos; attack.MoveTo(pos); // 开始释放技能 attack.Target = beAttack; beAttack.Target = attack; attack.UseNormalSkill(); currentAttackChess = attack; fightMainUIPanel.SetStateInfoString("战斗中..."); }
public void OnChessMove(int chess_id, int index_x, int index_z) { InputManager.ClearSelectChess(); ChessEntity chess = chessMap.ContainsKey(chess_id) ? chessMap[chess_id] : null; if (chess == null || !chess.Ready) { return; } chess.MoveTo(index_x, index_z); }
private void OnKillChessEvent(GameEventTypes eventType, object[] args) { ChessEntity attack = args[0] as ChessEntity; ChessEntity beAttack = args[1] as ChessEntity; if (attack == null || beAttack == null) { return; } if (beAttack.GetChessType() == ChessType.ChessTypeJiang) { fightMainUIPanel.SetStateInfoString(""); Account account = KBEngine.KBEngineApp.app.player() as Account; if ((int)beAttack.chessObj.chess_owner_player == account.CampType) { GUIManager.Open <FightLostUIPanel>("Fight", "FightLostUIPanel"); } else { GUIManager.Open <FightWinUIPanel>("Fight", "FightWinUIPanel"); } } else { Account account = KBEngine.KBEngineApp.app.player() as Account; account.baseCall("KillChess", beAttack.chessObj.id); if (currentAttackChess != null && currentAttackChess == attack) { currentAttackChess.MoveTo((int)beAttack.chessObj.chess_index_x, (int)beAttack.chessObj.chess_index_z); } } currentAttackChess = null; }