コード例 #1
0
    CE_Room GetNextRoom()
    {
        List <CE_Note> _nextRoomEmpty = noteSystem.PickRoomNotes(false);
        List <CE_Room> _correctRooms  = !lastRoom?CE_Board.Instance.AllRooms.Where(r => _nextRoomEmpty.Any(n => n.ID == r.Key)).Select(r => r.Value).ToList()
                                            :
                                            CE_Board.Instance.AllRooms.Where(r => r.Value != lastRoom && _nextRoomEmpty.Any(n => n.ID == r.Key)).Select(r => r.Value).ToList();

        CE_Room _room = _correctRooms.OrderBy(r => Vector3.Distance(r.Position, transform.position)).FirstOrDefault();

        return(_room);
    }
コード例 #2
0
    CE_Door GetNextDoor()
    {
        if (!nextRoomInvestigate)
        {
            return(null);
        }
        CE_Door _door    = nextRoomInvestigate.GetNearestDoor(this);
        CE_Door _outDoor = null;

        if (IsInRoom)
        {
            _outDoor           = lastRoom.GetNearestDoor(this);
            transform.position = _outDoor.Position;
            isInRoom           = false;
        }
        lastRoom = nextRoomInvestigate;
        return(_door);
    }
コード例 #3
0
    IEnumerator AIFSM()
    {
        currentAIPhase = AIPhase.Idle;
        if (!nextRoomInvestigate)
        {
            nextRoomInvestigate = GetNextRoom();
        }
        if ((!nextDoorTarget))
        {
            nextDoorTarget = GetNextDoor();
        }
        //Debug.Log($"it's my turn {characterRef.ColorName} with {nextRoomInvestigate.RoomName}");
        yield return(StartCoroutine(IAMove()));

        yield return(StartCoroutine(IAEndMove()));

        yield return(StartCoroutine(IASuggest()));

        OnEndTurn?.Invoke();
    }
コード例 #4
0
    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));
    }
コード例 #5
0
 public void AddRoom(int _id, CE_Room _room) => AllRooms.Add(_id, _room);