init: version 1
This commit is contained in:
14
Assets/Prefabs/Walls/Scripts/CubeWallController.cs
Normal file
14
Assets/Prefabs/Walls/Scripts/CubeWallController.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(SpriteRenderer), typeof(Collider2D), typeof(Animator))]
|
||||
public class CubeWallController : WallController
|
||||
{
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Cube"))
|
||||
{
|
||||
CubeController cube = other.GetComponent<CubeController>();
|
||||
cube.Respawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Prefabs/Walls/Scripts/CubeWallController.cs.meta
Normal file
3
Assets/Prefabs/Walls/Scripts/CubeWallController.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 043176b6637c4e31bbf66f4ca96fa49c
|
||||
timeCreated: 1751891142
|
||||
34
Assets/Prefabs/Walls/Scripts/WallController.cs
Normal file
34
Assets/Prefabs/Walls/Scripts/WallController.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(SpriteRenderer), typeof(Collider2D), typeof(Animator))]
|
||||
public class WallController : Activateable
|
||||
{
|
||||
[Header("Configuration")]
|
||||
public Color activatedColor = new(44 / 255f, 127 / 255f, 33 / 255f);
|
||||
public Color deactivatedColor = new(218 / 255f, 65 / 255f, 60 / 255f);
|
||||
|
||||
private SpriteRenderer _spriteRenderer;
|
||||
private Collider2D _collider;
|
||||
private Animator _animator;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
_collider = GetComponent<Collider2D>();
|
||||
_animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
protected override void OnActivation()
|
||||
{
|
||||
_spriteRenderer.color = activatedColor;
|
||||
_collider.enabled = false;
|
||||
_animator.SetBool("IsActive", true);
|
||||
}
|
||||
|
||||
protected override void OnDeactivation()
|
||||
{
|
||||
_spriteRenderer.color = deactivatedColor;
|
||||
_collider.enabled = true;
|
||||
_animator.SetBool("IsActive", false);
|
||||
}
|
||||
}
|
||||
2
Assets/Prefabs/Walls/Scripts/WallController.cs.meta
Normal file
2
Assets/Prefabs/Walls/Scripts/WallController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeaca36430f0d1047b856b66d6ea7c7c
|
||||
Reference in New Issue
Block a user