private void Awake()
    {
        // Set up singleton behaviour
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }

        // Disable the shadow player at the beginning
        ShadowPlayer.GetComponent <PlatformerPlayerController>().enabled = false;
        ShadowPlayer.GetComponent <BoxCollider2D>().enabled = false;

        // Set up events if they don't exist yet
        if (ChangeToShadowEvent == null)
        {
            ChangeToShadowEvent = new PerceptionChangeEvent();
        }
        if (ChangeToRealEvent == null)
        {
            ChangeToRealEvent = new PerceptionChangeEvent();
        }
    }
    // SETS UP ALL THE VARIABLES
    private void Start()
    {
        if (ShadowWorld)
        {
            _matchPoint.x = MatchingPoint.position.x;
            _matchPoint.y = MatchingPoint.position.y;
        }
        // Sets the two offsets to the difference in the matching positions transform and this
        _offsetY = MatchingPoint.position.y - transform.position.y;
        _offsetX = transform.position.x - MatchingPoint.position.x;


        // Get the singleton object
        _controller = PerceptionController.Instance;

        // If this offset collider is in the shadowworld
        if (ShadowWorld)
        {
            // Start deactivated and subscribe to the Shadow event
            _isActive = false;
            _controller.ChangeToShadowEvent.AddListener(SetColliderStatus);
        }
        else
        {
            // Start activated and subscribe to the Real event
            _isActive = true;
            _controller.ChangeToRealEvent.AddListener(SetColliderStatus);
        }

        _hasFlipped = false;
    }
Exemple #3
0
 // Start is called before the first frame update
 void Start()
 {
     PC     = PerceptionController.Instance;
     maxVal = PC.MaxTime;
 }