This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Last-Ember/Scripts/Game Objects/Structures/HazardController.cs
T
2019-03-08 09:54:14 +11:00

28 lines
661 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Structures {
public class HazardController : MonoBehaviour {
//internals
int DamageValue { get; set; }
DamagerController damagerController;
void Awake() {
DamageValue = 1;
}
void Start() {
damagerController = GetComponent<DamagerController>();
damagerController.PushOnTriggerStay((Collider2D collider) => {
if (collider.gameObject.tag == "Player") {
//deal damage to the player
collider.gameObject.GetComponent<PlayerController>().HealthValue -= DamageValue;
//NOTE: not every damager will deal damage
}
});
}
}
}