예제 #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);
    }
예제 #2
0
 /// <summary>
 /// 重置棋子情境状态
 /// </summary>
 public void ResetChessSituationState()
 {
     if (chessSituationState != ChessSituationState.Idle)
     {
         chessSituationState = ChessSituationState.Idle;
     }
 }
예제 #3
0
 /// <summary>
 /// 提示可吃事件触发,自身状态被标记为可吃
 /// </summary>
 /// <param name="point"></param>
 public void TipsBeTarget(Vector2 point)
 {
     if (GameUtil.CompareVector2(GameCache.Chess2Vector[gameObject], point))
     {
         chessSituationState = ChessSituationState.BeTaget;
     }
 }
예제 #4
0
    protected ChessSituationState chessSituationState;      //棋子形势状态

    public virtual void Awake()
    {
        createManager          = GameObject.Find("CreateManager").GetComponent <CreateManager>();
        chessReciprocalState   = ChessReciprocalState.unChoosed;
        chessSituationState    = ChessSituationState.Idle;
        PoolManager.PushEvent += SubscribeEvents;//棋子被创建时就该订阅这一堆事件
        //SubscribeEvents(gameObject);
        PoolManager.TakeEvent    += SubscribeEvents;
        PoolManager.RestoreEvent += CancelSubscribeEvents;
    }
예제 #5
0
    public virtual void Awake()
    {
        createManager             = CreateManager.Instance;
        chessReciprocalState      = ChessReciprocalState.unChoosed;
        chessSituationState       = ChessSituationState.Idle;
        PoolManager.PushEvent    += SubscribeEvents;//棋子被创建时就该订阅这一堆事件
        PoolManager.TakeEvent    += SubscribeEvents;
        PoolManager.RestoreEvent += CancelSubscribeEvents;

        gameObject.AddComponent <AttrBox>();
        attrBox = gameObject.GetComponent <AttrBox>();
        attrBox.SetAttrList(ChessConfig.GetAttrList(chessName));
    }