Added project
This commit is contained in:
34
Platformer/Assets/Scripts/BuffEmitter.cs
Normal file
34
Platformer/Assets/Scripts/BuffEmitter.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuffEmitter : MonoBehaviour {
|
||||
|
||||
[SerializeField] private Buff buff;
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other) {
|
||||
if (GameManager.Instance.buffReceiverContainer.ContainsKey(other.gameObject)) {
|
||||
var receiver = GameManager.Instance.buffReceiverContainer[other.gameObject];
|
||||
receiver.AddBuff(buff);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other) {
|
||||
if (GameManager.Instance.buffReceiverContainer.ContainsKey(other.gameObject)) {
|
||||
var receiver = GameManager.Instance.buffReceiverContainer[other.gameObject];
|
||||
receiver.RemoveBuff(buff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Buff {
|
||||
public BuffType type;
|
||||
public float additiveBonus;
|
||||
public float multipleBonus;
|
||||
}
|
||||
|
||||
public enum BuffType : byte {
|
||||
Damage, Force, Armor
|
||||
}
|
||||
Reference in New Issue
Block a user