Exemplo n.º 1
0
    private void ProcessCrowdSounds()
    {
        for (int i = 0; i < _dummyAiStateInfoCount; ++i)
        {
            _dummyAiStateInfos[i].stateCount = 0;
        }

        if (_dummies != null)
        {
            for (int i = 0; i < crowdSize; ++i)
            {
                if (_dummies[i] != null && !_dummies[i].dead)
                {
                    int dummyStateIndex = (int)_dummies[i].AiState;

                    ++_dummyAiStateInfos[dummyStateIndex].stateCount;
                }
            }

            int currentMaxStateIndex = -1;
            int currentMax           = 0;
            for (int i = 0; i < _dummyAiStateInfoCount; ++i)
            {
                if (currentMax < _dummyAiStateInfos[i].stateCount)
                {
                    currentMaxStateIndex = i;
                    currentMax           = _dummyAiStateInfos[i].stateCount;
                }
            }

            float bennyFactor = Mathf.Clamp01(_dummyAiStateInfos[(int)DummyAIState.Follow].stateCount / (float)crowdSize);
            Audio.Instance.SetMusicVolume(bennyFactor);

            if (currentMaxStateIndex != -1)
            {
                DummyAIState choosenState = (DummyAIState)currentMaxStateIndex;


                if (_lastChoosenDummyAIState == choosenState)
                {
                    _soundTimer += Time.deltaTime;
                    if (_soundTimer > _soundTimeInterval)
                    {
                        _soundTimer        = 0.0f;
                        _soundTimeInterval = Random.Range(_soundIntervalMin, _soundIntervalMax);

                        Audio.Instance.PlaySound(_dummyAiStateInfos[currentMaxStateIndex].stateSounds);
                    }
                }
                else
                {
                    _soundTimer        = 0.0f;
                    _soundTimeInterval = Random.Range(_soundIntervalMin, _soundIntervalMax);
                }

                _lastChoosenDummyAIState = choosenState;
            }
        }
    }
Exemplo n.º 2
0
    private void SetModelActive(DummyAIState state, bool active)
    {
        int index = (int)state;

        if (index >= 0 && index < _dummyStateCount)
        {
            _dummyStateInfos[index].stateGO.SetActive(active);
        }
    }
Exemplo n.º 3
0
    public void ChangeState(DummyAIState newState)
    {
        SetModelActive(_aiState, false);

        _aiState = newState;
        SetModelActive(_aiState, true);


        _stateTimer = 0.0f;

        switch (_aiState)
        {
        case DummyAIState.Idle:
            break;

        case DummyAIState.Roam:
            _targetDirection = NewRoamDirection();
            break;

        case DummyAIState.Follow:
            _followState_walkSpeed = _followState_initialWalkSpeed;
            break;

        case DummyAIState.Confusion:
            break;

        case DummyAIState.OnFire:
            break;

        case DummyAIState.Wow:
        {
            float randomValue = Random.value;
            float randomRange = Random.Range(_wowState_minRadius, _wowState_maxRadius);
            _targetPosition = _exhibitPosition + new Vector3(Mathf.Sin(randomValue * Mathf.PI * 2.0f) * randomRange, 0.0f, Mathf.Cos(randomValue * Mathf.PI * 2.0f) * randomRange);
        }
        break;

        case DummyAIState.Dying:
            break;

        case DummyAIState.Arrived:
        {
            float randomValue = Random.value;
            float randomRange = Random.Range(_arrivedState_radiusMin, _arrivedState_radiusMax);
            _targetPosition = _finishPosition + new Vector3(Mathf.Sin(randomValue * Mathf.PI * 2.0f) * randomRange, 0.0f, Mathf.Cos(randomValue * Mathf.PI * 2.0f) * randomRange);

            CrowdController.instance.UpdateCrowdCounter();
        }
        break;
        }
    }
