コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (gameObject.CompareTag("Coin"))
        {
            if (other.gameObject.GetComponent <PlayerHandler>())
            {
                OnAddCoins?.Invoke();
                gameObject.SetActive(false);
            }
        }
        else if (gameObject.CompareTag("Cube"))
        {
            if (other.gameObject.TryGetComponent <PlayerCubes>(out var cubes))
            {
                cubes.AddCube();
                gameObject.SetActive(false);
            }
        }
        else if (gameObject.CompareTag("Obstacle"))
        {
            if (other.gameObject.TryGetComponent <CapsuleCollider>(out var playerCollider))
            {
                Debug.Log("END!");
                Time.timeScale = 0f;
            }

            // else if (other.gameObject.TryGetComponent<PlayerCubes>(out var playerCubes))
            // {
            //     playerCubes.DeleteCube();
            // }
        }
    }
コード例 #2
0
    public void AddMoney(int amount)
    {
        CurrentCoins += amount;

        if (OnAddCoins != null)
        {
            OnAddCoins.Invoke(amount);
        }
    }
コード例 #3
0
    // Buttons
    public void Click(double value = default)
    {
        if (value == default)
        {
            value = coinsClickValue;
        }

        OnAddCoins?.Invoke(value);
        //_coins.coins += coinsClickValue;
        //coins += coinsClickValue;
        SetTextValue();
    }