Beispiel #1
0
    private bool Move(Unit src, Unit des, Position desPos)
    {
        if (des != null && src.Owner == des.Owner)
        {
            return(false);
        }

        Ruler.ConflictResult result = des == null?Ruler.ConflictResult.Nothing:Ruler.CheckConflict(src.Type, des.Type);
        switch (result)
        {
        case Ruler.ConflictResult.Boom:
            KillEnemyEffect(board.Pick(src.Pos));
            KillEnemyEffect(board.Pick(des.Pos));
            break;

        case Ruler.ConflictResult.Src_Win:
            KillEnemyEffect(board.Pick(des.Pos));
            MoveEffect(src, desPos);
            break;

        case Ruler.ConflictResult.Des_Win:
            return(false);

        case Ruler.ConflictResult.Eat_Bread:
            Unit bread = board.Pick(des.Pos);
            MoveEffect(src, desPos);
            CollectBreadEffect(bread, src.Owner);
            break;

        case Ruler.ConflictResult.Nothing:
            MoveEffect(src, desPos);
            break;
        }
        return(true);
    }
Beispiel #2
0
    public bool CanMove(Position src, Position tar)
    {
        if (GetOwner(src) == GetOwner(tar))
        {
            return(false);
        }

        return(!hasMove && Ruler.CheckConflict(GetType(src), GetType(tar)) != Ruler.ConflictResult.Des_Win);
    }
Beispiel #3
0
    private bool _DoMove(Unit src, Unit des, Position desPos)
    {
        if (des != null && src.Owner == des.Owner)
        {
            return(false);
        }

        Ruler.ConflictResult result = des == null?Ruler.ConflictResult.Nothing:Ruler.CheckConflict(src.Type, des.Type);
        switch (result)
        {
        case Ruler.ConflictResult.Boom:
            KillEnemyEffect(board.Pick(src.Pos));
            KillEnemyEffect(board.Pick(des.Pos));
            SoundManager.Instance.PlaySound("bomb");
            break;

        case Ruler.ConflictResult.Src_Win:
            KillEnemyEffect(board.Pick(des.Pos));
            MoveEffect(src, desPos);
            SoundManager.Instance.PlaySound("gun_fire");
            break;

        case Ruler.ConflictResult.Des_Win:
            return(false);

        case Ruler.ConflictResult.Eat_Bread:
            Unit bread = board.Pick(des.Pos);
            MoveEffect(src, desPos);
            CollectBreadEffect(bread, src.Owner);
            SoundManager.Instance.PlaySound("gain_resource");
            break;

        case Ruler.ConflictResult.Nothing:
            MoveEffect(src, desPos);
            SoundManager.Instance.PlaySound("move");
            break;
        }
        return(true);
    }
Beispiel #4
0
    public bool Move(Position src, Position tar)
    {
        if (GetOwner(src) == GetOwner(tar))
        {
            return(false);
        }

        Ruler.ConflictResult result = Ruler.CheckConflict(GetType(src), GetType(tar));
        switch (result)
        {
        case Ruler.ConflictResult.Boom:
            Pick(src);
            Pick(tar);
            break;

        case Ruler.ConflictResult.Src_Win:
            Pick(tar);
            Put(tar, Pick(src));
            break;

        case Ruler.ConflictResult.Des_Win:
            return(false);

        case Ruler.ConflictResult.Eat_Bread:
            Pick(tar);
            UnitInfo info = Put(tar, Pick(src));
            playerInfo[(int)info.owner][(int)Unit.TypeEnum.Bread]++;
            break;

        case Ruler.ConflictResult.Nothing:
            Put(tar, Pick(src));
            break;
        }
        hasMove = true;
        return(true);
    }