Example #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Example #2
0
    protected virtual void AttemptMove <T> (int xDir, int yDir)
        where T : Component
    {
        RaycastHit2D hit;

        bool canMove = Move(xDir, yDir, out hit);

        FoodTextManager.ChangeLightAmount(-2);

        if (hit.transform == null)
        {
            return;
        }

        T hitComponent = hit.transform.GetComponent <T> ();

        if (!canMove && hitComponent != null)
        {
            OnCantMove(hitComponent);
        }
    }