Пример #1
0
 public void Interact(HeroStuff whoInteract)
 {
     //var coin = collision.gameObject;
     //After animation coin will be destroyed
     Animator.Play("CoinDestroy");
     //Remove a few components from coin object.
     //After that, the Hero can go through the Coin
     Destroy(GetComponent <Rigidbody>());
     Destroy(GetComponent <CapsuleCollider>());
     whoInteract.HeroGetCoins();
 }
Пример #2
0
    void OnMouseDown()
    {
        var distanceBetweenHeroAndWall = Vector3.Distance(
            HeroStuff.gameObject.transform.position,
            transform.position);

        if (distanceBetweenHeroAndWall > DistandOfMining)
        {
            return;
        }

        var step = new Vector3(0, 0, 0);

        switch (WallType)
        {
        case WallType.Goldmine:
            if (!HeroStuff.CouldMineGold)
            {
                return;
            }

            HeroStuff.HeroGetCoins(3);
            step = new Vector3(0, 0, 0.35f);
            break;

        case WallType.BaseWall:
            if (!HeroStuff.CouldBrokeWall)
            {
                return;
            }

            step = new Vector3(0, 0, 0.11f);
            break;
        }

        transform.localScale -= step;
        if (transform.localScale.z <= 0)
        {
            Destroy(transform.gameObject);
        }

        transform.position += step / 2;
    }