void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
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); } }