예제 #1
0
    /// <summary>
    /// 判断是否会将军
    /// </summary>
    public bool DetectJiangJun(Dictionary <GameObject, Vector2> chess2Vector, Dictionary <Vector2, GameObject> vector2Chess)
    {
        //就是判断当前可移动的点包含将军的位置
        Vector2[] canMovePoints = CanMovePoints(chess2Vector, vector2Chess).ToArray();

        for (int i = 0; i < canMovePoints.Length; i++)
        {
            if (GetComponent <ChessCamp>().camp == Camp.Red)
            {
                if (canMovePoints[i] == chess2Vector[createManager.GetBlackBoss()])
                {
                    Debug.Log("将军,黑方注意");
                    chessSituationState = ChessSituationState.Attacking;
                    createManager.GetBlackBoss().GetComponent <Chess_Boss>().chessSituationState = ChessSituationState.BeAttacked;
                    return(true);
                }
            }
            else
            {
                if (canMovePoints[i] == chess2Vector[createManager.GetRedBoss()])
                {
                    Debug.Log("将军,红方注意");
                    chessSituationState = ChessSituationState.Attacking;
                    createManager.GetRedBoss().GetComponent <Chess_Boss>().chessSituationState = ChessSituationState.BeAttacked;
                    return(true);
                }
            }
        }
        chessSituationState = ChessSituationState.Idle;
        return(false);
    }