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 Animation animation; private bool action = false; // Start is called before the first frame update void Start() { if (blockType == BlockType.Door) { animation = this.GetComponent(); } } // Update is called once per frame void Update() { } public void Action() { if (blockType == BlockType.Door) { if (!animation.isPlaying) { if (!action) { animation["Door"].speed = 1; animation["Door"].time = 0; action = true; } else { animation["Door"].speed = -1; animation["Door"].time = animation["Door"].length; action = false; } animation.Play("Door"); } } } }