12345678910111213141516171819202122232425262728 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Points : MonoBehaviour
- {
- [HideInInspector] public Counter counter;
- [Header("Число очков")]
- [SerializeField] private int points=0;
- [Header("Число здоровья (от 0 до 100)")]
- [SerializeField] private int health=0;
- [HideInInspector]
- public hp HP;
- private void Start()
- {
- counter = FindObjectOfType<Counter>();
- HP = GameObject.FindGameObjectWithTag("Player").GetComponent<hp>();
- }
- private void OnTriggerStay2D(Collider2D other)
- {
- HP.SetHealth(health);
- counter.total += points;
- Destroy(this.gameObject);
- }
- }
|