public void StartMixingBottles(ScreamContainer heldBottle, ScreamContainer groundBottle)
    {
        Debug.Log($"Started mixing bottles {heldBottle.name} and {groundBottle.name}");
        ScreamInventoryComponent inventoryComponent = GameUI.Instance.ScreamComposerUI.ScreamInventory;

        inventoryComponent.StartMixingBottles(heldBottle, groundBottle);
        GameUI.Instance.ScreamComposerUI.Show();
    }
    private void ReleaseBottleScream()
    {
        ScreamContainer bottle = _objectHolder.HeldObject.GetComponent <ScreamContainer>();

        if (bottle != null && bottle.ScreamSounds.Count > 0)
        {
            StartCoroutine(ReleaseBottleScreamAsync());
        }
    }
Пример #3
0
    private void FixedUpdate()
    {
        for (int i = 0; i < _spawnedContainers.Count; ++i)
        {
            ScreamContainer bottle = _spawnedContainers[i];
            bottle.Holdable.Rigidbody.AddForce(bottle.transform.parent.forward * 0.01f, ForceMode.VelocityChange);

            if (bottle.transform.position.y > 1)
            {
                _spawnedContainers.Remove(bottle);
            }
        }
    }
    private IEnumerator ReleaseBottleScreamAsync()
    {
        _playerAnimation.PlayEmote(PlayerAnimatorController.EmoteState.OpenBottle);
        yield return(_playerAnimation.AnimatorCallbacks.WaitForEvent("OnBottleUncorked"));

        ScreamContainer bottle = _objectHolder.HeldObject.GetComponent <ScreamContainer>();

        if (bottle != null && bottle.ScreamSounds.Count > 0)
        {
            ScreamDamageable.DoScream(bottle.ScreamSounds, bottle.transform.position, transform.forward, _screamDamageable);
            bottle.ReleaseScream();
        }

        yield return(null);
    }
Пример #5
0
    private void SpawnAtPoint(Transform spawnPoint)
    {
        ScreamContainer screamContainer = Instantiate(_screamBottlePrefab, spawnPoint);

        screamContainer.transform.position  = spawnPoint.position;
        screamContainer.transform.rotation  = Random.rotationUniform;
        screamContainer.transform.position += (Random.insideUnitSphere * 10).WithY(0);

        for (int i = 0; i < 3; ++i)
        {
            ScreamSoundDefinition chosenSound = _bottlePossibleScreams.Screams[Random.Range(0, _bottlePossibleScreams.Screams.Count)];
            screamContainer.AddScream(chosenSound);
        }

        _spawnedContainers.Add(screamContainer);
    }
Пример #6
0
    public void StartMixingBottles(ScreamContainer heldBottle, ScreamContainer groundBottle)
    {
        Debug.Log($"Started mixing bottles {heldBottle.name} and {groundBottle.name}");
        ScreamInventoryComponent inventoryComponent = GameUI.Instance.ScreamComposerUI.ScreamInventory;

        _sourceBottle = heldBottle;
        _targetBottle = groundBottle;

        var sourceScreamNotes = _sourceBottle.ScreamSounds;
        var targetScreamNotes = _targetBottle.ScreamSounds;

        for (int slotIndex = 0; slotIndex < 3; ++slotIndex)
        {
            inventoryComponent.SetSourceBottleNote(slotIndex, slotIndex < sourceScreamNotes.Count ? sourceScreamNotes[slotIndex] : null);
            inventoryComponent.SetTargetBottleNote(slotIndex, slotIndex < targetScreamNotes.Count ? targetScreamNotes[slotIndex] : null);
        }
    }
    private void InteractWithObject(Interactable interactable)
    {
        // Pick up holdable objects
        if (interactable.InteractionType == "pickup")
        {
            HoldableObject holdable = interactable.GetComponentInParent <HoldableObject>();
            if (holdable != null)
            {
                if (GameStateManager.Instance.BottlesPickedUpCount == 0)
                {
                    GameUI.Instance.DialogUI.ShowDialog("Hmm... I wonder if I could use this on a monster?", 5, this.transform, Vector3.up * 3);
                }
                GameStateManager.Instance.BottlesPickedUpCount++;

                _objectHolder.HoldObject(holdable);
                return;
            }
        }
        else if (interactable.InteractionType == "mix")
        {
            // Mix bottles
            if (_objectHolder.IsHoldingObject)
            {
                ScreamContainer heldBottle   = _objectHolder.HeldObject.GetComponent <ScreamContainer>();
                ScreamContainer groundBottle = interactable.GetComponentInParent <ScreamContainer>();
                if (heldBottle != null && groundBottle != null)
                {
                    StartMixingBottles(heldBottle, groundBottle);
                }
            }
        }
        else if (interactable.InteractionType == "deposit")
        {
            // Deposit bottles into bank
            if (_objectHolder.IsHoldingObject)
            {
                ScreamContainer heldBottle = _objectHolder.HeldObject.GetComponent <ScreamContainer>();
                GameStateManager.Instance.ScreamBank.DepositScream(heldBottle.ScreamSounds);
                ReleaseBottleScream();
            }
        }
    }
