mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 09:00:58 +00:00
38 lines
1015 B
C#
38 lines
1015 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
[RequireComponent(typeof(MeshRenderer))]
|
|
public class Floor : MonoBehaviour
|
|
{
|
|
public MomBehavior Mom;
|
|
public Material NormalMaterial;
|
|
public Material LavaMaterial;
|
|
|
|
private MeshRenderer _renderer;
|
|
|
|
void Awake()
|
|
{
|
|
_renderer = GetComponent<MeshRenderer>();
|
|
Mom.OnEnterRoom += ChangeToNormalFloor;
|
|
Mom.OnLeaveRoom += ChangeToLavaFloor;
|
|
}
|
|
|
|
private void ChangeToNormalFloor()
|
|
{
|
|
_renderer.material = NormalMaterial;
|
|
gameObject.tag = "Floor"; // Might not be necessary since the player is most likely "dead" if he touches a non-lava floor
|
|
}
|
|
|
|
private void ChangeToLavaFloor()
|
|
{
|
|
_renderer.material = LavaMaterial;
|
|
gameObject.tag = "Lava"; // Might not be necessary since the player is most likely "dead" if he touches a non-lava floor
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
Mom.OnEnterRoom -= ChangeToNormalFloor;
|
|
Mom.OnLeaveRoom -= ChangeToLavaFloor;
|
|
}
|
|
}
|