private void PlacePawn(Move move) { if (move.Player != NextPlayer || move.To < 0 || !HasPawnsInHand(move.Player)) { throw new InvalidOperationException(); } else { GameBoard.PlaceAt(move.To, move.Player); GameHistory.SaveMove(move); if (move.Player == FieldState.White) { _whitesInHand--; } else if (move.Player == FieldState.Black) { _blacksInHand--; } if (GameBoard.GetField(move.To).IsInMill()) { CaptureEvent?.Invoke(this, move.Player); } else { NextPlayer = (FieldState)(-(int)NextPlayer); GameHistory.SaveState(GameBoard.ToString()); NextPlayersTurnEvent?.Invoke(this, NextPlayer); } } }
private void OnCapture(Piece capturedPiece) { var captureMove = new CaptureMove(Field, capturedPiece.Field, this, capturedPiece); var e = new CaptureEvent(captureMove); Capture?.Invoke(this, e); }
/// <summary> /// Initializes the capture and round events and listeners. /// </summary> private void Start() { // Create capture attempt listeners CaptureAttempted = new CaptureEvent(); // Start listening to capture attempts CaptureAttempted.AddListener(OnCaptureAttempted); // Create round event listeners RoundEnded = new RoundEvent(); // Start listening to round ends RoundEnded.AddListener(OnRoundEnded); }
/** * @brief Release the rgb camera. */ public static void Release() { if (m_NativeCamera != null) { NRDebugger.Log("[NRRgbCamera] Start to Release"); #if !UNITY_EDITOR m_NativeCamera.Release(); m_NativeCamera = null; #endif OnError = null; OnImageUpdate = null; isInitiate = false; isRGBCamStart = false; } }
/// <summary> /// Release the rgb camera. /// </summary> public static void Release() { if (m_NativeCamera == null) { return; } NRDebugger.Log("[NRRgbCamera] Start to Release"); #if !UNITY_EDITOR m_NativeCamera.Release(); m_NativeCamera = null; #endif m_CurrentFrame.data = null; OnError = null; OnImageUpdate = null; m_IsInitialized = false; m_IsPlaying = false; }
private void Player_Capture(object sender, CaptureEvent e) { var captureMove = e.Move as CaptureMove; Moves.Add(captureMove); var player = sender as Player; HalfmovesSinceLastCaptureOrPawn = 0; var aff = player.Affiliation; if (aff == PlayerAffiliation.Black) { WhosTurn = PlayerAffiliation.White; Movecounter++; } else { WhosTurn = PlayerAffiliation.Black; } }
private void MovePawn(Move move) { if (move.Player != NextPlayer) { throw new InvalidOperationException(); } else if (move.From < 0 || move.To < 0) { GameEnded = true; Winner = (FieldState)(-(int)NextPlayer); GameEndedEvent?.Invoke(this, (FieldState)(-(int)NextPlayer)); } else { GameBoard.RemoveFrom(move.From); GameBoard.PlaceAt(move.To, move.Player); GameHistory.SaveMove(move); if (GameBoard.GetField(move.To).IsInMill()) { CaptureEvent?.Invoke(this, move.Player); } else { bool isDraw = GameHistory.SaveState(GameBoard.ToString()); if (isDraw) { GameEnded = true; GameEndedEvent?.Invoke(this, FieldState.Empty); } else { NextPlayer = (FieldState)(-(int)NextPlayer); NextPlayersTurnEvent?.Invoke(this, NextPlayer); } } } }
private void AddCaptureEventToDict() { if (CaptureEventDictionary.Count != 0) { CaptureEventDictionary.Clear(); } if (scenarioContainer.EventSet.CaptureEventList == null) { Debug.Log("XML파일 EventSet의 CaptureEventList가 없다."); return; } for (int k = 0; k < scenarioContainer.EventSet.CaptureEventList.Length; k++) { int key = scenarioContainer.EventSet.CaptureEventList[k].ID; CaptureEvent CaptureEventInfo = scenarioContainer.EventSet.CaptureEventList[k]; if (!CaptureEventDictionary.ContainsKey(key)) { CaptureEventDictionary.Add(key, CaptureEventInfo); } } }
// Start is called before the first frame update private void Start() { //yield return captureScreen(CaptureSize, CaptureLocation); onCapture += startCapture; }
private void OnCapture(CaptureEvent e) { Capture?.Invoke(this, e); }
private void Piece_Capture(object sender, CaptureEvent e) { OnCapture(e); }