/// <summary> /// 检测是否被将军 /// </summary> public void DetectBeAttacked() { Vector2 currentPos = GameCache.Chess2Vector[gameObject]; List <Vector2> enemyPoints; if (gameObject.tag == "Red") { enemyPoints = GameUtil.getTeamMovePoints(PoolManager.work_List, "Black", GameCache.Chess2Vector, GameCache.Vector2Chess); } else { enemyPoints = GameUtil.getTeamMovePoints(PoolManager.work_List, "Red", GameCache.Chess2Vector, GameCache.Vector2Chess); } foreach (Vector2 point in enemyPoints) { if (GameUtil.CompareVector2(currentPos, point)) //敌军可走点有此boss位置点,则说明在将军 { Debug.Log("将军!!"); chessSituationState = ChessSituationState.BeAttacked; //检测是否被将死 //这时就要完善假设走步的逻辑了,处理起来比较庞大。 break; } } }
/// <summary> /// 提示可吃事件触发,自身状态被标记为可吃 /// </summary> /// <param name="point"></param> public void TipsBeTarget(Vector2 point) { if (GameUtil.CompareVector2(GameCache.Chess2Vector[gameObject], point)) { chessSituationState = ChessSituationState.BeTaget; } }
/// <summary> /// 通过鼠标点击来移动 /// </summary> public void Move(Vector2 point) { if (chessReciprocalState == ChessReciprocalState.beChoosed) { Vector2[] canMovePoints = CanMovePoints(GameCache.Chess2Vector, GameCache.Vector2Chess).ToArray(); if (canMovePoints.Length > 0) { for (int i = 0; i < canMovePoints.Length; i++) { if (GameUtil.CompareVector2(point, canMovePoints[i]) == true) { if (GameController.IsBattle == true) { SetAttackerEvent(gameObject);//派发事件设置攻击者 } int x = (int)point.x; int y = (int)point.y; Vector3 target = Scene3_UI.cells[x, y].transform.position; iTween.MoveTo(gameObject, iTween.Hash("time", 0.1f, "position", target, "easetype", iTween.EaseType.linear, "onstart", "OnMoveStart", "onstarttarget", gameObject, "oncomplete", "OnMoveComplete", "oncompletetarget", gameObject)); break; } else if (chessReciprocalState != ChessReciprocalState.moving) { CancelChoose(); Scene3_UI.ResetChessBoardPoints(); } else { CancelChoose(); Scene3_UI.ResetChessBoardPoints(); } } } else { CancelChoose(); } } }