public CE_Card GetSuggestCard(CE_Suggest _suggest) { CE_Card _character = handCards.Where(c => c.ID == _suggest.Character.ID).FirstOrDefault(); CE_Card _weapon = handCards.Where(c => c.ID == _suggest.Weapon.ID).FirstOrDefault(); CE_Card _room = handCards.Where(c => c.ID == _suggest.Room.ID).FirstOrDefault(); if (_character != null) { return(_character); } if (_weapon != null) { return(_weapon); } if (_room != null) { return(_room); } return(null); }
IEnumerator IASuggest() { if (!isInRoom) { yield break; } CE_Card _pickCharacterCard = CE_GameManager.Instance.GameDeck.GetCard(NoteSystem.PickRandomNotes(CardType.Character).ID); CE_Card _pickWeaponCard = CE_GameManager.Instance.GameDeck.GetCard(NoteSystem.PickRandomNotes(CardType.Weapon).ID); CE_Card _pickRoomCard = CE_GameManager.Instance.GameDeck.GetCard(nextRoomInvestigate.ID); CE_Suggest _suggest = new CE_Suggest(_pickCharacterCard, _pickRoomCard, _pickWeaponCard); OnStartSuggest?.Invoke(_suggest, this); int _askIndex = CE_GameManager.Instance.CurrentCharacterTurnIndex; Debug.Log($"{characterRef.ColorName} is suggesting {_suggest.Room.Name} with {_suggest.Weapon.Name} at {_suggest.Character.Name}"); while (isInRoom && currentAIPhase == AIPhase.Suggest) { _askIndex++; _askIndex = _askIndex > CE_GameManager.Instance.AllCharacterInGame.Count - 1 ? 0 : _askIndex; IGamePlayable _askTo = CE_GameManager.Instance.AllCharacterInGame[_askIndex]; CE_Card _result = _askTo.HandCards.GetSuggestCard(_suggest); OnSuggestProgress?.Invoke(_suggest, this, _askTo, _result); Debug.Log($"{_askTo.CharacterRef.ColorName} {(_result == null ? "can't" : "can")} answer."); if (_result != null) { NoteSystem.MatchCard(_result.ID); currentAIPhase = AIPhase.Idle; } if (CE_GameManager.Instance.CurrentCharacterTurnIndex == _askIndex) { CE_GameManager.Instance.EndGame(); currentAIPhase = AIPhase.Idle; } Debug.Log($"{_askTo.CharacterRef.ColorName} {(_result == null ? "can't" : "can")} answer."); yield return(new WaitForSeconds(1)); } nextRoomInvestigate = null; currentAIPhase = AIPhase.Idle; yield return(new WaitForSeconds(5)); }