Ejemplo n.º 1
0
    // I added here simple "context" exemple, if you want to do specific action on how the input was made.
    // In Unity's exemple they used this state to make some kind of "Charging" shoot
    public void OnFire(InputAction.CallbackContext context)
    {
        if (context.phase == InputActionPhase.Performed)
        {
            _fire     = true;
            _fireTime = Time.time;
            m_spriteRenderer.color = Color.red;
            GetComponent <ShootSoundManager>().PlayShootSound();

            RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.zero, Mathf.Infinity, LayerMask.GetMask("SuspectHitBox"));
            if (hit.collider != null)
            {
                SuspectController suspectController = hit.collider.GetComponent <SuspectController>();
                GameManager.Instance.HandlePlayerKill(this, suspectController);
            }
        }
    }
Ejemplo n.º 2
0
    public void HandlePlayerKill(PlayerController player, SuspectController suspect)
    {
        suspect.OnKilled();
        if (suspect.IsTarget)
        {
            player.AddPoints(m_clueManager.GetCurrentClueScore());
            m_shootSource.clip = m_gotchaSound;
            m_shootSource.Play();
            NextRound();
        }
        else
        {
            player.AddPoints(-m_clueManager.GetCurrentClueScore());
            m_shootSource.clip = m_missSound;
            m_shootSource.Play();
        }

        m_scores[player.Slot].SetText("Player " + (player.Slot + 1) + ": " + player.Score.ToString());
    }