void MoveBottomToTop() { BackgroundBoundFinder topBound = Backgrounds [CurrentTopIndex].GetComponent <BackgroundBoundFinder> (); BackgroundBoundFinder bottomBound = Backgrounds [CurrentBottomIndex].GetComponent <BackgroundBoundFinder> (); bottomBound.transform.position = new Vector3( bottomBound.transform.position.x, topBound.MaxY + (bottomBound.transform.position.y - bottomBound.MinY), bottomBound.transform.position.z ); if (CurrentTopIndex > 0) { CurrentTopIndex--; } else { CurrentTopIndex = Backgrounds.Length - 1; } if (CurrentBottomIndex > 0) { CurrentBottomIndex--; } else { CurrentBottomIndex = Backgrounds.Length - 1; } BackgroundSwapper bg = bottomBound.GetComponent <BackgroundSwapper> (); ChangeBG(bg); }
void MoveTopToBottom() { BackgroundBoundFinder topBound = Backgrounds [CurrentTopIndex].GetComponent <BackgroundBoundFinder> (); BackgroundBoundFinder bottomBound = Backgrounds [CurrentBottomIndex].GetComponent <BackgroundBoundFinder> (); topBound.transform.position = new Vector3( topBound.transform.position.x, bottomBound.MinY + (topBound.transform.position.y - topBound.MaxY), topBound.transform.position.z ); topBound.GetComponent <BackgroundController> ().Init(); if (CurrentTopIndex < Backgrounds.Length - 1) { CurrentTopIndex++; } else { CurrentTopIndex = 0; } if (CurrentBottomIndex < Backgrounds.Length - 1) { CurrentBottomIndex++; } else { CurrentBottomIndex = 0; } BackgroundSwapper bg = topBound.GetComponent <BackgroundSwapper> (); ChangeBG(bg); }
// Use this for initialization void Start() { _SpriteRenderer = GetComponent <SpriteRenderer>(); Bounds = GetComponent <BackgroundBoundFinder> (); // initialize SetBackground(CurrentType); _TmpCurrentType = CurrentType; }