34 lines
811 B
C#
34 lines
811 B
C#
|
|
using System;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.Assertions;
|
||
|
|
|
||
|
|
public class Potion : MonoBehaviour
|
||
|
|
{
|
||
|
|
private Player _player;
|
||
|
|
private GameManager _gameManager;
|
||
|
|
|
||
|
|
private void Start()
|
||
|
|
{
|
||
|
|
_player = GameObject.Find("Player").GetComponent<Player>();
|
||
|
|
Assert.IsNotNull(_player);
|
||
|
|
|
||
|
|
_gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||
|
|
Assert.IsNotNull(_gameManager);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnTriggerEnter(Collider other)
|
||
|
|
{
|
||
|
|
if (!other.name.Equals("Player"))
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
_player.AddHealth(5);
|
||
|
|
Debug.Log("Potion collected increased health by 5");
|
||
|
|
Destroy(gameObject);
|
||
|
|
_gameManager.SpawnPotion();
|
||
|
|
}
|
||
|
|
}
|