예제 #1
0
    // li--ok
    private static Skill checkSupportAndAttack(Vector3i position, GameBoard boardRef)
    {
        GameChess chess          = boardRef.getGameChessRef(position);
        int       chessDirection = chess.getDirection();
        GameChess fChess         = boardRef.getPointedGameChessRef(position, chessDirection);

        Skill skill = null;

        if (fChess == null)
        {
            return(null);
        }
        else
        {
            if (isFriend(fChess, chess))
            {
                skill = new Skill(EffectType.support, fChess.getPosition(), position);
            }
            else
            {
                skill = new Skill(EffectType.attack, fChess.getPosition(), position);
            }
        }
        return(skill);
    }
예제 #2
0
    // guan--ok
    private static Skill checkBasic(Vector3i position, GameBoard boardRef)
    {
        GameChess chess = boardRef.getGameChessRef(position);

        if (chess == null)
        {
            return(null);
        }

        Vector3i chessPos       = chess.getPosition();
        int      chessDirection = chess.getDirection();

        // 根据前后格 来判定血量加成(作用于自身)
        Skill skill = new Skill(EffectType.basic, chessPos, chessPos);

        GameChess forwardChess = boardRef.getPointedGameChessRef(position, chessDirection);

        GameChess backwardChess = boardRef.getPointedGameChessRef(position, (chessDirection + 3) % 6);

        //自身所占格子的生命值加成
        skill._HealthChange = 1;

        // 仅友方或空格加成血量
        if (forwardChess == null || isFriend(forwardChess, chess))
        {
            skill._HealthChange += 1;
        }
        // 仅友方或空格加成血量
        if (backwardChess == null || isFriend(backwardChess, chess))
        {
            skill._HealthChange += 1;
        }
        return(skill);
    }
예제 #3
0
    // li--ok
    private static Skill checkThron(Vector3i position, GameBoard boardRef)
    {
        GameChess chess = boardRef.getGameChessRef(position);

        if (chess == null)
        {
            return(null);
        }

        Vector3i chessPos       = chess.getPosition();
        int      chessDirection = chess.getDirection();
        Skill    skill          = null;
        //fChess是这个棋子背后的棋子
        GameChess fChess = boardRef.getPointedGameChessRef(position, (chessDirection + 3) % 6);

        if (isFriend(chess, fChess))
        {
            int dir01 = chessDirection;
            int dir02 = fChess.getDirection();


            if ((dir01 + 6 - dir02) % 6 == 3)
            {
                Vector3i pos = chessPos;
                skill = new Skill(EffectType.thron, pos, pos);
                skill._AttackChange = 2;
            }
        }
        return(skill);
    }
예제 #4
0
    // li--ok
    private static Skill checkRing(Vector3i position, GameBoard boardRef)
    {
        GameChess chess = boardRef.getGameChessRef(position);

        if (chess == null)
        {
            return(null);
        }
        Vector3i chessPos       = chess.getPosition();
        int      chessDirection = chess.getDirection();

        Skill skill = new Skill(EffectType.ring, chessPos, chessPos);

        GameChess fChess = boardRef.getPointedGameChessRef(chessPos, chessDirection);
        int       result = -1;

        if (fChess != null && isFriend(fChess, chess))
        {
            //对于所有五种方向进行判断(除了自己指向的方向)
            for (int i = 1; i < 6; i++)
            {
                //获得现在这个方向的棋子
                GameChess fg = boardRef.getPointedGameChessRef(chessPos, (chessDirection + i) % 6);
                if (fg != null)
                {
                    //如果非空则找这个棋子指向的对象
                    GameChess fgfg = boardRef.getPointedGameChessRef(fg.getPosition(), fg.getDirection());
                    //如果这个棋子指向自己
                    if (fgfg != null && fgfg.getPosition() == chess.getPosition() && isFriend(chess, fg))
                    {
                        //对这个方向进行搜索
                        result = getNextLength(chess, fg, boardRef);
                        //递归回来的结果如果是可用的
                        if (result > 0)
                        {
                            break;
                        }
                        //否则继续找其他方向
                    }
                }
            }
        }

        if (result > 0)
        {
            skill._HealthChange += result;
            return(skill);
        }
        else
        {
            return(null);
        }
    }
