Run-and-capture/Assets/Scripts/Bonus/BonusCollisionController.cs
2021-08-21 14:14:03 +03:00

24 lines
786 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BonusCollisionController : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
var playerBonusController = other.gameObject.GetComponent<PlayerBonusController>();
if (playerBonusController)
{
var currentBonus = GetComponent<BonusVisuals>().bonus;
bool bonusPickedUp = playerBonusController.AddBonusToPlayer(currentBonus);
if (bonusPickedUp)
{
Debug.Log("picked up " + gameObject.name);
var tile = TileManagment.GetTile(transform.position);
tile.canBuildHere = true;
Destroy(gameObject);
}
}
}
}