GlobalGameJame/Assets/Scripts/BlockManager.cs

46 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockManager : MonoBehaviour
{
public enum BlockType {None, Barricade, Door, Wood, Ammo};
public BlockType blockType = BlockType.None;
public float health = 100;
private Animator animator;
private bool action = false;
// Start is called before the first frame update
void Start()
{
if (blockType == BlockType.Door)
{
animator = this.GetComponent<Animator>();
}
}
// Update is called once per frame
void Update()
{
}
public void Action()
{
if (blockType == BlockType.Door)
{
if (!action)
{
this.GetComponent<BoxCollider>().isTrigger = true;
action = true;
}
else
{
this.GetComponent<BoxCollider>().isTrigger = false;
action = false;
}
animator.ResetTrigger("Door");
animator.SetTrigger("Door");
}
}
}