エイリアンエイジ FogManager.cs
- msandfrey3
- Aug 12, 2024
- 1 min read
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using IndieWizards.Audio;
using IndieWizards.WorldManagement;
namespace IndieWizards.FogStuff
{
public class FogManager : MonoBehaviour
{
[SerializeField]
private GameObject fogPrefab;
[SerializeField]
[Tooltip("How high above the tile should the fog sit.")]
private float fogHeight = 3.5f;
//[SerializeField]
//[Tooltip("The Gameobject that holds all the tiles for the region.")]
private GameObject tileGridParent;
[SerializeField]
[Tooltip("The parent object that will hold all the fog pieces in the region.")]
private GameObject fogParent;
[Header("Debug Purposes")]
[SerializeField]
private List<Fog> individualFogs = new List<Fog>();
private void Start()
{
tileGridParent = GetComponent<RegionManager>().TileGridParent;
Transform tiles = tileGridParent.transform;
foreach(Transform tile in tiles)
{
Vector3 tilePosition = tile.position;
Vector3 position = new Vector3(tilePosition.x, tilePosition.y + fogHeight, tilePosition.z);
GameObject fog = Instantiate(fogPrefab, position, Quaternion.identity, fogParent.transform);
fog.GetComponent<Fog>().SetFogManager(this);
individualFogs.Add(fog.GetComponent<Fog>());
}
}
public void MakeCollidersTriggers()
{
//allow clouds to be walked into and dont block
foreach(Fog fog in individualFogs)
{
fog.MakeCollidersTriggers();
}
}
public void RemoveFog(GameObject fog)
{
if (!individualFogs.Contains(fog.GetComponent<Fog>()))
{
return;
}
AudioManager.Instance.PlayWindEvent(this.gameObject);
individualFogs.Remove(fog.GetComponent<Fog>());
//activate fogs individual go away func here
//fog.GetComponent<Fog>().DisableFog();
}
}
}
Comments