Exemplo n.º 4
0
    private void ProcessCrowdSounds()
    {
        for(int i = 0;i < _dummyAiStateInfoCount;++i)
        {
            _dummyAiStateInfos[i].stateCount = 0;
        }

        if (_dummies != null)
        {
            for (int i = 0; i < crowdSize; ++i)
            {
                if (_dummies[i] != null && !_dummies[i].dead)
                {
                    int dummyStateIndex = (int)_dummies[i].AiState;

                    ++_dummyAiStateInfos[dummyStateIndex].stateCount;
                }
            }

            int currentMaxStateIndex = -1;
            int currentMax = 0;
            for (int i = 0; i < _dummyAiStateInfoCount; ++i)
            {
                if (currentMax < _dummyAiStateInfos[i].stateCount)
                {
                    currentMaxStateIndex = i;
                    currentMax = _dummyAiStateInfos[i].stateCount;
                }
            }

            float bennyFactor = Mathf.Clamp01(_dummyAiStateInfos[(int)DummyAIState.Follow].stateCount / (float)crowdSize);
            Audio.Instance.SetMusicVolume(bennyFactor);

            if (currentMaxStateIndex != -1)
            {
                DummyAIState choosenState = (DummyAIState)currentMaxStateIndex;

                if (_lastChoosenDummyAIState == choosenState)
                {
                    _soundTimer += Time.deltaTime;
                    if (_soundTimer > _soundTimeInterval)
                    {
                        _soundTimer = 0.0f;
                        _soundTimeInterval = Random.Range(_soundIntervalMin, _soundIntervalMax);

                        Audio.Instance.PlaySound(_dummyAiStateInfos[currentMaxStateIndex].stateSounds);
                    }
                }
                else
                {
                    _soundTimer = 0.0f;
                    _soundTimeInterval = Random.Range(_soundIntervalMin, _soundIntervalMax);
                }

                _lastChoosenDummyAIState = choosenState;
            }
        }
    }
Exemplo n.º 5
0
Arquivo: Dummy.cs Projeto: Ret44/SGJ16
    public void ChangeState(DummyAIState newState)
    {
        SetModelActive(_aiState, false);

        _aiState = newState;
        SetModelActive(_aiState, true);

        _stateTimer = 0.0f;

        switch(_aiState)
        {
            case DummyAIState.Idle:
                break;
            case DummyAIState.Roam:
                _targetDirection = NewRoamDirection();
                break;
            case DummyAIState.Follow:
                _followState_walkSpeed = _followState_initialWalkSpeed;
                break;
            case DummyAIState.Confusion:
                break;
            case DummyAIState.OnFire:
                break;
            case DummyAIState.Wow:
                {
                    float randomValue = Random.value;
                    float randomRange = Random.Range(_wowState_minRadius, _wowState_maxRadius);
                    _targetPosition = _exhibitPosition + new Vector3(Mathf.Sin(randomValue * Mathf.PI * 2.0f) * randomRange, 0.0f, Mathf.Cos(randomValue * Mathf.PI * 2.0f) * randomRange);
                }
                break;
            case DummyAIState.Dying:
                break;
            case DummyAIState.Arrived:
                {
                    float randomValue = Random.value;
                    float randomRange = Random.Range(_arrivedState_radiusMin, _arrivedState_radiusMax);
                    _targetPosition = _finishPosition + new Vector3(Mathf.Sin(randomValue * Mathf.PI * 2.0f) * randomRange, 0.0f, Mathf.Cos(randomValue * Mathf.PI * 2.0f) * randomRange);

                    CrowdController.instance.UpdateCrowdCounter();
                }
                break;
        }
    }
Exemplo n.º 6
0
Arquivo: Dummy.cs Projeto: Ret44/SGJ16
 private void SetModelActive(DummyAIState state, bool active)
 {
     int index = (int)state;
     if(index >= 0 && index < _dummyStateCount)
     {
         _dummyStateInfos[index].stateGO.SetActive(active);
     }
 }