Пример #8
0
    void OnBehaviorStateEntered(BehaviorState newBehavior)
    {
        switch (newBehavior)
        {
        case BehaviorState.Idle:
            _throttleUrgency   = 0.0f;  // stop
            _pathRefreshPeriod = -1.0f; // no refresh
            _idleDuration      = Random.Range(IdleMinDuration, IdleMaxDuration);
            break;

        case BehaviorState.Wander:
            _throttleUrgency   = 0.5f;  // half speed
            _pathRefreshPeriod = -1.0f; // manual refresh
            // Pick a path to a wander target
            {
                Vector2 offset       = Random.insideUnitCircle * WanderRange;
                Vector3 wanderTarget = _spawnLocation + Vector3.left * offset.x + Vector3.forward * offset.y;
                RecomputePathTo(wanderTarget);
            }
            break;

        case BehaviorState.Chase:
            _throttleUrgency   = 1.0f; // full speed
            _pathRefreshPeriod = 2.0f; // refresh path every 2 seconds while persuing player
            // Force on line of sight checks even when player is out of vision cone
            _perceptionComponent.ForceLineOfSightCheck = true;
            // Start dropping player sanity while pursuit active
            GameStateManager.Instance.PlayerSanity.OnPursuitStarted();
            // Head to the player
            // If this fails we take care of it in attack update
            RecomputePathTo(GetCurrentPlayerLocation());
            break;

        case BehaviorState.Cower:
            _throttleUrgency   = 0.0f;  // Stop and sh*t yourself
            _pathRefreshPeriod = -1.0f; // manual refresh
            _aiAnimation.PlayEmote(AIAnimatorController.EmoteState.Cower);
            // Set animation dead flag early so that we don't leave emote state
            _aiAnimation.IsDead = true;
            // Hide the vision cone
            _perceptionComponent.gameObject.SetActive(false);
            break;

        case BehaviorState.Attack:
            _throttleUrgency   = 0.0f;  // Stop and attack in place
            _pathRefreshPeriod = -1.0f; // manual refresh

            _aiAnimation.PlayEmote(AIAnimatorController.EmoteState.Attack);
            _timeSinceAttack = 0.0f; // We just attacked

            var screamSounds = new List <ScreamSoundDefinition>()
            {
                _attackScream
            };
            _screamController.StartScream(screamSounds, false, 1.0f);
            ScreamDamageable.DoScream(screamSounds, _perceptionComponent.transform.position, _perceptionComponent.transform.forward, _screamDamageable);

            break;

        case BehaviorState.Flee:
            _throttleUrgency   = 1.0f;  // full speed
            _pathRefreshPeriod = -1.0f; // manual refresh
            // Head back to spawn location
            // If this fails we take care of it in flee update
            RecomputePathTo(_spawnLocation);
            break;

        case BehaviorState.Dead:
            // Play death effects to cover the transition
            if (_deathFX != null)
            {
                Instantiate(_deathFX, transform.position, Quaternion.identity);
            }

            AudioManager.Instance.PlaySound(gameObject, _deathSound);

            // Spawn a death bottles in out place
            if (_deathBottleSpawn != null)
            {
                GameObject      bottle          = Instantiate(_deathBottleSpawn, transform.position, Quaternion.identity);
                ScreamContainer screamContainer = bottle.GetComponent <ScreamContainer>();
                if (screamContainer != null)
                {
                    screamContainer.FillScream(new List <ScreamSoundDefinition>()
                    {
                        _attackScream
                    });
                }
            }
            // Clean ourselves up after a moment
            Destroy(this, 0.1f);
            break;
        }
    }