Skip to content

Instantly share code, notes, and snippets.

@aki-lua87
Created June 25, 2021 19:34
Show Gist options
  • Save aki-lua87/95c5d986279316797b84fc5c364063c8 to your computer and use it in GitHub Desktop.
Save aki-lua87/95c5d986279316797b84fc5c364063c8 to your computer and use it in GitHub Desktop.
連打
// 各マスからのエントリポイント
public void PutStone()
{
var x = int.Parse(interactX);
var y = int.Parse(interactY);
if(mode != 0)
{
// 棋譜並べ中に置きたいのやつ対応
var isPut = putStoneKihu(x,y);
if(!isPut)
{
return;
}
isBlackTurn = !isBlackTurn;
// 次の石が置けないなら
if(!isNetxStonePut(isBlackTurn))
{
isBlackTurn = !isBlackTurn;
// TebanSkip();
}
return;
}
// 適正チェック マスのオーナーがプレイヤーObjのオーナーと一致するか
// 名前で比較
var player = isBlackTurn ? playerBText.text : playerWText.text;
var masuPlayer = Networking.GetOwner(masuXY[x-1][y-1]);
if(player != masuPlayer.displayName)
{
return;
}
// どちらかが置かれていたら抜ける
if(isExistStone(x,y))
{
return;
}
// 石をひっくりかえす or 返せるかチェック
var b1 = execFlipStones(x,y, 1, 0, isBlackTurn);
var b2 = execFlipStones(x,y, 1, 1, isBlackTurn);
var b3 = execFlipStones(x,y, 1, -1, isBlackTurn);
var b4 = execFlipStones(x,y, 0, -1, isBlackTurn);
var b5 = execFlipStones(x,y, 0, 1, isBlackTurn);
var b6 = execFlipStones(x,y, -1, 0, isBlackTurn);
var b7 = execFlipStones(x,y, -1, 1, isBlackTurn);
var b8 = execFlipStones(x,y, -1, -1, isBlackTurn);
if(b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8)
{
// 1つでもひっくりかえせたら置けてるので石を置く
if (isBlackTurn)
{
putStoneB(x,y);
}else{
putStoneW(x,y);
}
// 効果音
audioSource.Play();
// 棋譜
writeKihu(x,y);
// 手番を相手に
isBlackTurn = !isBlackTurn;
tebanHyoji();
allCountStone();
if(!isNetxStonePut(isBlackTurn))
{
// 次の石が置けないなら
TebanSkip();
}
}
else{
// 違うならこの話は無かったことに
// 何らかの副作用は欲しいところ
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment