using UnityEngine; public class Ghost : MonoBehaviour { ///public new Rigidbody2D rigidbody { get; private set;} public Movement movement { get; private set;} public Ghost_Home home { get; private set;} public Ghost_Scatter scatter { get; private set;} public Ghost_Chase chase { get; private set;} public Ghost_Frightened Frightened { get; private set;} public Ghost_behaviour initialBehavior; public Transform target; public int points = 200; private void Awake() { this.movement = GetComponent(); this.home = GetComponent(); this.scatter = GetComponent(); this.chase = GetComponent(); this.Frightened = GetComponent(); } public void Start() { ResetState(); } public void ResetState() { this.gameObject.SetActive(true); this.movement.ResetState(); this.Frightened.Disable(); this.chase.Disable(); this.scatter.Enable(); if(this.home != this.initialBehavior) { this.home.Disable(); } if(this.initialBehavior != null) { this.initialBehavior.Enable(); } } private void OnCollisionEnter2D(Collision2D collision) { if(collision.gameObject.layer == LayerMask.NameToLayer("Pacman")) { if(this.Frightened.enabled) { FindAnyObjectByType().GhostEaten(this); } else { FindAnyObjectByType().PacmanEaten(); } } } }