UI update 02
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace KD.Destro2D{
|
||||
|
||||
public class DoBasicDestruction : MonoBehaviour
|
||||
{
|
||||
[SerializeReference]
|
||||
public List<Destruction> destructions = new();
|
||||
[Header("Burn colors correspond to destructions in order, make sure to have SAME COUNT")]
|
||||
public List<Color> burncolors = new();
|
||||
public float radius = 1f;
|
||||
public bool doMainDestruction = false;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
Collider2D[] col = Physics2D.OverlapCircleAll(transform.position,radius);
|
||||
foreach(Collider2D c in col)
|
||||
{
|
||||
if(c.TryGetComponent<Destro2DMain>(out var d)){
|
||||
//important to setup when dealing with other object
|
||||
for(int i = 0; i < destructions.Count; i++)
|
||||
{
|
||||
var dest = destructions[i];
|
||||
var color = burncolors[i];
|
||||
dest.SetupWithColor(c.gameObject,color);
|
||||
}
|
||||
d.DynamicDestroyWorld(transform.position,destructions);
|
||||
if(doMainDestruction) d.DynamicDestroyWorld(transform.position);
|
||||
}
|
||||
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user