public void EarlyActionEasy(BoardController boardController, int myColor, int rivalColor) { //リーチラインの妨害を最優先とし、それ以外はゲームにおいて要となるポジションを埋めに行く (int x, int z)? candidatePos = null; GoSituations[] reachLines = boardController.HasLines(3); if (reachLines != null) { GoSituations[] myReachLines = reachLines.Where(item => item.BoardStatus == myColor).ToArray(); GoSituations[] rivalReachLines = reachLines.Where(item => item.BoardStatus == rivalColor).ToArray(); if (myReachLines.Length > 0) { //自身のリーチラインに碁を置ける場合は最優先でチェックメイトしにいく candidatePos = commonBehavior.PutReachLine(myReachLines, boardController); } if (candidatePos == null & rivalReachLines.Length > 0) { //相手のリーチラインがあればそのラインを止めに行く candidatePos = commonBehavior.PutReachLine(rivalReachLines, boardController); } } if (candidatePos == null) { //特にチェックメイトにからむラインがなければ重要ポジションを埋める candidatePos = earlyBehavior.PutImportantPosition(boardController); } boardController.AddGo(candidatePos.Value.x, candidatePos.Value.z, myColor); }
public void OnClicked() { playSE.PlaySound(AudioConfig.GoPutButtonIndex); boardController.AddGo(putPositionPanel.IndexXZ.x, putPositionPanel.IndexXZ.z, goColor); //連続してクリックされるのを防ぐため初回クリック時にボタンをfalseにする //自分のターンが回ってきたときにはGameControllerからtrueにされる this.GetComponent <Button>().enabled = false; }
public void MiddleActionEasy(BoardController boardController, int myColor, int rivalColor) { (int x, int z)? candidatePos = null; GoSituations[] single = boardController.HasLines(1); GoSituations[] preReachLines = boardController.HasLines(2); GoSituations[] reachLines = boardController.HasLines(3); if (reachLines != null) { GoSituations[] myReachLines = reachLines.Where(item => item.BoardStatus == myColor).ToArray(); GoSituations[] rivalReachLines = reachLines.Where(item => item.BoardStatus == rivalColor).ToArray(); if (myReachLines.Length > 0) { candidatePos = commonBehavior.PutReachLine(myReachLines, boardController); } if (candidatePos == null & rivalReachLines.Length > 0) { candidatePos = commonBehavior.PutReachLine(rivalReachLines, boardController); } } //相手の2連ラインがあればそれを邪魔する if (candidatePos == null) { GoSituations[] rivalPreReachLines = preReachLines.Where(item => item.BoardStatus == rivalColor).ToArray(); candidatePos = middleBehavior.PutPreReachLine(rivalPreReachLines, boardController); } //孤立している自身の碁があれば2連を作りに行く if (candidatePos == null) { single = single.Where(item => item.BoardStatus == myColor).ToArray(); candidatePos = middleBehavior.MakePreReachLine(single, boardController); } //自身の2連ラインがあればリーチを作りに行く if (candidatePos == null) { GoSituations[] myPreReachLines = preReachLines.Where(item => item.BoardStatus == myColor).ToArray(); candidatePos = middleBehavior.PutPreReachLine(myPreReachLines, boardController); } //上記いずれの処理も実行しなかった場合、ランダムな位置に置く if (candidatePos == null) { candidatePos = commonBehavior.NoPlan(boardController.VacantPos()); } boardController.AddGo(candidatePos.Value.x, candidatePos.Value.z, myColor); }
public void LateActionEasy(BoardController boardController, int myColor, int rivalColor) { (int x, int z)? candidatePos = null; GoSituations[] single = boardController.HasLines(1); GoSituations[] preReachLines = boardController.HasLines(2); GoSituations[] reachLines = boardController.HasLines(3); if (reachLines != null) { GoSituations[] myReachLines = reachLines.Where(item => item.BoardStatus == myColor).ToArray(); GoSituations[] rivalReachLines = reachLines.Where(item => item.BoardStatus == rivalColor).ToArray(); if (myReachLines.Length > 0) { candidatePos = commonBehavior.PutReachLine(myReachLines, boardController); } if (candidatePos == null & rivalReachLines.Length > 0) { candidatePos = commonBehavior.PutReachLine(rivalReachLines, boardController); } } if (candidatePos == null) { GoSituations[] myPreReachLines = preReachLines.Where(item => item.BoardStatus == myColor).ToArray(); candidatePos = middleBehavior.PutPreReachLine(myPreReachLines, boardController); } if (candidatePos == null) { GoSituations[] rivalPreReachLines = preReachLines.Where(item => item.BoardStatus == rivalColor).ToArray(); candidatePos = middleBehavior.PutPreReachLine(rivalPreReachLines, boardController); } if (candidatePos == null) { single = single.Where(item => item.BoardStatus == myColor).ToArray(); candidatePos = middleBehavior.MakePreReachLine(single, boardController); } if (candidatePos == null) { candidatePos = commonBehavior.NoPlan(boardController.VacantPos()); } boardController.AddGo(candidatePos.Value.x, candidatePos.Value.z, myColor); }
private async void ListenRival() { connectingText.enabled = true; try{ await UniTask.Run(async() => { (int x, int z, int y, int color)rivalAction = await firebaseUpdateBoard.WaitRivalAction(); boardController.AddGo(rivalAction.x, rivalAction.z, rivalAction.color); boardController.boardUpdated += SyncBoard; }); } catch (GiveUpSignalReceive) { //相手がギブアップした場合の処理 gameController.CurrentTurn = gameController.Player; boardController.boardUpdated -= SyncBoard; timeCountPanel.SwitchTimeCountStatus(false); rivalGiveUp(giveUpText); } catch { connectFailedPanel.SetActive(true); } finally{ connectingText.enabled = false; } }