Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        MinigameItem item = other.GetComponent <MinigameItem>();

        if (item.scored)
        {
            return;
        }
        goals++;
        score += (int)((transform.position - player.transform.position).magnitude * 2 + (transform.position - other.transform.position).magnitude * 10);
        OnScoreChanged?.Invoke(score);
        item.scored = true;
    }
Exemple #2
0
    /**<summary> Hit object with velocity and point to apply force </summary>*/
    private void Hit(Collider collider, Vector3 point, Vector2 velocity)
    {
        collider.attachedRigidbody.isKinematic = false;
        MinigameItem item = collider.attachedRigidbody.GetComponent <MinigameItem>();

        if (!item.moved)
        {
            item.moved = true;
        }
        collider.attachedRigidbody.transform.DOKill();
        collider.attachedRigidbody.transform.parent = null;
        Vector3 worldForce = cam.transform.TransformDirection((new Vector3(velocity.x, 0, velocity.y) + Vector3.ClampMagnitude(forceAdjust * velocity.y, forceAdjust.magnitude)) * hitForce);

        collider.attachedRigidbody.AddForceAtPosition(worldForce, point + positionAdjust);
    }
Exemple #3
0
 /**<summary> Set new ball to start position </summary>*/
 public void SetBall()
 {
     if (AvailableEquipment > 0)
     {
         Transform ball     = Instantiate(ballPrefab, player.transform).transform;
         Vector3   position = ball.localPosition;
         ball.localPosition = new Vector3(0, 0, -1);
         currentBall        = ball.GetComponent <MinigameItem>();
         ball.DOLocalMove(position, reloadTime);
     }
     else
     {
         OutOfEquipment();
     }
 }
Exemple #4
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.M))
     {
         StartMinigame();
     }
     if (active && currentBall && currentBall.moved)
     {
         shots++;
         ConsumeEquipment();
         OnItemCountChanged?.Invoke(AvailableEquipment);
         currentBall = null;
         Invoke("SetBall", 1);
     }
 }