예제 #5
0
    public bool moveChess(Vector3i position)
    {
        GameChess gc = getGameChessRef(position);

        //如果有这个棋子并且有移动技能

        if (gc != null && gc.hasSuchKindSkill(EffectType.move))
        {
            //移动并且告诉Judgement去掉其他移动技能
            //先把这个棋子从原来GameChessList那里抹杀掉
            _GameChessList.Remove(gc);
            //然后从ChessBoard层面也抹杀掉
            _ChessBoard.removeChess(gc.getPosition());
            //然后加入新棋子
            Skill sk = gc.findSkill(EffectType.move);
            Chess nc = _ChessBoard.placeChess(new Chess(gc.getPlayerID(), gc.getDirection(), sk.getEffectPosition()));
            _GameChessList.Add(new GameChess(nc));

            Vector3i pos = getPointedPosition(position, gc.getDirection());
            Rule.removeNewSkill(EffectType.move, pos, this);
            return(true);
        }
        return(false);
    }
예제 #6
0
 //递归函数
 private static int getNextLength(GameChess origin, GameChess thisC, GameBoard boardRef)
 {
     //当递归回到了头的时候-->返回长度
     if (thisC.getPosition() == origin.getPosition())
     {
         return(1);
     }
     else
     {
         //对于所有五种方向进行判断(除了自己指向的方向)
         for (int i = 1; i < 6; i++)
         {
             Vector3i pos            = thisC.getPosition();
             int      chessDirection = thisC.getDirection();
             //获得现在这个方向的棋子
             GameChess fChess = boardRef.getPointedGameChessRef(pos, (chessDirection + i) % 6);
             if (fChess != null)
             {
                 //如果非空则找这个棋子指向的对象
                 GameChess fcfc = boardRef.getPointedGameChessRef(fChess.getPosition(), fChess.getDirection());
                 //如果这个棋子指向自己
                 if (fcfc != null && fcfc.getPosition() == thisC.getPosition() && isFriend(fChess, thisC))
                 {
                     //对这个方向进行搜索
                     int result;
                     result = getNextLength(origin, fChess, boardRef);
                     //递归回来的结果如果是可用的
                     if (result > 0)
                     {
                         return(result + 1);
                     }
                     //否则继续找其他方向
                 }
             }
         }
         //如果这里所有方向都不行,则返回不可用的-1
         return(-1);
     }
 }
예제 #7
0
    // GameChess forwadChess = boardRef.getPointedGameChessCopy(position, chess.getDirection());

    // GameChess backwardChess = boardRef.getPointedGameChessCopy(position, (chess.getDirection() + 3) % 6);

    // check skill
    // li--ok
    private static Skill checkKiss(Vector3i position, GameBoard boardRef)
    {
        GameChess chess          = boardRef.getGameChessRef(position);
        Vector3i  chessPos       = chess.getPosition();
        int       chessDirection = chess.getDirection();
        Skill     skill          = null;
        GameChess fChess         = boardRef.getPointedGameChessRef(position, chessDirection);

        if (isFriend(chess, fChess))
        {
            Vector3i fChessPos       = fChess.getPosition();
            int      fChessDirection = fChess.getDirection();
            // 当前Chess指向对象所指向的位置
            Vector3i fPointedPos = boardRef.getPointedPosition(fChessPos, fChessDirection);
            if (fPointedPos == chessPos)
            {
                Vector3i pos = boardRef.getPointedPosition(chessPos, (chessDirection + 3) % 6);
                skill = new Skill(EffectType.kiss, pos, pos);
                skill._AttackChange = -2;
            }
        }
        return(skill);
    }